:root {
  --bg: #0b1020;
  --bg-elevated: #121a30;
  --bg-card: rgba(19, 27, 48, 0.85);
  --border: rgba(148, 163, 184, 0.18);
  --text: #f1f5f9;
  --text-muted: #94a3b8;

  --cyan: #38bdf8;
  --cyan-bright: #7dd3fc;
  --cyan-glow: rgba(56, 189, 248, 0.45);
  --cyan-bg: rgba(56, 189, 248, 0.14);

  --coral: #fb7185;
  --coral-bright: #fda4af;
  --coral-glow: rgba(251, 113, 133, 0.45);
  --coral-bg: rgba(251, 113, 133, 0.14);

  --emerald: #34d399;
  --emerald-bright: #6ee7b7;
  --emerald-glow: rgba(52, 211, 153, 0.42);
  --emerald-bg: rgba(52, 211, 153, 0.14);

  --amber: #fbbf24;
  --amber-bright: #fde68a;
  --amber-glow: rgba(251, 191, 36, 0.42);
  --amber-bg: rgba(251, 191, 36, 0.14);

  --x-color: var(--cyan);
  --x-bright: var(--cyan-bright);
  --x-glow: var(--cyan-glow);
  --x-bg: var(--cyan-bg);

  --o-color: var(--coral);
  --o-bright: var(--coral-bright);
  --o-glow: var(--coral-glow);
  --o-bg: var(--coral-bg);

  --warn: var(--amber);
  --warn-glow: var(--amber-glow);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at top, #152142 0%, var(--bg) 62%);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 60;
}

.bg-orb {
  position: fixed;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.2;
  pointer-events: none;
  z-index: 0;
}

.bg-orb-x {
  top: -130px;
  left: -120px;
  background: var(--cyan);
}

.bg-orb-o {
  bottom: -150px;
  right: -120px;
  background: var(--coral);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 18px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hidden {
  display: none !important;
}

.muted-copy {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

kbd {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 0.8rem;
  font-family: 'Space Grotesk', monospace;
}

/* Header */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(251, 113, 133, 0.22));
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -1px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.logo-x {
  color: var(--cyan);
  transform: translateY(-2px);
}

.logo-o {
  color: var(--coral);
  transform: translateY(2px);
}

.brand h1 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.85rem;
}

.player-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald-glow);
}

.text-link-btn {
  background: none;
  border: none;
  color: var(--cyan-bright);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0 2px;
}

.text-link-btn:hover {
  text-decoration: underline;
}

.room-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  backdrop-filter: blur(12px);
}

.room-pill-label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

#room-code-display {
  font-family: 'Space Grotesk', monospace;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
}

.icon-btn {
  background: rgba(30, 41, 59, 0.85);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.icon-btn:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(148, 163, 184, 0.4);
  transform: translateY(-1px);
}

.danger-btn:hover {
  border-color: rgba(251, 113, 133, 0.55);
  color: var(--coral-bright);
}

/* Shared Cards, Inputs, Buttons */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  backdrop-filter: blur(16px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.34);
}

.badge-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--cyan-bright);
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.28);
  padding: 4px 10px;
  border-radius: 999px;
}

.live-pill {
  color: var(--emerald-bright);
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.32);
}

.section-head h2,
.section-head h3,
.rooms-header h2,
.bs-waiting-head h2 {
  margin: 8px 0 0;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.02em;
}

.btn {
  position: relative;
  border: none;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.28);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 14px 30px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(30, 41, 59, 0.92);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(51, 65, 85, 0.95);
  transform: translateY(-1px);
}

.btn-accent {
  background: linear-gradient(135deg, #f43f5e, #fb7185);
  color: #fff;
  box-shadow: 0 8px 20px rgba(244, 63, 94, 0.28);
}

.btn-accent:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(244, 63, 94, 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.42);
}

.btn-large {
  width: 100%;
  padding: 14px 18px;
  font-size: 1rem;
}

.btn-small {
  padding: 8px 13px;
  font-size: 0.82rem;
}

input[type='text'] {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-size: 0.94rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type='text']:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.error-banner {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(244, 63, 94, 0.14);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: #fecdd3;
  font-size: 0.86rem;
}

/* 1. Name Gate */
.name-gate-card {
  max-width: 560px;
  margin: 34px auto 0;
  padding: 32px;
  text-align: left;
}

.name-gate-card h2 {
  margin: 12px 0 6px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.75rem;
}

.name-gate-form {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.name-gate-form input {
  flex: 1;
  min-width: 220px;
}

/* 2. Multi-Game Hub Grid */
.hub-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: start;
}

.hub-create-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.game-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.game-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: left;
  padding: 13px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.15s ease, box-shadow 0.18s ease;
}

.game-card:hover {
  border-color: rgba(148, 163, 184, 0.42);
  transform: translateY(-1px);
}

.game-card.selected {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.1);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.16);
}

.game-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.ttt-icon {
  background: rgba(56, 189, 248, 0.16);
  color: var(--cyan-bright);
  border: 1px solid rgba(56, 189, 248, 0.32);
}

.bs-icon {
  background: rgba(52, 211, 153, 0.16);
  color: var(--emerald-bright);
  border: 1px solid rgba(52, 211, 153, 0.32);
}

.game-card-body {
  flex: 1;
  min-width: 0;
}

.game-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.game-card-body p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.cap-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.15);
  color: var(--cyan-bright);
}

.cap-bs {
  background: rgba(52, 211, 153, 0.15);
  color: var(--emerald-bright);
}

.create-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.seg-btn {
  padding: 9px 8px;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: var(--cyan);
  color: var(--cyan-bright);
}

.create-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.waiting-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  font-size: 0.88rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cyan);
  animation: radar-pulse 1.5s infinite;
  flex-shrink: 0;
}

@keyframes radar-pulse {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

/* Open Rooms Directory */
.hub-rooms-panel {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.rooms-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.count-pill {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
}

.rooms-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.filter-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.filter-tab.active {
  background: rgba(56, 189, 248, 0.18);
  color: var(--cyan-bright);
}

.code-join-inline {
  display: flex;
  gap: 6px;
}

#join-code-input {
  width: 96px;
  padding: 7px 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-family: 'Space Grotesk', monospace;
  font-weight: 700;
  text-align: center;
  font-size: 0.84rem;
}

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 220px;
}

.rooms-empty {
  padding: 36px 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.9rem;
}

.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border);
  transition: border-color 0.18s ease, transform 0.15s ease;
}

.room-row.joinable:hover {
  border-color: rgba(56, 189, 248, 0.45);
  transform: translateY(-1px);
}

.room-row-info {
  flex: 1;
  min-width: 0;
}

.room-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-row-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
}

.room-row-code {
  font-family: 'Space Grotesk', monospace;
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-muted);
}

.game-type-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
}

.game-type-pill.ttt {
  background: var(--cyan-bg);
  color: var(--cyan-bright);
}

.game-type-pill.bs {
  background: var(--emerald-bg);
  color: var(--emerald-bright);
}

.room-row-players {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-player-chip {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border);
}

.mini-player-chip.color-cyan { border-color: rgba(56, 189, 248, 0.45); color: var(--cyan-bright); }
.mini-player-chip.color-coral { border-color: rgba(251, 113, 133, 0.45); color: var(--coral-bright); }
.mini-player-chip.color-emerald { border-color: rgba(52, 211, 153, 0.45); color: var(--emerald-bright); }
.mini-player-chip.color-amber { border-color: rgba(251, 191, 36, 0.45); color: var(--amber-bright); }

.room-row-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.room-slots-text {
  text-align: right;
  font-size: 0.8rem;
}

.room-slots-text strong {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.92rem;
}

.room-status-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.room-status-label.open {
  color: var(--emerald-bright);
}

/* Shared Game Banners */
.game-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.status-banner {
  text-align: center;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: rgba(30, 41, 59, 0.78);
  border: 1px solid var(--border);
  font-size: 0.94rem;
  font-weight: 500;
  transition: background 0.25s ease, border-color 0.25s ease;
}

.status-banner.your-turn-x,
.status-banner.your-turn-cyan {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.45);
  color: var(--cyan-bright);
}

.status-banner.your-turn-o,
.status-banner.your-turn-coral {
  background: rgba(251, 113, 133, 0.14);
  border-color: rgba(251, 113, 133, 0.45);
  color: var(--coral-bright);
}

.status-banner.your-turn-emerald {
  background: rgba(52, 211, 153, 0.14);
  border-color: rgba(52, 211, 153, 0.45);
  color: var(--emerald-bright);
}

.status-banner.your-turn-amber {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.45);
  color: var(--amber-bright);
}

.status-banner.warn-expiring {
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.4);
}

.victory-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.22), rgba(99, 102, 241, 0.22));
  border: 1px solid rgba(125, 211, 252, 0.52);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35), 0 0 32px rgba(56, 189, 248, 0.22);
  animation: victory-slide-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  flex-wrap: wrap;
}

.victory-banner.winner-o,
.victory-banner.winner-coral {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.22), rgba(251, 146, 60, 0.2));
  border-color: rgba(253, 164, 175, 0.55);
}

.victory-banner.winner-emerald {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(14, 165, 233, 0.2));
  border-color: rgba(110, 231, 183, 0.55);
}

.victory-banner.winner-amber {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(244, 63, 94, 0.18));
  border-color: rgba(253, 230, 138, 0.55);
}

@keyframes victory-slide-in {
  0% { opacity: 0; transform: translateY(-16px) scale(0.94); }
  65% { opacity: 1; transform: translateY(3px) scale(1.02); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.victory-trophy {
  font-size: 2.2rem;
  animation: trophy-bounce 1.2s ease-in-out infinite;
}

@keyframes trophy-bounce {
  0%, 100% { transform: translateY(0) rotate(-4deg) scale(1); }
  50% { transform: translateY(-6px) rotate(6deg) scale(1.12); }
}

.victory-copy {
  flex: 1;
  min-width: 180px;
}

.victory-copy h2 {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.4rem;
}

.victory-copy p {
  margin: 3px 0 0;
  font-size: 0.86rem;
  color: rgba(241, 245, 249, 0.85);
}

.victory-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.rematch-status {
  font-size: 0.76rem;
  color: #fde68a;
  min-height: 16px;
}

.invite-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.1);
  border: 1px dashed rgba(56, 189, 248, 0.45);
  flex-wrap: wrap;
}

.invite-banner p {
  margin: 3px 0 0;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.inline-code {
  font-family: 'Space Grotesk', monospace;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--cyan-bright);
  background: rgba(15, 23, 42, 0.8);
  padding: 2px 8px;
  border-radius: 6px;
}

.game-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  font-size: 0.86rem;
  color: #fde68a;
  z-index: 55;
}

/* 3. Infinite Tic-Tac-Toe Styles */
.scoreboard {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

#ttt-view .status-banner,
#ttt-view .victory-banner,
#ttt-view .invite-banner {
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}

.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.player-card.active-turn.player-x {
  border-color: rgba(56, 189, 248, 0.72);
  box-shadow: 0 0 26px rgba(56, 189, 248, 0.22);
  transform: translateY(-2px);
}

.player-card.active-turn.player-o {
  border-color: rgba(251, 113, 133, 0.72);
  box-shadow: 0 0 26px rgba(251, 113, 133, 0.22);
  transform: translateY(-2px);
}

.player-card.winner-card.player-x {
  border-color: var(--x-color);
  box-shadow: 0 0 36px rgba(56, 189, 248, 0.42);
}

.player-card.winner-card.player-o {
  border-color: var(--o-color);
  box-shadow: 0 0 36px rgba(251, 113, 133, 0.42);
}

.player-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.symbol-badge {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  flex-shrink: 0;
}

.symbol-x { background: var(--x-bg); color: var(--x-color); border: 1px solid rgba(56, 189, 248, 0.35); }
.symbol-o { background: var(--o-bg); color: var(--o-color); border: 1px solid rgba(251, 113, 133, 0.35); }

.player-meta { flex: 1; min-width: 0; }
.player-name-row { display: flex; align-items: center; gap: 6px; }
.player-name { font-weight: 600; font-size: 0.94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.you-tag,
.host-tag {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
}

.host-tag {
  background: rgba(251, 191, 36, 0.18);
  color: var(--amber-bright);
}

.turn-tag { display: block; font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.player-score { font-family: 'Space Grotesk', sans-serif; font-size: 1.5rem; font-weight: 700; padding-left: 6px; }

.mark-meter {
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.meter-label { font-size: 0.74rem; color: var(--text-muted); }
.pips { display: flex; gap: 6px; }
.pip { width: 11px; height: 11px; border-radius: 50%; background: rgba(148, 163, 184, 0.18); border: 1px solid rgba(148, 163, 184, 0.25); transition: all 0.22s ease; }
.player-x .pip.filled { background: var(--x-color); border-color: var(--x-bright); box-shadow: 0 0 10px var(--x-glow); }
.player-o .pip.filled { background: var(--o-color); border-color: var(--o-bright); box-shadow: 0 0 10px var(--o-glow); }
.pip.expiring-pip { background: var(--warn) !important; border-color: #fde68a !important; box-shadow: 0 0 12px var(--warn-glow) !important; animation: pip-pulse 1s ease-in-out infinite; }

@keyframes pip-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.25); opacity: 0.55; }
}

.round-pill { text-align: center; padding: 10px 14px; border-radius: var(--radius-md); background: var(--bg-card); border: 1px solid var(--border); }
.round-label { display: block; font-size: 0.66rem; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; }
#round-number { font-family: 'Space Grotesk', sans-serif; font-size: 1.2rem; }

.board-stage { display: flex; justify-content: center; padding: 4px 0; }
.board-wrapper {
  position: relative;
  width: min(420px, 92vw);
  aspect-ratio: 1 / 1;
  padding: 14px;
  border-radius: 26px;
  background: linear-gradient(145deg, rgba(22, 33, 62, 0.92), rgba(11, 16, 32, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.board-wrapper.celebrate-x { box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5), 0 0 55px rgba(56, 189, 248, 0.32); animation: board-win-pop 0.55s cubic-bezier(0.22, 1, 0.36, 1); }
.board-wrapper.celebrate-o { box-shadow: 0 28px 70px rgba(0, 0, 0, 0.5), 0 0 55px rgba(251, 113, 133, 0.34); animation: board-win-pop 0.55s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes board-win-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

.shockwave-ring { position: absolute; inset: 10%; border-radius: 50%; border: 4px solid transparent; pointer-events: none; opacity: 0; z-index: 4; }
.shockwave-ring.active-x { border-color: var(--x-color); animation: shockwave-expand 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.shockwave-ring.active-o { border-color: var(--o-color); animation: shockwave-expand 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

@keyframes shockwave-expand {
  0% { transform: scale(0.25); opacity: 0.95; border-width: 8px; }
  100% { transform: scale(1.38); opacity: 0; border-width: 1px; }
}

.board { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 12px; position: relative; z-index: 2; }

.cell {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.78);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.16s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.3s ease, box-shadow 0.25s ease;
  overflow: hidden;
}

.cell.playable:hover { background: rgba(30, 41, 59, 0.92); transform: translateY(-2px); }
.cell.playable.hover-x:hover { border-color: rgba(56, 189, 248, 0.55); box-shadow: 0 8px 20px rgba(56, 189, 248, 0.14); }
.cell.playable.hover-o:hover { border-color: rgba(251, 113, 133, 0.55); box-shadow: 0 8px 20px rgba(251, 113, 133, 0.14); }
.cell:disabled { cursor: default; }

.cell-order-badge { position: absolute; top: 7px; left: 9px; font-family: 'Space Grotesk', sans-serif; font-size: 0.68rem; font-weight: 700; color: rgba(148, 163, 184, 0.55); pointer-events: none; }
.cell-expiring-tag { position: absolute; bottom: 6px; right: 7px; font-size: 0.58rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 2px 5px; border-radius: 5px; background: rgba(251, 191, 36, 0.18); color: #fde68a; border: 1px solid rgba(251, 191, 36, 0.45); pointer-events: none; }

.cell.is-expiring { border-style: dashed; border-color: rgba(251, 191, 36, 0.72); background: rgba(251, 191, 36, 0.07); animation: expiring-cell-pulse 1.35s ease-in-out infinite; }
.cell.is-expiring .mark-svg { opacity: 0.6; }

@keyframes expiring-cell-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.28); }
  50% { box-shadow: 0 0 18px 2px rgba(251, 191, 36, 0.28); }
}

.mark-svg { width: 66%; height: 66%; overflow: visible; }
.mark-x line { stroke: var(--x-color); stroke-width: 11; stroke-linecap: round; filter: drop-shadow(0 0 10px var(--x-glow)); }
.mark-o circle { fill: none; stroke: var(--o-color); stroke-width: 11; stroke-linecap: round; filter: drop-shadow(0 0 10px var(--o-glow)); }
.mark-svg.animate-in.mark-x .x-line-1 { stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw-stroke 0.22s ease-out forwards; }
.mark-svg.animate-in.mark-x .x-line-2 { stroke-dasharray: 100; stroke-dashoffset: 100; animation: draw-stroke 0.22s ease-out 0.1s forwards; }
.mark-svg.animate-in.mark-o circle { stroke-dasharray: 220; stroke-dashoffset: 220; animation: draw-stroke 0.34s cubic-bezier(0.22, 1, 0.36, 1) forwards; }

@keyframes draw-stroke { to { stroke-dashoffset: 0; } }

.vanish-ghost { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; animation: mark-vanish 0.45s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
@keyframes mark-vanish {
  0% { opacity: 0.85; transform: scale(1) rotate(0deg); filter: blur(0px); }
  100% { opacity: 0; transform: scale(0.32) rotate(-18deg); filter: blur(4px); }
}

.cell.is-dimmed { opacity: 0.38; transform: scale(0.96); }
.cell.is-winner-x { background: rgba(56, 189, 248, 0.22); border-color: var(--x-bright); animation: win-cell-celebrate 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards, win-cell-glow-x 1.6s ease-in-out 0.7s infinite; }
.cell.is-winner-o { background: rgba(251, 113, 133, 0.22); border-color: var(--o-bright); animation: win-cell-celebrate 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards, win-cell-glow-o 1.6s ease-in-out 0.7s infinite; }
.cell.win-delay-0 { animation-delay: 0ms, 700ms; }
.cell.win-delay-1 { animation-delay: 110ms, 810ms; }
.cell.win-delay-2 { animation-delay: 220ms, 920ms; }

@keyframes win-cell-celebrate {
  0% { transform: scale(1); }
  38% { transform: scale(1.11) rotate(-2deg); }
  70% { transform: scale(0.97) rotate(1deg); }
  100% { transform: scale(1.03) rotate(0deg); }
}

@keyframes win-cell-glow-x {
  0%, 100% { box-shadow: 0 0 22px rgba(56, 189, 248, 0.45), inset 0 0 14px rgba(56, 189, 248, 0.22); }
  50% { box-shadow: 0 0 38px rgba(125, 211, 252, 0.8), inset 0 0 22px rgba(56, 189, 248, 0.38); }
}

@keyframes win-cell-glow-o {
  0%, 100% { box-shadow: 0 0 22px rgba(251, 113, 133, 0.45), inset 0 0 14px rgba(251, 113, 133, 0.22); }
  50% { box-shadow: 0 0 38px rgba(253, 164, 175, 0.8), inset 0 0 22px rgba(251, 113, 133, 0.38); }
}

.win-line-svg { position: absolute; inset: 14px; width: calc(100% - 28px); height: calc(100% - 28px); pointer-events: none; z-index: 3; }
.win-line-path { stroke-width: 10; stroke-linecap: round; opacity: 0; }
.win-line-path.glow-under { stroke-width: 20; opacity: 0; }
.win-line-path.show-x { stroke: #e0f2fe; opacity: 1; animation: draw-win-line 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.win-line-path.glow-under.show-x { stroke: rgba(56, 189, 248, 0.55); opacity: 1; animation: draw-win-line 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.win-line-path.show-o { stroke: #ffe4e6; opacity: 1; animation: draw-win-line 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
.win-line-path.glow-under.show-o { stroke: rgba(251, 113, 133, 0.55); opacity: 1; animation: draw-win-line 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
@keyframes draw-win-line { to { stroke-dashoffset: 0; } }

.board-footer { display: flex; justify-content: center; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); }
.legend-swatch { width: 14px; height: 14px; border-radius: 4px; }
.expiring-swatch { border: 2px dashed rgba(251, 191, 36, 0.85); background: rgba(251, 191, 36, 0.14); }

/* 4. 4-Player Battleship Styles */
.bs-roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 12px;
}

.admiral-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.25s ease;
}

.admiral-card.eliminated {
  opacity: 0.48;
  filter: grayscale(0.4);
}

.admiral-card.active-turn.color-cyan { border-color: var(--cyan); box-shadow: 0 0 24px rgba(56, 189, 248, 0.24); transform: translateY(-2px); }
.admiral-card.active-turn.color-coral { border-color: var(--coral); box-shadow: 0 0 24px rgba(251, 113, 133, 0.24); transform: translateY(-2px); }
.admiral-card.active-turn.color-emerald { border-color: var(--emerald); box-shadow: 0 0 24px rgba(52, 211, 153, 0.24); transform: translateY(-2px); }
.admiral-card.active-turn.color-amber { border-color: var(--amber); box-shadow: 0 0 24px rgba(251, 191, 36, 0.24); transform: translateY(-2px); }

.admiral-badge {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
}

.admiral-badge.color-cyan { background: var(--cyan-bg); color: var(--cyan-bright); border: 1px solid rgba(56, 189, 248, 0.4); }
.admiral-badge.color-coral { background: var(--coral-bg); color: var(--coral-bright); border: 1px solid rgba(251, 113, 133, 0.4); }
.admiral-badge.color-emerald { background: var(--emerald-bg); color: var(--emerald-bright); border: 1px solid rgba(52, 211, 153, 0.4); }
.admiral-badge.color-amber { background: var(--amber-bg); color: var(--amber-bright); border: 1px solid rgba(251, 191, 36, 0.4); }

.admiral-stats {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.bs-waiting-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.bs-waiting-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Battleship Setup */
.bs-setup-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 18px;
  align-items: start;
}

.bs-setup-controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ship-dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ship-dock-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.76);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.ship-dock-item.selected {
  border-color: var(--cyan);
  background: rgba(56, 189, 248, 0.14);
}

.ship-dock-item.placed {
  border-color: rgba(52, 211, 153, 0.45);
}

.ship-cells-preview {
  display: flex;
  gap: 4px;
}

.ship-cells-preview span {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--cyan);
  opacity: 0.85;
}

.ship-dock-item.placed .ship-cells-preview span {
  background: var(--emerald);
}

.setup-action-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Battleship Grids */
.grid-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.grid-card-head h3 {
  margin: 2px 0 0;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.08rem;
}

.coord-pill {
  font-family: 'Space Grotesk', monospace;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid var(--border);
  color: var(--cyan-bright);
}

.bs-grid-frame {
  display: grid;
  grid-template-columns: 24px repeat(8, 1fr);
  gap: 4px;
  align-items: center;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}

.bs-grid-frame.compact-grid {
  max-width: 310px;
  gap: 3px;
}

.bs-axis-label {
  text-align: center;
  font-family: 'Space Grotesk', monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  user-select: none;
}

.bs-cell {
  aspect-ratio: 1 / 1;
  border-radius: 7px;
  border: 1px solid rgba(56, 189, 248, 0.16);
  background: linear-gradient(180deg, rgba(15, 30, 58, 0.92), rgba(11, 20, 42, 0.95));
  color: var(--text);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  position: relative;
  cursor: default;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.compact-grid .bs-cell {
  border-radius: 5px;
  font-size: 0.78rem;
}

.bs-cell.interactive {
  cursor: pointer;
}

.bs-cell.interactive:hover {
  border-color: var(--amber);
  background: rgba(251, 191, 36, 0.18);
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.25);
  transform: scale(1.04);
  z-index: 2;
}

.bs-cell.has-ship {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.42), rgba(37, 99, 235, 0.45));
  border-color: rgba(125, 211, 252, 0.65);
}

.bs-cell.preview-valid {
  background: rgba(52, 211, 153, 0.38) !important;
  border-color: var(--emerald-bright) !important;
}

.bs-cell.preview-invalid {
  background: rgba(244, 63, 94, 0.4) !important;
  border-color: var(--coral-bright) !important;
}

.bs-cell.shot-miss {
  background: rgba(51, 65, 85, 0.68);
  border-color: rgba(148, 163, 184, 0.28);
}

.bs-cell.shot-hit {
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.55), rgba(234, 88, 12, 0.55));
  border-color: #fda4af;
  box-shadow: inset 0 0 10px rgba(244, 63, 94, 0.45);
}

.bs-cell.ship-sunk {
  background: linear-gradient(135deg, rgba(185, 28, 28, 0.78), rgba(127, 29, 29, 0.85));
  border-color: #fbbf24;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.35);
}

.bs-cell.just-hit {
  animation: bs-explode 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

.bs-cell.just-miss {
  animation: bs-splash 0.55s ease-out;
}

@keyframes bs-explode {
  0% { transform: scale(0.7); box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.95); }
  45% { transform: scale(1.22); box-shadow: 0 0 24px 8px rgba(251, 191, 36, 0.7); }
  100% { transform: scale(1); box-shadow: inset 0 0 10px rgba(244, 63, 94, 0.45); }
}

@keyframes bs-splash {
  0% { transform: scale(0.8); box-shadow: 0 0 0 0 rgba(125, 211, 252, 0.8); }
  100% { transform: scale(1); box-shadow: 0 0 0 14px rgba(125, 211, 252, 0); }
}

.target-radar.shake-impact {
  animation: board-shake 0.38s ease-in-out;
}

@keyframes board-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translate(-5px, 2px); }
  40% { transform: translate(5px, -2px); }
  60% { transform: translate(-4px, -1px); }
  80% { transform: translate(3px, 1px); }
}

/* Battleship Combat Layout */
.bs-combat-layout {
  display: grid;
  grid-template-columns: 1.25fr 0.85fr;
  gap: 18px;
  align-items: start;
}

.bs-attack-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.step-chip {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--amber-bright);
  background: rgba(251, 191, 36, 0.14);
  border: 1px solid rgba(251, 191, 36, 0.32);
  padding: 2px 8px;
  border-radius: 999px;
}

.target-selector-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.target-active-pill {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--coral-bright);
}

.target-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.target-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.target-btn:hover:not(:disabled) {
  border-color: rgba(251, 113, 133, 0.55);
  transform: translateY(-1px);
}

.target-btn.selected {
  border-color: var(--coral);
  background: rgba(251, 113, 133, 0.16);
  box-shadow: 0 0 18px rgba(251, 113, 133, 0.22);
}

.target-btn.eliminated {
  opacity: 0.45;
  text-decoration: line-through;
}

.target-btn-top {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  font-weight: 600;
  font-size: 0.88rem;
}

.color-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.color-dot.color-cyan { background: var(--cyan); }
.color-dot.color-coral { background: var(--coral); }
.color-dot.color-emerald { background: var(--emerald); }
.color-dot.color-amber { background: var(--amber); }

.target-btn-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.bs-side-column {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.battle-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 230px;
  overflow-y: auto;
}

.battle-log li {
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.74);
  border: 1px solid rgba(148, 163, 184, 0.12);
  font-size: 0.8rem;
  line-height: 1.4;
}

.battle-log li.log-hit {
  border-color: rgba(251, 113, 133, 0.35);
  background: rgba(244, 63, 94, 0.1);
}

.battle-log li.log-sunk {
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.12);
}

/* Responsive */
@media (max-width: 900px) {
  .hub-grid,
  .bs-setup-layout,
  .bs-combat-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .scoreboard {
    grid-template-columns: 1fr 1fr;
  }

  .round-pill {
    grid-column: 1 / -1;
    order: -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 12px;
  }

  .room-row {
    flex-direction: column;
    align-items: stretch;
  }

  .room-row-right {
    justify-content: space-between;
  }
}


/* ===== 7-Game Hub Icons & Room Badges ===== */
.mono-icon { background: rgba(251, 146, 60, 0.16); color: #fdba74; border: 1px solid rgba(251, 146, 60, 0.35); }
.uno-icon { background: rgba(244, 63, 94, 0.16); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.35); }
.sol-icon { background: rgba(168, 85, 247, 0.16); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.35); }
.race-icon { background: rgba(250, 204, 21, 0.16); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.35); }
.sw-icon { background: rgba(45, 212, 191, 0.16); color: #5eead4; border: 1px solid rgba(45, 212, 191, 0.35); }

.cap-mono { background: rgba(251, 146, 60, 0.16); color: #fdba74; }
.cap-uno { background: rgba(244, 63, 94, 0.16); color: #fda4af; }
.cap-sol { background: rgba(168, 85, 247, 0.16); color: #d8b4fe; }
.cap-race { background: rgba(250, 204, 21, 0.16); color: #fde047; }
.cap-sw { background: rgba(45, 212, 191, 0.16); color: #5eead4; }

.game-type-pill.mono { background: rgba(251, 146, 60, 0.18); color: #fdba74; }
.game-type-pill.uno { background: rgba(244, 63, 94, 0.18); color: #fda4af; }
.game-type-pill.sol { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }
.game-type-pill.race { background: rgba(250, 204, 21, 0.18); color: #fde047; }
.game-type-pill.sw { background: rgba(45, 212, 191, 0.18); color: #5eead4; }

.game-picker {
  max-height: 410px;
  overflow-y: auto;
  padding-right: 4px;
}

.filter-tabs {
  flex-wrap: wrap;
}

/* ===== MONOPOLY ===== */
.mono-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.75fr;
  gap: 18px;
  align-items: start;
}

.mono-board {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, minmax(74px, 1fr));
  gap: 5px;
  background: rgba(11, 16, 32, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 18px;
  padding: 8px;
}

.mono-center {
  grid-column: 2 / 7;
  grid-row: 2 / 7;
  border-radius: 14px;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(148, 163, 184, 0.16);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.mono-dice-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.die-face {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #f8fafc;
  color: #0f172a;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.mono-space {
  position: relative;
  border-radius: 9px;
  background: rgba(20, 30, 52, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 4px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.66rem;
  overflow: hidden;
  min-height: 74px;
}

.mono-space.corner {
  background: rgba(30, 41, 59, 0.95);
  font-weight: 700;
  text-align: center;
  justify-content: center;
  align-items: center;
}

.mono-color-bar {
  height: 7px;
  border-radius: 4px;
  width: 100%;
  margin-bottom: 2px;
}

.mono-space-name {
  font-weight: 700;
  line-height: 1.15;
  color: var(--text);
}

.mono-space-price {
  font-size: 0.62rem;
  color: var(--text-muted);
}

.mono-owner-bar {
  height: 4px;
  border-radius: 99px;
  margin-top: 2px;
}

.mono-owner-bar.color-cyan { background: var(--cyan); }
.mono-owner-bar.color-coral { background: var(--coral); }
.mono-owner-bar.color-emerald { background: var(--emerald); }
.mono-owner-bar.color-amber { background: var(--amber); }

.mono-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 2px;
}

.mono-token {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 0.56rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0b1020;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.mono-token.color-cyan { background: var(--cyan); }
.mono-token.color-coral { background: var(--coral); }
.mono-token.color-emerald { background: var(--emerald); }
.mono-token.color-amber { background: var(--amber); }

.mono-houses {
  font-size: 0.62rem;
  letter-spacing: -1px;
}

.mono-prop-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 240px;
  overflow-y: auto;
}

.mono-prop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

/* ===== UNO ===== */
.uno-table {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.uno-center-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 26px 16px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.92));
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.uno-card {
  width: 82px;
  height: 122px;
  border-radius: 13px;
  border: 3px solid rgba(255, 255, 255, 0.86);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1.55rem;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  position: relative;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
  user-select: none;
}

.uno-card.color-red { background: linear-gradient(145deg, #ef4444, #b91c1c); }
.uno-card.color-yellow { background: linear-gradient(145deg, #f59e0b, #ca8a04); }
.uno-card.color-green { background: linear-gradient(145deg, #22c55e, #15803d); }
.uno-card.color-blue { background: linear-gradient(145deg, #3b82f6, #1d4ed8); }
.uno-card.color-wild { background: conic-gradient(from 45deg, #ef4444 0 90deg, #3b82f6 90deg 180deg, #22c55e 180deg 270deg, #f59e0b 270deg 360deg); }
.uno-card.deck-back { background: linear-gradient(145deg, #1e293b, #0f172a); border-color: #f43f5e; font-size: 1.05rem; }

.uno-card.playable:hover {
  transform: translateY(-10px) scale(1.05);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.5);
  z-index: 3;
}

.uno-card.unplayable {
  opacity: 0.48;
  cursor: not-allowed;
}

.uno-hand {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 12px 6px;
}

.uno-color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  vertical-align: middle;
  margin-right: 6px;
}

.uno-color-swatch.red { background: #ef4444; }
.uno-color-swatch.yellow { background: #f59e0b; }
.uno-color-swatch.green { background: #22c55e; }
.uno-color-swatch.blue { background: #3b82f6; }

.wild-picker-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.24);
  flex-wrap: wrap;
}

.wild-color-btn {
  padding: 9px 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
.wild-color-btn.red { background: #dc2626; }
.wild-color-btn.yellow { background: #d97706; }
.wild-color-btn.green { background: #16a34a; }
.wild-color-btn.blue { background: #2563eb; }

/* ===== KLONDIKE SOLITAIRE ===== */
.sol-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sol-top-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.sol-tableau {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  min-height: 360px;
  align-items: start;
}

.sol-slot {
  aspect-ratio: 5 / 7;
  min-height: 92px;
  border-radius: 11px;
  border: 2px dashed rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(148, 163, 184, 0.45);
  font-size: 1.5rem;
  cursor: pointer;
  position: relative;
}

.sol-col {
  position: relative;
  min-height: 280px;
}

.sol-card {
  width: 100%;
  aspect-ratio: 5 / 7;
  min-height: 90px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.25);
  background: #f8fafc;
  color: #0f172a;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.sol-card.suit-red { color: #dc2626; }
.sol-card.suit-black { color: #0f172a; }

.sol-card.face-down {
  background: repeating-linear-gradient(45deg, #1d4ed8, #1d4ed8 8px, #1e3a8a 8px, #1e3a8a 16px);
  border: 2px solid #93c5fd;
  color: transparent;
}

.sol-card.selected {
  outline: 3px solid var(--amber);
  box-shadow: 0 0 22px var(--amber-glow);
  transform: translateY(-4px);
  z-index: 20 !important;
}

.sol-card-stack-item {
  position: absolute;
  left: 0;
  right: 0;
}

.sol-card-corner {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  line-height: 1;
}

.sol-card-center {
  text-align: center;
  font-size: 1.75rem;
  line-height: 1;
}

/* ===== NEON DRIFT RACING ===== */
.race-canvas-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.32);
  background: #070c18;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

#racing-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 560;
}

.race-hud-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.race-stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  text-align: center;
}

.race-stat-box span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.race-stat-box strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
}

.race-touch-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== STREET HUSTLE (DOPE WARS) ===== */
.sw-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
  gap: 10px;
}

.sw-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
}

.sw-stat label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sw-stat strong {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
}

.sw-stat.cash strong { color: var(--emerald-bright); }
.sw-stat.debt strong { color: var(--coral-bright); }
.sw-stat.net strong { color: var(--cyan-bright); }

.sw-main-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.75fr;
  gap: 16px;
  align-items: start;
}

.sw-market-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.sw-market-table th,
.sw-market-table td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  text-align: left;
}

.sw-market-table th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.sw-trade-btns {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.sw-mini-btn {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
}

.sw-mini-btn.buy:hover:not(:disabled) { border-color: var(--emerald); color: var(--emerald-bright); }
.sw-mini-btn.sell:hover:not(:disabled) { border-color: var(--amber); color: var(--amber-bright); }
.sw-mini-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.sw-districts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.sw-district-btn {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sw-district-btn:hover:not(:disabled) {
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.sw-district-btn.current {
  border-color: var(--emerald);
  background: rgba(52, 211, 153, 0.14);
  cursor: default;
}

.sw-encounter-box {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.2), rgba(245, 158, 11, 0.18));
  border: 1px solid rgba(251, 113, 133, 0.55);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .mono-layout,
  .sw-main-grid {
    grid-template-columns: 1fr;
  }
}


/* ===== FULL-VIEWPORT LAYOUT & 8-PLAYER COLORS ===== */
:root {
  --violet: #a78bfa;
  --violet-bright: #c4b5fd;
  --violet-bg: rgba(167, 139, 250, 0.16);
  --pink: #f472b6;
  --pink-bright: #fbcfe8;
  --pink-bg: rgba(244, 114, 182, 0.16);
  --lime: #a3e635;
  --lime-bright: #bef264;
  --lime-bg: rgba(163, 230, 53, 0.16);
  --orange: #fb923c;
  --orange-bright: #fdba74;
  --orange-bg: rgba(251, 146, 60, 0.16);
}

.app-shell {
  max-width: none;
  width: 100%;
  min-height: 100vh;
  padding: 14px 20px 24px;
  gap: 14px;
}

.game-layout {
  flex: 1;
  min-height: calc(100vh - 96px);
  width: 100%;
}

.hub-grid {
  flex: 1;
  grid-template-columns: minmax(380px, 460px) 1fr;
  min-height: calc(100vh - 104px);
}

.scoreboard,
#ttt-view .status-banner,
#ttt-view .victory-banner,
#ttt-view .invite-banner {
  max-width: none;
}

.board-stage {
  flex: 1;
  align-items: center;
}

.board-wrapper {
  width: min(56vh, 520px, 90vw);
}

.bs-combat-layout,
.bs-setup-layout {
  flex: 1;
}

.bs-grid-frame {
  max-width: min(56vh, 540px);
}

.bs-grid-frame.compact-grid {
  max-width: min(38vh, 360px);
}

.race-canvas-wrap {
  width: 100%;
  max-height: calc(100vh - 250px);
  display: flex;
  justify-content: center;
  align-items: center;
}

#racing-canvas {
  max-height: calc(100vh - 255px);
  width: auto;
  max-width: 100%;
}

/* 8-player color extensions */
.mini-player-chip.color-violet { border-color: rgba(167, 139, 250, 0.5); color: var(--violet-bright); }
.mini-player-chip.color-pink { border-color: rgba(244, 114, 182, 0.5); color: var(--pink-bright); }
.mini-player-chip.color-lime { border-color: rgba(163, 230, 53, 0.5); color: var(--lime-bright); }
.mini-player-chip.color-orange { border-color: rgba(251, 146, 60, 0.5); color: var(--orange-bright); }

.admiral-card.active-turn.color-violet { border-color: var(--violet); box-shadow: 0 0 22px rgba(167, 139, 250, 0.25); transform: translateY(-2px); }
.admiral-card.active-turn.color-pink { border-color: var(--pink); box-shadow: 0 0 22px rgba(244, 114, 182, 0.25); transform: translateY(-2px); }
.admiral-card.active-turn.color-lime { border-color: var(--lime); box-shadow: 0 0 22px rgba(163, 230, 53, 0.25); transform: translateY(-2px); }
.admiral-card.active-turn.color-orange { border-color: var(--orange); box-shadow: 0 0 22px rgba(251, 146, 60, 0.25); transform: translateY(-2px); }

.admiral-badge.color-violet { background: var(--violet-bg); color: var(--violet-bright); border: 1px solid rgba(167, 139, 250, 0.45); }
.admiral-badge.color-pink { background: var(--pink-bg); color: var(--pink-bright); border: 1px solid rgba(244, 114, 182, 0.45); }
.admiral-badge.color-lime { background: var(--lime-bg); color: var(--lime-bright); border: 1px solid rgba(163, 230, 53, 0.45); }
.admiral-badge.color-orange { background: var(--orange-bg); color: var(--orange-bright); border: 1px solid rgba(251, 146, 60, 0.45); }

.status-banner.your-turn-violet { background: var(--violet-bg); border-color: rgba(167, 139, 250, 0.5); color: var(--violet-bright); }
.status-banner.your-turn-pink { background: var(--pink-bg); border-color: rgba(244, 114, 182, 0.5); color: var(--pink-bright); }
.status-banner.your-turn-lime { background: var(--lime-bg); border-color: rgba(163, 230, 53, 0.5); color: var(--lime-bright); }
.status-banner.your-turn-orange { background: var(--orange-bg); border-color: rgba(251, 146, 60, 0.5); color: var(--orange-bright); }

.mono-owner-bar.color-violet, .mono-token.color-violet { background: var(--violet); }
.mono-owner-bar.color-pink, .mono-token.color-pink { background: var(--pink); }
.mono-owner-bar.color-lime, .mono-token.color-lime { background: var(--lime); }
.mono-owner-bar.color-orange, .mono-token.color-orange { background: var(--orange); }

/* ===== 40-SPACE FULL-VIEWPORT MONOPOLY BOARD ===== */
.mono-layout {
  grid-template-columns: minmax(620px, 1.45fr) minmax(320px, 0.75fr);
  gap: 16px;
  flex: 1;
}

.mono-board-40 {
  display: grid;
  grid-template-columns: repeat(11, minmax(0, 1fr));
  grid-template-rows: repeat(11, minmax(56px, 1fr));
  gap: 3px;
  background: rgba(11, 16, 32, 0.94);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  padding: 6px;
  min-height: calc(100vh - 230px);
}

.mono-center-40 {
  grid-column: 2 / 11;
  grid-row: 2 / 11;
  border-radius: 14px;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.94));
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  overflow-y: auto;
}

.mono-board-40 .mono-space {
  min-height: 54px;
  padding: 3px;
  font-size: 0.58rem;
  border-radius: 7px;
}

.mono-board-40 .mono-space.active-hop {
  border-color: var(--amber);
  box-shadow: 0 0 16px var(--amber-glow);
  z-index: 4;
}

.mono-token {
  width: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 0.54rem;
  font-weight: 800;
  white-space: nowrap;
}

.mono-token.hopping {
  animation: token-hop 0.16s ease-out;
}

@keyframes token-hop {
  0% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.35) translateY(-5px); }
  100% { transform: scale(1) translateY(0); }
}

.pot-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--emerald-bright);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
}

.mono-panel-box {
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  width: 100%;
  max-width: 520px;
  text-align: left;
}

.prop-check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.prop-check-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border);
  font-size: 0.75rem;
  cursor: pointer;
}

/* ===== UNO STACK ALERT ===== */
.uno-stack-alert {
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(244, 63, 94, 0.28), rgba(245, 158, 11, 0.28));
  border: 1px solid rgba(251, 113, 133, 0.7);
  color: #fef08a;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  animation: pip-pulse 1.1s ease-in-out infinite;
}

/* ===== STREET HUSTLE CLEAN INPUTS ===== */
.sw-qty-input,
.sw-bank-input {
  width: 78px;
  padding: 6px 8px;
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.84rem;
  font-family: 'Space Grotesk', monospace;
}

.sw-bank-input {
  width: 100%;
  margin-bottom: 8px;
}

@media (max-width: 1120px) {
  .mono-layout {
    grid-template-columns: 1fr;
  }
}


/* ===== 10-Game Badges (Checkers, Tetris, Block Breaker) ===== */
.chk-icon { background: rgba(244, 63, 94, 0.18); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.4); }
.tet-icon { background: rgba(99, 102, 241, 0.18); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.4); }
.brk-icon { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border: 1px solid rgba(245, 158, 11, 0.4); }

.cap-chk, .game-type-pill.chk { background: rgba(244, 63, 94, 0.18); color: #fda4af; }
.cap-tet, .game-type-pill.tet { background: rgba(99, 102, 241, 0.18); color: #a5b4fc; }
.cap-brk, .game-type-pill.brk { background: rgba(245, 158, 11, 0.18); color: #fcd34d; }

/* ===== CHECKERS ===== */
.checkers-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
}

.checkers-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  width: min(68vh, 600px, 94vw);
  aspect-ratio: 1 / 1;
  border-radius: 18px;
  overflow: hidden;
  border: 3px solid rgba(148, 163, 184, 0.35);
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.5);
}

.chk-sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  padding: 0;
  cursor: default;
}

.chk-sq.light { background: #cbd5e1; }
.chk-sq.dark { background: #1e293b; }

.chk-sq.legal-dest {
  cursor: pointer;
  background: radial-gradient(circle, rgba(52, 211, 153, 0.38) 0%, #1e293b 72%);
}

.chk-sq.legal-dest::after {
  content: '';
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: rgba(52, 211, 153, 0.85);
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.85);
}

.chk-sq.jump-dest::after {
  background: #fbbf24;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.9);
}

.chk-sq.last-move {
  box-shadow: inset 0 0 0 3px rgba(56, 189, 248, 0.6);
}

.chk-piece {
  width: 76%;
  height: 76%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
  position: relative;
}

.chk-piece.p1 {
  background: radial-gradient(circle at 32% 30%, #7dd3fc, #0284c7 68%, #075985);
  border: 3px solid #bae6fd;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

.chk-piece.p2 {
  background: radial-gradient(circle at 32% 30%, #fda4af, #e11d48 68%, #881337);
  border: 3px solid #fecdd3;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.35);
}

.chk-sq.selectable {
  cursor: pointer;
}

.chk-sq.selectable:hover .chk-piece {
  transform: scale(1.08) translateY(-2px);
}

.chk-sq.must-jump .chk-piece {
  box-shadow: 0 0 0 3px #fbbf24, 0 0 18px rgba(251, 191, 36, 0.75);
}

.chk-sq.selected .chk-piece {
  transform: scale(1.12) translateY(-3px);
  box-shadow: 0 0 0 4px #ffffff, 0 0 24px rgba(56, 189, 248, 0.9);
}

/* ===== TETRIS ===== */
.tetris-layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) auto minmax(220px, 280px);
  gap: 18px;
  justify-content: center;
  align-items: start;
  flex: 1;
}

.tetris-canvas-box {
  padding: 10px;
  border-radius: 18px;
  background: rgba(11, 16, 32, 0.94);
  border: 2px solid rgba(99, 102, 241, 0.45);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
}

#tetris-canvas {
  display: block;
  height: min(74vh, 640px);
  width: auto;
  aspect-ratio: 10 / 20;
  border-radius: 8px;
}

.tetris-mini-canvas {
  display: block;
  margin: 8px auto 0;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 10px;
  border: 1px solid var(--border);
}

/* ===== BLOCK BREAKER ===== */
.breaker-canvas-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 2px solid rgba(245, 158, 11, 0.38);
  background: #070c18;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

#breaker-canvas {
  display: block;
  max-height: calc(100vh - 250px);
  width: auto;
  max-width: 100%;
  aspect-ratio: 900 / 560;
  cursor: none;
}

@media (max-width: 900px) {
  .tetris-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }
}


/* =====================================================================
   14-GAME UPDATE: new card games + VIEWPORT FILL PASS (authoritative)
   ===================================================================== */
.c8-icon { background: rgba(250, 204, 21, 0.18); color: #fde047; border: 1px solid rgba(250, 204, 21, 0.4); }
.p10-icon { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.4); }
.pok-icon { background: rgba(34, 197, 94, 0.18); color: #86efac; border: 1px solid rgba(34, 197, 94, 0.4); }
.cah-icon { background: #0b0b0f; color: #fff; border: 1px solid rgba(255, 255, 255, 0.55); font-size: 0.78rem; }
.cap-c8, .game-type-pill.c8 { background: rgba(250, 204, 21, 0.18); color: #fde047; }
.cap-p10, .game-type-pill.p10 { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }
.cap-pok, .game-type-pill.pok { background: rgba(34, 197, 94, 0.18); color: #86efac; }
.cap-cah, .game-type-pill.cah { background: rgba(255, 255, 255, 0.14); color: #f8fafc; }

/* ---- Viewport fill: every active view stretches to the full window ---- */
html, body { height: 100%; }
body { min-height: 100vh; }

.app-shell {
  width: 100%;
  max-width: none;
  min-height: 100vh;
  padding: 12px 18px 16px;
  gap: 12px;
}

.app-shell > section:not(.hidden) {
  flex: 1 1 auto;
  min-height: 0;
}

.game-layout {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 90px);
}

.hub-grid {
  grid-template-columns: minmax(440px, 560px) 1fr;
  min-height: calc(100vh - 96px);
  align-items: stretch;
}

.hub-create-panel,
.hub-rooms-panel {
  min-height: 0;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
}

.rooms-list {
  flex: 1;
  overflow-y: auto;
  align-content: start;
}

.game-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: none;
  overflow: visible;
  gap: 8px;
}

.game-card { padding: 9px 10px; }
.game-card-icon { width: 36px; height: 36px; font-size: 0.95rem; }
.game-card-body p {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 0.72rem;
}
.game-card-title-row strong { font-size: 0.86rem; }

/* Scale every board to the space actually available */
.board-wrapper { width: min(calc(100vh - 360px), 94vw, 920px); min-width: 260px; }
.bs-grid-frame { max-width: min(calc(100vh - 320px), 100%); }
.bs-grid-frame.compact-grid { max-width: min(calc(50vh - 110px), 100%); }
.checkers-board { width: min(calc(100vh - 300px), 94vw); }
.mono-board-40 { min-height: calc(100vh - 250px); }
.sol-tableau { min-height: calc(100vh - 400px); }
#racing-canvas { height: calc(100vh - 280px); width: auto; max-width: 100%; max-height: none; }
#breaker-canvas { height: calc(100vh - 280px); width: auto; max-width: 100%; max-height: none; }
#tetris-canvas { height: calc(100vh - 230px); }
.race-canvas-wrap, .breaker-canvas-wrap { max-height: none; }

/* ---- Shared card-game kit ---- */
.gk-table { display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
.gk-center-arena {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 6vw, 90px);
  padding: 18px;
  border-radius: var(--radius-lg);
  background: radial-gradient(circle at center, rgba(22, 101, 52, 0.35), rgba(15, 23, 42, 0.92));
  border: 1px solid var(--border);
  flex-wrap: wrap;
  min-height: 200px;
}
.gk-pile { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.gk-hand-panel { margin-top: auto; }
.gk-hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; padding: 8px 4px; }
.gk-select {
  background: #0f172a; color: #f1f5f9; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 8px; font-size: 0.82rem;
}

.suit-chip {
  padding: 6px 14px; border-radius: 999px; background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border); font-weight: 700; font-size: 0.9rem;
}
.suit-chip.red { color: #fb7185; }
.suit-pick-btn {
  padding: 10px 18px; border-radius: 999px; border: 2px solid rgba(255, 255, 255, 0.7);
  background: #f8fafc; color: #0f172a; font-weight: 800; cursor: pointer; font-size: 0.95rem;
}
.suit-pick-btn.red { color: #dc2626; }
.suit-pick-btn:hover { transform: translateY(-2px); }

/* Playing cards */
.pc {
  position: relative;
  width: clamp(66px, 7.4vw, 108px);
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.3);
  background: #f8fafc;
  color: #0f172a;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
  cursor: default;
  transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
  user-select: none;
}
.pc.red { color: #dc2626; }
.pc-corner { position: absolute; top: 6px; left: 8px; font-size: clamp(0.8rem, 1.1vw, 1.05rem); line-height: 1.05; text-align: center; }
.pc-corner-b { top: auto; left: auto; bottom: 6px; right: 8px; transform: rotate(180deg); }
.pc-mid { font-size: clamp(1.6rem, 2.6vw, 2.6rem); }
.pc.small { width: clamp(40px, 3.8vw, 56px); border-radius: 7px; }
.pc.small .pc-corner { font-size: 0.66rem; top: 3px; left: 4px; }
.pc.small .pc-corner-b { top: auto; left: auto; bottom: 3px; right: 4px; }
.pc.small .pc-mid { font-size: 1.15rem; }
.pc.static { cursor: default; }
.pc.playable { cursor: pointer; }
.pc.playable:hover:not(:disabled) { transform: translateY(-12px) scale(1.05); box-shadow: 0 18px 32px rgba(0, 0, 0, 0.55); z-index: 3; }
.pc.unplayable { opacity: 0.5; }
.pc.win { outline: 3px solid #fbbf24; box-shadow: 0 0 22px rgba(251, 191, 36, 0.8); }
.pc.empty { background: rgba(15, 23, 42, 0.45); border: 2px dashed rgba(148, 163, 184, 0.3); box-shadow: none; }
.pc.back {
  background: repeating-linear-gradient(45deg, #1d4ed8, #1d4ed8 8px, #1e3a8a 8px, #1e3a8a 16px);
  border: 3px solid #bfdbfe; color: #fff; flex-direction: column; font-size: 0.9rem;
}
.pc.back small { font-size: 0.68rem; opacity: 0.9; }
.pc.back span { font-size: 1rem; }
.pc.back.playable { cursor: pointer; box-shadow: 0 0 0 3px #fde047, 0 0 22px rgba(253, 224, 71, 0.6); }

/* ---- Phase 10 ---- */
.p10-layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(300px, 0.9fr); gap: 14px; flex: 1; min-height: 0; }
.p10-left { display: flex; flex-direction: column; gap: 12px; }
.p10-right { overflow-y: auto; max-height: calc(100vh - 560px); min-height: 240px; }
.p10-card {
  position: relative;
  width: clamp(54px, 5.8vw, 86px);
  aspect-ratio: 5 / 7;
  border-radius: 10px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  color: #fff;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: clamp(1.1rem, 2vw, 1.9rem);
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: transform 0.14s ease, opacity 0.14s ease;
}
.p10-card:disabled { cursor: default; }
.p10-card.color-red { background: linear-gradient(145deg, #ef4444, #b91c1c); }
.p10-card.color-blue { background: linear-gradient(145deg, #3b82f6, #1d4ed8); }
.p10-card.color-green { background: linear-gradient(145deg, #22c55e, #15803d); }
.p10-card.color-yellow { background: linear-gradient(145deg, #f59e0b, #ca8a04); }
.p10-card.color-wild { background: conic-gradient(from 45deg, #ef4444 0 90deg, #3b82f6 90deg 180deg, #22c55e 180deg 270deg, #f59e0b 270deg 360deg); }
.p10-card.color-skip { background: linear-gradient(145deg, #334155, #0f172a); border-color: #f43f5e; }
.p10-card.back { background: linear-gradient(145deg, #1e293b, #0f172a); border-color: #a855f7; font-size: 0.95rem; }
.p10-card.back.playable { box-shadow: 0 0 0 3px #fde047, 0 0 22px rgba(253, 224, 71, 0.6); }
.p10-card.empty { background: rgba(15, 23, 42, 0.45); border: 2px dashed rgba(148, 163, 184, 0.3); box-shadow: none; }
.p10-card.small { width: clamp(38px, 3.8vw, 54px); font-size: 1rem; border-width: 2px; border-radius: 8px; }
.p10-card.small small { font-size: 0.55rem; }
.p10-card.selected { transform: translateY(-14px); outline: 3px solid #fde047; box-shadow: 0 0 24px rgba(253, 224, 71, 0.7); z-index: 4; }
.p10-card.dim { opacity: 0.5; }
.p10-card:not(:disabled):not(.back):hover { transform: translateY(-6px); }
.p10-card.selected:hover { transform: translateY(-14px); }
.slot-tag { position: absolute; top: 2px; right: 3px; font-size: 0.6rem; font-style: normal; background: rgba(0, 0, 0, 0.6); padding: 1px 4px; border-radius: 4px; }
.p10-slot { padding: 10px; border-radius: 12px; background: rgba(15, 23, 42, 0.7); border: 1px dashed var(--border); margin-top: 8px; }
.p10-slot.ok { border-color: var(--emerald); background: rgba(52, 211, 153, 0.08); }
.p10-group { margin-top: 8px; padding: 8px; border-radius: 10px; background: rgba(15, 23, 42, 0.7); border: 1px solid var(--border); }
.p10-group-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 0.82rem; flex-wrap: wrap; }
.p10-group-head span { display: inline-flex; gap: 6px; }
.p10-group-cards { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.p10-laid-owner h4 { margin: 10px 0 0; font-family: 'Space Grotesk', sans-serif; font-size: 0.92rem; }

/* ---- Poker ---- */
.pk-table { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: calc(100vh - 110px); }
.pk-seats { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.pk-seat {
  width: clamp(150px, 13.5vw, 210px);
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.pk-seat.acting { border-color: #fde047; box-shadow: 0 0 26px rgba(253, 224, 71, 0.45); }
.pk-seat.out { opacity: 0.45; }
.pk-seat.winner { border-color: var(--emerald); box-shadow: 0 0 28px rgba(52, 211, 153, 0.55); }
.pk-seat-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 0.9rem; }
.pk-chips { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.1rem; margin-top: 4px; }
.pk-status { font-size: 0.76rem; color: var(--text-muted); }
.pk-bet { margin-top: 4px; display: inline-block; padding: 2px 8px; border-radius: 999px; background: rgba(251, 191, 36, 0.18); color: #fde68a; font-size: 0.74rem; font-weight: 700; }
.pk-reveal { display: flex; gap: 4px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.pk-reveal small { font-size: 0.7rem; color: #fde68a; }
.pk-tag { font-size: 0.6rem; font-weight: 800; padding: 1px 5px; border-radius: 999px; background: rgba(148, 163, 184, 0.25); }
.pk-tag.dealer { background: #f8fafc; color: #0f172a; }
.pk-felt {
  flex: 1;
  min-height: 260px;
  border-radius: 30px;
  background: radial-gradient(ellipse at center, #15803d 0%, #166534 45%, #14532d 100%);
  border: 6px solid #3f2a14;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.45), 0 20px 50px rgba(0, 0, 0, 0.45);
  padding: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.pk-felt-info { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; align-items: center; }
.pk-community { display: flex; gap: clamp(6px, 1vw, 14px); justify-content: center; flex-wrap: wrap; }
.pk-community .pc { width: clamp(64px, 7vw, 104px); }
.pk-results {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 18px;
  border-radius: 14px; background: rgba(11, 16, 32, 0.78); border: 1px solid rgba(253, 224, 71, 0.45);
  text-align: center; font-size: 0.95rem;
}
.pk-me-cards { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.pk-hole { display: flex; gap: 10px; margin-top: 4px; }
.pk-me-stats { display: flex; gap: 10px; }
.pk-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.pk-raise { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.pk-raise input[type='range'] { width: clamp(120px, 18vw, 260px); accent-color: #f43f5e; }
.pk-quick { display: flex; gap: 4px; }

/* ---- Cards Against Humanity ---- */
.cah-layout { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: 16px; flex: 1; min-height: 0; align-items: stretch; }
.cah-left { display: flex; flex-direction: column; align-items: flex-start; }
.cah-black {
  background: #0a0a0d;
  color: #fff;
  border: 3px solid #fff;
  border-radius: 16px;
  padding: 22px 22px 16px;
  min-height: clamp(220px, 34vh, 420px);
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}
.cah-black-text { font-family: 'Inter', sans-serif; font-weight: 800; font-size: clamp(1.1rem, 1.9vw, 1.75rem); line-height: 1.3; }
.cah-black-foot { display: flex; justify-content: space-between; align-items: center; font-size: 0.72rem; color: rgba(255, 255, 255, 0.65); margin-top: 14px; }
.cah-black-foot b { background: #fff; color: #0a0a0d; padding: 2px 8px; border-radius: 999px; }
.cah-ans { color: #fde047; text-decoration: underline; text-underline-offset: 3px; }
.cah-blank { text-decoration: underline; }
.cah-main { display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.cah-wait { text-align: center; padding: 34px 20px; }
.cah-sub-preview { max-width: 420px; margin: 12px auto; }
.cah-hand { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(150px, 14vw, 210px), 1fr)); gap: 12px; }
.cah-white {
  position: relative;
  text-align: left;
  background: #f8fafc;
  color: #0a0a0d;
  border: 3px solid transparent;
  border-radius: 12px;
  padding: 14px;
  min-height: clamp(110px, 17vh, 190px);
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: clamp(0.88rem, 1.1vw, 1.08rem);
  line-height: 1.3;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.14s ease, border-color 0.14s ease;
}
.cah-white:hover { transform: translateY(-5px); }
.cah-white.picked { border-color: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.4), 0 12px 26px rgba(0, 0, 0, 0.5); transform: translateY(-8px); }
.cah-order { position: absolute; top: 6px; right: 8px; background: #fbbf24; color: #0a0a0d; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; }
.cah-submissions { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(260px, 26vw, 380px), 1fr)); gap: 14px; }
.cah-submission { background: none; border: 3px solid transparent; border-radius: 18px; padding: 0; cursor: pointer; color: inherit; text-align: left; }
.cah-submission:disabled, .cah-submission.static { cursor: default; }
.cah-submission:not(:disabled):not(.static):hover { transform: translateY(-4px); }
.cah-submission.picked { border-color: #fbbf24; box-shadow: 0 0 26px rgba(251, 191, 36, 0.55); }
.cah-submission .cah-black { min-height: 0; padding: 16px; }
.cah-submission .cah-black-text { font-size: clamp(0.95rem, 1.3vw, 1.2rem); }
.cah-win-card { max-width: 520px; margin: 4px auto 12px; width: 100%; }
.cah-others { margin-top: 8px; }
.cah-others summary { cursor: pointer; color: var(--text-muted); font-size: 0.86rem; margin-bottom: 10px; }

@media (max-width: 1100px) {
  .hub-grid { grid-template-columns: 1fr; }
  .game-picker { grid-template-columns: 1fr; }
  .p10-layout, .cah-layout { grid-template-columns: 1fr; }
  .hub-create-panel, .hub-rooms-panel { max-height: none; }
}

/* ---- Fit-to-window polish ---- */
.cah-main .gk-hand-panel { margin-top: 0; }
.cah-main { justify-content: flex-start; }
.p10-slot { padding: 6px 10px; margin-top: 6px; }
.p10-left { gap: 8px; }
.p10-left .gk-center-arena { min-height: 0; padding: 10px; }
.p10-left .panel-card, .p10-right { padding: 14px; }
.p10-right { max-height: calc(100vh - 470px); }
.gk-roster .admiral-card { padding: 8px 12px; }
@media (max-height: 820px) {
  .pc { width: clamp(56px, 6vw, 92px); }
  .p10-card { width: clamp(46px, 5vw, 72px); }
  .gk-center-arena { min-height: 150px; padding: 10px; }
  .gk-hand { gap: 6px; }
}


/* ---- CAH expansion pack picker ---- */
.pack-list {
  max-height: 210px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
}
.pack-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 7px;
  font-size: 0.8rem;
  cursor: pointer;
}
.pack-item:hover { background: rgba(56, 189, 248, 0.1); }
.pack-item input { accent-color: #38bdf8; }
.pack-item .pack-name { flex: 1; font-weight: 600; }
.pack-item small { color: var(--text-muted); font-size: 0.68rem; white-space: nowrap; }


/* =====================================================================
   CHAT + VOICE PANEL
   ===================================================================== */
.chat-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
}
.chat-fab:hover { transform: translateY(-2px); }
.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #f43f5e;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chat-panel {
  position: fixed;
  right: 16px;
  bottom: 82px;
  z-index: 71;
  width: min(360px, calc(100vw - 24px));
  height: min(520px, 70vh);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(13, 20, 38, 0.97);
  border: 1px solid rgba(148, 163, 184, 0.3);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(14px);
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-family: 'Space Grotesk', sans-serif;
}
.chat-voice-controls { display: flex; gap: 6px; }
.chat-mini {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-height: 34px;
}
.chat-mini.active { background: rgba(52, 211, 153, 0.2); border-color: var(--emerald); color: var(--emerald-bright); }
.chat-voice-info { padding: 6px 12px; font-size: 0.76rem; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.chat-list {
  list-style: none;
  margin: 0;
  padding: 10px 12px;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-msg { max-width: 92%; align-self: flex-start; }
.chat-msg.mine { align-self: flex-end; text-align: right; }
.chat-who { font-weight: 700; font-size: 0.78rem; }
.chat-who.color-cyan { color: var(--cyan-bright); }
.chat-who.color-coral { color: var(--coral-bright); }
.chat-who.color-emerald { color: var(--emerald-bright); }
.chat-who.color-amber { color: var(--amber-bright); }
.chat-who.color-violet { color: var(--violet-bright); }
.chat-who.color-pink { color: var(--pink-bright); }
.chat-who.color-lime { color: var(--lime-bright); }
.chat-who.color-orange { color: var(--orange-bright); }
.chat-time { font-size: 0.66rem; color: var(--text-muted); margin-left: 6px; }
.chat-text {
  margin-top: 2px;
  padding: 7px 11px;
  border-radius: 12px;
  background: rgba(30, 41, 59, 0.9);
  font-size: 0.88rem;
  line-height: 1.35;
  word-break: break-word;
  display: inline-block;
  text-align: left;
}
.chat-msg.mine .chat-text { background: rgba(14, 165, 233, 0.28); }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); }
.chat-form input { flex: 1; min-width: 0; }
.chat-send {
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  background: linear-gradient(135deg, #0ea5e9, #6366f1);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* =====================================================================
   MOBILE / TOUCH
   ===================================================================== */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, .btn, input, select, label { touch-action: manipulation; }
canvas { touch-action: none; }
.app-shell { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
@supports (height: 100dvh) {
  body { min-height: 100dvh; }
  .app-shell { min-height: 100dvh; }
}

@media (max-width: 700px) {
  .app-shell { padding: 8px 8px calc(84px + env(safe-area-inset-bottom)); gap: 8px; }
  .brand-subtitle, #fullscreen-btn { display: none; }
  .brand h1 { font-size: 1.1rem; }
  .brand-logo { width: 38px; height: 38px; }
  .top-header { gap: 8px; }
  .header-actions { width: 100%; justify-content: flex-start; gap: 6px; }
  .icon-btn { padding: 8px 12px; min-height: 40px; }
  .room-pill { padding: 3px 4px 3px 10px; }

  /* comfortable tap targets; 16px inputs stop iOS zooming on focus */
  .btn, .seg-btn, .filter-tab, .sw-mini-btn { min-height: 42px; }
  .btn-small { min-height: 38px; }
  input[type='text'], input[type='number'], select { font-size: 16px; min-height: 42px; }
  .panel-card { padding: 14px; border-radius: 16px; overflow-x: auto; }
  .status-banner { font-size: 0.86rem; padding: 8px 10px; }
  .victory-banner { padding: 12px; gap: 10px; }
  .victory-actions { width: 100%; align-items: stretch; }
  .game-toast { bottom: calc(80px + env(safe-area-inset-bottom)); max-width: 92vw; text-align: center; }

  /* name gate + hub */
  .name-gate-card { margin-top: 6px; padding: 18px; }
  .name-gate-form input { min-width: 0; }
  .hub-grid { grid-template-columns: 1fr; min-height: 0; }
  .hub-create-panel, .hub-rooms-panel { max-height: none; overflow: visible; padding: 14px; }
  .game-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .game-card { padding: 10px; gap: 8px; }
  .game-card-body p { display: none; }
  .game-card-title-row { flex-direction: column; align-items: flex-start; gap: 3px; }
  .game-card-icon { width: 34px; height: 34px; }
  .create-btn-row { grid-template-columns: 1fr; }
  .rooms-toolbar { flex-direction: column; align-items: stretch; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; -webkit-overflow-scrolling: touch; }
  .filter-tab { white-space: nowrap; }
  .code-join-inline { width: 100%; }
  #join-code-input { flex: 1; width: auto; }
  .rooms-list { min-height: 100px; overflow: visible; }
  .room-row { flex-direction: column; align-items: stretch; }
  .room-row-right { justify-content: space-between; }
  .pack-list { max-height: 180px; }

  /* shared roster / banners */
  .bs-roster, .gk-roster { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .admiral-card { padding: 8px 10px; }
  .admiral-card .player-name { font-size: 0.82rem; }
  .admiral-card .turn-tag { font-size: 0.68rem; }
  .game-layout { min-height: 0; }

  /* Tic-Tac-Toe / Checkers / Battleship */
  .scoreboard { grid-template-columns: 1fr 1fr; }
  .board-wrapper { width: min(94vw, calc(100dvh - 380px)); min-width: 250px; }
  .checkers-board { width: min(96vw, calc(100dvh - 330px)); min-width: 250px; }
  .bs-setup-layout, .bs-combat-layout { grid-template-columns: 1fr; }
  .bs-grid-frame, .bs-grid-frame.compact-grid { max-width: 100%; }
  .bs-cell { font-size: 0.8rem; }
  .target-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Monopoly: fit the whole 40-space board on screen */
  .mono-layout { grid-template-columns: 1fr; }
  .mono-board-40 {
    min-height: 0;
    width: 100%;
    aspect-ratio: 1 / 1;
    grid-template-rows: repeat(11, minmax(0, 1fr));
    gap: 1px;
    padding: 3px;
    border-radius: 10px;
  }
  .mono-board-40 .mono-space { min-height: 0; padding: 1px; font-size: 0.34rem; border-radius: 3px; overflow: hidden; }
  .mono-board-40 .mono-space-name { line-height: 1.05; }
  .mono-board-40 .mono-space-price { display: none; }
  .mono-board-40 .mono-color-bar { height: 3px; }
  .mono-board-40 .mono-houses { font-size: 0.4rem; }
  .mono-board-40 .mono-owner-bar { height: 2px; }
  .mono-token { min-width: 11px; height: 11px; font-size: 0.38rem; padding: 0 2px; }
  .mono-center-40 { padding: 6px; gap: 6px; overflow-y: auto; }
  .mono-center-40 .btn { padding: 8px 10px; font-size: 0.8rem; min-height: 38px; }
  .mono-panel-box { max-width: 100%; padding: 8px; font-size: 0.78rem; }
  .die-face { width: 34px; height: 34px; font-size: 1.1rem; border-radius: 8px; }
  .pot-badge { font-size: 0.7rem; padding: 4px 8px; }

  /* card games */
  .uno-card { width: 58px; height: 86px; font-size: 1.15rem; border-width: 2px; }
  .uno-hand { gap: 6px; }
  .uno-center-arena, .gk-center-arena { gap: 14px; padding: 10px; min-height: 0; }
  .pc { width: clamp(52px, 15vw, 82px); }
  .pc.small { width: clamp(34px, 9vw, 46px); }
  .gk-hand { gap: 6px; }
  .p10-layout, .cah-layout { grid-template-columns: 1fr; }
  .p10-right { max-height: none; }
  .p10-card { width: clamp(44px, 12vw, 64px); font-size: 1.1rem; }
  .p10-card.small { width: clamp(34px, 9vw, 44px); }

  /* Solitaire */
  .sol-top-row, .sol-tableau { gap: 4px; }
  .sol-card { padding: 2px 3px; min-height: 0; border-radius: 5px; }
  .sol-card-corner { font-size: 0.55rem; }
  .sol-card-center { font-size: 0.9rem; }
  .sol-slot { min-height: 0; font-size: 1rem; border-radius: 6px; }
  .sol-tableau { min-height: 360px; }

  /* Racing / Block Breaker / Tetris: full-width canvases + big touch buttons */
  #racing-canvas, #breaker-canvas { height: auto; width: 100%; max-width: 100%; }
  .race-canvas-wrap, .breaker-canvas-wrap { max-height: none; }
  .race-hud-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .race-touch-controls { gap: 8px; }
  .race-touch-controls .btn { min-width: 76px; min-height: 58px; font-size: 1rem; user-select: none; touch-action: none; }
  .tetris-layout { grid-template-columns: 1fr; justify-items: center; }
  .tetris-canvas-box { order: -1; }
  .tetris-layout .bs-side-column { width: 100%; }
  #tetris-canvas { height: min(56dvh, 500px); }

  /* Street Hustle */
  .sw-main-grid { grid-template-columns: 1fr; }
  .sw-stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sw-market-table { display: block; overflow-x: auto; }
  .sw-qty-input { width: 64px; }

  /* Poker */
  .pk-table { min-height: 0; }
  .pk-seats { gap: 6px; }
  .pk-seat { width: calc(50% - 4px); padding: 8px 10px; }
  .pk-felt { border-width: 4px; border-radius: 22px; padding: 12px; min-height: 200px; }
  .pk-community { gap: 5px; }
  .pk-community .pc { width: clamp(44px, 14vw, 68px); }
  .pk-me-cards { flex-direction: column; align-items: flex-start; }
  .pk-actions .btn { flex: 1; }
  .pk-raise { width: 100%; }
  .pk-raise input[type='range'] { width: 100%; }

  /* Cards Against Humanity */
  .cah-black { min-height: 150px; padding: 14px; }
  .cah-hand { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cah-white { min-height: 110px; padding: 10px; font-size: 0.82rem; }
  .cah-submissions { grid-template-columns: 1fr; }

  /* Chat becomes a bottom sheet */
  .chat-fab { right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
  .chat-panel { right: 0; left: 0; bottom: 0; width: auto; height: 74dvh; border-radius: 18px 18px 0 0; }
}

/* Phones held sideways: keep boards a usable size and let the page scroll */
@media (max-height: 520px) and (orientation: landscape) {
  .app-shell { padding-top: 6px; gap: 6px; }
  .board-wrapper { width: clamp(240px, 70vh, 94vw); }
  .checkers-board { width: clamp(240px, 78vh, 94vw); }
  .bs-grid-frame, .bs-grid-frame.compact-grid { max-width: clamp(240px, 80vh, 100%); }
  #racing-canvas, #breaker-canvas { height: auto; width: min(100%, 130vh); }
  #tetris-canvas { height: 76vh; }
  .chat-panel { height: 80vh; bottom: 70px; }
  .hub-create-panel, .hub-rooms-panel { max-height: none; }
}


/* Grid columns must be allowed to shrink below their content on phones */
@media (max-width: 700px) {
  .hub-grid, .p10-layout, .cah-layout, .mono-layout, .sw-main-grid,
  .bs-setup-layout, .bs-combat-layout, .tetris-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .hub-create-panel, .hub-rooms-panel, .panel-card, .bs-side-column { min-width: 0; }
  .game-card { min-width: 0; }
  .game-card-body { min-width: 0; }
  .game-card-body strong { overflow-wrap: anywhere; }
}


/* Phones: hide empty seats and keep the Tetris controls right under the board */
@media (max-width: 700px) {
  .admiral-card.open-seat { display: none; }
  .tetris-layout { display: flex; flex-direction: column; align-items: center; gap: 10px; }
  .tetris-layout > .tetris-canvas-box { order: 1; }
  .tetris-layout > .bs-side-column:nth-child(3) { order: 2; width: 100%; }
  .tetris-layout > .bs-side-column:nth-child(1) {
    order: 3;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .tetris-layout .race-stat-box { padding: 6px 10px; }
  .tetris-layout .panel-card { margin: 0; }
  .tetris-layout > .bs-side-column:nth-child(3) button { min-height: 48px; font-size: 0.95rem; }
}
