/*
 * buggs.io, the landing page (the game's front door, like slither.io's):
 * the live arena behind a flat scrim, then the wordmark, a nickname field and
 * Play, small corner widgets and a tiny legal footer. Below the fold, a solid
 * band of plain words about the game (.about-game), which leaves that first
 * screen exactly as it was.
 *
 * Flat by rule, like the game's UI (godot/scripts/game/theme_kit.gd): solid
 * fills and 1 px hairlines, state by colour, no shadows, glows, blurs,
 * gradients or pulsing. Tokens are the game's (docs/CLIENT.md, ThemeKit).
 * Phones get bigger text and fewer elements; system fonts only.
 */

:root {
  --clear: #0b0d0a;
  --scrim: rgba(7, 9, 10, 0.64);
  --glass: rgba(16, 22, 19, 0.74);
  --raised: rgba(34, 44, 39, 0.96);
  --raised-hover: rgba(52, 61, 56, 0.96);
  --raised-press: rgba(29, 37, 33, 0.96);
  --stroke: rgba(255, 255, 255, 0.08);
  --stroke-hi: rgba(255, 255, 255, 0.16);
  --text: #eef3ee;
  --muted: #98a59c;
  --faint: #5f6c64;
  /* text that informs (placeholder, ©): --faint is ≈ 3:1 over the scrimmed
     arena, below WCAG AA; this is ≈ 4.6–4.8:1 (the soil's median and its
     lightest tenth). --faint stays for decorative dots. */
  --faint-text: #7d8a82;
  --accent: #a3e635;
  --accent-hover: #b0ea51;
  --accent-press: #8fca2f;
  --on-accent: #0b1605;
  --warn: #f59e0b;
  --danger: #f43f5e;
  /* --danger lightened for text (the game's C_DANGER.lightened(0.2)) */
  --danger-text: #f6657e;
  --font-display: Helvetica, "Helvetica Neue", Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-text: Helvetica, "Helvetica Neue", Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --gutter: 24px;
  color-scheme: dark;
}

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

html { background: var(--clear); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--clear);
  color: var(--text);
  font: 400 15px/1.45 var(--font-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- the arena and the menu scrim over it -------------------------------- */

.arena {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 0.6s cubic-bezier(0.215, 0.61, 0.355, 1);
}
.arena.ready { opacity: 1; }

.scrim {
  position: fixed;
  inset: 0;
  background: var(--scrim);
  pointer-events: none;
}

/* ---- page frame: the menu centred, a bottom row of corner widgets ------- */

.page {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    max(16px, env(safe-area-inset-top))
    max(var(--gutter), env(safe-area-inset-right))
    max(14px, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
}

.front {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px 0 32px;
}

.brand, .entry {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

/* The game's wordmark: "buggs" in text white, ".io" in lime, weight 800, no effects. */
.wordmark {
  margin: 0;
  font: 800 72px/1 var(--font-display);
  letter-spacing: 0;
  color: var(--text);
}
.wordmark span { color: var(--accent); }

.tagline {
  margin: 14px 0 0;
  max-width: 34em;
  color: var(--muted);
  font-size: 15px;
}

/* ---- nickname + Play ------------------------------------------------------- */

.play {
  margin: 40px 0 0;
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nick {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1px solid var(--stroke-hi);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: 600 18px/1 var(--font-text);
  text-align: center;
  caret-color: var(--accent);
  outline: none;
  transition: border-color 0.14s var(--ease), background-color 0.14s var(--ease);
}
.nick::placeholder { color: var(--faint-text); opacity: 1; }
.nick::selection { background: rgba(163, 230, 53, 0.3); }
.nick:hover { border-color: rgba(255, 255, 255, 0.24); }
/* a 2 px focus border without moving the text */
.nick:focus { border: 2px solid rgba(163, 230, 53, 0.85); padding: 0 15px; background: rgba(0, 0, 0, 0.38); }
/* a nickname the filter refuses (landing.js): the game's red field, focused or not */
.nick[aria-invalid="true"],
.nick[aria-invalid="true"]:focus { border: 2px solid var(--danger); padding: 0 15px; background: rgba(244, 63, 94, 0.1); }
/* …and the line under it that says why (empty, and gone, while the name is fine) */
.nick-note {
  margin: -4px 0 0;
  color: var(--danger-text);
  font: 600 14px/1.35 var(--font-text);
  text-align: center;
}
.nick-note:empty { display: none; }

.btn-play {
  height: 60px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--on-accent);
  font: 800 22px/1 var(--font-display);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.14s var(--ease), transform 0.14s var(--ease);
}
.btn-play .icon { width: 20px; height: 20px; fill: currentColor; flex: none; }
.btn-play:hover { background: var(--accent-hover); transform: scale(1.02); }
.btn-play:active { background: var(--accent-press); transform: scale(0.97); }
.btn-play:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
/* loading: flat, no spinner, the label says it */
.btn-play[aria-busy="true"],
.btn-play[aria-busy="true"]:hover {
  background: var(--accent-press);
  transform: none;
  cursor: progress;
}
.btn-play[aria-busy="true"] .icon { display: none; }

/* ---- server status: a static dot (nothing pulses) and one muted line ----- */

.status {
  margin: 0;
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font: 500 13px/1.3 var(--font-text);
  font-variant-numeric: tabular-nums;
}
.status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--warn);
}
.status[data-state="online"] .dot { background: var(--accent); }
.status[data-state="offline"] .dot { background: var(--danger); }

.consent {
  margin: 20px 0 0;
  max-width: 340px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.consent a {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: rgba(238, 243, 238, 0.35);
  text-underline-offset: 2px;
}
.consent a:hover { text-decoration-color: var(--text); }

/* key hints: desktop (mouse) only */
.keys {
  display: none;
  margin: 18px 0 0;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.keys .sep { margin: 0 4px; color: var(--faint); }
kbd {
  font: 600 11px/1.3 var(--font-text);
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke-hi);
  border-radius: 6px;
  padding: 2px 7px;
}
@media (hover: hover) and (pointer: fine) {
  .keys { display: flex; }
}

/* phones in portrait: the game itself runs in landscape */
.rotate { display: none; margin: 18px 0 0; color: var(--muted); font-size: 13px; }

.noscript { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.noscript a { color: var(--accent); }

/* ---- the store badges, under Play on every screen --------------------------
   The stores' own artwork (assets/badges/, tools/build-site.mjs STORE_BADGES),
   never restyled: no filters or opacity, only the size and the same press
   scale as the buttons. Side by side at one height, as both stores ask. */

.stores {
  margin: 22px 0 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.store {
  display: block;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s var(--ease);
}
.store img { display: block; width: auto; height: 48px; }
.store:hover { transform: scale(1.03); }
.store:active { transform: scale(0.97); }
.store:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* ---- bottom row: "Choose your bug" · legal footer ------------------------ */

.bottom {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 16px;
}

.pick {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 5px 16px 5px 8px;
  border: 1px solid var(--stroke-hi);
  border-radius: 12px;
  background: var(--raised);
  color: var(--text);
  font: 600 14px/1.2 var(--font-text);
  white-space: nowrap;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease), transform 0.14s var(--ease);
}
.pick img { width: 40px; height: 40px; flex: none; }
.pick:hover { background: var(--raised-hover); border-color: rgba(163, 230, 53, 0.45); transform: scale(1.03); }
.pick:active { background: var(--raised-press); border-color: rgba(163, 230, 53, 0.6); transform: scale(0.97); }
.pick:focus-visible { outline: 1px solid rgba(163, 230, 53, 0.85); outline-offset: 2px; }
.pick[aria-busy="true"] { cursor: progress; transform: none; }

.legal {
  justify-self: center;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.legal nav span { color: var(--faint); }
.legal a { color: var(--muted); text-decoration: none; white-space: nowrap; }
.legal a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 2px; }
.legal a:focus-visible, .consent a:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
.copy { margin: 2px 0 0; color: var(--faint-text); }

/* the social row above the links: brand marks in the footer's muted colour,
   one tap target each (36 px, 40 px on phones) */
.legal .social { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px; margin: 0 0 4px; }
.legal .social a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--muted);
}
.legal .social a:hover { color: var(--text); background: var(--stroke); text-decoration: none; }
.legal .social a:focus-visible { outline: 1px solid var(--accent); outline-offset: 0; }
.legal .social svg { width: 18px; height: 18px; fill: currentColor; }

/* ---- below the fold: what the game is, in words ----------------------------
   A solid band after .page. .page fills the viewport (min-height 100dvh), so
   this starts where the first screen ends and nothing above it moves.
   position: relative paints it over the fixed arena and scrim (earlier in
   the page, z-index auto) and its background hides them, so the text never
   sits on the moving arena. Flat like the rest: one hairline on top, no
   shadows, glows or gradients. Its rules are scoped to .about-game, so none
   of them reach the first screen. */

.about-game {
  position: relative;
  background: var(--clear);
  border-top: 1px solid var(--stroke);
  padding:
    56px
    max(var(--gutter), env(safe-area-inset-right))
    max(56px, env(safe-area-inset-bottom))
    max(var(--gutter), env(safe-area-inset-left));
}
.about-inner { max-width: 760px; margin: 0 auto; }

.about-game h2 {
  margin: 56px 0 14px;
  color: var(--text);
  font: 800 26px/1.2 var(--font-display);
  letter-spacing: 0;
}
.about-inner > h2:first-child { margin-top: 0; }
.about-game h3 {
  margin: 0 0 6px;
  padding-top: 20px;
  border-top: 1px solid var(--stroke);
  color: var(--text);
  font: 700 17px/1.35 var(--font-text);
}
.about-game h2 + h3 { border-top: 0; padding-top: 4px; }

.about-game p,
.about-game li {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: break-word;
}
.about-game p { margin: 0 0 14px; }
.about-game h3 + p { margin-bottom: 20px; }
.about-game strong { color: var(--text); font-weight: 700; }

.about-game a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(163, 230, 53, 0.4);
  text-underline-offset: 3px;
}
.about-game a:hover { color: var(--accent-hover); text-decoration-color: var(--accent-hover); }
.about-game a:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* the five steps: lime numbers, the text in the band's muted grey */
.about-game .steps { margin: 0 0 14px; padding-left: 1.5em; }
.about-game .steps li { margin: 0 0 8px; padding-left: 4px; }
.about-game .steps li::marker { color: var(--accent); font-weight: 700; }

/* every bug's name (<!--@roster-teaser-->), each a chip that links to its card on /bugs */
.roster-teaser {
  list-style: none;
  margin: 18px 0 18px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.about-game .roster-teaser li { margin: 0; font-size: 14px; line-height: 1.2; }
.about-game .roster-teaser a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--stroke-hi);
  border-radius: 10px;
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.about-game .roster-teaser a:hover { background: var(--raised-hover); border-color: rgba(163, 230, 53, 0.45); color: var(--text); }

.about-game .faq { margin-top: 56px; }
.about-game .faq h2 { margin-top: 0; }

/* the way out: the first screen's lime Play button, then the guide pages as
   cards in the roster chips' idiom (raised fill, hairline, lime edge on hover) */
.about-end {
  margin-top: 56px;
  padding-top: 32px;
  border-top: 1px solid var(--stroke);
  display: grid;
  gap: 20px;
}
.about-game a.btn-play {
  justify-self: start;
  padding: 0 28px;
  color: var(--on-accent);
  text-decoration: none;
}
.about-game a.btn-play:hover { color: var(--on-accent); }
.about-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.about-game .about-links li { margin: 0; }
/* wide enough for three: the three game pages on the first row, then pairs
   (Skins and Updates, About and Press), so no row ends on a gap (seven cards:
   three, then pairs; keep in step) */
@media (min-width: 640px) {
  .about-links { grid-template-columns: repeat(6, 1fr); }
  .about-links li { grid-column: span 2; }
  .about-links li:nth-child(n + 4) { grid-column: span 3; }
}
.about-game .about-links a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  padding: 14px 16px;
  border: 1px solid var(--stroke-hi);
  border-radius: 12px;
  background: var(--raised);
  text-decoration: none;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.about-game .about-links a:hover { background: var(--raised-hover); border-color: rgba(163, 230, 53, 0.45); }
.about-game .about-links strong { color: var(--text); font-size: 16px; line-height: 1.3; }
.about-game .about-links strong::after { content: " \203A"; color: var(--accent); }
.about-game .about-links span { color: var(--muted); font-size: 14px; line-height: 1.4; }

/* ---- smaller screens ------------------------------------------------------- */

/* tablets / narrow windows: the corner widgets stack under the menu (from
   1060 px down: the row needs ≈ 1050 px) */
@media (max-width: 1060px) {
  .bottom { grid-template-columns: 1fr; justify-items: center; gap: 14px; }
  .pick, .legal { justify-self: center; }
}

/* phones: bigger text, fewer elements, 16 px gutters */
@media (max-width: 600px) {
  :root { --gutter: 16px; }
  .front { padding: 20px 0 24px; }
  .wordmark { font-size: 48px; }
  .tagline { margin-top: 12px; font-size: 15px; }
  .play { margin-top: 32px; max-width: none; }
  .nick { height: 56px; font-size: 18px; }
  .btn-play { height: 60px; font-size: 22px; }
  .status { font-size: 14px; }
  .consent { max-width: none; font-size: 13px; }
  .legal { font-size: 13px; }
  /* the links wrap onto two lines here: spaced, without the dots, so no line
     ends on a stray "·" */
  .legal nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; }
  .legal nav span { display: none; }
  .pick { font-size: 15px; }
  .legal .social a { width: 40px; height: 40px; }
  .legal .social svg { width: 20px; height: 20px; }
  .stores { margin-top: 20px; }
  .store img { height: 52px; }
  /* the band below the fold: the 16 px gutters, slightly smaller headings,
     and 40 px chips (thumbs) */
  .about-game { padding-top: 40px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
  .about-game h2 { margin-top: 44px; font-size: 22px; }
  .about-game h3 { font-size: 16px; }
  .about-game p, .about-game li { font-size: 15px; }
  .about-game .roster-teaser a { min-height: 40px; }
  .about-game .faq { margin-top: 44px; }
  .about-end { margin-top: 44px; padding-top: 28px; }
  .about-game a.btn-play { justify-self: stretch; }
}
@media (max-width: 600px) and (orientation: portrait) and (pointer: coarse) {
  .rotate { display: block; }
}
/* both badges at 52 px need 342 px: on a narrower phone they would wrap onto
   two rows, so they shrink to stay side by side */
@media (max-width: 374px) {
  .stores:has(> .store + .store) .store img { height: 46px; }
}

/* short landscape (phones on their side): the menu in two columns */
@media (orientation: landscape) and (max-height: 520px) {
  .front {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 40px;
    padding: 8px 0 12px;
  }
  .brand { width: auto; flex: 0 1 auto; align-items: flex-start; text-align: left; }
  .wordmark { font-size: 48px; }
  .tagline { max-width: 15em; }
  .entry { width: auto; flex: 0 1 360px; }
  .play { margin-top: 0; max-width: 360px; gap: 10px; }
  .nick { height: 48px; }
  .btn-play { height: 54px; }
  .consent { margin-top: 12px; max-width: 360px; }
  .keys { margin-top: 12px; }
  .bottom { grid-template-columns: auto 1fr auto; justify-items: stretch; gap: 12px; }
  .pick { justify-self: start; min-height: 44px; padding: 4px 12px 4px 6px; }
  .pick img { width: 34px; height: 34px; }
  .legal { justify-self: center; font-size: 12px; line-height: 1.55; }
  .legal .social { margin: 0 0 2px; }
  .legal .social a { width: 32px; height: 32px; }
  .legal nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 12px; }
  .legal nav span { display: none; }
  /* one badge sits beside the consent line, not under it: stacked it would push
     "Choose your bug" off a 360 px tall screen. Two badges leave the line no
     room beside them (one word a line), so then they take one row under it,
     which the consent line, two lines at this width, leaves room for. */
  .entry:has(> .stores > .store:only-child) { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 14px; }
  .entry:has(> .stores > .store:only-child) > * { grid-column: 1 / -1; }
  .entry:has(> .stores > .store:only-child) > .consent { grid-column: 1; text-align: left; }
  .stores { margin-top: 12px; }
  .store img { height: 44px; }
  .entry:has(> .stores > .store + .store) > .consent { margin-top: 6px; }
  .entry:has(> .stores > .store + .store) > .stores { margin-top: 8px; }
  .entry:has(> .stores > .store + .store) .store img { height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .arena { transition: none; }
  .btn-play, .pick, .nick, .store, .about-game .roster-teaser a { transition: none; }
  .btn-play:hover, .btn-play:active, .pick:hover, .pick:active, .store:hover, .store:active { transform: none; }
}
