*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
}
:root {
  --bg: #0e0e1a;
  --bg2: #161625;
  --bg3: #1e1e32;
  --border: #2a2a48;
  --accent: #e53935;
  --accent-2: #f5a623;
  --green: #00ff41;
  --amber: #ffb000;
  --yellow: #ffe600;
  --cyan: #00f0ff;
  --prompt: #5ebb52;
  --text: #c8c0c0;
  --muted: #777;
  --radius: 8px;
  --bs: min(calc(100dvh - 140px), calc(100svw - 24px));
  --ts: 40px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 1rem;
  padding-top: calc(6rem + env(safe-area-inset-top, 0px));
  padding-right: calc(1rem + env(safe-area-inset-right, 0px));
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  padding-left: calc(1rem + env(safe-area-inset-left, 0px));
}

@keyframes shine {
  to {
    background-position: 200% center;
  }
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
h1 {
  font-size: 3rem;
  letter-spacing: 0.3em;
  font-family: 'IBM Plex Mono', monospace;
  background: linear-gradient(135deg, var(--accent), #ff8a65, var(--accent));
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  margin-bottom: 0.5rem;
}
/* ===== BRAND HEADER (wQ$x emblem) ===== */
#main-title.brand {
  margin: 0;
  padding: 0;
}
#main-title.brand:empty {
  display: none;
}

/* ===== BRAND ECHOES (qlashique / waiting) ===== */
.qlas-mark {
  width: 56px;
  height: auto;
  display: block;
  margin: 0 auto 6px;
  filter: drop-shadow(0 0 6px rgba(var(--game-accent-rgb), 0.55))
    drop-shadow(0 0 14px rgba(var(--game-accent-rgb), 0.22));
}
.qlas-waiting-mark {
  width: 72px;
  height: auto;
  display: block;
  margin: 0 auto 14px;
  animation: qlas-mark-spin 4s linear infinite;
  filter: drop-shadow(0 0 8px rgba(var(--game-accent-rgb), 0.55))
    drop-shadow(0 0 18px rgba(var(--game-accent-rgb), 0.22));
}
@keyframes qlas-mark-spin {
  to {
    transform: rotate(360deg);
  }
}
/* Empty-state watermark for dynamically-populated leaderboard containers */
.lb-rows:empty::after,
#lb-rows:empty::after {
  content: 'No scores yet.';
  display: block;
  text-align: center;
  padding: 60px 20px 40px;
  color: var(--muted);
  opacity: 0.7;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 72 64' fill='none'><circle cx='32' cy='32' r='14' stroke='%2300ff41' stroke-width='2.5'/><path d='M 4 32 L 18 32' stroke='%2300ff41' stroke-width='2.5'/><circle cx='4' cy='32' r='2' fill='%2300ff41'/><path d='M 32 4 L 32 18' stroke='%2300ff41' stroke-width='2.5'/><circle cx='32' cy='4' r='2' fill='%2300ff41'/><path d='M 42 42 L 52 52 L 62 52' stroke='%23ffe600' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'/><circle cx='62' cy='52' r='2.5' fill='%23ffe600'/></svg>");
  background-repeat: no-repeat;
  background-position: center 18px;
  background-size: 80px auto;
  min-height: 160px;
  opacity: 0.5;
}

/* ===== ANNOUNCEMENTS ===== */
#announcements {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 680px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  background: rgba(22, 22, 37, 0.5);
  border-radius: 8px;
  padding: 14px 20px;
  font-size: 0.78rem;
  font-family: 'IBM Plex Mono', monospace;
  line-height: 1.6;
}
#announcements .ann-header {
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
}
#announcements ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
#announcements li::before {
  content: '— ';
  color: var(--muted);
  margin-right: 2px;
}
#announcements a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}
#announcements a:hover {
  color: var(--text);
}

/* ===== CARDS (connect / lobby) ===== */
.card {
  background: rgba(22, 22, 37, 0.5);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: 0.5rem 2rem;
}

/* ===== CONNECT LAYOUT =====
   Vertical stack: horizontal nav on top, content card below. Class name kept
   from the old 2-col layout for low-churn migration. */
.main-columns {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  position: relative;
  z-index: 1;
}
.main-columns .card {
  max-width: 680px;
}
.connect-card {
  width: 100%;
  position: relative;
  z-index: 1;
  background: transparent;
  border-color: transparent;
  padding: 0;
}

/* Home-page scattered shape background (populated by home-bg module).
   z-index:-1 places it behind static body content (h1, announcements, screen-connect).
   Overlay screens (#screen-skipnot, etc.) are position:fixed inset:0 and naturally
   cover this since they have higher z-index. */
#home-bg {
  display: none;
}
#home-bg .home-bg-shape {
  position: absolute;
  display: block;
  pointer-events: none;
}
#home-bg .home-bg-shape svg {
  width: 100%;
  height: 100%;
  display: block;
}
@media (prefers-reduced-motion: reduce) {
  #home-bg {
    display: none;
  }
}

/* ===== ISOMETRIC BOARD BANNER (home background) ===== */
#board-banner {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.bb-grid {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%) rotateX(58deg) rotateZ(45deg) scale(3.5);
  transform-style: preserve-3d;
  display: grid;
  grid-template-columns: repeat(5, 36px);
  grid-template-rows: repeat(5, 36px);
  gap: 3px;
}
.bb-t {
  width: 36px;
  height: 36px;
  border-radius: 4px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
}
.bb-t--light {
  background: #222240;
  border: 1px solid #2e2e52;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.bb-t--dark {
  background: #161630;
  border: 1px solid #1e1e3c;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.bb-t--q {
  background: rgba(255, 176, 0, 0.2);
  border: 1.5px solid rgba(255, 176, 0, 0.4);
  font-size: 1.1rem;
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(255, 176, 0, 0.5);
  box-shadow:
    0 0 18px rgba(255, 176, 0, 0.12),
    0 2px 6px rgba(0, 0, 0, 0.3);
  animation: bb-qpulse 2.5s ease-in-out infinite alternate;
}
@keyframes bb-qpulse {
  0% {
    box-shadow:
      0 0 12px rgba(255, 176, 0, 0.1),
      0 2px 6px rgba(0, 0, 0, 0.3);
  }
  100% {
    box-shadow:
      0 0 30px rgba(255, 176, 0, 0.25),
      0 2px 6px rgba(0, 0, 0, 0.3);
  }
}
.bb-t--a {
  background: rgba(229, 57, 53, 0.22);
  border: 1.5px solid rgba(229, 57, 53, 0.4);
  color: var(--accent);
  font-size: 0.75rem;
  text-shadow: 0 0 8px rgba(229, 57, 53, 0.4);
  box-shadow:
    0 0 10px rgba(229, 57, 53, 0.1),
    0 2px 6px rgba(0, 0, 0, 0.3);
}
.bb-t--b {
  background: rgba(0, 240, 255, 0.15);
  border: 1.5px solid rgba(0, 240, 255, 0.35);
  color: #00f0ff;
  font-size: 0.75rem;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  box-shadow:
    0 0 10px rgba(0, 240, 255, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.3);
}
.bb-t--c {
  background: rgba(0, 255, 65, 0.13);
  border: 1.5px solid rgba(0, 255, 65, 0.3);
  color: #00ff41;
  font-size: 0.75rem;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.4);
  box-shadow:
    0 0 10px rgba(0, 255, 65, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.3);
}
.bb-t--d {
  background: rgba(255, 176, 0, 0.13);
  border: 1.5px solid rgba(255, 176, 0, 0.3);
  color: var(--accent-2);
  font-size: 0.75rem;
  text-shadow: 0 0 8px rgba(255, 176, 0, 0.4);
  box-shadow:
    0 0 10px rgba(255, 176, 0, 0.08),
    0 2px 6px rgba(0, 0, 0, 0.3);
}
.bb-t--peg-r,
.bb-t--peg-b {
  background: #1a1a36;
  border: 1px solid #252548;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.bb-t--peg-r::after,
.bb-t--peg-b::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
}
.bb-t--peg-r::after {
  background: var(--accent);
  box-shadow:
    0 0 12px rgba(229, 57, 53, 0.5),
    0 0 3px rgba(229, 57, 53, 0.8);
}
.bb-t--peg-b::after {
  background: #00f0ff;
  box-shadow:
    0 0 12px rgba(0, 240, 255, 0.5),
    0 0 3px rgba(0, 240, 255, 0.8);
}
.bb-ambient {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 35% 42%, rgba(229, 57, 53, 0.07) 0%, transparent 40%),
    radial-gradient(ellipse at 65% 58%, rgba(0, 240, 255, 0.06) 0%, transparent 40%);
  pointer-events: none;
}
.bb-vignette {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, transparent 20%, var(--bg) 70%);
  pointer-events: none;
}
.col-triviandom {
  --triv-accent: #125f9d;
}
.col-triviandom .leaderboard-panel::before {
  background: linear-gradient(90deg, transparent, var(--triv-accent), transparent);
  opacity: 0.8;
}
.col-triviandom .lb-heading {
  text-align: center;
}
.col-triviandom .lb-divider {
  background: linear-gradient(90deg, var(--triv-accent), #3d6aaf, transparent);
}
.col-triviandom .lb-thead {
  border-bottom-color: #2a4a7a;
  color: #bd4c84;
}
.col-triviandom .lb-thead div:first-child {
  padding-left: 12px;
}
.col-triviandom .lb-thead div:last-child {
  padding-right: 4px;
  text-align: center;
}
.col-triviandom .lb-thead div:nth-child(2) {
  padding-left: 10px;
}
.col-triviandom .lb-thead div:nth-child(3) {
  padding-right: 10px;
}
.col-triviandom .lb-row {
  border-bottom-color: #2a4a7a;
}
.col-triviandom .lb-row .lb-rk {
  text-align: center;
}
.col-triviandom .lb-row div:nth-child(2) {
  padding-left: 10px;
}
.col-triviandom .lb-row div:nth-child(3) {
  text-align: center;
}
.col-triviandom .lb-row div:last-child {
  padding-right: 14px;
  text-align: center;
  color: rgba(7, 155, 29, 0.5);
}
.btn-triviandom {
  background: var(--triv-accent) !important;
  font-weight: 700;
  letter-spacing: 0.04em;
  width: 100%;
}
.btn-triviandom:hover {
  opacity: 0.85;
}
/* ===== HORIZONTAL CONNECT NAV =====
   Items with [data-view] swap content via showView (see client js nav module).
   Items without are one-shot actions (Help / Stats modal triggers, HC toggle,
   Sign out, Admin). */
.connect-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
  max-width: 680px;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 1;
}
.nav-item {
  width: auto;
  height: auto;
  background: rgba(14, 14, 26, 0.5);
  border: 1px solid transparent;
  color: var(--muted);
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px;
  letter-spacing: 0.02em;
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s;
}
.nav-item:hover {
  color: var(--text);
  border-color: var(--border);
}
.nav-item.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(229, 57, 53, 0.08);
}
.nav-item[hidden] {
  display: none;
}
.nav-item-danger:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

/* ===== VIEWS ===== */
.view[hidden] {
  display: none;
}
.view-narrow {
  max-width: 320px;
  margin: 0 auto;
}
.auth-input {
  display: block;
  width: 100%;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--bg3);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 0.9rem;
  height: 40px;
  box-sizing: border-box;
}
.auth-submit {
  display: block;
  width: 100%;
  padding: 0.55rem;
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.auth-submit:hover {
  border-color: var(--accent);
}
.auth-submit-primary {
  background: var(--accent);
  border-color: var(--accent);
}
.auth-submit-primary:hover {
  opacity: 0.9;
}
.card h2 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}
label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}
input,
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg3);
  border: 1px solid #ffffff18;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  margin-bottom: 1rem;
  outline: none;
}
input:focus,
select:focus {
  border-color: var(--accent);
}
button {
  width: 100%;
  height: 40px;
  background: var(--accent);
  color: #cecdcd;
  border: none;
  border-radius: var(--radius);
  font-size: 1.2rem;
  font-weight: 600;
  transition: opacity 0.15s;
}
button:hover {
  opacity: 0.85;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.error {
  color: #e57335;
  font-size: 1rem;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
  background: linear-gradient(45deg, black, transparent);
}
/* Settings sections — scoped to settings view to avoid affecting mode-cards */
[data-view-name='settings'] .setup-section {
  margin-bottom: 0;
  background: rgba(255, 255, 255, 0.015);
  padding: 12px 16px 14px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
[data-view-name='settings'] .setup-section + .setup-section {
  margin-top: 8px;
}
.setup-section {
  margin-bottom: 0;
}
.setup-section + .setup-section {
  border-top: 1px solid #1e2d4a;
  margin-top: 4px;
}
[data-view-name='settings'] .setup-section + .setup-section {
  padding-top: 12px;
  border-top: none;
}
.setup-section h3 {
  font-size: 0.7rem;
  letter-spacing: 2px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
  margin-top: 30px;
  font-weight: 700;
}
[data-view-name='settings'] .setup-section h3 {
  margin-top: 0;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(229, 57, 53, 0.15);
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 2.5px;
  font-family: 'Chakra Petch', sans-serif;
}
.opt-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 0;
}
.opt-btn {
  flex: 1;
  padding: 9px 8px;
  background: var(--bg3);
  border: 2px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
  width: auto;
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.04em;
}
.opt-btn.active {
  border-color: var(--accent);
  background: rgba(229, 57, 53, 0.08);
  color: var(--accent);
  box-shadow: 0 0 8px rgba(229, 57, 53, 0.15);
}
.opt-btn:hover:not(.active) {
  background: #0d2040;
  border-color: rgba(255, 255, 255, 0.1);
}
.setup-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.setup-actions button {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: 2px solid var(--bg3);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    border-color 0.15s,
    color 0.15s;
  width: auto;
  letter-spacing: 0.3px;
}
.setup-actions button:hover,
.setup-actions button.active {
  border-color: var(--accent);
  color: var(--accent);
}
.cat-toggle-btns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
}
.cat-toggle-btn {
  padding: 8px 10px;
  background: var(--bg3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    box-shadow 0.15s;
  text-align: center;
  letter-spacing: 0.02em;
  width: auto;
  font-family: 'Chakra Petch', system-ui, sans-serif;
}
.cat-toggle-btn.active {
  border-color: var(--accent);
  background: rgba(229, 57, 53, 0.1);
  color: #ff6b5e;
  box-shadow: 0 0 8px rgba(229, 57, 53, 0.15);
}
.cat-toggle-btn:hover:not(.active) {
  background: #0d2040;
  border-color: rgba(255, 255, 255, 0.1);
}
#help-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
#help-modal.show {
  display: flex;
}
.help-content {
  background: var(--bg2);
  border: 2px solid var(--bg3);
  border-radius: 12px;
  max-width: 500px;
  max-height: 80svh;
  overflow-y: auto;
  padding: 24px;
  width: 100%;
}
.help-content h2 {
  color: var(--accent);
  margin-bottom: 16px;
  font-size: 1.4rem;
  font-weight: 900;
}
.help-content h3 {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 16px 0 8px;
  font-weight: 700;
}
.help-content p,
.help-content li {
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 6px;
}
.help-content ul {
  padding-left: 20px;
}
.help-content button {
  margin-top: 16px;
  max-width: none;
}
body.high-contrast {
  filter: contrast(1.3) brightness(1.05);
}
.player-list {
  list-style: none;
  margin-bottom: 1.5rem;
}
.player-list li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #ffffff0a;
  font-size: 0.95rem;
}
.player-list li:last-child {
  border-bottom: none;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  background: var(--bg3);
  border-radius: 4px;
  color: var(--muted);
  margin-left: auto;
}
.room-code {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.room-code-label {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 1.5rem;
}

/* ===== GAME SCREEN ===== */
#screen-game {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 10px;
  gap: 8px;
  z-index: 10;
}

/* ===== TOP BAR ===== */
#top-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  width: var(--bs);
}
#turn-panel {
  flex: 1;
  background: #0a0a0a;
  border: 2px solid #444;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  color: #ccc;
  min-height: 64px;
}
#turn-player-box {
  display: flex;
  align-items: center;
  padding: 8px 16px;
}
#turn-player-name {
  font-size: 25px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
}
#turn-moves {
  font-size: 19px;
  color: #888;
  padding-left: 18px;
}
#turn-info {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 20px;
}
#turn-number {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1;
  color: #0f0;
}
#player-stats {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: flex-end;
  flex-shrink: 0;
  padding: 8px 16px;
  font-size: 16px;
}
.player-stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  line-height: 1.2;
}
.player-stat-ratio {
  font-size: 20px;
}
.player-stat-pct {
  font-size: 17px;
  opacity: 0.8;
}

/* ===== BOARD ===== */
#board {
  display: grid;
  width: var(--bs);
  max-width: calc(100vw - 24px);
  gap: 3px;
  background: #0a0a1a;
  padding: 3px;
  border-radius: 8px;
  border: 2px solid var(--bg3);
  overflow: hidden;
}

/* ===== TILES ===== */
.tile {
  aspect-ratio: 1;
  min-width: 0;
  min-height: 0;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: default;
  transition:
    transform 0.1s,
    filter 0.1s;
  user-select: none;
}
.tile.clickable {
  cursor: pointer;
}
.tile.clickable:hover {
  filter: brightness(1.3);
  transform: scale(1.06);
  z-index: 2;
}
.tile.valid-move {
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.7),
    0 0 10px 2px rgba(255, 255, 255, 0.2);
  animation: pulse 1s infinite alternate;
  z-index: 1;
}
.tile.selected-peg-tile {
  box-shadow:
    0 0 0 2px white,
    0 0 10px 3px rgba(255, 255, 255, 0.4);
  z-index: 3;
}
.tile.dimmed {
  opacity: 0.35;
  pointer-events: none;
}
.tile.flag-tile {
  background: #1a1a2e;
  border: 2px solid #555;
  flex-direction: column;
}

@keyframes pulse {
  from {
    opacity: 0.7;
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.5),
      0 0 6px 1px rgba(255, 255, 255, 0.1);
  }
  to {
    opacity: 1;
    box-shadow:
      0 0 0 2px rgba(255, 255, 255, 0.9),
      0 0 14px 4px rgba(255, 255, 255, 0.3);
  }
}
@keyframes peg-arrive {
  0% {
    transform: scale(0.55);
    opacity: 0.3;
  }
  65% {
    transform: scale(1.22);
    opacity: 1;
  }
  100% {
    transform: scale(1);
  }
}
@keyframes peg-pulse {
  0%,
  100% {
    box-shadow:
      0 0 0 3px white,
      0 0 8px 2px rgba(255, 255, 255, 0.5);
  }
  50% {
    box-shadow:
      0 0 0 4px white,
      0 0 14px 5px rgba(255, 255, 255, 0.2);
  }
}

.tile-cat-label {
  position: absolute;
  bottom: 3px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: calc(var(--ts) * 0.12);
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.flag-icon {
  font-size: calc(var(--ts) * 0.45);
  line-height: 1;
}
.flag-owner {
  font-size: calc(var(--ts) * 0.14);
  font-weight: 700;
  text-align: center;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== CATEGORY COLORS ===== */
.cat-arts {
  background: #c62828;
}
.cat-arts .tile-cat-label {
  color: #ffd6d6;
}
.cat-music {
  background: #6a1b9a;
}
.cat-music .tile-cat-label {
  color: #e8ccff;
}
.cat-death_metal {
  background: #37474f;
}
.cat-death_metal .tile-cat-label {
  color: #cfd8dc;
}
.cat-entertainment {
  background: #e65100;
}
.cat-entertainment .tile-cat-label {
  color: #fff0cc;
}
.cat-literature {
  background: #1565c0;
}
.cat-literature .tile-cat-label {
  color: #c5dcff;
}
.cat-nature {
  background: #388e3c;
}
.cat-nature .tile-cat-label {
  color: #c8e6c9;
}
.cat-science {
  background: #969517;
}
.cat-science .tile-cat-label {
  color: #f9f7d0;
}
.cat-history {
  background: #6d4c41;
}
.cat-history .tile-cat-label {
  color: #ffe0c8;
}
.cat-geography {
  background: #00695c;
}
.cat-geography .tile-cat-label {
  color: #b2dfdb;
}
.cat-sports {
  background: #bd1b8a;
}
.cat-sports .tile-cat-label {
  color: #ffd6e8;
}
.cat-other {
  background: #546e7a;
}
.cat-other .tile-cat-label {
  color: #d6e8f0;
}

/* ===== PEGS ===== */
.peg {
  width: calc(var(--ts) * 0.55);
  height: calc(var(--ts) * 0.55);
  border-radius: 50%;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--ts) * 0.2);
  font-weight: 900;
  color: white;
  border: 2.5px solid rgba(255, 255, 255, 0.9);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  position: relative;
  z-index: 2;
  transition: transform 0.15s;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}
.peg:hover {
  transform: scale(1.18);
}
.peg.selected {
  border-color: white;
  animation: peg-pulse 1.2s ease-in-out infinite;
}
.peg.just-moved {
  animation: peg-arrive 0.32s cubic-bezier(0.2, 0, 0.4, 1) forwards;
}
.peg.can-move {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5);
  cursor: pointer;
}
.peg-hp {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: calc(var(--ts) * 0.22);
  height: calc(var(--ts) * 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.peg-hp-heart {
  position: absolute;
  inset: 0;
  font-size: calc(var(--ts) * 0.22);
  line-height: 1;
  color: #e53935;
  filter: drop-shadow(0 0 2px #000);
}
.peg-hp-count {
  position: relative;
  font-size: calc(var(--ts) * 0.1);
  font-weight: 900;
  color: white;
  text-shadow: 0 0 2px #000;
  line-height: 1;
}

/* ===== QUESTION MODAL ===== */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
#modal {
  background: var(--bg2);
  border: 2px solid var(--bg3);
  border-top: 4px solid #444;
  border-radius: 12px;
  padding: 28px;
  max-width: 520px;
  width: 90%;
  max-height: 90svh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition:
    transform 0.2s,
    border-top-color 0.2s;
}
#modal-overlay.visible #modal {
  transform: scale(1);
}
.modal-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
#modal-cat-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: white;
}
#modal-player-label {
  font-size: 0.85rem;
  color: var(--muted);
}
#modal-game-timer {
  font-size: 2.4rem;
  color: #63a437;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
#modal-combat-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 1px;
}
#modal-question {
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 22px;
}
.modal-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.modal-option {
  padding: 12px 16px;
  background: var(--bg3);
  border: 2px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition:
    background 0.15s,
    border-color 0.15s;
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
}
.modal-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: #1a2a50;
}
.modal-option:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.modal-option.answer-correct {
  border-color: #43a047 !important;
  background: #1b3a1c !important;
  opacity: 1 !important;
}
.modal-option.answer-wrong {
  border-color: var(--accent) !important;
  background: #2a1a30 !important;
  opacity: 1 !important;
}
.option-key {
  font-weight: 900;
  font-size: 0.8rem;
  opacity: 0.75;
  flex-shrink: 0;
}
.timer-bar-wrap {
  margin: 16px 0;
}
.timer-bar-container {
  width: 100%;
  height: 8px;
  background: #0a1628;
  border-radius: 4px;
  overflow: hidden;
}
.timer-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition:
    width 0.1s linear,
    background-color 0.3s;
}
.timer-bar-fill.safe {
  background: #43a047;
}
.timer-bar-fill.warning {
  background: #fb8c00;
}
.timer-bar-fill.danger {
  background: #e53935;
  animation: timer-pulse 0.5s ease-in-out infinite;
}
@keyframes timer-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}
.timer-text {
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  margin-top: 6px;
}
#modal-continue-wrap {
  margin-top: 16px;
  display: none;
}
#modal-continue-btn {
  width: 100%;
  padding: 6px;
  letter-spacing: 1px;
}

/* ===== STATS MODAL OVERLAY ===== */
#stats-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
#stats-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ===== STATS MODAL CONTENT ===== */
#stats-modal {
  background: var(--bg2);
  border: 2px solid var(--bg3);
  border-top: 4px solid #444;
  border-radius: 12px;
  padding: 28px;
  max-width: 500px;
  width: 90%;
  max-height: 90svh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition:
    transform 0.2s,
    border-top-color 0.2s;
}
#stats-modal-overlay.visible #stats-modal {
  transform: scale(1);
}

/* ===== TURN ANNOUNCE ===== */
#turn-announce {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, 0.85);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
#turn-announce.visible {
  opacity: 1;
  pointer-events: all;
}
#turn-announce-name {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
}
#turn-announce-sub {
  font-size: 0.8rem;
  letter-spacing: 5px;
  color: var(--muted);
  margin-top: 6px;
}

/* ===== NAV CURSOR ===== */
.tile.nav-highlight {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: -3px;
  z-index: 4;
}

/* ===== GAME OVER ===== */
#screen-gameover {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.96);
  z-index: 300;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1rem;
  padding: 2rem;
}
#screen-gameover h1 {
  font-size: 2.5rem;
  color: var(--accent);
}
#winner-text {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffd700;
}
#screen-gameover button {
  max-width: 240px;
  margin-top: 0.5rem;
}

/* ===== LEADERBOARD ===== */
#screen-leaderboard {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}
#screen-leaderboard.show {
  display: flex;
}

.leaderboard-panel {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 8px;
  padding: 28px 22px;
  width: 100%;
  max-width: 420px;
  position: relative;
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
}

/* SkipNoT/Qlashique variant — same structural panel, transparent bg + blue
   border, slightly wider, centered text. Use this class instead of inline
   style overrides so every place that shows a SkipNoT leaderboard looks
   identical. */
/* Landing-page lb-skipnot — stays amber regardless of game theme.
   Game-over copy (inside #screen-skipnot) is themed via the override below. */
.leaderboard-panel.lb-skipnot {
  background: transparent;
  border-color: #5a3300;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}
.leaderboard-panel.lb-skipnot .lb-heading {
  color: #ffd060;
  text-shadow: 0 0 18px rgba(255, 176, 0, 0.35);
}
.leaderboard-panel.lb-skipnot .lb-heading span {
  color: #ffb000;
}
.leaderboard-panel.lb-skipnot .lb-divider {
  background: linear-gradient(90deg, #ffb000, #3a1f00, transparent);
}
.leaderboard-panel.lb-skipnot .lb-thead {
  color: #5a3300;
  border-bottom-color: #3a1f00;
}
.leaderboard-panel.lb-skipnot .lb-row {
  border-bottom-color: rgba(90, 51, 0, 0.4);
}
/* Game-over copy of lb-skipnot inherits the active game theme */
#screen-skipnot .leaderboard-panel.lb-skipnot {
  border-color: var(--game-border-2);
}
#screen-skipnot .leaderboard-panel.lb-skipnot .lb-heading {
  color: var(--game-text);
  text-shadow: 0 0 18px var(--game-accent);
}
#screen-skipnot .leaderboard-panel.lb-skipnot .lb-heading span {
  color: var(--game-accent);
}
#screen-skipnot .leaderboard-panel.lb-skipnot .lb-divider {
  background: linear-gradient(90deg, var(--game-accent), var(--game-border), transparent);
}
#screen-skipnot .leaderboard-panel.lb-skipnot .lb-thead {
  color: var(--game-border-2);
  border-bottom-color: var(--game-border);
}
#screen-skipnot .leaderboard-panel.lb-skipnot .lb-row {
  border-bottom-color: var(--game-border);
}

.leaderboard-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.5;
}

.lb-heading {
  font-size: 1.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  margin-bottom: 6px;
  text-shadow: 0 0 18px rgba(233, 69, 96, 0.35);
}

.lb-heading span {
  color: var(--accent);
}

.lb-divider {
  height: 1px;
  background: linear-gradient(90deg, var(--accent), var(--bg3), transparent);
  margin-bottom: 18px;
  opacity: 0.6;
}

.lb-thead {
  display: grid;
  grid-template-columns: 30px 1fr 58px 50px;
  padding: 0 0 6px 0;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--bg3);
  border-bottom: 1px solid var(--bg3);
  margin-bottom: 2px;
}

.lb-row {
  display: grid;
  grid-template-columns: 30px 1fr 58px 50px;
  padding: 8px 0;
  font-size: 0.97rem;
  border-bottom: 1px solid rgba(15, 52, 96, 0.4);
  align-items: center;
  color: var(--muted);
}

.lb-row:last-child {
  border-bottom: none;
}

.lb-row-empty {
  opacity: 0.35;
}

/* SkipNoT score delta — flashes +13 / -7 next to the score on each answer.
   Cleared after RESULT_DISPLAY_MS by the SkipNoT client module. */
.skipnot-score-delta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  min-width: 0;
  transition: opacity 0.15s;
}
.skipnot-score-delta:empty {
  display: none;
}
.skipnot-score-delta {
  text-shadow: none;
}
.skipnot-score-delta.hit {
  color: var(--game-accent, #ffb000);
}
.skipnot-score-delta.miss {
  color: #ff4949;
}

.lb-rk {
  font-size: 0.78rem;
  color: var(--bg3);
  font-weight: 600;
}

.lb-row:nth-child(1) .lb-rk {
  color: #c9a227;
}
.lb-row:nth-child(2) .lb-rk {
  color: #888;
}
.lb-row:nth-child(3) .lb-rk {
  color: #7a4a2a;
}

.lb-row.new {
  color: var(--text);
  background: rgba(233, 69, 96, 0.06);
  margin: 0 -22px;
  padding: 8px 22px;
  border-left: 2px solid var(--accent);
  border-bottom: 1px solid rgba(233, 69, 96, 0.15);
}

.lb-row.new .lb-rk {
  color: var(--accent);
}

.lb-inp-wrap {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.lb-inp-wrap input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--accent);
  color: var(--text);
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.93rem;
  outline: none;
  padding: 1px 0;
  caret-color: var(--accent);
}

.lb-inp-wrap input::placeholder {
  color: #334;
}

.lb-inp-wrap button {
  width: auto;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.75rem;
  padding: 2px 8px;
  cursor: pointer;
  letter-spacing: 0.05em;
  border-radius: 3px;
  white-space: nowrap;
  transition:
    background 0.15s,
    color 0.15s;
}

.lb-inp-wrap button:hover {
  background: var(--accent);
  color: #fff;
}

.lb-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.lb-actions button {
  flex: 1;
  background: transparent;
  border: 1px solid var(--bg3);
  color: var(--muted);
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.75rem;
  padding: 8px 10px;
  cursor: pointer;
  letter-spacing: 0.05em;
  border-radius: 4px;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.lb-actions button.primary {
  border-color: var(--accent);
  color: var(--accent);
}

.lb-actions button:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ===== FOOTER ===== */
#site-footer {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  position: relative;
  z-index: 1;
}
#site-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
  cursor: pointer;
}
#site-footer a:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}
#site-footer .sep {
  margin: 0 0.5rem;
  opacity: 0.4;
}

/* ===== LEGAL MODALS ===== */
.legal-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.legal-modal.open {
  display: flex;
}
.legal-content {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 600px;
  width: 100%;
  max-height: 80svh;
  overflow-y: auto;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.7;
}
.legal-content h2 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 1.25rem;
  text-transform: uppercase;
}
.legal-content h3 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
  text-transform: uppercase;
  margin: 1rem 0 0.4rem;
}
.legal-content p {
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.legal-content ul {
  color: var(--muted);
  padding-left: 1.2rem;
  margin-bottom: 0.5rem;
}
.legal-content li {
  margin-bottom: 0.25rem;
}
.legal-close {
  display: block;
  margin-top: 1.5rem;
  width: 100%;
  background: transparent;
  border: 1px solid var(--bg3);
  color: var(--muted);
  font-family: 'Chakra Petch', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.75rem;
  padding: 8px;
  cursor: pointer;
  border-radius: 4px;
  letter-spacing: 0.05em;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.legal-close:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ===== QLASHIQUE ===== */
#screen-qlashique {
  position: fixed;
  inset: 0;
  background: var(--game-bg);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 12px;
  z-index: 20;
  overflow-y: auto;
  font-family: 'Martian Mono', monospace;
  color: var(--game-text);
  min-height: 75dvh;
}
#screen-qlashique h2.qlas-title {
  font-family: 'Martian Mono', monospace;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
  letter-spacing: 0.12em;
  color: var(--game-accent);
  text-shadow:
    0 0 30px var(--game-accent),
    0 0 60px rgba(var(--game-accent-rgb), 0.3);
  line-height: 1;
  margin-bottom: 4px;
}
.qlas-subtitle {
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--game-key);
  text-transform: uppercase;
  margin-bottom: 16px;
}
#screen-qlashique .qlas-inner {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
/* Shared game theme tokens — apply to all in-game screens (SkipNoT, Qlashique,
   Brawl). Default = amber. Switch by setting data-game-theme="green|cyan|pink"
   on <body>. Persisted in localStorage by the game-theme module. Tokens are
   only consumed inside game-screen selectors, so the landing page is unaffected. */
body {
  --game-bg: #1a0d02;
  --game-bg-2: #2a1605;
  --game-bg-3: #1a0d00;
  --game-border: #3a1f00;
  --game-border-2: #5a3300;
  --game-text: #ffd060;
  --game-accent: #ffb000;
  --game-accent-rgb: 255, 176, 0;
  --game-accent-2: #ff7a00;
  --game-key: #ffffff;
}
body[data-game-theme='green'] {
  --game-bg: #020c02;
  --game-bg-2: #071007;
  --game-bg-3: #041004;
  --game-border: #0d2e0d;
  --game-border-2: #1c4d1c;
  --game-text: #88ff88;
  --game-accent: #00ff41;
  --game-accent-rgb: 0, 255, 65;
  --game-accent-2: #00b8ff;
  --game-key: #ffe600;
}
body[data-game-theme='cyan'] {
  --game-bg: #02091a;
  --game-bg-2: #06112a;
  --game-bg-3: #040d20;
  --game-border: #1a2a52;
  --game-border-2: #2a4080;
  --game-text: #9ed8ff;
  --game-accent: #00f0ff;
  --game-accent-rgb: 0, 240, 255;
  --game-accent-2: #7c5cff;
  --game-key: #ff3df0;
}
body[data-game-theme='pink'] {
  --game-bg: #1a0218;
  --game-bg-2: #2a0a26;
  --game-bg-3: #1a081a;
  --game-border: #4a1840;
  --game-border-2: #6a2a5a;
  --game-text: #ffaee0;
  --game-accent: #ff3df0;
  --game-accent-rgb: 255, 61, 240;
  --game-accent-2: #ff7a00;
  --game-key: #ffffff;
}

#screen-skipnot {
  position: fixed;
  inset: 0;
  background: var(--game-bg);
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 4rem 0 0;
  gap: 12px;
  z-index: 20;
  overflow-y: auto;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--game-text);
}
#screen-skipnot .qlas-inner {
  width: 70vw;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* SkipNoT theme overrides — reskin shared qlas components via CSS vars.
   Qlashique (#screen-qlashique) zadržava zelenu phosphor paletu nepromijenjenu. */
#screen-skipnot .qlas-pbar {
  background: var(--game-bg-2);
}
#screen-skipnot .qlas-qpanel {
  background: var(--game-bg-2);
  border-color: var(--game-accent);
}
#screen-skipnot .qlas-pb-name {
  color: var(--game-text);
}
#screen-skipnot .qlas-hp-num {
  color: var(--game-accent);
}
#screen-skipnot .qlas-question {
  color: var(--game-text);
}
#screen-skipnot .qlas-options {
  border-top-color: var(--game-border-2);
}
#screen-skipnot .qlas-opt {
  background: var(--game-bg-3);
  color: var(--game-text);
}
#screen-skipnot .qlas-opt:hover:not(:disabled) {
  border-color: var(--game-accent-2);
  background: var(--game-bg-3);
}
#screen-skipnot .qlas-opt.correct {
  border-color: #00ff41 !important;
  background: rgba(0, 255, 65, 0.1) !important;
}
#screen-skipnot .qlas-opt-key {
  color: var(--game-key);
}
#screen-skipnot .btn-qlas-stop {
  background: var(--game-bg-3);
  border: 2px solid var(--game-border);
  color: var(--game-key);
}
#screen-skipnot .btn-qlas-stop:hover {
  border-color: var(--game-accent);
  color: var(--game-accent);
}
#screen-skipnot .qlas-go-head {
  color: var(--game-accent);
  text-shadow:
    0 0 18px rgba(255, 255, 255, 0.18),
    0 0 36px rgba(255, 255, 255, 0.08);
}
#screen-skipnot .qlas-go-stats {
  background: var(--game-bg-3);
  border-color: var(--game-border);
}
#screen-skipnot .qlas-go-row {
  border-bottom-color: var(--game-border-2);
}
#screen-skipnot .qlas-go-k {
  color: var(--game-text);
}
#screen-skipnot .qlas-go-v {
  color: var(--game-accent);
}
#screen-skipnot .qlas-btn--primary {
  background: var(--game-accent);
  color: #000;
}
#screen-skipnot .qlas-btn--ghost {
  border-color: var(--game-accent);
  color: var(--game-accent);
}
#screen-skipnot .qlas-btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}
#screen-skipnot #skipnot-name-input {
  background: var(--game-bg-3) !important;
  border-color: var(--game-accent) !important;
  color: var(--game-accent) !important;
}
#screen-skipnot .qlas-timer-ring .ring-progress {
  stroke: var(--game-accent);
  transition: stroke 0.2s;
}
#screen-skipnot .qlas-timer-ring .ring-track {
  stroke: var(--game-border);
}

/* Theme picker — 4 small color dots in top-right corner of game screen */
.game-theme-picker {
  position: absolute;
  top: 14px;
  right: 18px;
  display: flex;
  gap: 6px;
  z-index: 21;
}
.game-theme-picker .skp {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  background: var(--swatch, #ffb000);
  cursor: pointer;
  padding: 0;
  transition:
    transform 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}
.game-theme-picker .skp:hover {
  transform: scale(1.15);
  border-color: rgba(255, 255, 255, 0.5);
}
.game-theme-picker .skp.active {
  border-color: #fff;
  box-shadow: 0 0 8px var(--swatch, #ffb000);
}
.game-theme-picker .skp[data-theme='amber'] {
  --swatch: #ffb000;
}
.game-theme-picker .skp[data-theme='green'] {
  --swatch: #00ff41;
}
.game-theme-picker .skp[data-theme='cyan'] {
  --swatch: #00f0ff;
}
.game-theme-picker .skp[data-theme='pink'] {
  --swatch: #ff3df0;
}
#screen-skipnot .qlas-timer-ring .ring-label {
  color: #ffb000;
  transition: color 0.2s;
}
/* Color escalation: ring transitions amber → yellow (warn, ≤4s) → red (danger, ≤2s) */
#screen-skipnot .qlas-timer-ring.warn .ring-progress {
  stroke: #ffe600;
}
#screen-skipnot .qlas-timer-ring.warn .ring-label {
  color: var(--game-key);
}
#screen-skipnot .qlas-timer-ring.danger .ring-progress {
  stroke: #ff5555;
}
#screen-skipnot .qlas-timer-ring.danger .ring-label {
  color: #ff5555;
}
#screen-skipnot .qlas-timer-ring.danger {
  animation: skipnotRingPulse 0.5s ease-in-out infinite;
}
@keyframes skipnotRingPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

/* Progress dots — 20 across the top of the game phase */
.skipnot-progress {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0 4px;
}
.skipnot-progress .pdot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--game-bg-3, #1a0d00);
  border: 1px solid var(--game-border, #3a1f00);
  transition: all 0.2s;
}
.skipnot-progress .pdot.ok {
  background: var(--game-accent, #ffb000);
  border-color: var(--game-accent, #ffb000);
  box-shadow: 0 0 4px var(--game-accent, #ffb000);
}
.skipnot-progress .pdot.bad {
  background: #ff5555;
  border-color: #ff5555;
}
.skipnot-progress .pdot.skip {
  background: var(--game-border-2, #5a3300);
  border-color: var(--game-border-2, #5a3300);
}
.skipnot-progress .pdot.now {
  border-color: var(--game-accent-2, #ff7a00);
  box-shadow: 0 0 8px var(--game-accent-2, #ff7a00);
  animation: skipnotDotPulse 1.4s ease-in-out infinite;
}
@keyframes skipnotDotPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Streak indicator — appears at streak >= 3 */
.skipnot-streak {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--game-bg-3, #1a0d00);
  border-radius: 2px;
  border-left: 2px solid var(--game-accent-2, #ff7a00);
  font-family: 'IBM Plex Mono', monospace;
  flex-shrink: 0;
}
.skipnot-streak-icon {
  font-size: 1.3rem;
  filter: drop-shadow(0 0 4px var(--game-accent-2, #ff7a00));
}
.skipnot-streak-num {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--game-accent-2, #ff7a00);
  line-height: 1;
}
.skipnot-streak-lbl {
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  color: var(--game-text, #ffd060);
  opacity: 0.8;
}
.skipnot-streak.broke {
  animation: skipnotStreakBroke 0.4s ease-out;
}
@keyframes skipnotStreakBroke {
  0% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-4px);
  }
  40% {
    transform: translateX(4px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(2px);
  }
  100% {
    transform: translateX(0);
  }
}

/* Heatmap on game over — 5 cols x 4 rows */
.skipnot-heatmap-wrap {
  max-width: 480px;
  margin: 0 auto 1rem;
  padding: 12px 16px;
  background: var(--game-bg-3, #1a0d00);
  border: 1px solid var(--game-border, #3a1f00);
  border-radius: 2px;
}
.skipnot-heatmap-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  color: var(--game-text, #ffd060);
  opacity: 0.75;
  margin-bottom: 8px;
  text-align: left;
}
.skipnot-heatmap {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
}
.skipnot-heatmap .hcell {
  aspect-ratio: 1;
  border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--game-border, #3a1f00);
  color: transparent;
  animation: heatmapReveal 0.3s ease-out backwards;
  transition:
    transform 0.12s,
    box-shadow 0.12s;
  cursor: default;
  position: relative;
}
.skipnot-heatmap .hcell:hover {
  transform: scale(1.4);
  z-index: 2;
}
.skipnot-heatmap .hcell.ok:hover {
  box-shadow: 0 0 8px var(--game-accent, #ffb000);
}
.skipnot-heatmap .hcell.bad:hover {
  box-shadow: 0 0 8px #ff5555;
}
@keyframes heatmapReveal {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}
.skipnot-heatmap .hcell.ok {
  background: var(--game-accent, #ffb000);
  color: #000;
}
.skipnot-heatmap .hcell.bad {
  background: #ff5555;
  color: #000;
}
.skipnot-heatmap .hcell.skip {
  background: var(--game-border-2, #5a3300);
  color: var(--game-text, #ffd060);
}

/* Reduced motion — kill all skipnot animations */
@media (prefers-reduced-motion: reduce) {
  #screen-skipnot .qlas-timer-ring.danger {
    animation: none;
  }
  .skipnot-progress .pdot.now {
    animation: none;
  }
  .skipnot-streak.broke {
    animation: none;
  }
  .skipnot-heatmap .hcell {
    animation: none;
  }
}
/* Unified qlashique-style button. One base + two color variants
   (primary = filled, ghost = outline). Layout (width/flex/margin) is the
   caller's responsibility — keep it in markup or wrapper, not in here. */
.qlas-btn {
  border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.2rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.qlas-btn--primary {
  background: var(--game-accent);
  border: none;
  color: #000;
}
.qlas-btn--primary:hover:not(:disabled) {
  opacity: 0.85;
}
.qlas-btn--primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.qlas-btn--ghost {
  background: transparent;
  border: 2px solid var(--game-accent);
  color: var(--game-accent);
}
.qlas-btn--ghost:hover {
  background: rgba(var(--game-accent-rgb), 0.15);
}
/* Waiting */
.qlas-waiting {
  text-align: center;
  padding: 24px;
  background: var(--game-bg-2);
  border: 1px solid var(--game-border);
  border-radius: 2px;
}
.qlas-code-display {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 2.8rem;
  letter-spacing: 0.3em;
  color: var(--game-key);
  margin: 8px 0;
}
.qlas-waiting-msg {
  font-size: 0.7rem;
  color: var(--game-key);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
/* Player bars */
.qlas-pbar {
  flex: 1;
  background: var(--game-bg-2);
  border-radius: 2px;
  padding: 6px 7px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s;
}
.qlas-pbar::after {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--pc, transparent);
  border-radius: 2px 0 0 2px;
}
.qlas-pbar.active-turn {
  border-color: var(--pc);
  box-shadow:
    0 0 18px -6px var(--pc),
    inset 0 0 0 1px var(--pc);
}
.qlas-pb-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.qlas-pb-grid .qlas-hp-num {
  grid-column: 2;
  grid-row: span 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.qlas-pb-name {
  font-weight: 600;
  font-size: 0.9rem;
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 6px;
  min-width: 0;
}
.qlas-hp-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--pc, #00ff41);
  transition:
    width 0.5s,
    background 0.3s;
}
.qlas-hp-bar-fill.hp-low {
  background: linear-gradient(90deg, #ff8844, var(--pc, #00ff41));
}
.qlas-hp-bar-fill.hp-critical {
  background: #ff5555;
  animation: hpCriticalPulse 0.8s ease-in-out infinite;
}
@keyframes hpCriticalPulse {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 4px rgba(255, 85, 85, 0.3);
  }
  50% {
    opacity: 0.55;
    box-shadow: 0 0 12px rgba(255, 85, 85, 0.7);
  }
}
.qlas-hp-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 2.4rem;
  line-height: 1;
  color: var(--pc, #88ff88);
  transition: color 0.3s;
  text-shadow: 0 0 10px var(--pc);
}
.qlas-turn-score {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  color: var(--active-pc, #00ff41);
  margin-left: auto;
  padding-right: 20px;
  font-variant-numeric: tabular-nums;
  transition:
    color 0.2s,
    text-shadow 0.2s,
    transform 0.2s;
  display: inline-block;
}
.qlas-turn-score.combo-up {
  animation: qlas-score-pop 0.35s ease-out;
}
.qlas-turn-score.combo-2 {
  color: var(--game-key);
  text-shadow: 0 0 6px rgba(255, 230, 0, 0.5);
}
.qlas-turn-score.combo-5 {
  color: #ff9a3c;
  text-shadow: 0 0 10px rgba(255, 154, 60, 0.6);
  font-size: 1.55rem;
}
.qlas-turn-score.combo-8 {
  color: #ff5555;
  text-shadow:
    0 0 14px rgba(255, 85, 85, 0.75),
    0 0 3px #fff;
  font-size: 1.7rem;
  animation: qlas-combo-pulse 0.8s ease-in-out infinite;
}
@keyframes qlas-score-pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}
@keyframes qlas-combo-pulse {
  0%,
  100% {
    text-shadow:
      0 0 14px rgba(255, 85, 85, 0.75),
      0 0 3px #fff;
  }
  50% {
    text-shadow:
      0 0 22px rgba(255, 85, 85, 1),
      0 0 6px #fff;
  }
}
/* Combat two-column layout */
.qlas-combat-layout {
  display: grid;
  grid-template-columns: 175px 1fr;
  gap: 12px;
  align-items: start;
}
.qlas-col-game {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
/* Question panel */
.qlas-qpanel {
  background: var(--game-bg-2);
  border: 2px solid var(--game-accent);
  border-radius: 2px;
  padding: 18px 20px;
}
.qlas-question {
  font-size: 0.96rem;
  line-height: 1.65;
  margin-bottom: 10px;
  color: var(--game-text);
  font-family: 'IBM Plex Mono', monospace;
}
.qlas-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 2px solid rgb(57 173 87);
}
.qlas-opt {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--game-bg-3);
  border: 1.5px solid transparent;
  border-radius: 2px;
  color: var(--game-text);
  font-size: 0.86rem;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-family: 'IBM Plex Mono', monospace;
  width: 100%;
}
.qlas-opt:hover:not(:disabled) {
  border-color: var(--game-accent-2);
  background: #030803;
}
.qlas-opt.correct {
  border-color: #00ff41 !important;
  background: rgba(var(--game-accent-rgb), 0.15) !important;
}
.qlas-opt.wrong {
  border-color: #ff5555 !important;
  background: rgba(255, 85, 85, 0.15) !important;
}
.qlas-opt:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}
.qlas-opt-key {
  font-size: 0.72rem;
  opacity: 0.75;
  flex-shrink: 0;
  width: 28px;
  font-weight: 500;
  color: var(--game-key);
  letter-spacing: 0.04em;
}
.qlas-opt-key::before {
  content: '[';
}
.qlas-opt-key::after {
  content: ']';
}
/* Action row */
.qlas-action-row {
  display: flex;
  gap: 8px;
  min-height: 50px;
  align-items: stretch;
}
.btn-qlas-end {
  flex: 2;
  background: var(--game-bg-3);
  border: 2px solid var(--game-border);
  border-radius: 2px;
  color: var(--game-key);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-qlas-end:hover:not(:disabled) {
  border-color: var(--game-text);
  color: var(--game-text);
}
.btn-qlas-end:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.btn-qlas-stop {
  flex: 2;
  background: rgba(var(--game-accent-rgb), 0.15);
  border: 2px solid var(--game-accent);
  border-radius: 2px;
  color: var(--game-accent);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-qlas-stop:hover:not(:disabled) {
  background: rgba(var(--game-accent-rgb), 0.28);
  box-shadow: 0 0 12px -4px var(--game-accent);
}
.btn-qlas-stop:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.btn-qlas-heal {
  flex: 1;
  padding: 12px 14px;
  background: rgba(var(--game-accent-rgb), 0.12);
  border: 2px solid rgba(var(--game-accent-rgb), 0.35);
  border-radius: 2px;
  color: var(--game-accent);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.05rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn-qlas-heal:hover:not(:disabled) {
  background: rgba(var(--game-accent-rgb), 0.22);
  border-color: var(--game-accent);
}
.btn-qlas-heal:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.qlas-heal-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.68rem;
  background: rgba(var(--game-accent-rgb), 0.2);
  border: 1px solid rgba(var(--game-accent-rgb), 0.3);
  padding: 2px 6px;
  border-radius: 2px;
}
/* Gameover */
.qlas-gameover {
  text-align: center;
  padding: 40px 20px;
}
.qlas-gameover h1.qlas-go-head {
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(1.4rem, 3.5vw, 1.9rem);
  color: var(--game-accent);
  letter-spacing: 0.14em;
  text-shadow:
    0 0 18px rgba(var(--game-accent-rgb), 0.55),
    0 0 36px rgba(var(--game-accent-rgb), 0.22);
  margin-bottom: 22px;
  text-align: center;
}
.qlas-go-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 22px;
  margin: 0 auto 24px;
  max-width: 420px;
  background: var(--game-bg-2);
  border: 1px solid var(--game-border);
  border-radius: 2px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.95rem;
  text-align: left;
}
.qlas-go-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px dashed rgba(var(--game-accent-rgb), 0.15);
  padding-bottom: 6px;
}
.qlas-go-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.qlas-go-k {
  color: var(--game-text);
  opacity: 0.75;
  font-weight: 500;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  text-transform: uppercase;
}
/* Flash animations */
@keyframes qlasDmg {
  0% {
    background: rgba(255, 85, 85, 0);
  }
  20% {
    background: rgba(255, 85, 85, 0.22);
  }
  100% {
    background: transparent;
  }
}
@keyframes qlasHeal {
  0% {
    background: rgba(var(--game-accent-rgb), 0);
  }
  20% {
    background: rgba(var(--game-accent-rgb), 0.2);
  }
  100% {
    background: transparent;
  }
}
.qlas-take-dmg {
  animation: qlasDmg 0.6s ease-out;
}
.qlas-take-heal {
  animation: qlasHeal 0.6s ease-out;
}

/* Screen shake on damage */
@keyframes qlasScreenShake {
  0%,
  100% {
    transform: translate(0);
  }
  15% {
    transform: translate(-4px, 2px);
  }
  30% {
    transform: translate(3px, -3px);
  }
  45% {
    transform: translate(-2px, 1px);
  }
  60% {
    transform: translate(2px, -1px);
  }
  75% {
    transform: translate(-1px, 2px);
  }
}
.qlas-combat-layout.screen-shake {
  animation: qlasScreenShake 0.3s ease-out;
}

/* Floating damage / heal numbers above pbar (added by JS, removed after anim) */
.qlas-floating-host {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.qlas-floating-num {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  pointer-events: none;
  animation: qlasFloat 1.2s ease-out forwards;
  text-shadow: 0 0 12px currentColor;
}
.qlas-floating-num.dmg {
  color: #ff5555;
}
.qlas-floating-num.heal {
  color: #4ade80;
}
@keyframes qlasFloat {
  0% {
    opacity: 0;
    transform: translateY(-50%);
  }
  20% {
    opacity: 1;
    transform: translateY(calc(-50% - 10px));
  }
  100% {
    opacity: 0;
    transform: translateY(calc(-50% - 36px));
  }
}

/* Score delta micro-flash next to running score */
.qlas-turn-score {
  position: relative;
}
.qlas-score-mini {
  position: absolute;
  left: 100%;
  top: 0;
  margin-left: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
  animation: qlasFloat 0.9s ease-out forwards;
  white-space: nowrap;
}
.qlas-score-mini.up {
  color: #4ade80;
}
.qlas-score-mini.down {
  color: #ff5555;
}

/* Turn history dots — single row, color by outcome */
.qlas-history-dots {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
  padding: 6px 2px 0;
  min-height: 14px;
}
.qlas-history-dots .hd {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1a2a1a;
  border: 1px solid #244524;
  flex-shrink: 0;
}
.qlas-history-dots .hd.win {
  background: #4ade80;
  border-color: #4ade80;
}
.qlas-history-dots .hd.loss {
  background: #ff5555;
  border-color: #ff5555;
}
.qlas-history-dots .hd.zero {
  background: #5a5a5a;
  border-color: #5a5a5a;
}

/* Opponent thinking indicator next to active player's name */
.qlas-thinking {
  display: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.12em;
  margin-left: 8px;
  text-transform: uppercase;
}
.qlas-thinking.active {
  display: inline;
}
.qlas-thinking .dots {
  display: inline-block;
  animation: qlasThinkDots 1.2s steps(4) infinite;
  width: 1ch;
  overflow: hidden;
  vertical-align: bottom;
}
@keyframes qlasThinkDots {
  0% {
    width: 0;
  }
  100% {
    width: 1ch;
  }
}

/* Streak fire badge inside player name row */
.qlas-streak-badge {
  display: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 700;
  margin-left: 8px;
  letter-spacing: 0.04em;
  color: #ff7a00;
}
.qlas-streak-badge.show {
  display: inline;
}
/* Streak visual intensity on player bar */
.qlas-pbar.streak-high {
  box-shadow:
    0 0 18px -4px var(--pc),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  transition:
    border-color 0.3s,
    box-shadow 0.3s;
}
.qlas-streak-badge .flame {
  font-size: 0.95rem;
  margin-right: 2px;
  filter: drop-shadow(0 0 4px rgba(255, 122, 0, 0.6));
}

@media (prefers-reduced-motion: reduce) {
  .qlas-floating-num,
  .qlas-score-mini {
    animation: none;
    opacity: 0;
  }
  .qlas-thinking .dots {
    animation: none;
    width: 1ch;
  }
  .qlas-combat-layout.screen-shake {
    animation: none;
  }
  .qlas-hp-bar-fill.hp-critical {
    animation: none;
  }
}
/* Qlashique buttons in right column */
.btn-qlashique {
  width: 100%;
  background: rgba(var(--game-accent-rgb), 0.1);
  border: 1px solid rgba(var(--game-accent-rgb), 0.4);
  color: var(--game-accent);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.1rem;
}
.btn-qlashique:hover {
  background: rgba(var(--game-accent-rgb), 0.2);
  border-color: var(--game-accent);
}
/* SkipNoT amber variant — leaderboard toggle on landing.
   (Start button is now a .mode-card with its own styling below.) */
#btn-show-skipnot-lb.btn-qlashique {
  background: rgba(255, 176, 0, 0.06);
  border: 1px solid rgba(255, 176, 0, 0.3);
  border-radius: 8px;
  color: var(--amber);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
}
#btn-show-skipnot-lb.btn-qlashique:hover {
  background: rgba(255, 176, 0, 0.12);
  border-color: var(--amber);
}

/* Join buttons — color-match the mode cards above
   (Brawl=green, Qlashique=yellow) */
#btn-join {
  background: rgba(var(--game-accent-rgb), 0.12);
  border: 1px solid rgba(var(--game-accent-rgb), 0.5);
  color: var(--game-accent);
}
#btn-join:hover {
  background: rgba(var(--game-accent-rgb), 0.22);
  border-color: var(--game-accent);
}
#btn-qlas-start.btn-qlashique {
  background: rgba(255, 230, 0, 0.1);
  border-color: rgba(255, 230, 0, 0.5);
  color: var(--game-key);
}
#btn-qlas-start.btn-qlashique:hover {
  background: rgba(255, 230, 0, 0.22);
  border-color: var(--game-key);
}

/* Mode cards — 3 visual cards (Brawl / Qlashique / SkipNoT) on the home page */
/* ===== MODE CARDS — concept dashboard card grid ===== */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.mode-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 22px 22px;
  height: auto;
  min-height: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(22, 22, 37, 0.5);
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  text-align: left;
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.28s ease,
    box-shadow 0.28s ease;
  width: 100%;
  margin: 0;
  position: relative;
  overflow: hidden;
}
.mode-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
}
.mode-card:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.6);
}
.mode-card .mode-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.mode-card .mode-icon svg {
  width: 100%;
  height: 100%;
}
.mode-card .mode-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.mode-card .mode-name {
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
}
.mode-card .mode-desc {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.76rem;
  color: var(--muted);
  letter-spacing: 0.01em;
  line-height: 1.65;
}
/* Entrance animations */
.mode-card,
.mode-card-wrap--brawl,
.mode-card-wrap--qlas,
.mode-card-wrap--howhigh {
  animation: cardIn 0.4s ease-out backwards;
}
.mode-cards > :nth-child(1) {
  animation-delay: 0.05s;
}
.mode-cards > :nth-child(2) {
  animation-delay: 0.1s;
}
.mode-cards > :nth-child(3) {
  animation-delay: 0.15s;
}
.mode-cards > :nth-child(4) {
  animation-delay: 0.2s;
}
@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mode-card--brawl {
  color: var(--green);
}
.mode-card--brawl .mode-name {
  color: var(--green);
}
.mode-card--brawl::before {
  background: linear-gradient(90deg, var(--green), transparent);
}
.mode-card--brawl:hover {
  border-color: rgba(0, 255, 65, 0.3);
  box-shadow:
    0 12px 36px -8px rgba(0, 255, 65, 0.15),
    0 0 0 1px rgba(0, 255, 65, 0.06);
}
.mode-card--qlas {
  color: var(--yellow);
}
.mode-card--qlas .mode-name {
  color: var(--yellow);
}
.mode-card--qlas:hover {
}
.mode-card-wrap--qlas {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(22, 22, 37, 0.5);
  overflow: hidden;
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.28s ease,
    box-shadow 0.28s ease;
  position: relative;
}
.mode-card-wrap--qlas::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, var(--yellow), transparent);
  z-index: 1;
}
.mode-card-wrap--qlas:hover {
  border-color: rgba(255, 230, 0, 0.3);
  transform: translateY(-3px);
  box-shadow:
    0 12px 36px -8px rgba(255, 230, 0, 0.12),
    0 0 0 1px rgba(255, 230, 0, 0.06);
}
.mode-card-wrap--qlas .mode-card--qlas:hover {
  transform: none;
  box-shadow: none;
}
.mode-card-wrap--qlas .mode-card--qlas {
  border: none;
  border-radius: 0;
  background: transparent;
}
.mode-card-wrap--qlas .mode-card--qlas::before {
  display: none;
}
.qlas-hp-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 18px 8px;
  background: transparent;
  border-top: 1px solid rgba(255, 230, 0, 0.15);
}
.qlas-hp-label {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin-right: 2px;
}
.qlas-hp-opt {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  width: auto;
  height: auto;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid rgba(255, 230, 0, 0.25);
  background: transparent;
  color: rgba(255, 230, 0, 0.6);
  cursor: pointer;
  font-weight: 500;
  transition:
    border-color 0.12s,
    color 0.12s,
    background 0.12s;
}
.qlas-hp-opt:hover {
  border-color: rgba(255, 230, 0, 0.5);
  color: var(--yellow);
  opacity: 1;
}
.qlas-hp-opt.selected {
  border-color: var(--yellow);
  color: var(--yellow);
  background: rgba(255, 230, 0, 0.1);
}
.mode-card--skipnot {
  color: var(--amber);
}
.mode-card--skipnot .mode-name {
  color: var(--amber);
}
.mode-card--skipnot::before {
  background: linear-gradient(90deg, var(--amber), transparent);
}
.mode-card--skipnot:hover {
  border-color: rgba(255, 176, 0, 0.3);
  box-shadow:
    0 12px 36px -8px rgba(255, 176, 0, 0.15),
    0 0 0 1px rgba(255, 176, 0, 0.06);
}
.mode-card--howhigh {
  color: #e040fb;
}
.mode-card--howhigh .mode-name {
  color: #e040fb;
}
.mode-card--howhigh::before {
  background: linear-gradient(90deg, #e040fb, transparent);
}
.mode-card--howhigh:hover {
  border-color: rgba(224, 64, 251, 0.3);
  box-shadow:
    0 12px 36px -8px rgba(224, 64, 251, 0.15),
    0 0 0 1px rgba(224, 64, 251, 0.06);
}
/* --- Card-inline join rows (inside each mode-card-wrap) --- */
.card-join-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: stretch;
  padding: 6px 18px 10px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}
.card-join-input {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
  border-radius: 5px;
  outline: none;
  margin: 0;
  height: auto;
}
.card-join-input:focus {
  border-color: var(--cyan);
}
.card-join-input::placeholder {
  color: var(--muted);
  letter-spacing: 0.15em;
  font-size: 0.72rem;
}
.card-join-go {
  padding: 6px 0;
  width: 56px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 5px;
  height: auto;
  transition: all 0.15s;
  white-space: nowrap;
}
.card-join-row--brawl .card-join-input:focus {
  border-color: var(--green);
}
.card-join-row--brawl .card-join-go {
  border-color: rgba(0, 255, 65, 0.3);
  color: var(--green);
  background: rgba(0, 255, 65, 0.06);
}
.card-join-row--brawl .card-join-go:hover {
  background: rgba(0, 255, 65, 0.15);
  border-color: var(--green);
}
.card-join-row--qlas .card-join-input:focus {
  border-color: var(--yellow);
}
.card-join-row--qlas .card-join-go {
  border-color: rgba(255, 230, 0, 0.3);
  color: var(--yellow);
  background: rgba(255, 230, 0, 0.06);
}
.card-join-row--qlas .card-join-go:hover {
  background: rgba(255, 230, 0, 0.15);
  border-color: var(--yellow);
}
.card-join-row--howhigh .card-join-input:focus {
  border-color: #e040fb;
}
.card-join-row--howhigh .card-join-go {
  border-color: rgba(224, 64, 251, 0.3);
  color: #e040fb;
  background: rgba(224, 64, 251, 0.06);
}
.card-join-row--howhigh .card-join-go:hover {
  background: rgba(224, 64, 251, 0.15);
  border-color: #e040fb;
}
/* --- mode-card-wrap shared (Brawl + HowHigh, Qlas already defined) --- */
.mode-card-wrap--brawl,
.mode-card-wrap--howhigh {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(22, 22, 37, 0.5);
  overflow: hidden;
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.28s ease,
    box-shadow 0.28s ease;
  position: relative;
}
.mode-card-wrap--brawl::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, var(--green), transparent);
  z-index: 1;
}
.mode-card-wrap--brawl:hover {
  border-color: rgba(0, 255, 65, 0.3);
  transform: translateY(-3px);
  box-shadow:
    0 12px 36px -8px rgba(0, 255, 65, 0.15),
    0 0 0 1px rgba(0, 255, 65, 0.06);
}
.mode-card-wrap--brawl .mode-card--brawl {
  border: none;
  border-radius: 0;
  background: transparent;
}
.mode-card-wrap--brawl .mode-card--brawl::before {
  display: none;
}
.mode-card-wrap--brawl .mode-card--brawl:hover {
  transform: none;
  box-shadow: none;
}
.mode-card-wrap--howhigh::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, #e040fb, transparent);
  z-index: 1;
}
.mode-card-wrap--howhigh:hover {
  border-color: rgba(224, 64, 251, 0.3);
  transform: translateY(-3px);
  box-shadow:
    0 12px 36px -8px rgba(224, 64, 251, 0.15),
    0 0 0 1px rgba(224, 64, 251, 0.06);
}
.mode-card-wrap--howhigh .mode-card--howhigh {
  border: none;
  border-radius: 0;
  background: transparent;
}
.mode-card-wrap--howhigh .mode-card--howhigh::before {
  display: none;
}
.mode-card-wrap--howhigh .mode-card--howhigh:hover {
  transform: none;
  box-shadow: none;
}
/* Join card — legacy, hidden — kept for potential reuse */
.mode-join-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition:
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    border-color 0.28s ease,
    box-shadow 0.28s ease;
  position: relative;
  overflow: hidden;
}
.mode-join-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, var(--cyan), transparent);
}
.mode-join-card:hover {
  border-color: rgba(0, 240, 255, 0.3);
  box-shadow:
    0 12px 36px -8px rgba(0, 240, 255, 0.12),
    0 0 0 1px rgba(0, 240, 255, 0.06);
}
.mode-join-card .join-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1.06rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--cyan);
}
.mode-join-card .join-desc {
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.65;
  letter-spacing: 0.01em;
}
.mode-join-card .join-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.mode-join-card .join-input {
  flex: 1;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
  border-radius: 6px;
  outline: none;
  margin: 0;
  height: auto;
}
.mode-join-card .join-input:focus {
  border-color: var(--cyan);
}
.mode-join-card .join-input::placeholder {
  color: var(--muted);
  letter-spacing: 0.15em;
  font-size: 0.8rem;
}
.mode-join-card .join-go {
  padding: 8px 14px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.4);
  color: var(--cyan);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  border-radius: 6px;
  width: auto;
  height: auto;
  transition: all 0.15s;
  white-space: nowrap;
}
.mode-join-card .join-go:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--cyan);
}
#btn-howhigh-join {
  background: rgba(224, 64, 251, 0.1);
  border-color: rgba(224, 64, 251, 0.4);
  color: #e040fb;
}
#btn-howhigh-join:hover {
  background: rgba(224, 64, 251, 0.2);
  border-color: #e040fb;
}
@media (max-width: 520px) {
  .mode-cards {
    grid-template-columns: 1fr;
  }
}
.btn-show-triv-lb {
  width: 100%;
  padding: 0.45rem;
  margin-bottom: 0.6rem;
  background: transparent;
  border: 1px solid #2a4a7a;
  color: #6b8ab4;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  transition:
    border-color 0.15s,
    color 0.15s;
}
.btn-show-triv-lb:hover {
  border-color: #3d6aaf;
  color: #8aaad4;
}
@media (max-width: 600px) {
  .qlas-combat-layout {
    grid-template-columns: 1fr;
  }
}

/* Small phones (iPhone 13 / SE etc) — keep board chrome and qlashique combat above the fold */
@media (max-width: 480px) {
  /* Tight on small screens — give content ~25px back from each side */
  .card {
    padding: 1.25rem;
  }

  /* Board top bar — without this, #turn-panel renders ~498px wide in a 390px viewport
     and the username, "TURN" label, and player stats clip off the right edge. */
  #turn-panel {
    font-size: 13px;
    min-height: 48px;
  }
  #turn-player-box {
    padding: 6px 10px;
    min-width: 0;
  }
  #turn-player-name {
    font-size: 15px;
    min-width: 0;
  }
  #turn-moves {
    font-size: 11px;
    padding-left: 8px;
  }
  #turn-info {
    padding: 6px 8px;
  }
  #turn-number {
    font-size: 15px;
    letter-spacing: 1px;
  }
  #player-stats {
    padding: 6px 10px;
    font-size: 11px;
    gap: 2px;
  }
  .player-stat-item {
    gap: 5px;
  }
  .player-stat-ratio {
    font-size: 13px;
  }
  .player-stat-pct {
    font-size: 11px;
  }

  /* Qlashique combat — shrink decorative chrome so the question + all 4 options fit. */
  #screen-qlashique .qlas-inner {
    max-width: 100%;
  }
  #screen-qlashique h2.qlas-title {
    font-size: 1.4rem;
    margin-bottom: 2px;
  }
  .qlas-subtitle {
    font-size: 0.55rem;
    margin-bottom: 6px;
  }
  .qlas-pbar {
    padding: 6px 10px;
  }
  .qlas-pb-grid {
    margin-bottom: 3px;
  }
  .qlas-pb-name {
    font-size: 0.9rem;
  }
  .qlas-hp-num {
    font-size: 1.5rem;
  }
  .qlas-timer-ring {
    width: 44px;
    height: 44px;
  }
  .qlas-timer-ring .ring-label {
    font-size: 0.7rem;
  }
  .qlas-qpanel {
    padding: 10px 12px;
  }
  .qlas-question {
    font-size: 0.85rem;
    line-height: 1.45;
    margin-bottom: 8px;
  }

  /* Bump tap targets to ~44px (Apple HIG) */
  .qlas-opt {
    min-height: 44px;
    padding: 8px 12px;
  }
  .qlas-btn,
  .btn-qlas-stop,
  .btn-qlas-end,
  .btn-qlas-heal {
    min-height: 44px;
  }
}

/* Stats Modal */
#stats-modal-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}
#stats-modal-overlay.visible #stats-modal {
  transform: scale(1);
}

/* Qlashique timer ring */
.qlas-timer-ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex: none;
}
.qlas-timer-ring svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}
.qlas-timer-ring circle {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
}
.qlas-timer-ring .ring-track {
  stroke: var(--game-border);
}
.qlas-timer-ring .ring-progress {
  stroke: var(--game-accent);
  transition:
    stroke-dashoffset 0.1s linear,
    stroke 0.2s ease;
}
.qlas-timer-ring.warn .ring-progress {
  stroke: #ffff00;
}
.qlas-timer-ring.danger .ring-progress {
  stroke: #ff5555;
  animation: qlas-timer-pulse 0.6s ease-in-out infinite;
}
.qlas-timer-ring .ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--game-text);
}
.qlas-timer-ring.warn .ring-label {
  color: #ffff00;
}
.qlas-timer-ring.danger .ring-label {
  color: #ff5555;
}
@keyframes qlas-timer-pulse {
  0%,
  100% {
    filter: drop-shadow(0 0 2px #ff5555);
  }
  50% {
    filter: drop-shadow(0 0 8px #ff5555);
  }
}

/* Qlashique recap */
.qlas-recap {
  margin-top: 1.5rem;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.4rem;
}
.qlas-recap-empty {
  color: #556;
  font-size: 0.8rem;
  text-align: center;
  padding: 1rem;
}
.qlas-recap-card {
  background: var(--game-bg-3);
  border: 1px solid var(--game-border);
  border-radius: 2px;
  padding: 0.6rem 0.8rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  color: var(--game-text);
  text-align: left;
}
.qlas-recap-card.p0 {
  border-color: var(--game-accent);
}
.qlas-recap-card.p1 {
  border-color: var(--game-accent-2);
}
.qlas-recap-card.wrong {
  border-style: dashed;
}
.qlas-recap-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: #556;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.qlas-recap-turn {
  color: var(--game-text);
}
.qlas-recap-p0 {
  color: var(--game-accent);
}
.qlas-recap-p1 {
  color: var(--game-accent-2);
}
.qlas-recap-entry + .qlas-recap-entry {
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--game-border);
}
.qlas-recap-q {
  color: #aaffaa;
  margin-bottom: 0.4rem;
  line-height: 1.3;
}
.qlas-recap-cat {
  color: #556;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  margin-right: 0.3rem;
}
.qlas-recap-ans {
  display: flex;
  gap: 0.5rem;
  font-size: 0.76rem;
}
.qlas-recap-ans .ok {
  color: var(--game-accent);
}
.qlas-recap-ans .bad {
  color: #ff5555;
}
.qlas-recap-score {
  float: right;
  font-weight: 600;
  color: var(--game-key);
}
.qlas-recap-toggle {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--game-border);
  color: var(--game-text);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
  cursor: pointer;
}
.qlas-recap-toggle:hover {
  border-color: var(--game-accent);
  color: var(--game-accent);
}
.qlas-recap-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.qlas-recap-modal.show {
  display: flex;
}
.qlas-recap-modal-body {
  background: #0a0a0a;
  border: 1px solid var(--game-accent);
  padding: 1rem;
  max-width: 720px;
  width: calc(100% - 2rem);
  max-height: calc(100vh - 2rem);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.qlas-recap-modal-head {
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--game-accent);
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--game-border);
  padding-bottom: 0.4rem;
}
.qlas-recap-modal-close {
  background: transparent;
  border: 1px solid var(--game-border);
  color: var(--game-text);
  padding: 0.2rem 0.6rem;
  font-family: inherit;
  cursor: pointer;
}
.qlas-recap-modal-close:hover {
  border-color: var(--game-accent);
  color: var(--game-accent);
}

/* ===== TERMINAL QUERY META (#9) ===== */
.qlas-q-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px dashed rgba(var(--game-accent-rgb), 0.25);
  padding-bottom: 6px;
  margin-bottom: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.qlas-q-tag {
  color: #5ebb52;
  font-weight: 600;
}
.qlas-q-cat {
  color: var(--game-key);
  opacity: 0.72;
  font-weight: 500;
}
.qlas-q-text {
  font-size: 1.05rem;
  line-height: 1.4;
}

/* ===== ANSWER FLASH BANNER (#11) ===== */
.qlas-flash {
  display: none;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 10px;
  margin-bottom: 8px;
  border-left: 3px solid transparent;
  background: rgba(0, 0, 0, 0.35);
  font-weight: 600;
}
.qlas-flash.show {
  display: block;
  animation: qlas-flash-in 220ms ease-out;
}
.qlas-flash.hit {
  color: var(--game-accent);
  border-left-color: var(--game-accent);
  text-shadow: 0 0 8px rgba(var(--game-accent-rgb), 0.55);
}
.qlas-flash.miss {
  color: #ff5577;
  border-left-color: #ff5577;
  text-shadow: 0 0 8px rgba(255, 85, 119, 0.5);
}
@keyframes qlas-flash-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ===== COMBO LOG (#6) ===== */
.qlas-log {
  position: absolute;
  top: 72px;
  right: 14px;
  width: 220px;
  max-width: 42vw;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30;
  pointer-events: none;
}
.qlas-log-entry {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 5px 9px;
  background: rgba(0, 0, 0, 0.55);
  border-left: 2px solid var(--game-key);
  color: var(--game-key);
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: qlas-log-fade 2.5s ease-out forwards;
}
@keyframes qlas-log-fade {
  0% {
    opacity: 0;
    transform: translateX(12px);
  }
  10% {
    opacity: 1;
    transform: none;
  }
  85% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(12px);
  }
}
@media (max-width: 600px) {
  .qlas-log {
    top: 64px;
    right: 8px;
    width: 170px;
  }
  .qlas-log-entry {
    font-size: 0.62rem;
    padding: 4px 7px;
  }
}

/* ===== QLASHIQUE CONCEPT B — CENTERED ARENA ===== */

#screen-qlashique .qlas-combat-layout {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  max-width: 560px;
  width: 100%;
}

/* Force Martian Mono on all qlashique children that inherit IBM Plex from shared rules */
#screen-qlashique .qlas-opt,
#screen-qlashique .qlas-question,
#screen-qlashique .qlas-flash,
#screen-qlashique .qlas-log-entry,
#screen-qlashique .qlas-floating-num,
#screen-qlashique .qlas-thinking,
#screen-qlashique .qlas-streak-badge,
#screen-qlashique .qlas-score-mini,
#screen-qlashique .qlas-code-display,
#screen-qlashique .qlas-go-stats,
#screen-qlashique .qlas-gameover h1,
#screen-qlashique .qlas-btn,
#screen-qlashique .btn-qlas-end,
#screen-qlashique .btn-qlas-stop,
#screen-qlashique .btn-qlas-heal,
#screen-qlashique .qlas-heal-val,
#screen-qlashique .qlas-opt-key,
#screen-qlashique .qlas-timer-ring .ring-label,
#screen-qlashique .qlas-recap-card,
#screen-qlashique .qlas-recap-modal-head,
#screen-qlashique .qlas-recap-toggle,
#screen-qlashique .qlas-recap-modal-close,
#screen-qlashique .qlas-hp-opt,
#screen-qlashique .btn-qlashique {
  font-family: 'Martian Mono', monospace;
}

/* VS Header — P1 | VS | P2 */
.qlb-vs-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  align-items: stretch;
  margin-bottom: 10px;
}
.qlb-player {
  background: var(--game-bg-2);
  padding: 8px 16px;
  position: relative;
  overflow: hidden;
}
.qlb-player--left {
  border-radius: 6px 0 0 6px;
  border: 1px solid var(--game-border);
  border-right: none;
}
.qlb-player--right {
  border-radius: 0 6px 6px 0;
  border: 1px solid var(--game-border);
  border-left: none;
  text-align: right;
}
.qlb-player.active-turn {
  border-color: var(--pc);
  box-shadow: inset 0 0 20px -8px var(--pc);
}
.qlb-name {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.qlb-player--left .qlb-name {
  color: var(--game-accent);
}
.qlb-player--right .qlb-name {
  color: var(--game-accent-2);
  justify-content: flex-end;
}
.qlb-hp {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 0 14px currentColor;
  margin-bottom: 6px;
  color: var(--pc);
}
.qlb-hpbar-bg {
  height: 5px;
  background: #030803;
  border-radius: 3px;
  overflow: hidden;
}
.qlb-hpbar-bg .qlas-hp-bar-fill {
  background: var(--pc, var(--game-accent));
}
.qlb-divider {
  background: var(--game-bg-3);
  border-top: 1px solid var(--game-border);
  border-bottom: 1px solid var(--game-border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  min-width: 44px;
}
.qlb-vs-text {
  font-family: 'Martian Mono', monospace;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--game-accent);
  text-shadow: 0 0 8px rgba(var(--game-accent-rgb), 0.5);
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* Turn strip */
.qlb-turn-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--game-bg-2);
  border: 1px solid var(--game-border);
  border-radius: 4px;
  padding: 6px 12px;
  margin-bottom: 10px;
}
.qlb-turn-label {
  font-size: 0.72rem;
  color: var(--active-pc, var(--game-accent));
  font-weight: 600;
  letter-spacing: 0.08em;
}
#screen-qlashique .qlas-turn-score {
  font-size: 1.3rem;
  color: var(--active-pc, var(--game-accent));
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding-right: 12px;
}
#screen-qlashique .qlas-history-dots {
  padding: 0;
}
#screen-qlashique .qlas-timer-ring {
  width: 48px;
  height: 48px;
}

/* Log: fixed overlay in concept B (no two-column parent) */
#screen-qlashique .qlas-log {
  position: fixed;
  top: 50px;
  right: 14px;
}

/* Streak badge sizing in concept B */
#screen-qlashique .qlas-streak-badge {
  font-size: 0.72rem;
}

/* Recap button */
.qlb-recap-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--game-border);
  color: var(--game-text);
  font-family: 'Martian Mono', monospace;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  text-align: center;
}
.qlb-recap-btn:hover {
  border-color: var(--game-accent);
  color: var(--game-accent);
}

/* Theme picker dropdown */
.qlb-theme-picker {
  position: absolute;
  top: 12px;
  right: 14px;
  z-index: 50;
}
.qlb-theme-picker select {
  background: rgba(0, 0, 0, 0.6);
  color: #ccc;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 5px 8px;
  font-family: 'Martian Mono', monospace;
  font-size: 0.65rem;
  cursor: pointer;
  outline: none;
}
.qlb-theme-picker select:hover {
  border-color: #666;
}
.qlb-theme-picker select:focus {
  border-color: #888;
}

/* Concept B mobile */
@media (max-width: 480px) {
  .qlb-hp {
    font-size: 1.8rem;
  }
  .qlb-player {
    padding: 8px 12px;
  }
  .qlb-theme-picker {
    top: auto;
    bottom: 12px;
    right: 10px;
  }
}

/* ==========================================================================
   HowHigh? game screen
   ========================================================================== */
#screen-howhigh {
  position: fixed;
  inset: 0;
  background: var(--game-bg);
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 4rem 0 0;
  gap: 12px;
  z-index: 20;
  overflow-y: auto;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--game-text);
}
#screen-howhigh .qlas-inner {
  width: 70vw;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#screen-howhigh .qlas-pbar {
  background: var(--game-bg-2);
}
#screen-howhigh .qlas-qpanel {
  background: var(--game-bg-2);
  border-color: var(--game-accent);
}
#screen-howhigh .qlas-pb-name {
  color: var(--game-text);
}
#screen-howhigh .qlas-hp-num {
  color: var(--game-accent);
}
#screen-howhigh .qlas-question {
  color: var(--game-text);
}
#screen-howhigh .qlas-options {
  border-top-color: var(--game-border);
}
#screen-howhigh .qlas-opt {
  background: var(--game-bg-3);
  color: var(--game-text);
}
#screen-howhigh .qlas-opt:hover:not(:disabled) {
  border-color: var(--game-accent-2);
  background: var(--game-bg-3);
}
#screen-howhigh .qlas-opt.correct {
  border-color: #00ff41 !important;
  background: rgba(0, 255, 65, 0.1) !important;
}
#screen-howhigh .qlas-opt-key {
  color: var(--game-accent-2);
}
#screen-howhigh .qlas-go-head {
  color: var(--game-accent);
  text-shadow: 0 0 18px rgba(var(--game-accent-rgb), 0.4);
}
#screen-howhigh .qlas-go-stats {
  background: var(--game-bg-3);
  border-color: var(--game-border);
}
#screen-howhigh .qlas-go-row {
  border-bottom-color: var(--game-border);
}
#screen-howhigh .qlas-go-k {
  color: var(--game-text);
}
#screen-howhigh .qlas-go-v {
  color: var(--game-accent);
}
#screen-howhigh .qlas-btn--primary {
  background: var(--game-accent);
  color: #000;
}
#screen-howhigh .qlas-btn--primary:hover {
  opacity: 0.85;
}
#screen-howhigh .qlas-btn--ghost {
  border-color: var(--game-accent);
  color: var(--game-accent);
}
#screen-howhigh .qlas-btn--ghost:hover {
  background: rgba(var(--game-accent-rgb), 0.1);
}
#screen-howhigh .qlas-timer-ring .ring-progress {
  stroke: var(--game-accent);
  transition: stroke 0.2s;
}
#screen-howhigh .qlas-timer-ring .ring-track {
  stroke: var(--game-border);
}
#screen-howhigh .skipnot-heatmap-label {
  color: var(--game-accent-2);
}

/* Dice bonus card */
.howhigh-bonus-card {
  max-width: 480px;
  margin: 2rem auto;
  background: var(--game-bg-2);
  border: 2px solid var(--game-accent);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
}
.howhigh-bonus-title {
  color: var(--game-accent);
  font-size: 1.6rem;
  margin: 0 0 0.8rem;
  text-shadow: 0 0 18px rgba(var(--game-accent-rgb), 0.4);
}
.howhigh-bonus-desc {
  color: var(--game-text);
  opacity: 0.85;
  margin: 0 0 1.2rem;
  font-size: 0.9rem;
}
.howhigh-dice-container {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.howhigh-die {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: bold;
  color: var(--game-accent);
  background: var(--game-bg);
  border: 2px solid var(--game-accent);
  border-radius: 10px;
}
.howhigh-die.rolling {
  animation: diceRoll 0.1s infinite;
}
@keyframes diceRoll {
  0% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(8deg) scale(1.05);
  }
  100% {
    transform: rotate(-8deg) scale(1);
  }
}
.howhigh-dice-info {
  color: var(--game-text);
  font-size: 0.9rem;
  min-height: 2.5em;
}

/* GoWild stakes */
.howhigh-gowild-stakes {
  margin: 1rem 0;
  text-align: left;
}
.howhigh-gowild-pro {
  color: #4caf50;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}
.howhigh-gowild-con {
  color: #f44336;
  font-size: 0.9rem;
}

/* Challenge list */
.howhigh-challenges-list {
  display: flex;
  flex-direction: column;
  max-width: 480px;
}
.hh-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 14px;
  background: var(--bg3);
  border-bottom: 1px solid var(--border);
  font-family: 'Martian Mono', 'IBM Plex Mono', monospace;
  font-size: 1rem;
}
.hh-row:last-child {
  border-bottom: none;
}
.hh-col-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hh-col-center {
  font-family: 'Martian Mono', 'IBM Plex Mono', monospace;
  font-weight: 600;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}
.hh-sep {
  padding: 0 3px;
  opacity: 0.4;
}
.hh-col-right {
  text-align: right;
  opacity: 0.5;
  font-size: 0.9rem;
}
.hh-badge {
  font-family: 'Martian Mono', 'IBM Plex Mono', monospace;
  font-weight: 700;
  font-size: 0.9rem;
}
.hh-w .hh-badge {
  color: #4caf50;
}
.hh-l .hh-badge {
  color: #f44336;
}
.hh-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.5;
  padding: 8px 14px 4px;
}
.hh-row--waiting {
  opacity: 0.7;
}
.hh-badge--waiting {
  color: var(--muted);
}
.hh-code {
  font-family: 'Martian Mono', 'IBM Plex Mono', monospace;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text);
}
.howhigh-challenges-empty {
  font-size: 0.9rem;
}

/* ============================================================
   QLASHWORD (1v1 Scrabble + trivia-gated bonus squares)
   ============================================================ */

/* Home mode card */
.mode-card--qlashword {
  color: #5efbef;
}
.mode-card--qlashword .mode-name {
  color: #5efbef;
}

/* Screen — provides the --game-* vars the reused qlas question styles need */
/* Qlashword fills the viewport — drop the home-screen title's big top padding. */
body.qw-active {
  padding-top: calc(1rem + env(safe-area-inset-top, 0px));
}
#screen-qlashword {
  --game-bg: #07120f;
  --game-bg-2: #0c1a16;
  --game-bg-3: #10231d;
  --game-border: #16463a;
  --game-border-2: #1f6650;
  --game-text: #aef0dc;
  --game-accent: #2fe0a8;
  --game-accent-2: #5efbef;
  --game-accent-rgb: 47, 224, 168;
  --game-key: #ffe600;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: var(--game-bg);
  color: var(--game-text);
  min-height: 100vh;
  padding: 0 16px 12px;
  font-family: 'IBM Plex Mono', monospace;
}
.qw-inner {
  width: 100%;
  max-width: min(96vw, 1080px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.qw-phase {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.qw-title {
  color: var(--game-accent);
  letter-spacing: 0.12em;
  margin: 8px 0 0;
}
.qw-subtitle {
  color: var(--game-text);
  opacity: 0.7;
  font-size: 0.82rem;
  text-align: center;
  margin: 0;
}
.qw-waiting-msg {
  color: var(--game-text);
  font-size: 0.9rem;
}
.qw-code-line {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}
.qw-code-display {
  font-size: 1.6rem;
  letter-spacing: 0.25em;
  color: var(--game-accent);
  border: 1px dashed var(--game-border-2);
  padding: 6px 14px;
  border-radius: 3px;
}
.qw-btn-small {
  background: var(--game-bg-3);
  border: 1px solid var(--game-accent);
  color: var(--game-accent);
  font-family: inherit;
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
}
.qw-btn-primary,
.qw-btn-secondary {
  font-family: inherit;
  cursor: pointer;
  border-radius: 3px;
  padding: 10px 18px;
  font-size: 0.84rem;
  letter-spacing: 0.06em;
}
.qw-btn-primary {
  background: var(--game-accent);
  color: #042018;
  border: none;
  font-weight: 600;
}
.qw-btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.qw-btn-secondary {
  background: var(--game-bg-3);
  color: var(--game-text);
  border: 1px solid var(--game-border-2);
}
.qw-btn-secondary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.qw-btn-secondary.active {
  border-color: var(--game-accent);
  color: var(--game-accent);
}

/* Scores block (lives in the sidebar, stacked vertically) */
/* Sidebar top block: turn indicator + clock */
/* Timer cell: indicator + big clock inside one bordered box. */
.qw-turn-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1.5px solid var(--game-border-2);
  border-radius: 6px;
  padding: 8px 6px;
}
.qw-turn-indicator {
  font-size: 0.78rem;
  text-align: center;
  opacity: 0.85;
}
.qw-turn-indicator.mine {
  color: var(--game-accent);
  font-weight: 600;
}
.qw-turn-clock {
  text-align: center;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--game-accent);
  min-height: 1.9rem;
}
.qw-turn-clock.danger {
  color: #ff5555;
}
.qw-turn-top:has(.qw-turn-clock.danger) {
  border-color: #ff5555;
}
/* Final 10 seconds: calm hide/unhide blink of the whole timer cell (+ border). */
.qw-turn-top:has(.qw-turn-clock.urgent) {
  animation: qw-clock-blink 1s step-end infinite;
}
@keyframes qw-clock-blink {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* Result: one cell — player names on top, "42 : 56" below. */
/* Result: one box split into two centered halves (name + score). */
.qw-scorebox {
  display: flex;
  border: 1px solid var(--game-border);
  border-radius: 6px;
  overflow: hidden;
}
.qw-score-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 6px;
}
.qw-score-half + .qw-score-half {
  border-left: 1px solid var(--game-border);
}
.qw-score-half.active {
  background: rgba(var(--game-accent-rgb), 0.12);
}
.qw-pname {
  font-size: 0.82rem;
  opacity: 0.8;
}
.qw-score-half.active .qw-pname {
  color: var(--game-accent);
  opacity: 1;
  font-weight: 700;
}
.qw-pscore {
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--game-text);
}
.qw-score-half.active .qw-pscore {
  color: var(--game-accent);
}

/* Mid layout: board column (board + rack) beside the sidebar (status/actions) */
/* Grid so the sidebar is exactly the BOARD's height (row 1); the rack sits in
   row 2 under the board. This lets the history button align to the board's
   bottom edge rather than the rack's. */
.qw-mid {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 16px;
  row-gap: 10px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
}
.qw-board-wrap {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  justify-content: center;
}
.qw-sidebar {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  gap: 42px;
  min-width: 160px;
  max-width: 210px;
}
.qw-rack-row {
  grid-column: 1;
  grid-row: 2;
  justify-content: center;
}
/* History button on the board's bottom edge (sidebar == board height). */
.qw-history-btn {
  margin-top: auto;
}
.qw-board {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  /* Fixed equal rows + NO gap. The old 1px gap didn't divide evenly into the
     fluid width → uneven (distorted-looking) gridlines. Gridlines now come from
     each cell's own border (border-box), which stays crisp at any size. */
  grid-template-rows: repeat(15, 1fr);
  /* Largest square that fits both the viewport height (minus the rack below)
     and the width (minus the sidebar), so it fills the space without a
     scrollbar. Hard cap keeps it sane on huge monitors. */
  width: min(1000px, calc(100vh - 130px), calc(100vw - 280px));
  aspect-ratio: 1 / 1;
  /* Vintage tan board */
  background: #b9a268;
  /* Tan/wood frame */
  border: 7px solid #ab9457;
  border-radius: 4px;
  box-shadow:
    0 6px 22px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}
.qw-cell {
  box-sizing: border-box;
  /* Thin lighter gridline + a subtle bevel so cells read as raised, not like
     flat graph-paper. */
  border: 1px solid rgba(255, 252, 240, 0.32);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.28),
    inset -1px -1px 1px rgba(90, 70, 30, 0.3);
  /* Board surface + paper grain. */
  background-color: #356c47;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='90'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  font-size: clamp(6px, 2vmin, 13px);
  user-select: none;
}
/* Classic vintage Scrabble premium colours with dark labels. */
.qw-prem-label {
  font-size: clamp(6px, 1.7vmin, 12px);
  font-weight: 700;
  color: #23314a;
  opacity: 0.92;
  letter-spacing: 0.02em;
}
.qw-prem-tw {
  background-color: #d65241;
}
.qw-prem-tw .qw-prem-label {
  color: #3a1410;
}
.qw-prem-dw {
  background-color: #e7a7ae;
}
.qw-prem-tl {
  background-color: #e0c64a;
}
.qw-prem-dl {
  background-color: #aed6ea;
}
/* Use outline (not box-shadow) for state rings so the cell bevel is preserved. */
.qw-cell-pending {
  outline: 2px solid var(--game-accent);
  outline-offset: -2px;
}
/* Cells the player can't legally play on this turn (recomputed live). */
.qw-cell-dim {
  opacity: 0.28;
}
/* Legal anchor cells get a clear accent ring so plain (non-premium) ones pop. */
.qw-cell-playable {
  outline: 2px solid rgba(var(--game-accent-rgb), 0.7);
  outline-offset: -2px;
}

/* Tiles (settled + pending + rack) — physical wood/cardboard look: warm
   gradient, paper grain, and a bevel so they read as raised pieces. */
.qw-tile,
.qw-rack-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 100%;
  height: 100%;
  background-color: #a9844c;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='70' height='70'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)' opacity='0.14'/%3E%3C/svg%3E"),
    linear-gradient(155deg, #c2a064 0%, #a8844c 55%, #8d6c37 100%);
  color: #2a1e08;
  border-radius: 3px;
  font-weight: 700;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.55),
    inset -1px -1px 2px rgba(120, 90, 30, 0.4),
    0 1px 2px rgba(0, 0, 0, 0.35);
}
.qw-tile-pending {
  background: #bfe6c4;
}
.qw-tile-blank .qw-tile-letter {
  font-style: italic;
}
.qw-tile-letter {
  font-size: clamp(12px, 3.7vmin, 30px);
  font-weight: 800;
  line-height: 1;
}
.qw-tile-val {
  position: absolute;
  right: 1px;
  bottom: 0;
  font-size: clamp(6px, 1.7vmin, 13px);
  font-weight: 700;
  opacity: 0.85;
}

/* Rack */
.qw-rack-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.qw-shuffle-btn {
  flex-shrink: 0;
  background: var(--game-bg-3);
  color: var(--game-accent);
  border: 1px solid var(--game-border-2);
  border-radius: 4px;
  font-size: 1.5rem;
  width: 48px;
  height: 56px;
  cursor: pointer;
  font-family: inherit;
}
.qw-shuffle-btn:hover {
  border-color: var(--game-accent);
}
.qw-rack {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 44px;
  padding: 6px;
  background: var(--game-bg-2);
  border: 1px solid var(--game-border);
  border-radius: 4px;
}
.qw-rack-tile {
  width: 48px;
  height: 56px;
  border: 1px solid #b8a76a;
  cursor: pointer;
  font-family: inherit;
}
.qw-rack-tile .qw-tile-letter {
  font-size: 1.6rem;
}
.qw-rack-tile .qw-tile-val {
  font-size: 0.8rem;
}
.qw-rack-tile.used {
  opacity: 0.25;
  cursor: default;
}
.qw-rack-tile.selected {
  box-shadow: 0 0 0 2px var(--game-accent);
  transform: translateY(-3px);
}
.qw-rack-tile.swap-sel {
  box-shadow: 0 0 0 2px #ff5555;
}

/* Actions / status */
.qw-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.qw-sidebar .qw-btn-primary,
.qw-sidebar .qw-btn-secondary {
  width: 100%;
}
.qw-status {
  font-size: 0.8rem;
  color: #ffb454;
  text-align: center;
}
.qw-status:empty {
  display: none;
}

/* Turn history log (opens as an overlay via the HISTORY button) */
.qw-history-card {
  max-width: 420px;
}
.qw-history-title {
  color: var(--game-accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  text-align: center;
}
.qw-history {
  max-height: 60vh;
  overflow-y: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.qw-history:empty::after {
  content: 'No turns played yet.';
  opacity: 0.6;
  font-size: 0.8rem;
}
.qw-hist-turn {
  color: var(--game-accent);
  font-weight: 700;
  margin-top: 6px;
  opacity: 0.9;
}
.qw-hist-turn:first-child {
  margin-top: 0;
}
.qw-hist-entry {
  color: var(--game-text);
  opacity: 0.88;
  padding-left: 6px;
}

/* Narrow screens: stack the sidebar below the board, actions back to a row. */
@media (max-width: 760px) {
  /* Stack: board, then rack, then sidebar. */
  .qw-mid {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .qw-board-wrap {
    order: 0;
  }
  .qw-rack-row {
    order: 1;
  }
  .qw-sidebar {
    order: 2;
    max-width: none;
    width: 100%;
  }
  .qw-board {
    width: min(94vw, 560px);
  }
  .qw-history-btn {
    margin-top: 0;
  }
  .qw-actions {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }
  .qw-sidebar .qw-btn-primary,
  .qw-sidebar .qw-btn-secondary {
    width: auto;
  }
}

/* Bonus question modal */
.qw-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.qw-modal.show {
  display: flex;
}
.qw-modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--game-bg-2);
  border: 2px solid var(--game-border-2);
  border-radius: 6px;
  padding: 18px;
}
.qw-bonus-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.qw-bonus-badge {
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 2px;
  background: var(--game-bg-3);
  color: var(--game-accent);
}
.qw-bonus-progress {
  font-size: 0.74rem;
  opacity: 0.7;
}
.qw-bonus-timer {
  font-size: 0.9rem;
  color: var(--game-accent);
}
.qw-bonus-timer.danger {
  color: #ff5555;
}
.qw-bonus-spectate {
  margin-top: 10px;
  text-align: center;
  font-size: 0.8rem;
  opacity: 0.7;
}
.qw-bonus-prompt-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 6px 8px;
}
.qw-bonus-prompt-text {
  text-align: center;
  font-size: 0.9rem;
  color: var(--game-text);
}

/* Game over */
.qw-final-scores {
  display: flex;
  gap: 24px;
  font-size: 1rem;
}
.qw-final-scores span {
  color: var(--game-accent);
}
