/* =========================================================
   FocusLa – shared styles
   Colours and fonts live in :root so every page and game
   uses the same look. Change a value here, it changes everywhere.
   ========================================================= */

/* The playful font for the "Focus Lah!" name (must come before other rules) */
@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@600;700&display=swap");

/* ---------- Dark theme (the default) ---------- */
:root {
  color-scheme: dark; /* scrollbars and form controls match */

  /* Backgrounds */
  --bg: #15171c;
  --surface: #1e2128;
  --surface-2: #262a33;
  --inset: #191b21;

  /* Borders */
  --border: #2c303a;
  --border-strong: #3a404c;

  /* Text */
  --text: #eef0f4;
  --text-muted: #9aa3b2;
  --text-faint: #5b6372;

  /* Accent green
     --accent       text, lines, pieces (your X, your discs)
     --accent-fill  the background of green buttons and chips
     --accent-text  text sitting on --accent-fill
     --accent-soft  faint green tint (e.g. behind a winning line) */
  --accent: #7be0b0;
  --accent-fill: #7be0b0;
  --accent-text: #10231a;
  --accent-soft: rgba(123, 224, 176, 0.14);

  /* Warnings */
  --danger: #ff8a7a;   /* lost life, wrong key */
  --warn: #f5c76a;     /* "so close!" */

  /* See-through layers over a game board */
  --overlay: rgba(21, 23, 28, 0.92);
  --overlay-light: rgba(21, 23, 28, 0.5);
  --hover-tint: rgba(255, 255, 255, 0.04);

  /* Game card pictures sit on a dark tile in both themes */
  --art-bg: #191b21;
}

/* ---------- Light theme ----------
   Used when someone picks it with the toggle, or when their device
   is set to light mode and they haven't picked anything. */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #e9ecf0;
  --inset: #eef0f3;
  --border: #dde1e7;
  --border-strong: #c3c9d2;
  --text: #16181d;
  --text-muted: #525a69;
  --text-faint: #8a92a0;
  --accent: #13784d;
  --accent-fill: #7be0b0;
  --accent-text: #10231a;
  --accent-soft: rgba(19, 120, 77, 0.12);
  --danger: #c4352b;
  --warn: #8a5a00;
  --overlay: rgba(243, 244, 246, 0.94);
  --overlay-light: rgba(243, 244, 246, 0.6);
  --hover-tint: rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #e9ecf0;
    --inset: #eef0f3;
    --border: #dde1e7;
    --border-strong: #c3c9d2;
    --text: #16181d;
    --text-muted: #525a69;
    --text-faint: #8a92a0;
    --accent: #13784d;
    --accent-fill: #7be0b0;
    --accent-text: #10231a;
    --accent-soft: rgba(19, 120, 77, 0.12);
    --danger: #c4352b;
    --warn: #8a5a00;
    --overlay: rgba(243, 244, 246, 0.94);
    --overlay-light: rgba(243, 244, 246, 0.6);
    --hover-tint: rgba(0, 0, 0, 0.04);
  }
}

:root {
  /* Type */
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-fun: "Fredoka", "Baloo 2", "Comic Sans MS", system-ui, sans-serif;
  --font-body: Inter, system-ui, sans-serif;

  /* Shape */
  --radius: 16px;
  --radius-sm: 10px;
}

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

/* Anything marked hidden stays hidden, even if a class
   (like .btn) gives it a display value. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
}

a {
  color: var(--accent);
}

/* ---------- Layout ---------- */

/* Centred column with side padding, used on every page */
.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

.hero {
  margin: 32px 0 28px;
}

.hero h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(30px, 5vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.muted {
  margin: 0;
  color: var(--text-muted);
  font-size: 17px;
}

.small {
  font-size: 14px;
}

/* ---------- Join form ---------- */

.join-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.join-form input {
  width: 96px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.join-form input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.join-message {
  min-height: 21px;
  margin-top: 8px;
  text-align: right;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  border: 0;
  background: var(--accent-fill);
  color: var(--accent-text);
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-secondary {
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--text-faint);
}

.btn:disabled {
  cursor: not-allowed;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  filter: none;
}

.btn:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Category chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 36px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent-fill);
  background: var(--accent-fill);
  color: var(--accent-text);
}

.chip-count {
  font-size: 12px;
  opacity: 0.75;
}

/* ---------- Sections + cards ---------- */

.sections {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-head {
  margin-bottom: 16px;
}

.section-title {
  margin: 0 0 2px;
  font-family: var(--font-display);
  font-size: 24px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
}

.card-art {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  border-radius: var(--radius-sm);
  background: var(--art-bg);
}

.card-art img {
  max-width: 160px;
  max-height: 92px;
}

.card-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
}

.card-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
}

.card-meta {
  font-size: 13px;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  gap: 8px;
}

.card-actions .btn {
  flex: 1 1 0;
  padding: 0 10px;
}

/* ---------- Game pages (shared by every game) ---------- */

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--text);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
}

.game-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--text-muted);
}

.game-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin-top: 32px;
}

/* Easy / Medium / Hard style toggle */
.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.segmented button {
  height: 40px;
  min-width: 80px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button:hover {
  color: var(--text);
}

.segmented button[aria-pressed="true"] {
  background: var(--accent-fill);
  color: var(--accent-text);
}

.segmented button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.scoreboard {
  display: flex;
  gap: 36px;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.score-label {
  font-size: 13px;
  color: var(--text-muted);
}

.score-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}

.mark-x {
  color: var(--accent);
  font-weight: 700;
}

.mark-o {
  color: var(--text);
  font-weight: 700;
}

.game-status {
  min-height: 30px;
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
}

.game-status[data-tone="good"] {
  color: var(--accent);
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

/* ---------- Light / dark toggle (added by js/theme.js) ---------- */

.site-header,
.game-header {
  justify-content: flex-start;
}

/* Push everything after the logo / back link to the right */
.site-header .join-form,
.game-header .game-title {
  margin-left: auto;
}

.theme-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--text-faint);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
}

/* ---------- Small screens ---------- */

@media (max-width: 560px) {
  .join-form label {
    display: none;
  }
  .join-message {
    text-align: left;
  }
}

/* ---------- Side menu: every game, one click away (js/nav.js) ---------- */

.menu-toggle,
.menu-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.menu-close {
  width: 40px;
  height: 40px;
  border-color: transparent;
  background: transparent;
}

.menu-toggle:hover,
.menu-close:hover {
  border-color: var(--text-faint);
}

.menu-toggle svg,
.menu-close svg {
  width: 20px;
  height: 20px;
}

.menu-toggle:focus-visible,
.menu-close:focus-visible,
.menu-game:focus-visible,
.menu-home:focus-visible,
.menu-logo:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* The page behind can't scroll while the menu is open */
html.menu-open {
  overflow: hidden;
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.menu-backdrop.is-open {
  opacity: 1;
}

.side-menu {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(340px, 88vw);
  padding: 16px 14px 14px;
  border-right: 1px solid var(--border);
  background: var(--bg);
  box-shadow: 12px 0 40px rgba(0, 0, 0, 0.3);
  transform: translateX(-102%);
  transition: transform 0.22s ease;
}

.side-menu.is-open {
  transform: none;
}

.menu-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.menu-logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.menu-search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
}

.menu-search:focus-within {
  border-color: var(--accent);
}

.menu-search svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.menu-search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
}

.menu-list {
  flex: 1;
  margin: 0 -6px;
  padding: 0 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu-group h2 {
  margin: 14px 8px 6px;
  color: var(--text-faint);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-group:first-child h2 {
  margin-top: 4px;
}

.menu-row {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 12px;
}

.menu-row:has(.is-current) {
  background: color-mix(in srgb, var(--game) 16%, transparent);
}

.menu-game {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
}

.menu-game:hover {
  background: var(--hover-tint);
}


.menu-art {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 38px;
  overflow: hidden;
  border-radius: 9px;
  background: color-mix(in srgb, var(--game) 22%, #14161c);
}

.menu-art img {
  width: 46px;
  height: 32px;
  object-fit: contain;
}

.menu-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.menu-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-meta {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.menu-badge {
  margin-left: auto;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--game);
  color: #14161c;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

/* ---------- Solo / With friends switch (game headers) ---------- */

.mode-switch {
  flex: none;
}

.mode-switch button,
.mode-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  min-width: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.mode-switch button:hover,
.mode-switch a:hover {
  color: var(--text);
}

.mode-switch [aria-pressed="true"] {
  background: var(--accent-fill);
  color: var(--accent-text);
  cursor: default;
}

.mode-switch .is-busy {
  opacity: 0.6;
  cursor: progress;
}

.mode-switch a:focus-visible,
.mode-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Phones: the switch takes the game name's place */
@media (max-width: 560px) {
  .game-header.has-mode-switch .game-title {
    display: none;
  }
  /* …and the back link is just its arrow (the menu has the rest) */
  .game-header.has-mode-switch .back-link {
    justify-content: center;
    min-width: 32px;
    font-size: 0;
    gap: 0;
  }
  .game-header.has-mode-switch .mode-switch {
    margin-left: auto;
  }
  .mode-switch button,
  .mode-switch a {
    padding: 0 10px;
    font-size: 13px;
  }
}

.menu-empty {
  margin: 16px 8px;
  color: var(--text-muted);
  font-size: 14px;
}

.menu-home {
  padding: 10px 8px 2px;
  border-top: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.menu-home:hover {
  color: var(--accent);
}

/* The button sits right before the logo / back link */
.site-header .menu-toggle,
.game-header .menu-toggle {
  margin-right: -4px;
}

@media (prefers-reduced-motion: reduce) {
  .side-menu,
  .menu-backdrop {
    transition: none;
  }
}

/* ---------- Game pages wear their game's colour (js/gamepage.js) ---------- */

/* The dotted notebook page, like the home page */
html.game-page body {
  background-image: radial-gradient(var(--page-dots, rgba(255, 255, 255, 0.05)) 1.2px, transparent 1.3px);
  background-size: 22px 22px;
  background-attachment: fixed;
}

:root[data-theme="light"].game-page.game-page {
  --page-dots: rgba(0, 0, 0, 0.07);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]).game-page.game-page {
    --page-dots: rgba(0, 0, 0, 0.07);
  }
}

/* Buttons, highlights and pieces take the game's colour.
   On a dark page the colour itself reads well; on a light page
   text and lines use a darker shade of it. (The doubled class
   just makes these win over the light/dark colour rules.) */
:root.has-game-colour.has-game-colour {
  --accent-fill: var(--game);
  --accent-text: #14161c;
  --accent: var(--game);
  --accent-soft: color-mix(in srgb, var(--game) 16%, transparent);
}

:root[data-theme="light"].has-game-colour.has-game-colour {
  --accent: color-mix(in srgb, var(--game) 58%, #000);
  --accent-soft: color-mix(in srgb, var(--game) 20%, transparent);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]).has-game-colour.has-game-colour {
    --accent: color-mix(in srgb, var(--game) 58%, #000);
    --accent-soft: color-mix(in srgb, var(--game) 20%, transparent);
  }
}

/* The game's name, with its little picture (one line, always) */
.game-header .game-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  white-space: nowrap;
}

@media (max-width: 820px) {
  .game-header .game-title-art {
    display: none;
  }
  .game-header .game-title {
    display: block;
    text-overflow: ellipsis;
  }
  /* The back link is just its arrow (the menu has the rest) */
  .game-header .back-link {
    justify-content: center;
    min-width: 32px;
    font-size: 0;
    gap: 0;
  }
}

.game-title-art {
  display: grid;
  place-items: center;
  flex: none;
  width: 46px;
  height: 34px;
  overflow: hidden;
  border-radius: 9px;
  background: color-mix(in srgb, var(--game) 24%, #14161c);
}

.game-title-art img {
  width: 40px;
  height: 28px;
  object-fit: contain;
}

/* The sound button sits next to the light/dark one */
.game-header .sound-toggle {
  margin-left: 0;
}

.sound-toggle[aria-pressed="true"] {
  border-color: var(--accent-fill);
  color: var(--accent);
}

/* ---------- Win moment (js/fx.js) ---------- */

.fx-confetti {
  position: fixed;
  inset: 0;
  z-index: 200;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fx-pop {
  animation: fx-pop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes fx-pop {
  0% { transform: scale(0.7); }
  100% { transform: scale(1); }
}

/* Phones: one row in the header, so long names give way */
@media (max-width: 560px) {
  .game-header .game-title {
    display: block;
    min-width: 0;
    overflow: hidden;
    font-size: 17px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .game-header .game-title-art {
    display: none;
  }
  .game-header {
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-pop {
    animation: none;
  }
}

/* Phones: the back link is just its arrow (the menu has the rest),
   so the game's name has room */
@media (max-width: 560px) {
  .game-header .back-link {
    justify-content: center;
    min-width: 32px;
    font-size: 0;
    gap: 0;
  }
}

/* ---------- How to play (every game) + your record ---------- */

.how-to {
  width: min(100%, 560px);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px dashed var(--border-strong);
  background: var(--surface);
}

.how-to summary {
  cursor: pointer;
  font-weight: 700;
  list-style-position: inside;
}

.how-to summary::marker {
  color: var(--accent);
}

.how-to p {
  margin: 8px 0 0;
}

.game-record {
  margin: -6px 0 0;
  text-align: center;
}

/* ---------- The name: "Focus Lah!" ---------- */

.wordmark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.22em;
  font-family: var(--font-fun);
  font-weight: 700;
  font-size: 1.12em;
  letter-spacing: 0.005em;
  line-height: 1;
  white-space: nowrap;
}
.wordmark-lah {
  display: inline-block;
  padding: 0.08em 0.32em 0.12em;
  border-radius: 0.45em;
  background: var(--accent-fill, var(--accent));
  color: var(--accent-text, #10231a);
  transform: rotate(-6deg) translateY(-0.04em);
  box-shadow: 0 0.12em 0 rgba(0, 0, 0, 0.18);
  transition: transform 0.25s cubic-bezier(0.34, 1.8, 0.5, 1);
}
a:hover .wordmark-lah,
a:focus-visible .wordmark-lah {
  transform: rotate(4deg) translateY(-0.12em) scale(1.06);
}
@media (prefers-reduced-motion: reduce) {
  .wordmark-lah { transition: none; }
}

/* ---------- About / Privacy / Terms ---------- */

.doc-page {
  max-width: 760px;
}
.doc .site-header .theme-toggle {
  margin-left: auto;
}
.doc .logo {
  font-size: 22px;
}
.doc-body {
  margin-top: 28px;
  line-height: 1.7;
}
.doc-body h1 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(28px, 6vw, 38px);
  line-height: 1.15;
}
.doc-body h2 {
  margin: 34px 0 6px;
  font-family: var(--font-display);
  font-size: 20px;
}
.doc-body p,
.doc-body li {
  color: var(--text-muted);
}
.doc-body b {
  color: var(--text);
}
.doc-body ul {
  padding-left: 1.2em;
}
.doc-body li + li {
  margin-top: 6px;
}
.doc-body a {
  color: var(--accent);
  text-underline-offset: 3px;
}
.doc-lead {
  font-size: 18px;
}
.doc-meta {
  margin: 0 0 14px;
  font-size: 14px;
}

/* Small links at the bottom of every page */
.site-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 18px;
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px dashed var(--border-strong);
  font-size: 14px;
}
.site-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 2px;
}
.site-links a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.site-footer .site-links {
  margin-top: 14px;
  padding-top: 0;
  border-top: 0;
}

/* The same links at the bottom of the side menu */
.menu-links {
  display: flex;
  gap: 14px;
  padding: 10px 4px 0;
  font-size: 13px;
}
.menu-links a {
  color: var(--text-muted);
  text-decoration: none;
}
.menu-links a:hover {
  color: var(--accent);
}

/* ---------- Phones held sideways ----------
   The screen is wide but only ~350–430px tall, so the game goes on
   the right, sized to the screen's height, and the buttons and
   scores stack in a column on the left. Each game marks its play
   area with .land-play and sets how big it can get (in its own
   style.css) from --play-h and --play-w. */
@media (orientation: landscape) and (max-height: 540px) {
  :root {
    --land-side: clamp(200px, 34vw, 320px);
    --play-h: calc(100dvh - 72px);
    --play-w: calc(100vw - var(--land-side) - 52px);
  }
  .game-page .page {
    padding-top: 8px;
    padding-bottom: 16px;
  }
  .game-layout {
    display: grid;
    grid-template-columns: var(--land-side) minmax(0, 1fr);
    grid-template-rows: repeat(16, max-content) 1fr;
    column-gap: 20px;
    row-gap: 10px;
    align-items: start;
    margin-top: 10px;
  }
  .game-layout > * {
    grid-column: 1;
    justify-self: center;
    max-width: 100%;
    margin-top: 0;
    margin-bottom: 0;
  }
  /* The play area: marked on the solo pages, and the same boards
     when a game is played with friends in a room */
  .game-layout > :is(.land-play, .ttt-board, .ut-holder, .ck-holder, .db-holder,
      .c4-holder, .ps-holder, .rps-arena, .bs-place, .bs-seas) {
    grid-column: 2;
    grid-row: 1 / -1;
    justify-self: center;
  }
  /* Party games in a room bring their own layout (scores, players, the
     game), and setup screens (teams, waiting for the host): full width */
  .room-board > :is(.cr-setup, .sn-setup, .sr-race-setup, .sd-race-setup, .wrr-setup, .cf-teams, .dd-setup,
      .sd-race, .sn-race, .sr-race, .wrr-race, .cr-race, .cf-match, .dd-stage) {
    grid-column: 1 / -1;
    --play-w: calc(100vw - 32px);
  }
  /* In a room the score bar sits above the game, so there's a bit less height */
  .room-play {
    --play-h: calc(100dvh - 124px);
  }
  .room-play .room-bar {
    margin-bottom: 0;
  }
  .room-board {
    margin-top: 6px;
  }
  /* Tighter buttons so the left column fits (and wrap if they still don't) */
  .game-layout .segmented {
    flex-wrap: wrap;
    justify-content: center;
  }
  .game-layout .segmented button {
    padding-left: 9px;
    padding-right: 9px;
    min-width: 0;
    font-size: 13px;
  }
  .game-layout .scoreboard {
    gap: 18px;
  }
  .game-layout .score-value {
    font-size: 22px;
  }
  .game-layout .how-to,
  .game-layout .game-record {
    width: 100%;
  }
  .site-links {
    margin-top: 24px;
  }
}
