:root {
  --bg: #0f1020;
  --panel: #1a1c33;
  --border: #2d3058;
  --text: #e8e9f5;
  --muted: #9a9cc0;
  --accent: #5ad1ff;
  --ad-bg: #15172b;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body { padding: 0 16px; background: transparent; }

/* Slowly drifting colored glow behind the whole page. */
body::before {
  content: '';
  position: fixed;
  inset: -25%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 25%, rgba(90, 209, 255, 0.13), transparent 35%),
    radial-gradient(circle at 80% 20%, rgba(181, 123, 255, 0.13), transparent 35%),
    radial-gradient(circle at 55% 85%, rgba(255, 107, 154, 0.10), transparent 40%);
  animation: bg-drift 28s ease-in-out infinite alternate;
}
@keyframes bg-drift {
  from { transform: translate(0, 0) rotate(0deg); }
  to   { transform: translate(6%, -5%) rotate(10deg); }
}
/* Faint block outlines drifting down (two sizes for depth), plus a vignette around the edges. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  --blocks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cg fill='none' stroke='white' stroke-opacity='0.07' stroke-width='2'%3E%3Crect x='20' y='20' width='18' height='18' rx='3'/%3E%3Crect x='40' y='20' width='18' height='18' rx='3'/%3E%3Crect x='60' y='20' width='18' height='18' rx='3'/%3E%3Crect x='40' y='40' width='18' height='18' rx='3'/%3E%3Crect x='180' y='30' width='18' height='18' rx='3'/%3E%3Crect x='180' y='50' width='18' height='18' rx='3'/%3E%3Crect x='180' y='70' width='18' height='18' rx='3'/%3E%3Crect x='180' y='90' width='18' height='18' rx='3'/%3E%3Crect x='110' y='80' width='18' height='18' rx='3'/%3E%3Crect x='130' y='80' width='18' height='18' rx='3'/%3E%3Crect x='110' y='100' width='18' height='18' rx='3'/%3E%3Crect x='130' y='100' width='18' height='18' rx='3'/%3E%3Crect x='80' y='150' width='18' height='18' rx='3'/%3E%3Crect x='100' y='150' width='18' height='18' rx='3'/%3E%3Crect x='60' y='170' width='18' height='18' rx='3'/%3E%3Crect x='80' y='170' width='18' height='18' rx='3'/%3E%3Crect x='150' y='180' width='18' height='18' rx='3'/%3E%3Crect x='150' y='200' width='18' height='18' rx='3'/%3E%3Crect x='170' y='200' width='18' height='18' rx='3'/%3E%3Crect x='190' y='200' width='18' height='18' rx='3'/%3E%3C/g%3E%3C/svg%3E");
  background:
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.55) 100%),
    var(--blocks) 0 0 / 240px 240px,
    var(--blocks) 120px 60px / 380px 380px;
  animation: blocks-fall 45s linear infinite;
}
@keyframes blocks-fall {
  from { background-position: center, 0 0, 120px 60px; }
  to   { background-position: center, 0 240px, 120px 440px; }
}
@media (prefers-reduced-motion: reduce) {
  body::before, body::after { animation: none; }
}

.site-header { text-align: center; padding: 16px 0 8px; position: relative; max-width: 760px; margin: 0 auto; }
.sound-toggles { position: absolute; top: 16px; right: 0; display: flex; gap: 6px; }
.icon-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
}
.icon-btn.off { opacity: 0.4; }
.site-header h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #5ad1ff, #b57bff, #ff6b9a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 14px rgba(181, 123, 255, 0.45));
}
.tagline { margin: 4px 0 0; color: var(--muted); }
.home-link { position: absolute; top: 22px; left: 0; color: var(--muted); font-size: .85rem; text-decoration: none; }
.home-link:hover { color: var(--accent); }
@media (max-width: 640px) { .home-link { position: static; display: inline-block; margin-bottom: 4px; } }

/* ---------- Ad slots ---------- */
.ad-slot {
  background: var(--ad-bg);
  border: 1px dashed var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  overflow: hidden;
  position: relative;
}
.ad-slot > span { position: absolute; top: 4px; left: 8px; opacity: 0.6; }
/* Ad boxes stay hidden until real AdSense code (<ins class="adsbygoogle">) is pasted inside them. */
.ad-slot:not(:has(ins.adsbygoogle)) { display: none; }

/* Simple header for the About / Contact / Privacy pages */
.page-header { padding-bottom: 0; }
.site-logo {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-decoration: none;
  background: linear-gradient(90deg, #5ad1ff, #b57bff, #ff6b9a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.about h1 { color: var(--text); }
.about a { color: var(--accent); }
.about a.btn { display: inline-block; color: #0f1020; text-decoration: none; margin-top: 8px; }
.contact-email { font-size: 1.3rem; font-weight: 700; }
.ad-top { max-width: 728px; height: 90px; margin: 150px auto 16px; }
.ad-side { width: 160px; height: 600px; flex: none; margin-left: 134px; display: none; }

/* ---------- Layout ---------- */
.layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
}
.panel { width: 160px; display: flex; flex-direction: column; gap: 12px; }
.box {
  background: rgba(26, 28, 51, 0.78);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(6px);
}
.box h2 {
  margin: 0 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.box canvas { display: block; margin: 0 auto; }

.stats div { display: flex; justify-content: space-between; padding: 4px 0; }
.stats label { color: var(--muted); font-size: 0.85rem; }
.stats span { font-weight: 700; font-variant-numeric: tabular-nums; }

.effects { font-size: 0.85rem; line-height: 1.6; font-variant-numeric: tabular-nums; }
.effects .none { color: var(--muted); }

.controls-help ul { list-style: none; margin: 0; padding: 0; font-size: 0.8rem; }
.controls-help li { padding: 3px 0; color: var(--muted); }
kbd {
  background: #2a2d50;
  border: 1px solid #3c4075;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.75rem;
  color: var(--text);
  margin-right: 2px;
}

/* Glowing gradient frame around the board. */
.board-wrap {
  position: relative;
  padding: 3px;
  border-radius: 11px;
  background: linear-gradient(160deg, #5ad1ff, #b57bff 50%, #ff6b9a);
  box-shadow: 0 0 40px rgba(124, 150, 255, 0.28), 0 18px 50px rgba(0, 0, 0, 0.55);
}
#board {
  display: block;
  background: #0a0b17;
  border-radius: 8px;
  /* Fill nearly the whole window height (board is 1:2), between 600px and 860px tall. */
  height: clamp(600px, calc(100vh - 100px), 860px);
  width: auto;
  max-width: 100%;
}

.overlay {
  position: absolute;
  inset: 3px;
  background: rgba(10, 11, 23, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  border-radius: 8px;
}
.overlay.hidden { display: none; }
.overlay h2 { margin: 0 0 8px; font-size: 1.8rem; }
.overlay p { margin: 0 0 16px; color: var(--muted); white-space: pre-line; }
.overlay { overflow-y: auto; }
.overlay-buttons { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.overlay .mode-info { font-size: 0.8rem; margin: 10px 0 0; max-width: 320px; min-height: 2.6em; }
.mode-btns { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 14px; }
.mode-btns button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}
.mode-btns button:hover { border-color: #b57bff; }
.mode-btns button.active { border-color: var(--accent); color: var(--accent); }
.mode-btns[hidden], .mode-info[hidden] { display: none; }
.btn.reward { background: linear-gradient(90deg, #5ee07a, #ffd84d); font-size: 1rem; padding: 10px 22px; }
.btn.secondary {
  background: transparent;
  color: var(--text);
  border: 2px solid #b57bff;
  font-size: 1rem;
  padding: 10px 22px;
}
.btn[hidden] { display: none; }
#fx-layer, .fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; }



/* ---------- Toast notifications ---------- */
.toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  pointer-events: none;
  width: min(90vw, 320px);
}
.toast {
  background: rgba(26, 28, 51, 0.97);
  border: 1px solid #ffd84d;
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.3s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast strong { color: #ffd84d; font-size: 0.8rem; }
.toast span { font-weight: 700; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px); } }

/* ---------- Records, themes, achievements ---------- */
.progress {
  max-width: 900px;
  margin: 32px auto 0;
  display: grid;
  gap: 16px;
}
.progress-block {
  background: rgba(26, 28, 51, 0.82);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
}
.progress-block h2 { margin: 0 0 12px; font-size: 1.1rem; }
.progress-block .count { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 20px; }
.records div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding: 4px 0; }
.records span { color: var(--muted); }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.theme-card {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.theme-card:hover:not(:disabled) { border-color: #b57bff; }
.theme-card.active { border-color: var(--accent); }
.theme-card.locked { cursor: default; opacity: 0.55; }
.theme-card small { color: var(--muted); font-size: 0.72rem; }
.swatches { display: flex; gap: 4px; padding: 8px; border-radius: 6px; }
.swatches i { width: 16px; height: 16px; border-radius: 3px; display: block; }

.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.ach {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.ach-icon { font-size: 1.5rem; width: 32px; text-align: center; }
.ach strong { display: block; font-size: 0.9rem; }
.ach small { color: var(--muted); font-size: 0.75rem; }
.ach.locked { opacity: 0.45; }

a.icon-btn { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }

/* 1 Player / 2 Players toggle on both start screens */
.player-switch {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin: 14px 0 0;
}
.player-switch a, .player-switch span {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
}
.player-switch a:hover { color: var(--text); }
.player-switch .active {
  background: linear-gradient(90deg, #5ad1ff, #b57bff);
  color: #0f1020;
}
.player-switch[hidden] { display: none; }
.vs-overlay .player-switch { margin: 0 0 12px; }

/* ---------- 2 Player Versus ---------- */
.versus {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 14px;
}
.vs-player { display: flex; gap: 10px; align-items: flex-start; }
.vs-side { width: 110px; display: flex; flex-direction: column; gap: 10px; }
.vs-board {
  display: block;
  height: clamp(480px, calc(100vh - 150px), 860px);
  width: auto;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: #0a0b17;
}
.p1 .vs-board { border-color: #4dd8ff; box-shadow: 0 0 18px rgba(77,216,255,0.25); }
.p2 .vs-board { border-color: #ff6b9a; box-shadow: 0 0 18px rgba(255,107,154,0.25); }
.vs-tag { font-weight: 800; font-size: 1.05rem; text-align: center; }
.vs-tag small { display: block; font-weight: 400; font-size: 0.75rem; color: var(--muted); }
.p1 .vs-tag, .w1 { color: #4dd8ff; }
.p2 .vs-tag, .w2 { color: #ff6b9a; }

.vs-center {
  width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 40px;
}
.vs-vs {
  font-size: 2.4rem;
  font-weight: 900;
  background: linear-gradient(180deg, #4dd8ff, #ff6b9a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.vs-wins { display: flex; gap: 8px; font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.vs-meta { text-align: center; }
.vs-meta label { display: block; color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; }
.vs-meta span { font-weight: 700; font-variant-numeric: tabular-nums; }

.vs-overlay {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  width: min(94%, 420px);
  max-height: calc(100% - 24px);
  overflow-y: auto;
  background: rgba(15, 16, 32, 0.96);
  border: 2px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  z-index: 10;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.vs-overlay[hidden] { display: none; }
.vs-overlay h2 { margin: 0 0 8px; font-size: 1.7rem; }
.vs-overlay p { color: var(--muted); white-space: pre-line; margin: 0 0 14px; }
.vs-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; text-align: left; }
.vs-controls div { background: var(--panel); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 4px; font-size: 0.78rem; color: var(--muted); }
.vs-controls strong { font-size: 0.95rem; }
.vs-hint { font-size: 0.8rem; margin: 12px 0 0 !important; }

.vs-touch-note { display: none; text-align: center; color: #ffd84d; }

.vs-format { color: #ffd84d; font-size: 0.75rem; font-weight: 700; text-align: center; white-space: pre-line; }

/* Single rounds / Best of 3 toggle */
.format-switch {
  display: inline-flex;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  margin: 0 0 14px;
}
.format-switch[hidden] { display: none; }
.format-switch button {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.format-switch button:hover { color: var(--text); }
.format-switch button.active { background: #ffd84d; color: #0f1020; }

@media (max-width: 900px) {
  .vs-side { width: 80px; }
  .vs-side .box h2 { font-size: 0.6rem; }
  .vs-side canvas { width: 70px; height: auto; }
  .vs-side .stats div { flex-direction: column; }
  .vs-board { height: auto; width: min(30vw, 260px); }
  .vs-center { width: 60px; }
}
@media (pointer: coarse) {
  .vs-touch-note { display: block; }
}

.btn {
  background: linear-gradient(90deg, #5ad1ff, #b57bff);
  border: none;
  color: #0f1020;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 12px 36px;
  border-radius: 999px;
  cursor: pointer;
}
.btn:hover { filter: brightness(1.1); }

/* ---------- Touch controls ---------- */
.touch-controls {
  display: none;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  max-width: 480px;
  margin: 12px auto 0;
}
.touch-controls button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.1rem;
  padding: 14px 0;
  border-radius: 8px;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.touch-controls button:active { background: #2a2d50; }

/* ---------- Content ---------- */
.about {
  max-width: 720px;
  margin: 32px auto;
  padding: 8px 28px 20px;
  color: var(--muted);
  line-height: 1.6;
  background: rgba(26, 28, 51, 0.82);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
}
@media (max-width: 640px) {
  .about { padding: 4px 16px 16px; }
}
.about h2 { color: var(--text); font-size: 1.1rem; }

.site-footer {
  text-align: center;
  padding: 24px 0;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .site-header h1 { font-size: 1.6rem; }
  .sound-toggles { position: static; justify-content: center; margin-top: 8px; }
  .ad-top { height: 50px; max-width: 320px; }
  .layout { gap: 8px; }
  .panel { width: 72px; gap: 8px; }
  .box { padding: 6px; }
  .box h2 { font-size: 0.6rem; }
  .box canvas { width: 60px; height: auto; }
  .stats div { flex-direction: column; padding: 2px 0; }
  .stats label { font-size: 0.6rem; }
  .stats span { font-size: 0.8rem; }
  .controls-help { display: none; }
  #board { width: min(70vw, 360px); height: auto; }
}

@media (pointer: coarse) {
  .touch-controls { display: grid; }
}

/* ---------- Pro controls ---------- */
body:not(.pro) .pro-only { display: none !important; }

/* ---------- Settings panel ---------- */
.settings {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 15, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 70;
  padding: 16px;
}
.settings[hidden] { display: none; }
.settings-box {
  background: rgba(26, 28, 51, 0.97);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px 22px;
  width: min(100%, 440px);
  max-height: 100%;
  overflow-y: auto;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6);
}
.settings-box h2 { margin: 0 0 14px; }
.settings-box h3 {
  margin: 18px 0 8px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.settings-box small { display: block; color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.setting-toggle {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
}
.setting-toggle input { width: 20px; height: 20px; margin-top: 2px; accent-color: #b57bff; }
.setting-slider { display: block; margin-bottom: 14px; }
.setting-slider output { float: right; color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
.setting-slider input { width: 100%; margin-top: 6px; accent-color: #5ad1ff; }
.settings-box .overlay-buttons { margin-top: 18px; }

/* ---------- Ad spacing (AdSense game pages: every ad at least 150px from the play area and its buttons) ----------
   Computer: the board shrinks to fit the window so the banner stays on screen, 150px under the game.
   Phone/tablet: the game fills the screen minus a 34px "How to play and more below" strip; the banner is below it. */
.layout { flex-wrap: wrap; }
.touch-controls { flex: 0 0 100%; }
.scroll-hint { display: none; }
@media (pointer: fine) {
  #board { height: clamp(360px, calc(100vh - 370px), 860px); }
  .vs-board { height: clamp(360px, calc(100vh - 370px), 860px); }
}
@media (pointer: fine) and (min-width: 1500px) and (min-height: 900px) {
  .ad-slot.ad-side:has(ins.adsbygoogle) { display: flex; }
  /* balance the side ad (16px gap + 134px margin + 160px) so the game stays centred */
  .layout:has(> .ad-side ins.adsbygoogle) { padding-left: 310px; }
}
/* Short computer screens: keep the side panels no taller than the board. */
@media (pointer: fine) and (max-height: 900px) {
  .site-header { padding-top: 10px; }
  .tagline { display: none; }
  #next { height: 150px; width: auto; }
  .controls-help li { padding: 1px 0; }
}
@media (pointer: coarse) {
  .site-header { padding: 6px 0 4px; }
  .tagline { display: none; }
  .controls-help { display: none; }
  .layout { gap: 8px; }
  .touch-controls { margin: 0; max-width: 480px; }
  #board { height: min(860px, calc(2 * (100vw - 400px)), calc(100vh - 170px), calc(100dvh - 170px)); width: auto; }
  .scroll-hint { display: block; height: 34px; line-height: 34px; text-align: center; font-size: 12px; color: var(--muted); }
  .ad-banner { margin-top: 116px; }
}
@media (pointer: coarse) and (max-width: 640px) {
  #board { height: min(720px, calc(2 * (100vw - 200px)), calc(100vh - 230px), calc(100dvh - 230px)); }
}
/* Landscape phones: slim header, touch buttons beside the board. */
@media (pointer: coarse) and (max-height: 500px) {
  .site-header { padding: 4px 0; }
  .site-header h1 { font-size: 1.1rem; }
  .home-link { top: 6px; }
  .sound-toggles { top: 2px; }
  .icon-btn { width: 30px; height: 30px; font-size: 0.9rem; }
  .touch-controls { flex: none; grid-auto-flow: row; grid-template-columns: repeat(3, 52px); align-content: start; }
  .touch-controls button { padding: 10px 0; }
  #board { height: min(calc(100vh - 80px), calc(100dvh - 80px)); }
  #next { height: 150px; width: auto; }
}
/* Short screens (laptops, landscape phones): the board is short, so compact the menus to fit without scrolling. */
@media (pointer: fine) and (max-height: 900px), (pointer: coarse) and (max-height: 500px) {
  .overlay { padding: 8px; overflow-x: hidden; }
  .overlay h2 { font-size: 1.2rem; margin-bottom: 4px; }
  .overlay p { margin-bottom: 8px; font-size: 0.85rem; }
  .overlay .btn { padding: 8px 26px; font-size: 1rem; }
  .player-switch { margin-top: 10px; }
  .player-switch a, .player-switch span { padding: 5px 10px; font-size: 0.78rem; }
  .mode-btns { margin-top: 8px; gap: 4px; }
  .mode-btns button { padding: 4px 10px; font-size: 0.78rem; }
  .overlay .mode-info { font-size: 0.72rem; margin-top: 6px; min-height: 0; }
  .vs-overlay { top: 8px; max-height: calc(100% - 8px); padding: 12px 14px; }
  .vs-overlay h2 { font-size: 1.2rem; margin-bottom: 4px; }
  .vs-overlay p { font-size: 0.82rem; margin-bottom: 8px; }
  .vs-controls { margin-top: 8px; gap: 6px; }
  .vs-controls div { padding: 6px 8px; gap: 2px; font-size: 0.72rem; }
}
