:root {
  --primary: #d71e56;
  --primary-hover: #b8184a;
  --secondary: #a855f7;        /* purple-500 */
  --secondary-hover: #9333ea;  /* purple-600 */
  --background: #02021e; /* #0d0d1a */
  --surface: rgba(255,255,255,0.055);
  --surface-solid: #18182a;    /* fallback where blur isn't supported */
  --surface-dark: rgba(0,0,0,0.35);
  --text-main: #f0f0f5;
  --text-muted: #8892a4;
  --border: rgba(255,255,255,0.10);
  --border-focus: #d71e56;
  --success: #34d399;          /* emerald-400 — readable on dark */
  --danger: #f87171;           /* red-400 */

  --glass-blur: blur(20px) saturate(160%);

  --font-display: 'Archivo', 'Arial Black', sans-serif;
  --font-body: 'Nunito', sans-serif;

  --radius-xl: 1.5rem;
  --radius-lg: 1rem;
  --radius-md: 0.5rem;

  --shadow-lg:  0 10px 30px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.3);
  --shadow-xl:  0 24px 48px rgba(0,0,0,0.6), 0 8px 16px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  background-color: var(--background);
  background-image:
    radial-gradient(ellipse at 15% 40%, rgba(215,30,86,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 8%,  rgba(99,102,241,0.09) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 92%, rgba(215,30,86,0.07) 0%, transparent 45%);
  background-attachment: fixed;
  color: var(--text-main);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 900;
  margin: 0;
}

/* Utilities */
.hidden { display: none !important; }
.pointer-events-none { pointer-events: none !important; }
.pointer-events-auto { pointer-events: auto !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
.text-center { text-align: center; }

/* ─── Brand Header ─────────────────────────────────────────────────────────── */
.brand-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  margin-bottom: 1rem;
  text-align: left;
}
.brand-logo {
  width: 64px;
  height: auto;
  border-radius: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(215,30,86,0.4);
  padding: 10px 14px 10px 6px;
  background: rgb(215, 30, 86);
  box-sizing: content-box;
}
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.brand-wordmark {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.02em;
}
.brand-main { color: var(--text-main); }
.brand-live  { font-weight: 800; opacity: 0.35; }
.brand-tagline {
  margin: 0;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

/* ─── Game Select Screen ───────────────────────────────────────────────────── */

.game-select-container {
  max-width: 52rem !important;
  width: 95%;
  text-align: center;
}

.game-select-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.current-room-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1rem;
  padding: 0.65rem 0.8rem;
  border: 1px solid rgba(52,211,153,0.3);
  border-radius: 0.75rem;
  background: rgba(52,211,153,0.08);
  color: #cbd5e1;
  font-size: 0.85rem;
}

.current-room-code { color: #fff; letter-spacing: 0.08em; }

.room-invite-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  border: 0;
  background: none;
  color: #f9a8d4;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.room-invite-link:hover { color: #fff; }
.room-invite-link:disabled { opacity: 0.45; cursor: default; }
.room-invite-link.invite-at-capacity {
  opacity: 0.72;
  text-decoration: none;
}
.room-invite-link.invite-at-capacity svg { display: none; }
.room-invite-link svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.shared-session-exit {
  margin-top: 1.1rem;
  color: #64748b;
}

.shared-session-exit button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0;
  border: 0;
  background: none;
  color: #94a3b8;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.shared-session-exit button:hover { color: #fda4af; }
.shared-session-exit button svg {
  width: 1.15rem;
  height: 1.15rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.shared-session-exit p { margin: 0.3rem auto 0; max-width: 30rem; font-size: 0.68rem; line-height: 1.35; }

.summary-session-exit {
  margin-top: 1.25rem;
  text-align: center;
}

.summary-session-exit button { font-size: 1rem; }

@media (min-width: 600px) {
  .game-select-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.game-tile {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 0.75rem;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  position: relative;
  text-align: center;
}

.game-tile:hover:not(:disabled) {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(215,30,86,0.15);
}

.game-tile:active:not(:disabled) {
  transform: translateY(0);
}

.game-tile-locked {
  opacity: 0.55;
  cursor: not-allowed;
}

.game-tile-icon {
  font-size: 2.25rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.game-tile-icon-image {
  display: block;
  width: 5rem;
  /* height: 5rem; */
  object-fit: contain;
}
.landing-game-icon-image {
  display: block;
 /*  width: 3rem; */
  height: 10rem;
  margin: 0 auto;
  object-fit: contain;
}

.game-tile-name {
  font-weight: 800 !important;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

.game-tile-players {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.game-tile-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
  line-height: 1.3;
}

.game-tile-badge {
  position: absolute;
  top: -0.4rem;
  right: -0.4rem;
  background: var(--secondary);
  color: white;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 999px;
  letter-spacing: 0.04em;
}

/* Landing step outer wrapper (button above card) */
.landing-step-outer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 28rem;
}

/* Setup step outer wrapper (All Games button above the wider setup card) */
.setup-step-outer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 64rem;
}

/* Back button — floats above the card */
.btn-back-select {
  align-self: center;
  background: rgba(255,255,255,0.07);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.14);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  letter-spacing: 0.01em;
  margin-bottom: 12px;
}
.btn-back-select:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(215,30,86,0.08);
}

/* Game stage areas */
.game-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative; /* anchor for waiting overlay */
}

/* Waiting-for-opponent overlay (injected by game modules) */
.game-waiting-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  text-align: center;
  background: var(--background);
  z-index: 10;
  padding: 2rem;
}
.game-waiting-icon  { font-size: 3rem; line-height: 1; }
.game-waiting-icon-image {
  display: block;
  width: clamp(4rem, 10vw, 6rem);
  height: clamp(4rem, 10vw, 6rem);
  object-fit: contain;
}
.game-waiting-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; margin: 0; }
.game-waiting-sub   { color: var(--text-muted); margin: 0; }
.game-waiting-action {
  padding: 0.65rem 1.15rem;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 0.7rem;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
}
.game-waiting-action:hover { filter: brightness(1.1); }

/* Coming-soon placeholder inside game stages */
.coming-soon-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}
.coming-soon-stage .coming-soon-icon { font-size: 4rem; }
.coming-soon-stage h2 { color: var(--text-main); font-size: 1.5rem; }
.coming-soon-stage p { font-size: 1rem; }

/* Overlay & Modals */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background-color: var(--background);
  background-image:
    radial-gradient(ellipse at 15% 40%, rgba(215,30,86,0.14) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 8%,  rgba(99,102,241,0.09) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 92%, rgba(215,30,86,0.07) 0%, transparent 45%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: rgba(255,255,255,0.06);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-xl), inset 0 1px 0 rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.12);
  max-width: 28rem;
  width: 100%;
  text-align: center;
  position: relative;
  overflow-y: auto;
  max-height: 95vh;
}

/* Landing Step */
.landing-title {
  font-size: 3rem;
  color: #ffffff;
  margin-bottom: 0.5rem;
}

.landing-subtitle {
  color: var(--text-muted);
  font-size: 1.125rem;
  margin-bottom: 2rem;
}

.btn-primary {
  width: 100%;
  background-color: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 1.5rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  /* box-shadow: 0 4px 0 rgba(215, 30, 86, 0.5); */ /* shadow-bouncy */
  transition: transform 0.1s, box-shadow 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:active {
  transform: translateY(4px);
  box-shadow: none;
}

.divider {
  position: relative;
  text-align: center;
  margin: 1.5rem 0;
}

.divider span {
  background: #18182e;
  padding: 0 1rem;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.875rem;
  position: relative;
  z-index: 10;
}

.divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 100%;
  border-top: 2px solid var(--border);
}

.input-code {
  width: 100%;
  font-size: 1.25rem;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text-main);
  text-align: center;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  outline: none;
  margin-bottom: 0.75rem;
}
.input-code::placeholder { color: var(--text-muted); }
.input-code:focus {
  border-color: var(--secondary);
  background: rgba(255,255,255,0.09);
}

.btn-secondary {
  width: 100%;
  background-color: var(--secondary);
  color: white;
  font-weight: 700;
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  font-size: 1.125rem;
  transition: transform 0.1s;
}

.btn-secondary:hover { background-color: var(--secondary-hover); }
.btn-secondary:active { transform: scale(0.98); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Setup Step */
.setup-container {
  max-width: 64rem !important; /* Override modal-content */
  width: 100%; /* Full width of modal */
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* Fix overflow on mobile */
  gap: 1rem; /* Reduced gap */
  /* removed overflow: hidden to allow modal-content to handle scroll */
}

@media (min-width: 768px) {
  .setup-container {
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* Force equal width */
    text-align: left;
    width: 100%;
    align-items: center; /* Vertically center content */
    gap: 2rem; /* Larger gap on desktop */
  }
}

.setup-left {
  width: 100%;
  min-width: 0; /* Allow shrinking if needed */
  display: flex;
  flex-direction: column;
  gap: 0.5rem; /* Reduced gap */
}

.preview-box {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.12);
}

.preview-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.preview-badge {
  position: absolute;
  bottom: 0.75rem;
  left: 0.75rem;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 0.5rem;
  height: 0.5rem;
  background-color: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

.preview-badge--error .status-dot {
  background: #f87171;
  animation: none;
}

/* Camera-off overlay (inside preview-box) */
.cam-off-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(0,0,0,0.7);
  color: rgba(255,255,255,0.6);
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 5;
  pointer-events: none;
}
.cam-off-overlay.hidden { display: none; }

.cam-off-overlay.camera-error {
  padding: 1.5rem;
  color: #fecaca;
  text-align: center;
  background: rgba(15, 5, 15, 0.9);
}

/* Media toggle buttons — shared between setup preview bar & in-game bar */
.media-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.10);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  backdrop-filter: blur(8px);
}
.media-btn:hover { background: rgba(255,255,255,0.18); }
.media-btn--off {
  background: rgba(215,30,86,0.18);
  border-color: rgba(215,30,86,0.45);
  color: #f87171;
}
.media-btn--off:hover { background: rgba(215,30,86,0.28); }

.media-btn--active {
  color: #fff;
  background: rgba(219, 39, 119, 0.88);
  border-color: rgba(244, 114, 182, 0.9);
}

.media-btn--active:hover { background: rgba(219, 39, 119, 1); }

.media-btn--busy svg { animation: blur-pulse 1s ease-in-out infinite; }

.blur-status {
  position: absolute;
  left: 50%;
  bottom: 3.15rem;
  z-index: 6;
  max-width: calc(100% - 2rem);
  padding: 0.42rem 0.75rem;
  border: 1px solid rgba(244, 114, 182, 0.42);
  border-radius: 999px;
  color: #fdf2f8;
  background: rgba(15, 23, 42, 0.88);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  transform: translateX(-50%);
  pointer-events: none;
}

@keyframes blur-pulse {
  0%, 100% { opacity: 0.45; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1.08); }
}

/* Setup preview controls bar (bottom-right of preview box) */
.preview-media-bar {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  display: flex;
  gap: 0.4rem;
  z-index: 10;
}

/* In-game media bar (above video grid) */
.game-media-bar {
  display: flex;
  gap: 0.4rem;
  padding: 0 0 0.5rem;
  justify-content: flex-start;
}

.device-controls {
  display: grid;
  grid-template-columns: 1fr 1fr; /* Side by side on all screens */
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* Removed media query as we want side-by-side always */

.control-group label {
  display: block;
  font-size: 0.65rem; /* Smaller label */
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 0.125rem;
}

.select-wrapper {
  position: relative;
}

.device-select {
  color-scheme: dark;
  width: 100%;
  max-width: 100%;
  font-size: 0.875rem;
  padding: 0.625rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: #18182a;
  color: var(--text-main);
  outline: none;
  appearance: none;
  cursor: pointer;
  text-overflow: ellipsis;
}

.device-select option,
.active-player-controls select option,
.host-dialog-content select option {
  background-color: #18182a;
  color: #f0f0f5;
}

.active-player-controls select,
.host-dialog-content select {
  color-scheme: dark;
}

.select-arrow {
  position: absolute;
  right: 0.5rem;
  top: 0.75rem;
  pointer-events: none;
  font-size: 0.75rem;
  color: #94a3b8;
}

.setup-right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem; /* Reduced gap */
}

.setup-title {
  font-size: 1.5rem; /* Slightly smaller title */
  color: var(--primary);
  margin-bottom: 0.25rem;
  line-height: 1.2;
}

.input-name {
  width: 100%;
  font-size: 1.25rem;
  padding: 0.6rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.07);
  color: var(--text-main);
  text-align: center;
  font-weight: 700;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}
.input-name::placeholder { color: var(--text-muted); }
.input-name:focus {
  border-color: var(--primary);
  background: rgba(255,255,255,0.10);
}

.lobby-info {
  background: rgba(255,255,255,0.05);
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px dashed rgba(255,255,255,0.15);
  text-align: center;
}

.copy-link-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,255,255,0.06);
  padding: 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  cursor: pointer;
  margin-top: 0.5rem;
}

.copy-link-text {
  flex: 1;
  font-family: monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0; /* Allow shrinking in flex container */
}

.lobby-roster {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.roster-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.roster-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-start {
  width: 100%;
  background-color: var(--secondary);
  color: white;
  font-weight: 700;
  font-size: 1.25rem; /* Smaller button text */
  padding: 0.75rem 1rem; /* Reduced padding */
  border-radius: var(--radius-lg);
  border: none;
  cursor: pointer;
  /* box-shadow: 0 4px 0 #6b21a8; */ /* purple-800 */
  transition: transform 0.1s;
}
.setup-header p {
    margin-block-start: 0;
    margin-block-end: 0;
    margin: 0px 0px 12px 0px;
}

.btn-start:hover { background-color: #9333ea; }
.btn-start:active { transform: translateY(4px); box-shadow: none; }
.btn-start:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none;}


/* Game Container */
.game-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  background-color: var(--background);
}

@media (min-width: 768px) {
  .game-container {
    flex-direction: row;
  }
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: 0;
  overflow: hidden;
}

.game-header {
  /* background: rgba(13,13,26,0.75); */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  gap: 4px 12px;
  padding: 3px 12px 4px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  z-index: 10;
}

.game-header .active-game-icon-image {
    width: 4.5rem;
    height: 4.5rem;
  }

@media (max-width: 767px) {
  .game-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "title rules exit"
      "round round round";
    gap: 4px 12px;
    padding: 3px 12px 0px 12px;
  }
  .game-header .header-left { display: contents; }
  .game-header .game-title {
    grid-area: title;
    min-width: 0;
    font-size: 1.3rem;
    line-height: 1.05;
  }
  .game-header .game-title > span:nth-child(2) { display: none; }
  .game-header .active-game-icon-image {
    width: 4.5rem;
    height: 4.5rem;
  }
  .game-header .round-badge { grid-area: round; justify-self: center; margin-bottom: 0.5rem; width: 100%; text-align: center;}
  .game-header #btn-rules { grid-area: rules; justify-self: end; }
  .game-header .btn-exit { grid-area: exit; justify-self: end; }
}

.topbar-actions {
  display: flex;
  flex-direction: row;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.game-title { color: var(--primary); font-size: 1.5rem; font-weight: 900; display: flex; align-items: center; gap: .25rem; }
.active-game-icon { display: inline-flex; align-items: center; }
.active-game-icon-image { width: 1.55rem; height: 1.55rem; object-fit: contain; }
.round-badge {
  background: rgba(255,255,255,0.08);
  padding: 0.25rem 1rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.08);
  margin: 0.5rem; 
  width: calc(100% - 1rem); 
  text-align: center;
}

.memory-category-bar {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
  min-width: 0;
  padding: .65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.025);
}
.memory-category-label {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.category-selector {
  display: flex;
  gap: .5rem;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.32) transparent;
  padding: 2px 2px 4px;
}

.category-selector::-webkit-scrollbar {
  height: 6px;
}

.category-selector::-webkit-scrollbar-track {
  background: transparent;
}

.category-selector::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 999px;
}

.category-selector::-webkit-scrollbar-thumb:hover {
  background: rgba(215, 30, 86, 0.65);
}

.category-selector::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.category-btn {
  flex-shrink: 0;
  padding: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.category-btn.active {
  background-color: var(--primary);
  color: white;
}

.category-btn:not(.active) {
  background-color: rgba(255,255,255,0.08);
  color: var(--text-muted);
}
.category-btn:not(.active):hover { background-color: rgba(255,255,255,0.14); color: var(--text-main); }

.btn-exit {
  /* background-color: rgba(215,30,86,0.12);
  color: #fff; 
  border: 1px solid rgba(215,30,86,0.25); */
  background-color: rgb(147,51,234,0.25);
  color: #fff; 
  border: 1px solid rgba(147,51,234,0.5);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.15s;
}
.btn-exit:hover { background-color: rgba(170, 80, 253, 0.5); }

/* Game Grid */
.game-board {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#memory-game-area .game-board {
  overflow: hidden;
}

#memory-game-area .grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(0.35rem, 1.25dvh, 1rem);
  width: min(100%, 42rem);
  max-width: 100%;
  aspect-ratio: var(--memory-card-ratio, 0.8);
  flex: 0 0 auto;
}

/* Card Styles */
.card-container {
  perspective: 1000px;
  cursor: pointer;
  min-width: 0;
  min-height: 0;
  aspect-ratio: var(--memory-card-ratio, 0.8);
}

/* Compact screens use square cards so all 16 remain visible without scrolling. */
@media (max-width: 767px), (max-height: 720px) {
  #memory-game-area .game-board { padding: 0.5rem; }
  #memory-game-area .grid {
    width: min(100%, 42rem);
    aspect-ratio: 1;
    gap: clamp(0.25rem, 1dvh, 0.5rem);
  }
  #memory-game-area .card-container { aspect-ratio: 1; }
  #memory-game-area .card-front,
  #memory-game-area .card-back { border-radius: 0.6rem; }
  #memory-game-area .memory-card-image { border-radius: 0.45rem; }
  #memory-game-area .memory-card-front-shade { border-radius: 0.6rem; }
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
}

.card-container.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.card-front {
  background-color: var(--primary);
  border: 2px solid rgba(255,255,255,0.3);
}

.card-back {
  background-color: rgba(255,255,255,0.07);
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  border: 2px solid rgba(255,255,255,0.12);
  overflow: hidden;
}

.memory-card-image {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 0;
  border-radius: inherit;
}

.memory-card-image-backdrop {
  display: none;
  position: absolute;
  z-index: 0;
  inset: -0.75rem;
  width: calc(100% + 0.25rem);
  height: calc(100% + 0.25rem);
  object-fit: cover;
  filter: blur(1.5px) saturate(0.8) brightness(0.8);
  transform: scale(1.12);
  opacity: 0.9;
  pointer-events: none;
}

/* When compact layouts force portrait artwork into square tiles, use a
   softened copy of the artwork to fill the otherwise empty side space. */
@media (max-width: 767px), (max-height: 720px) {
  #memory-game-area .memory-card-image-backdrop {
    display: block;
  }
}

.memory-card-front-shade {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.1);
  border-radius: 1rem;
}

.card-container.matched .card-back {
  background-color: rgba(52,211,153,0.15);
  border-color: var(--success);
}

/* Sidebar */
.sidebar {
  width: 100%;
  /* background: rgba(13,13,26,0.80); */
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  height: auto;
  z-index: 20;
  box-shadow: -4px 0 24px rgba(0,0,0,0.4);
}

@media (max-width: 767px) {
  .sidebar {
    flex: 0 0 clamp(10.5rem, 23dvh, 12.5rem);
    height: clamp(10.5rem, 23dvh, 12.5rem);
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 9rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    border-left: 0;
    box-shadow: 0 -10px 28px rgba(0,0,0,0.28);
  }
  .sidebar .scoreboard {
    min-width: 0;
    padding: 0.65rem;
    border-right: 1px solid rgba(255,255,255,0.07);
    border-bottom: 0;
  }
  .sidebar .scoreboard h3 { margin-bottom: 0.45rem !important; }
  .sidebar .player-card {
    padding: 0.45rem;
    margin-bottom: 0.4rem;
    border-radius: 0.6rem;
  }
  .sidebar .player-info { gap: 0.45rem; }
  .sidebar .avatar { width: 1.75rem; height: 1.75rem; font-size: 0.75rem; }
  .sidebar .player-score { font-size: 1.15rem; }
}

@media (min-width: 768px) {
  .sidebar { width: 20rem; height: 100vh; }
}

.scoreboard {
  padding: 1.5rem;
  background: transparent;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex: 1;
  overflow-y: auto;
}

.players-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.players-heading-row h3 {
  margin: 0 !important;
  color: #64748b;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
}

.current-room-label {
  margin-top: 0.2rem;
  color: #64748b;
  font-size: 0.65rem;
  white-space: nowrap;
}

.active-player-controls {
  margin: -0.25rem 0 1rem;
  padding: 0.65rem;
  border: 1px solid rgba(219, 39, 119, 0.35);
  border-radius: 0.75rem;
  background: rgba(30, 25, 55, 0.72);
}

.active-player-controls-title {
  margin-bottom: 0.45rem;
  color: #f9a8d4;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.active-player-controls label {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.35rem;
  color: #94a3b8;
  font-size: 0.7rem;
  font-weight: 700;
}

.active-player-controls select {
  min-width: 0;
  padding: 0.35rem 0.45rem;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 0.45rem;
  background: #211a3b;
  color: #f8fafc;
  font: inherit;
}

.active-player-controls-note {
  margin-top: 0.5rem;
  color: #64748b;
  font-size: 0.63rem;
  line-height: 1.3;
}

.active-player-toggle-list {
  display: grid;
  gap: 0.35rem;
}

.active-player-controls .active-player-toggle {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.35rem 0.45rem;
  border-radius: 0.45rem;
  background: rgba(255,255,255,0.045);
  color: #cbd5e1;
  cursor: pointer;
}

.active-player-toggle input {
  accent-color: #db2777;
}

.active-player-sit-out {
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 0.5rem;
  background: rgba(255,255,255,0.06);
  color: #cbd5e1;
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
}

.player-card {
  background: rgba(255,255,255,0.05);
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 0.75rem;
  opacity: 0.7;
  transform: scale(0.95);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.player-card.active {
  opacity: 1;
  transform: scale(1);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
  z-index: 10;
}

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
}

.player-details { flex: 1; overflow: hidden; }
.player-name { font-weight: 700; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn-badge { font-size: 0.625rem; font-weight: 700; color: var(--text-muted); display: none; }
.player-card.active .turn-badge { display: block; }
.player-score { font-family: var(--font-display); font-weight: 700; font-size: 1.5rem; color: var(--text-main); }

/* Video Chat */
.video-area {
  padding: 0.75rem 1rem 1rem;
  background: rgba(0,0,0,0.25);
  height: 400px;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .sidebar { height: 100dvh; overflow-y: auto; }
  .sidebar .scoreboard { flex: 1 0 auto; overflow-y: visible; }
  .sidebar .video-area { height: auto; flex: 0 0 auto; }
  .sidebar .video-grid { flex: 0 0 auto; }
}

@media (max-width: 767px) {
  .video-area {
    min-width: 0;
    width: 9rem;
    height: auto;
    padding: 0.5rem;
  }
  .video-area .game-media-bar {
    gap: 0.3rem;
    margin-bottom: 0.4rem;
    padding-bottom: 0;
  }
  .video-area .game-media-bar .media-btn { padding: 0.35rem 0.5rem; }
  .video-area .game-media-bar .media-btn[data-type="cam"] .media-btn-label,
  .video-area .game-media-bar .media-btn[data-type="mic"] .media-btn-label { display: none; }
  .video-area .game-media-bar .media-btn svg { width: 15px; height: 15px; }
  .video-area .video-grid {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(148,163,184,.3) transparent;
  }
  .video-area .video-box {
    flex: 0 0 8rem;
    align-self: flex-start;
  }
}

.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
}

.video-box {
  position: relative;
  border-radius: 0.75rem;
  overflow: hidden;
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.15);
  aspect-ratio: 16/9;
}

.video-box video, .video-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-box video { transform: scaleX(-1); }

.local-video-status {
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
  color: #fdf2f8;
  background: rgba(15, 23, 42, 0.78);
  font-size: 0.66rem;
  font-weight: 800;
  text-align: center;
  z-index: 3;
}

.local-video-status.hidden { display: none; }
.local-video-status--error { color: #fecaca; }

.video-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #94a3b8);
  font-size: .72rem;
  font-weight: 700;
  background: radial-gradient(circle, rgba(51,65,85,.8), rgba(15,23,42,.95));
}

.video-status.local-video-status {
  padding: 0.55rem;
  color: #fdf2f8;
  background: rgba(15, 23, 42, 0.78);
  font-size: 0.66rem;
  font-weight: 800;
  text-align: center;
  z-index: 3;
}

.video-status.local-video-status--error { color: #fecaca; }

.video-label {
  position: absolute;
  bottom: 0.25rem;
  left: 0.25rem;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  color: white;
  font-size: 0.625rem;
  font-weight: 700;
  z-index: 10;
}

.video-expand-btn,
.video-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(0,0,0,.58);
  backdrop-filter: blur(6px);
  cursor: pointer;
  transition: background .15s, transform .15s;
}
.video-expand-btn:hover,
.video-collapse-btn:hover { background: rgba(215,30,86,.8); transform: scale(1.05); }
.video-expand-btn img,
.video-collapse-btn img { width: 18px; height: 18px; display: block; }
.video-expand-btn {
  position: absolute;
  right: .3rem;
  bottom: .3rem;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 7px;
  z-index: 12;
}

.video-focus-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 3vw, 40px);
  background: rgba(2,6,23,.92);
  backdrop-filter: blur(16px);
}
.video-focus-modal.hidden { display: none; }
.video-focus-frame {
  position: relative;
  width: min(94vw, 1400px);
  height: min(88vh, 900px);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 18px;
  background: #020617;
  box-shadow: 0 28px 90px rgba(0,0,0,.65);
}
.video-focus-frame video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1);
}
.video-focus-label {
  position: absolute;
  left: 18px;
  bottom: 16px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-weight: 750;
}
.video-focus-status {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #94a3b8);
  font-weight: 700;
}
.video-focus-status.hidden { display: none; }
.video-collapse-btn {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 11px;
}

/* Animations & Modals */
.turn-notification {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  z-index: 20;
  transition: opacity 0.3s;
}

.turn-pill {
  background: rgba(0,0,0,0.7);
  color: white;
  padding: 1rem 2rem;
  border-radius: 999px;
  font-size: 1.5rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
}

.shared-toast {
  left: 50%;
}

@media (min-width: 768px) {
  .shared-toast {
    left: calc((100vw - 20rem) / 2);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}

@keyframes bounceInScale {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); opacity: 1; }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.animate-bounce-in-scale {
  animation: bounceInScale 0.5s cubic-bezier(0.215, 0.610, 0.355, 1.000) forwards;
}

/* Modal specific */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.memory-round-modal {
  width: min(28rem, 100%);
  padding: clamp(1.35rem, 5vw, 2.25rem);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 1.4rem;
  background: rgba(18,18,32,.96);
  box-shadow: var(--shadow-xl);
  text-align: center;
}
.memory-round-logo { width: 4rem; height: 4rem; object-fit: contain; margin: 0 auto .5rem; }
.memory-round-kicker { color: var(--primary); font-size: .72rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.memory-round-modal h2 { margin: .35rem 0 .6rem; font-family: var(--font-display); font-size: clamp(1.55rem, 6vw, 2rem); }
.memory-round-result { color: var(--text-main); font-weight: 750; }
.memory-round-next { margin-top: .4rem; color: var(--text-muted); font-size: .9rem; }
.memory-round-actions { display: grid; gap: .65rem; margin-top: 1.35rem; }
.memory-round-actions button { width: 100%; padding: .8rem 1rem; border-radius: .75rem; font-weight: 800; cursor: pointer; }
.memory-round-continue { border: 0; color: #fff; background: var(--secondary); box-shadow: 0 4px 0 #6b21a8; }
.memory-round-continue:active { transform: translateY(3px); box-shadow: 0 1px 0 #6b21a8; }
.memory-round-restart { border: 1px solid rgba(255,255,255,.16); color: var(--text-main); background: rgba(255,255,255,.08); }
.memory-round-waiting { margin-top: 1.25rem; color: var(--text-muted); font-weight: 700; }

/* ─── Rules button (game header) ───────────────────────────────────────────── */
.btn-rules {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.07);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
  height: 34px;
}
.btn-rules img { width: 17px; height: 17px; display: block; }
.btn-rules:hover { border-color: var(--primary); background: rgba(215,30,86,0.1); color: var(--text-main); }

.setup-connection-error {
  padding: 10px 12px;
  border: 1px solid rgba(248,113,113,.45);
  border-radius: 9px;
  background: rgba(127,29,29,.28);
  color: #fecaca;
  font-size: .84rem;
  font-weight: 650;
  line-height: 1.35;
}

/* ─── Rules modal ──────────────────────────────────────────────────────────── */
.rules-modal {
  background: rgba(18,18,32,0.92);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 2rem;
  border-radius: 1.5rem;
  width: 100%;
  max-width: 36rem;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  text-align: left;
  box-shadow: var(--shadow-xl);
}
.rules-icon {
  font-size: 2.5rem;
  text-align: center;
  margin-bottom: 0.25rem;
}
.rules-icon-image {
  display: block;
  width: 3rem;
  height: 3rem;
  margin: 0 auto;
  object-fit: contain;
}
.rules-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--primary);
  text-align: center;
  margin-bottom: 1.25rem;
}
.rules-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.rules-section {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
}
.rules-section h3 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}
.rules-section ul {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.65;
}
.rules-section ul li { margin-bottom: 0.2rem; }
.rules-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  margin-top: 0.25rem;
}

.summary-modal {
  background: rgba(18,18,32,0.92);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 2rem;
  border-radius: 1.5rem;
  width: 100%;
  max-width: 42rem;
  position: relative;
  text-align: center;
  box-shadow: var(--shadow-xl);
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
}

.summary-grid {
  display: grid;
  gap: 2rem;
  margin-bottom: 2rem;
  text-align: left;
}
@media (min-width: 768px) { .summary-grid { grid-template-columns: 1fr 1fr; } }

.summary-list-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 0.5rem;
  margin-bottom: 0.5rem;
}

.summary-next-game-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.summary-next-game-actions .btn-secondary {
  width: auto;
  margin: 0;
  padding-inline: 1.25rem;
}

.summary-next-game-message {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
}

#btn-request-different-game {
  background: rgba(168,85,247,0.16);
  border-color: rgba(192,132,252,0.55);
  color: #f5e8ff;
}

#btn-request-different-game:disabled {
  cursor: default;
  opacity: 0.62;
}

@media (max-width: 560px) {
  .summary-next-game-actions {
    flex-direction: column;
  }
}

/* ─── Connect Four ─────────────────────────────────────────────────────────── */

.cf-info-bar {
  padding: 0.5rem 1rem;
  background: rgba(13,13,26,0.6);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 2.5rem;
}

.cf-turn-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  color: #fff;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 700;
}

.cf-turn-chip {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 0.9rem;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.8);
  box-shadow: 0 0 7px rgba(255,255,255,0.28);
}
.cf-turn-chip.red {
  background: radial-gradient(circle at 35% 35%, #fca5a5, #ef4444 60%, #b91c1c);
}
.cf-turn-chip.yellow {
  background: radial-gradient(circle at 35% 35%, #fef08a, #eab308 60%, #a16207);
}

.cf-board-outer {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  gap: 0.375rem;
  overflow: auto;
  min-height: 0;
}

/* Preview row — 1 row above the board showing where chip will land */
.cf-preview-row {
  display: grid;
  gap: 0.5rem;
  align-self: center;
}

.cf-preview-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-preview-chip {
  width: 55%;
  height: 55%;
  border-radius: 50%;
  background: transparent;
  transition: background 0.1s;
}

.cf-preview-chip.red    { background: radial-gradient(circle at 35% 35%, #fca5a5, #ef4444 60%, #b91c1c); }
.cf-preview-chip.yellow { background: radial-gradient(circle at 35% 35%, #fef08a, #eab308 60%, #a16207); }

/* Blue board frame */
.cf-board-wrap {
  position: relative;
  padding: 0.75rem;           /* 12px — match BOARD_PADDING in JS */
  background: #2563eb;        /* blue-600 */
  border-radius: 1.25rem;
  box-shadow: 0 8px 32px rgba(37,99,235,0.45), inset 0 4px 10px rgba(0,0,0,0.25);
  overflow: hidden;           /* clips drop animation from above */
  align-self: center;
}

.cf-board {
  display: grid;
  gap: 0.5rem;                /* 8px — match CELL_GAP in JS */
}

/* Cell = the circular "hole" in the board */
.cf-cell {
  border-radius: 50%;
  background: #1d4ed8;        /* blue-700 — slightly darker than frame */
  box-shadow: inset 0 4px 10px rgba(0,0,0,0.4), inset 0 1px 3px rgba(0,0,0,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}

/* Chip inside the cell */
.cf-chip {
  width: 88%;
  height: 88%;
  border-radius: 50%;
  background: #bfdbfe;        /* empty slot = light blue */
  position: relative;
}

.cf-chip.red {
  background: radial-gradient(circle at 35% 35%, #fca5a5, #ef4444 60%, #b91c1c);
  box-shadow: 0 3px 8px rgba(185,28,28,0.5);
}

.cf-chip.yellow {
  background: radial-gradient(circle at 35% 35%, #fef08a, #eab308 60%, #a16207);
  box-shadow: 0 3px 8px rgba(161,98,7,0.5);
}

.cf-chip.winning {
  animation: cf-win-pulse 0.65s ease-in-out infinite alternate !important;
}

@keyframes cf-win-pulse {
  from { box-shadow: 0 0 0 3px white, 0 0 10px rgba(255,255,255,0.7); }
  to   { box-shadow: 0 0 0 5px white, 0 0 22px rgba(255,255,255,1); }
}

/* Drop animation — chip falls from above the board into its cell */
@keyframes cf-chip-drop {
  0%   { transform: translateY(var(--cf-drop-from)); }
  72%  { transform: translateY(5px); }
  86%  { transform: translateY(-3px); }
  100% { transform: translateY(0); }
}

.cf-chip.dropping {
  animation: cf-chip-drop var(--cf-drop-dur, 0.35s) cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Scoreboard chip avatars */
.cf-avatar-chip {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  flex-shrink: 0;
}
.cf-avatar-red    { background: radial-gradient(circle at 35% 35%, #fca5a5, #ef4444 60%, #b91c1c); box-shadow: 0 2px 6px rgba(185,28,28,0.4); }
.cf-avatar-yellow { background: radial-gradient(circle at 35% 35%, #fef08a, #eab308 60%, #a16207); box-shadow: 0 2px 6px rgba(161,98,7,0.4); }

/* Win/draw banner */
.cf-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  padding: 0.625rem 1.5rem;
  background: #111827;
  border-top: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 -6px 20px rgba(0,0,0,0.22);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.cf-banner-text {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: #f8fafc;
}

.cf-banner #cf-banner-waiting {
  color: #94a3b8 !important;
}

.cf-rematch-btn {
  padding: 0.4rem 1.1rem;
  border-radius: 0.75rem;
  border: 2px solid var(--primary);
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.cf-rematch-btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

/* ─── SOS Game ─────────────────────────────────────────────────────────────── */

.sos-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: white;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
  position: relative;
}

.sos-size-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.sos-size-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sos-size-btn {
  padding: 0.25rem 0.45rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid var(--border);
  background: white;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1.6;
}

.sos-size-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.sos-size-btn:not(:disabled):hover:not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

.sos-turn-info {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: max-content;
  max-width: 46%;
  font-size: 1.05rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

@media (max-width: 600px) {
  .sos-controls {
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
  }
  .sos-size-controls { gap: 0.2rem; }
  .sos-size-btn { padding-inline: 0.5rem; }
  .sos-turn-info {
    position: static;
    transform: none;
    width: auto;
    max-width: none;
    margin-left: auto;
    flex-shrink: 0;
    font-size: clamp(0.82rem, 3.7vw, 0.95rem);
  }
}

/* Board layout */
.sos-board-outer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow: auto;
  min-height: 0;
}

.sos-board-wrap {
  position: relative;
  display: inline-block;
  line-height: 0; /* prevent gap below inline svg */
}

.sos-board {
  display: grid;
  gap: 1px;
  background: var(--border);
  border: 2px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  user-select: none;
}

.sos-cell {
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.1s;
  position: relative;
}

.sos-cell:not(.sos-cell-filled):hover {
  background: #fdf2f8;
}

.sos-cell.sos-cell-pending {
  background: #fce7f3;
  box-shadow: inset 0 0 0 3px var(--primary);
}

.sos-cell.sos-cell-filled {
  cursor: default;
  font-size: inherit; /* controlled by JS */
}

/* SVG overlay — sits on top of board, pointer-events:none so clicks pass through */
.sos-svg {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  display: block;
}

/* Letter picker action bar */
.sos-action-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  background: white;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.sos-action-label {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.sos-letter-btn {
  width: 3rem;
  height: 3rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  border-radius: 0.75rem;
  border: 3px solid var(--primary);
  background: white;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}

.sos-letter-btn:hover {
  background: var(--primary);
  color: white;
  transform: scale(1.08);
}

.sos-cancel-btn {
  padding: 0.4rem 0.875rem;
  border-radius: 0.75rem;
  border: 2px solid var(--border);
  background: white;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
}

.sos-cancel-btn:hover {
  background: #f1f5f9;
}

/* ─── Fleet Strike ───────────────────────────────────────────────────────────── */

/* Phase containers */
.bs-phase {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* ── Placement phase ──────────────────── */
.bs-place-header {
  padding: 0.5rem 1rem;
  background: rgba(15, 23, 42, 0.88);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.bs-phase-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-right: auto;
}

.bs-btn-ready {
  padding: 0.4rem 1.1rem;
  border-radius: 0.75rem;
  border: 2px solid var(--primary);
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.bs-btn-ready:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.bs-btn-ready:disabled { opacity: 0.45; cursor: not-allowed; }

.bs-place-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.5rem 1rem 0.75rem;
  overflow: hidden;
  min-height: 0;
}

/* Ship queue — horizontal wrapping strip */
.bs-ship-queue {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.375rem;
  flex-shrink: 0;
}

.bs-ship-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
  border: 2px solid var(--border);
  background: rgba(30, 41, 59, 0.9);
  transition: border-color 0.15s;
  opacity: 0.55;
}
.bs-ship-row.bs-ship-active {
  border-color: var(--secondary);
  background: rgba(168, 85, 247, 0.18);
  opacity: 1;
}
.bs-ship-row.bs-ship-placed {
  border-color: rgba(34, 197, 94, 0.6);
  background: rgba(34, 197, 94, 0.12);
  opacity: 1;
}

.bs-ship-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

.bs-ship-dots {
  display: flex;
  gap: 2px;
}
.bs-ship-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: #cbd5e1;
  transition: background 0.15s;
}
.bs-ship-dot.placed { background: #22c55e; }
.bs-ship-row.bs-ship-active .bs-ship-dot { background: var(--secondary); }

.bs-orientation-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.bs-orientation-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bs-orientation-toggle {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 0.2rem;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  color: #94a3b8;
  font: inherit;
  cursor: pointer;
}

.bs-orientation-option {
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.bs-orientation-option.is-selected {
  background: var(--secondary);
  color: white;
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.35);
}

/* Placement grid wrapper — full width below the ship strip */
.bs-place-grid-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
  width: 100%;
}

/* ── Shared grid ────────────────────────── */
.bs-grid {
  display: grid;
  gap: 2px;
  background: #0f172a;     /* dark frame around grid */
  border: 3px solid #0f172a;
  border-radius: 4px;
}

/* Generic cell styles (used in placement + attack) */
.bs-pcell,
.bs-board-cell {
  background: #1e3a8a;     /* deep-blue sea */
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  transition: background 0.08s;
}

.bs-pcell:hover,
.bs-ecell:hover {
  background: #1d4ed8;
}

/* Placement states */
.bs-cell-ship    { background: #475569 !important; }
.bs-cell-hover-ok  { background: #a855f7 !important; }     /* valid preview — purple */
.bs-cell-hover-bad { background: #ef4444 !important; }     /* invalid preview — red */

/* Attack states */
.bs-cell-hit  { background: #ef4444 !important; }         /* red peg */
.bs-cell-miss { background: #e2e8f0 !important; }         /* white peg */
.bs-cell-sunk { background: #991b1b !important; }         /* dark-red — sunk ship */

/* My board: ship cells are visible to ME only */
.bs-mcell.bs-cell-ship { background: #475569 !important; }

/* Peg dots on hit/miss cells */
.bs-board-cell.bs-cell-hit::after,
.bs-board-cell.bs-cell-miss::after,
.bs-board-cell.bs-cell-sunk::after {
  content: '';
  position: absolute;
  inset: 20%;
  border-radius: 50%;
}
.bs-board-cell.bs-cell-hit::after  { background: rgba(255,255,255,0.6); box-shadow: inset 0 2px 4px rgba(0,0,0,0.4); }
.bs-board-cell.bs-cell-miss::after { background: #94a3b8; box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }
.bs-board-cell.bs-cell-sunk::after { background: rgba(255,100,100,0.5); box-shadow: inset 0 2px 4px rgba(0,0,0,0.5); }

/* Hit flash animation */
@keyframes bs-hit-flash {
  0%, 100% { opacity: 1; }
  30%       { opacity: 0.3; }
}
.bs-board-cell.bs-cell-hit { animation: bs-hit-flash 0.4s ease; }

/* ── Attack phase ────────────────────────── */
.bs-attack-outer {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  gap: 1rem;
  padding: 0.75rem 1rem 0;
  overflow: hidden;
  min-height: 0;
  align-items: center;
  justify-content: center;
}

.bs-board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  min-height: 0;
}

@media (max-width: 767px) {
  .bs-attack-outer {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
}

.bs-board-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.bs-board-frame-wrap {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}

/* Blur overlay when it's not your turn */
.bs-board-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px) brightness(0.6);
  -webkit-backdrop-filter: blur(6px) brightness(0.6);
  background: rgba(0, 0, 0, 0.35);
  z-index: 5;
  border-radius: 4px;
  pointer-events: none;
}
.bs-overlay-text {
  color: white;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  text-align: center;
  padding: 0 0.5rem;
}

/* ── Bottom bar: status + sunk log ──────── */
.bs-bottom-bar {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.92);
  max-height: 7rem;
  overflow: hidden;
}

.bs-status-bar {
  flex-shrink: 0;
  min-height: 2.65rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  background: rgba(30, 41, 59, 0.94);
  color: #f8fafc;
  font-size: 0.9rem;
  font-weight: 800;
  text-align: center;
}

.bs-status-bar--your-turn {
  animation: bs-turn-pulse 2.4s ease-in-out infinite;
}

@keyframes bs-turn-pulse {
  0%, 100% { background: rgba(30, 41, 59, 0.94); box-shadow: inset 0 0 0 rgba(215,30,86,0); }
  50% { background: rgba(75, 38, 75, 0.96); box-shadow: inset 0 0 22px rgba(215,30,86,0.2); }
}

.bs-sunk-log {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

@media (max-width: 767px) {
  /* Keep a short recent history on-screen and give both 10-row boards priority. */
  .bs-bottom-bar { max-height: 5rem; }
}

.bs-log-entry {
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
}

.bs-shot-toast {
  position: absolute;
  left: 50%;
  top: calc(1.325rem + 8px);
  z-index: 30;
  min-width: min(18rem, calc(100% - 2rem));
  padding: 0.9rem 1.35rem;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 999px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0,0,0,0.55), 0 0 0 5px rgba(255,255,255,0.08);
  pointer-events: none;
  animation: bs-toast-in 0.2s ease-out;
}

.bs-shot-toast--hit { background: #dc2626; }
.bs-shot-toast--miss { background: #365d7d; }
.bs-shot-toast.is-leaving { opacity: 0; transform: translate(-50%, -50%) scale(0.96); transition: opacity 0.35s, transform 0.35s; }

@keyframes bs-toast-in {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.88); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .bs-status-bar--your-turn { animation: none; }
}

/* ── Game over ───────────────────────────── */
.bs-gameover-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 2rem;
}

.bs-winner-text {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
}

.bs-rematch-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  max-width: 24rem;
  padding: 1rem 1.15rem;
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 0.85rem;
  background: rgba(30, 25, 55, 0.9);
  text-align: center;
}

.bs-rematch-prompt-text {
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 800;
}

/* ─── Word Race ─────────────────────────────────────────────────────────────── */

#qless-game-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.ql-phase {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.ql-phase.hidden { display: none; }

/* Lobby */
.ql-lobby-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
}
.ql-big-icon img  { display: block; width: 4.5rem; height: 4.5rem; object-fit: contain; }
.match-modal-logo { display: block; width: 4rem; height: 4rem; object-fit: contain; margin: 0 auto .5rem; }
.ql-lobby-title   { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; margin: 0; color: var(--text-main); }
.ql-lobby-sub     { margin: 0; color: var(--text-muted, #94a3b8); font-size: 0.95rem; text-align: center; }
.ql-board-mode-option {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: min(100%, 31rem);
  max-width: 25rem;
  padding: .65rem;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: .75rem;
  background: rgba(255,255,255,.055);
}
.ql-mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .25rem;
  padding: .25rem;
  border-radius: .65rem;
  background: rgba(2,2,30,.75);
}
.ql-mode-choice { position: relative; cursor: pointer; }
.ql-mode-choice input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.ql-mode-choice span {
  display: flex;
  min-height: 2.65rem;
  align-items: center;
  justify-content: center;
  padding: .55rem .65rem;
  border: 1px solid transparent;
  border-radius: .5rem;
  color: var(--text-muted);
  font-weight: 800;
  text-align: center;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.ql-mode-choice input:checked + span {
  border-color: rgba(168,85,247,.75);
  background: linear-gradient(135deg, rgba(126,34,206,.9), rgba(79,70,229,.9));
  color: #fff;
  box-shadow: 0 4px 14px rgba(79,70,229,.3);
}
.ql-mode-choice input:focus-visible + span { outline: 2px solid #fff; outline-offset: 2px; }
.ql-mode-choice input:disabled + span { opacity: .5; cursor: not-allowed; }
.ql-board-mode-option > small { color: var(--text-muted); line-height: 1.3; text-align: center; }
.ql-btn-roll {
  padding: 10px 28px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
}
.ql-btn-roll:disabled { opacity: .4; cursor: not-allowed; }
.ql-btn-roll:not(:disabled):hover { opacity: .85; }

.ql-host-start-options {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.ql-btn-invite {
  padding: 10px 24px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #f8fafc;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
}

.ql-btn-invite:hover { border-color: #d8b4fe; background: rgba(168,85,247,0.15); }

.ql-max-players-msg {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
}

/* Playing phase layout */
.ql-hand-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2, #1e293b);
  border-bottom: 1px solid var(--border, #334155);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.ql-stopwatch {
  flex-shrink: 0;
  min-width: 78px;
  padding: 7px 10px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: rgba(15,23,42,.6);
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: .9rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Letter hand */
.ql-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.ql-hand-tile {
  width: 38px;
  height: 42px;
  border-radius: 6px;
  background: #d4a843;
  color: #1a0e00;
  font-weight: 800;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid #a87c28;
  box-shadow: 0 2px 4px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .1s, box-shadow .1s;
  user-select: none;
  position: relative;
}
.ql-hand-tile:hover { transform: translateY(-3px); box-shadow: 0 5px 10px rgba(0,0,0,.4); }
.ql-hand-tile[draggable="true"], .ql-tile-own[draggable="true"] { cursor: grab; }
.ql-hand-tile[draggable="true"]:active, .ql-tile-own[draggable="true"]:active { cursor: grabbing; }
.ql-hand-tile, .ql-tile-own { touch-action: none; }
.ql-dragging { opacity: 0.45; }
.ql-touch-drag-ghost {
  position: fixed;
  z-index: 100;
  width: 42px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -65%);
  border: 2px solid #facc15;
  border-radius: 7px;
  background: #d4a843;
  color: #1a0e00;
  font-size: 1.15rem;
  font-weight: 900;
  box-shadow: 0 8px 22px rgba(0,0,0,.5);
  pointer-events: none;
}
.ql-hand-tile-held {
  background: #f8d97e;
  border-color: #e6b800;
  box-shadow: 0 0 0 3px #facc15, 0 4px 12px rgba(0,0,0,.4);
  transform: translateY(-4px);
}
.ql-hand-tile-grid {
  background: #5b8dd9;
  border-color: #3b6fbf;
  color: #fff;
}

/* DONE! button */
.ql-btn-qless {
  flex-shrink: 0;
  padding: 8px 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #7e22ce, #a855f7);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.ql-btn-qless:disabled { opacity: .35; cursor: not-allowed; }
.ql-btn-qless:not(:disabled):hover { opacity: .85; transform: scale(1.04); }
.player-score small {
  font-family: var(--font-body);
  font-size: .62rem;
  color: var(--text-muted, #94a3b8);
}
.player-score > span:last-child { display: inline-flex; flex-direction: column; align-items: flex-end; }
.player-score .ql-score-detail { display: block; margin-top: 2px; white-space: nowrap; }
.avatar.ql-rank-avatar {
  flex-shrink: 0;
  font-size: 0.68rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.ql-dict-loading {
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 4px 10px;
  white-space: nowrap;
  animation: ql-pulse 1.4s ease-in-out infinite;
}
@keyframes ql-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .55; }
}

/* Board */
.ql-board-outer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  min-height: 0;
}

.ql-grid {
  display: grid;
  gap: 2px;
  background: #2d3748;
  border: 3px solid #4a5568;
  border-radius: 4px;
  padding: 2px;
  flex-shrink: 0;
}

/* Grid cells */
.ql-cell {
  background: #edf0f0;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: background .1s;
}
.ql-cell.ql-cell-drop {
  background: #dde8dd;
  cursor: crosshair;
}
.ql-cell.ql-cell-drop:hover { background: #c5ddc5; }
.ql-cell.ql-drop-target, #ql-hand.ql-drop-target {
  outline: 3px solid #a855f7;
  outline-offset: -3px;
}
.ql-cell.ql-cell-filled { background: transparent; cursor: pointer; }

/* Placed tile on grid */
.ql-tile {
  width: 88%;
  height: 88%;
  border-radius: 4px;
  background: #d4a843;
  color: #1a0e00;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.25);
  user-select: none;
  border: 1px solid #a87c28;
  transition: transform .08s;
}
.ql-cell.ql-cell-filled:hover .ql-tile { transform: scale(1.08); }

/* Own tiles — white inner ring signals "you can pick this up" */
.ql-tile-own {
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,.35), inset 0 0 0 2px rgba(255,255,255,.6);
}

/* Other players' tiles — coloured by player, not pick-uppable */
.ql-tile-other {
  opacity: 0.85;
  border-color: transparent;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.ql-tile-invalid {
  background: #050505 !important;
  color: #fff !important;
  border-color: #fff !important;
  animation: ql-invalid-flash 0.55s ease-in-out 6;
}
@keyframes ql-invalid-flash {
  0%, 100% { background: #050505; color: #fff; transform: scale(1); }
  50% { background: #475569; color: #fff; transform: scale(1.08); }
}
.ql-cell.ql-cell-other { cursor: default; }
.ql-cell.ql-cell-other:hover .ql-tile { transform: none; }

/* Status bar */
.ql-status-row {
  flex-shrink: 0;
  padding: 4px 12px 6px;
  min-height: 24px;
}
.ql-status-text {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  text-align: center;
  display: block;
}

.ql-result-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px;
  align-items: center;
  width: min(360px, 80vw);
  padding: 10px 12px;
  margin: 7px auto;
  border: 1px solid var(--border, #334155);
  border-radius: 9px;
  background: var(--surface-2, #1e293b);
  text-align: left;
}
.ql-result-row span small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted, #94a3b8);
  font-size: .72rem;
}

/* Word list (shown after a win) */
.ql-words-wrap {
  width: 100%;
  max-width: 360px;
}
.ql-words-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted, #94a3b8);
  text-align: center;
  margin-bottom: 0.5rem;
}
.ql-words-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}
.ql-word-chip {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: .02em;
}

/* Game over */
.ql-gameover-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  overflow-y: auto;
}
.ql-winner-text {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
}
.ql-word-list {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 480px;
  width: 100%;
}
.ql-result-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ql-player-words {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 0 12px 8px;
}
.ql-word-count {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}
.ql-word-entries {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.ql-word-entry {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 700;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}
.ql-word-valid   { background: rgba(168,85,247,0.18); color: #d8b4fe; }
.ql-word-invalid { background: #fee2e2; color: #dc2626; text-decoration: line-through; opacity: .82; }
.ql-word-unknown { background: #f1f5f9; color: #475569; }
.ql-no-valid-words { color: var(--text-muted, #94a3b8); }

/* ── Color legend (playing phase) ─────────────────────────────────────────── */
.ql-color-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: center;
  padding: 0.4rem 0.75rem;
}
.ql-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main, #1e293b);
}
.ql-legend-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}

/* ─── Banner Battle ─────────────────────────────────────────────────────────── */

#stratego-game-area {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Phase bars (placement header / attack header) */
.st-phase-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2, #1e293b);
  border-bottom: 1px solid var(--border, #334155);
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Piece palette */
.st-piece-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.st-palette-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 42px;
  border-radius: 6px;
  background: #1e3a5f;
  border: 2px solid #3b82f6;
  cursor: pointer;
  position: relative;
  transition: transform .12s, border-color .12s;
  user-select: none;
}
.st-palette-chip:hover { transform: translateY(-2px); border-color: #60a5fa; }
.st-palette-chip.st-palette-selected { border-color: #facc15; background: #1e3a1a; box-shadow: 0 0 0 2px #facc15; }
.st-palette-chip.st-palette-empty { opacity: .35; cursor: not-allowed; }
.st-palette-chip[draggable="true"],
.st-chip-mine[draggable="true"] { cursor: grab; touch-action: none; }
.st-palette-chip[draggable="true"]:active,
.st-chip-mine[draggable="true"]:active { cursor: grabbing; }
.st-dragging { opacity: .45; }
.st-cell.st-drop-target {
  background: #4c1d95 !important;
  outline: 3px solid #c084fc;
  outline-offset: -3px;
}
.st-touch-drag-ghost {
  position: fixed;
  z-index: 200;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  translate: -50% -50%;
  pointer-events: none;
  background: radial-gradient(circle at 35% 35%, #3b82f6, #1d4ed8);
  border: 2px solid #93c5fd;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
}

.st-chip-label {
  font-size: 13px;
  font-weight: 800;
  color: #93c5fd;
  line-height: 1;
}
.st-chip-count {
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  line-height: 1;
}

/* Placement action buttons */
.st-place-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.st-btn-sm {
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: #334155;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.st-btn-sm:hover { background: #475569; }
.st-btn-deploy {
  padding: 6px 14px;
  border-radius: 8px;
  background: linear-gradient(135deg, #b91c1c, #dc2626);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  border: none;
  cursor: pointer;
  transition: opacity .15s;
}
.st-btn-deploy:disabled { opacity: .4; cursor: not-allowed; }
.st-btn-deploy:not(:disabled):hover { opacity: .85; }

/* Turn info (attack header) */
.st-turn-info {
  flex: 1;
  width: 100%;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

/* Board outer container */
.st-board-outer {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 6px;
  min-height: 0;
}

/* Board grid */
.st-board {
  display: grid;
  gap: 2px;
  background: #334155;
  border: 3px solid #475569;
  border-radius: 4px;
  padding: 2px;
  flex-shrink: 0;
}

/* Cells */
.st-cell {
  background: #0f172a;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  position: relative;
  transition: background .1s;
}
.st-cell.st-lake {
  background: #0e4f7a;
  cursor: not-allowed;
}
.st-cell.st-empty { background: #1e293b; }
.st-cell.st-my-zone { background: #1a2e1a; }
.st-cell.st-my-zone:hover { background: #1e3a1e; cursor: crosshair; }

/* Selection & move highlights */
.st-cell.st-selected { outline: 2px solid #facc15; outline-offset: -2px; z-index: 1; }
.st-cell.st-valid-move {
  background: #14532d !important;
  cursor: pointer;
}
.st-cell.st-valid-move::after {
  content: '';
  width: 30%;
  height: 30%;
  border-radius: 50%;
  background: #4ade80;
  position: absolute;
}
.st-cell.st-valid-attack {
  background: #7f1d1d !important;
  cursor: pointer;
  outline: 2px solid #ef4444;
  outline-offset: -2px;
}

/* Piece chips */
.st-chip {
  width: 88%;
  height: 88%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  transition: transform .1s;
  box-sizing: border-box;
}

/* My pieces — blue */
.st-chip-mine {
  background: radial-gradient(circle at 35% 35%, #3b82f6, #1d4ed8);
  color: #e0f2fe;
  border: 2px solid #60a5fa;
}
.st-chip-mine.st-chip-canmove {
  cursor: pointer;
  box-shadow: 0 0 6px #60a5fa88;
}
.st-cell.st-my-piece:has(.st-chip-canmove):hover .st-chip-mine {
  transform: scale(1.08);
}

/* Enemy pieces — face down */
.st-chip-enemy {
  background: radial-gradient(circle at 35% 35%, #dc2626, #991b1b);
  color: #fee2e2;
  border: 2px solid #f87171;
  font-size: 70% !important;
  letter-spacing: -0.5px;
}
/* Revealed enemy pieces get a lighter, distinct look */
.st-chip-enemy.st-chip-revealed {
  background: radial-gradient(circle at 35% 35%, #b45309, #78350f);
  border-color: #fbbf24;
  color: #fef3c7;
}

/* Status bar */
.st-status-bar-wrap {
  flex-shrink: 0;
  padding: 4px 12px;
  min-height: 24px;
}
.st-status-text {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  text-align: center;
}

/* Game over overlay */
.st-gameover {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.78);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 50;
  border-radius: inherit;
}
.st-gameover.st-gameover-hidden {
  display: none;
}
.st-winner-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
  padding: 0 20px;
}

.cancel-join-button {
  width: 100%;
  min-height: 32px;
  background-color: rgba(255,255,255,0.1);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.12);
  font-weight: 400;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.2;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 12px;
  margin: 12px 0 0;
  border-radius: 12px;
  cursor: pointer;
}
.cancel-join-button:hover { background-color: rgba(255,255,255,0.16); }

.btn-switch-host, .host-dialog-content button {
  font: inherit;
  color: #fff;
  background: #533489;
  border: 1px solid #9b77d4;
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}
.btn-switch-host { margin: 8px 0; }
.host-dialog-content {
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
  box-sizing: border-box;
  padding: 26px;
  border: 1px solid #9b77d4;
  border-radius: 20px;
  background: #211b36;
  color: #fff;
  box-shadow: 0 16px 60px #0008;
}
.host-dialog-content h2 { margin: 0 0 14px; }
.host-dialog-content p { margin: 12px 0; line-height: 1.5; }
.host-dialog-content select { width: 100%; padding: 10px; margin-top: 8px; color: #fff; background: #34284d; border-radius: 8px; }
.host-dialog-content button { display: block; width: 100%; margin-top: 10px; }
.host-dialog-content a { color: #d9b8ff; overflow-wrap: anywhere; }
.host-dialog-content button:disabled, .btn-switch-host:disabled { opacity: .5; cursor: default; }
#host-dialog, #room-ended-notice { z-index: 10000; }
#btn-end-room { background: #73293c; border-color: #d87a8b; }
#btn-cancel-host { background: transparent; }
.game-stage { position: relative; }
.vacant-seat-notice { position: absolute; inset: 0; z-index: 40; display: grid; place-content: center; padding: 32px; text-align: center; background: #17112aee; color: #fff; line-height: 1.6; }
.bs-cinematic {
  position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center;
  padding: 16px; background: rgba(2, 8, 15, .97);
}
.bs-cinematic-frame { width: min(1100px, 100%); }
.bs-cinematic video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: contain; max-height: calc(100dvh - 140px); background: #000; }
.bs-cinematic-status { color: #e2e8f0; padding-top: 8px; text-align: center; }
.bs-cinematic-actions { display: flex; justify-content: flex-end; gap: 12px; padding-top: 12px; }
.bs-cinematic-actions button {
  padding: 10px 18px; border: 1px solid #7890a6; border-radius: 8px;
  background: #183044; color: #fff; font: inherit; cursor: pointer;
}
.bs-cinematic-actions button:focus-visible { outline: 3px solid #ffcf50; outline-offset: 3px; }
.game-camera-selector {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .65rem;
  flex-shrink: 0; min-width: 0;
}
.game-camera-selector label { font-size: .75rem; color: var(--text-muted); }
.game-camera-selector select { min-width: 0; flex: 1; width: 100%; padding: .35rem .5rem; font-size: .75rem; }
.camera-refresh {
  border: 1px solid var(--border); border-radius: .5rem; padding: .3rem .5rem;
  background: var(--surface-solid); color: var(--text-main); font: inherit;
  font-size: .7rem; cursor: pointer; flex-shrink: 0;
}
