/* ===================================================================
   TINY ARCADE — style.css
   Central stylesheet. All colors, spacing, radii and type live in the
   variables below. Change the palette here — nowhere else has a
   hard-coded color.
   =================================================================== */

/* -------------------------------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------------------------------- */
:root {
  /* -- light theme (default): old arcade poster on warm paper -- */
  --bg: #f1ead9;
  --bg-grain: #e9e0c9;
  --surface: #faf5e8;
  --text: #201b15;
  --muted: #74695a;
  --border: #201b15;
  --border-soft: #cdc2a8;
  --accent: #9a3324;
  --accent-soft: #c97a63;
  --accent-ink: #faf1e6;
  --shadow: rgba(32, 27, 21, 0.16);

  /* spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* radii — square-ish, "printed" not "app" */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-pill: 999px;

  /* type */
  --font-display: 'Space Mono', 'Courier New', monospace;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'Space Mono', 'Courier New', monospace;

  --border-width: 2px;
  --max-width: 720px;
}

[data-theme='dark'] {
  /* -- dark theme: same poster, at night, red-tinted black -- */
  --bg: #170f0e;
  --bg-grain: #1e1412;
  --surface: #221715;
  --text: #efe6d6;
  --muted: #9c8b7c;
  --border: #efe6d6;
  --border-soft: #3a2a26;
  --accent: #c25a49;
  --accent-soft: #7c332a;
  --accent-ink: #170f0e;
  --shadow: rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #170f0e;
    --bg-grain: #1e1412;
    --surface: #221715;
    --text: #efe6d6;
    --muted: #9c8b7c;
    --border: #efe6d6;
    --border-soft: #3a2a26;
    --accent: #c25a49;
    --accent-soft: #7c332a;
    --accent-ink: #170f0e;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}

/* -------------------------------------------------------------------
   2. RESET / BASE
   ------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100%;
}

body {
  background-image:
    radial-gradient(var(--bg-grain) 1px, transparent 1px);
  background-size: 3px 3px;
}
/* colour fade only after the theme button is pressed, never on page load */
.theme-anim body { transition: background-color 0.2s ease, color 0.2s ease; }

img, svg { max-width: 100%; display: block; }

a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}

h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }

p { line-height: 1.55; margin: 0 0 var(--space-3); max-width: 62ch; }

button, input, select { font-family: inherit; font-size: 1rem; }

::selection { background: var(--accent); color: var(--accent-ink); }

:focus-visible {
  outline: var(--border-width) dashed var(--accent);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------
   3. LAYOUT
   ------------------------------------------------------------------- */
.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.main {
  flex: 1;
  padding: var(--space-6) 0 var(--space-8);
}

/* -------------------------------------------------------------------
   4. NAV
   ------------------------------------------------------------------- */
.nav {
  border-bottom: var(--border-width) solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  max-width: var(--max-width);
  margin: 0 auto;
  gap: var(--space-3);
}

.nav-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--text);
}

.nav-brand .dot {
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

.nav-links {
  display: flex;
  gap: var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-links a {
  text-decoration: none;
  font-size: 0.9rem;
  color: var(--muted);
  padding: var(--space-1) 0;
  border-bottom: 2px solid transparent;
}

.nav-links a.active,
.nav-links a:hover {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.nav-actions { display: flex; align-items: center; gap: var(--space-3); }

.theme-toggle {
  border: var(--border-width) solid var(--border);
  background: transparent;
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.9rem;
}

/* mobile nav: bottom tab bar under 640px */
@media (max-width: 640px) {
  .nav-links {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--surface);
    border-top: var(--border-width) solid var(--border);
    justify-content: space-around;
    padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
    z-index: 30;
  }
  .nav-links a { border-bottom: none; font-size: 0.78rem; text-align: center; }
  .nav-links a.active { color: var(--text); font-weight: 700; }
  .main { padding-bottom: calc(var(--space-8) + 56px); }
}

/* -------------------------------------------------------------------
   5. BUTTONS
   ------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: var(--border-width) solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
  transition: transform 0.08s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-block { width: 100%; }

.btn-google {
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  color: var(--text);
}

/* -------------------------------------------------------------------
   6. CARDS / SURFACES
   ------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: 3px 3px 0 var(--shadow);
}

.card-row { display: flex; align-items: center; gap: var(--space-3); }

.stamp {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  display: inline-block;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 2px var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--muted);
}

.chip.streak { border-color: var(--accent); border-width: 2px; color: var(--text); font-weight: 700; }

hr.rule {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: var(--space-5) 0;
}

/* -------------------------------------------------------------------
   7. GRID OF GAME CARDS
   ------------------------------------------------------------------- */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: var(--space-4);
}

.game-card {
  background: var(--surface);
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-decoration: none;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: 3px 3px 0 var(--shadow);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.game-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--shadow);
}

.game-card .tile {
  width: 100%;
  aspect-ratio: 1;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--muted);
}

.game-card .tile img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }

.game-card .name { font-family: var(--font-display); font-size: 0.95rem; }
.game-card .status { font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }

/* -------------------------------------------------------------------
   8. LEADERBOARD LIST
   ------------------------------------------------------------------- */
.board-list { list-style: none; margin: 0; padding: 0; }

.board-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-soft);
}
.board-row:last-child { border-bottom: none; }

.board-rank {
  font-family: var(--font-mono);
  width: 2.2em;
  color: var(--muted);
  flex-shrink: 0;
}
.board-row.top .board-rank { color: var(--text); font-weight: 700; }

.board-name { flex: 1; font-weight: 600; }
.board-score { font-family: var(--font-mono); color: var(--muted); }

.board-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-1);
  margin-bottom: var(--space-4);
}
.board-tabs button {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--muted);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.board-tabs button.active {
  border-color: var(--accent);
  border-width: 2px;
  color: var(--text);
  font-weight: 700;
}

/* -------------------------------------------------------------------
   9. PROFILE
   ------------------------------------------------------------------- */
.profile-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
  margin: var(--space-5) 0;
}

.stat-box {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
}
.stat-box .num {
  font-family: var(--font-display);
  font-size: 1.3rem;
  display: block;
}
.stat-box .label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}

/* -------------------------------------------------------------------
   10. AVATAR (pixel, generated from SVG grid)
   ------------------------------------------------------------------- */
.avatar {
  border: var(--border-width) solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  flex-shrink: 0;
  overflow: hidden;
}

/* -------------------------------------------------------------------
   11. HERO (index.html)
   ------------------------------------------------------------------- */
.hero {
  position: relative;
  padding: var(--space-7) 0 var(--space-6);
  overflow: hidden;
}

.hero-title {
  font-size: clamp(2.4rem, 11vw, 4rem);
  margin-bottom: var(--space-2);
}

.hero-sub {
  color: var(--muted);
  max-width: 46ch;
}

.hero-stage {
  position: relative;
  height: 120px;
  margin: var(--space-5) 0;
  border-top: 1px dashed var(--border-soft);
  border-bottom: 1px dashed var(--border-soft);
  overflow: hidden;
}

.hero-stage .sprite {
  position: absolute;
  bottom: 10px;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  color: var(--muted);
  animation: float-across linear infinite;
}

@keyframes float-across {
  from { transform: translateX(-10vw); }
  to { transform: translateX(110vw); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-stage .sprite { animation: none; display: none; }
}

.login-card {
  max-width: 360px;
}

.preview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.preview-tile {
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--muted);
}
.preview-tile .glyph { font-size: 1.5rem; margin-bottom: var(--space-1); }

/* -------------------------------------------------------------------
   12. FOOTER (rendered by app.js)
   ------------------------------------------------------------------- */
.footer {
  border-top: var(--border-width) solid var(--border);
  background: var(--surface);
  padding: var(--space-5) 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}
.footer .wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* -------------------------------------------------------------------
   12b. SEARCH BOX
   ------------------------------------------------------------------- */
.search-box input,
.ta-modal input {
  width: 100%;
  border: var(--border-width) solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  min-height: 44px;
}
.search-box input::placeholder,
.ta-modal input::placeholder { color: var(--muted); }

/* -------------------------------------------------------------------
   12c. MODAL (username prompt)
   ------------------------------------------------------------------- */
.ta-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  z-index: 100;
}
.ta-modal { max-width: 360px; width: 100%; }
.ta-modal-error { font-size: 0.85rem; margin-top: var(--space-2); }

/* -------------------------------------------------------------------
   13. UTILITY
   ------------------------------------------------------------------- */
.center { text-align: center; }
.muted { color: var(--muted); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.hidden { display: none !important; }
.empty-state {
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  color: var(--muted);
}

/* ---------- loading screen: a pixel snake chasing around a 3x3 grid ---------- */
.ta-loading{--c:10px;display:flex;flex-direction:column;align-items:center;gap:12px;padding:28px 12px;
  color:var(--muted);font-size:.85rem;grid-column:1/-1}
.ta-loading.sm{--c:7px;flex-direction:row;justify-content:flex-start;gap:10px;padding:8px 0}
.ta-loader{display:grid;grid-template-columns:repeat(3,var(--c));gap:calc(var(--c) * .4)}
.ta-loader i{display:block;width:var(--c);height:var(--c);animation:ta-chase 1.35s linear infinite;
  animation-delay:calc((var(--i) - 9) * .15s);opacity:.25}
.ta-loading span::after{content:'';animation:ta-dots 1.2s steps(1) infinite}
@keyframes ta-chase{
  0%{background:var(--accent);transform:scale(1.2);opacity:1}
  14%{background:var(--accent);transform:scale(1);opacity:1}
  45%{background:var(--text);transform:scale(.55);opacity:.25}
  100%{background:var(--text);transform:scale(.55);opacity:.25}
}
@keyframes ta-dots{0%{content:''}25%{content:'.'}50%{content:'..'}75%{content:'...'}}
@keyframes ta-spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion: reduce){
  .ta-loader i{animation:none;background:var(--text)}
}

/* -------------------------------------------------------------------
   14. POLISH — responsive layout, seamless navigation, animation
   ------------------------------------------------------------------- */
:root { --danger: #b3261e; --success: #2e7d32; --ease: cubic-bezier(.2, .7, .2, 1); }
[data-theme='dark'] { --danger: #ff8a80; --success: #81c995; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) { --danger: #ff8a80; --success: #81c995; }
}
.ta-modal .ta-err, .ta-lf .ta-err { color: var(--danger); }
.ta-modal .ta-err.ta-ok, .ta-lf .ta-err.ta-ok { color: var(--success); }

html { scrollbar-gutter: stable; }

/* -- seamless page changes: the page body cross-fades, the chrome stays put -- */
@view-transition { navigation: auto; }
.main { view-transition-name: content; }
::view-transition-group(content) { animation-duration: 0s; }
::view-transition-old(content) { animation: ta-out .12s ease-in both; }
::view-transition-new(content) { animation: ta-in .3s var(--ease) .04s both; }
.no-vt .main { animation: ta-in .3s var(--ease) both; }
@keyframes ta-out { to { opacity: 0; } }
@keyframes ta-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes ta-pop { from { opacity: 0; transform: translateY(12px) scale(.94); } }
@keyframes ta-row { from { opacity: 0; transform: translateX(-10px); } }
@keyframes ta-fade { from { opacity: 0; } }
@keyframes ta-pulse { 50% { transform: scale(.6); opacity: .55; } }
@keyframes ta-glow { 50% { box-shadow: 0 0 0 3px var(--accent-soft); } }
@keyframes ta-bar { from { transform: scaleX(0); } }

/* signed-in / signed-out controls are settled before first paint (no flicker) */
html[data-auth='out'] [data-auth='in'],
html[data-auth='in'] [data-auth='out'] { display: none !important; }

/* colour fade on theme switch, without overriding components' own transitions */
:where(.theme-anim) * { transition: background-color .25s ease, color .25s ease, border-color .25s ease; }

/* -- nav -- */
.nav { padding-top: env(safe-area-inset-top, 0px); }
.nav-brand .dot { animation: ta-pulse 2.8s ease-in-out infinite; }
.nav-links a { position: relative; }
.nav-actions { gap: var(--space-2); }

.theme-toggle, .icon-btn {
  border: var(--border-width) solid var(--border);
  background: transparent;
  color: var(--text);
  width: 36px; height: 36px; padding: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: transform .08s ease, background-color .15s ease, color .15s ease;
}
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle { font-size: 0; }
.theme-toggle::before { content: '●'; font-size: .9rem; }
[data-theme='dark'] .theme-toggle::before { content: '☀'; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) .theme-toggle::before { content: '☀'; }
}
@media (hover: hover) {
  .theme-toggle:hover, .icon-btn:hover { background: var(--text); color: var(--bg); }
}
.theme-toggle:active, .icon-btn:active { transform: translate(1px, 1px); }

/* -- buttons: printed-key press feel -- */
.btn {
  box-shadow: 2px 2px 0 var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease, background-color .15s ease, color .15s ease, opacity .15s ease;
}
@media (hover: hover) {
  .btn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow); }
}
.btn:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--shadow); }
.btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn-sm { min-height: 36px; padding: var(--space-2) var(--space-3); font-size: .8rem; }

/* -- cards -- */
.game-grid { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.game-card { transition: transform .1s ease, box-shadow .1s ease, background-color .2s ease, color .2s ease, border-color .2s ease; }
.game-card:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }

/* -- hero -- */
.hero { overflow: visible; }
.hero-stage .sprite { animation-fill-mode: both; }   /* no sprite parked at the edge while waiting to start */

/* -- leaderboard -- */
.board-name { min-width: 0; overflow-wrap: anywhere; }
.board-score { font-variant-numeric: tabular-nums; }
.board-tabs { min-height: 40px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.board-tabs::-webkit-scrollbar { display: none; }
.board-tabs button { flex-shrink: 0; min-height: 36px; transition: color .15s ease, border-color .15s ease; }
.board-tabs button.active { border-width: 1px; box-shadow: inset 0 0 0 1px var(--accent); }   /* no 1px jiggle */
@media (hover: hover) { .board-tabs button:hover { color: var(--text); border-color: var(--text); } }
#player-search { min-height: 82px; }
#board-list { min-height: 180px; }

/* -- profile -- */
#profile-avatar { width: 68px; height: 68px; }
#profile-avatar:empty { background: var(--bg-grain); animation: ta-fade 1s ease-in-out infinite alternate; }
.profile-head > div:last-child { min-width: 0; }
#profile-username { overflow-wrap: anywhere; }
.profile-stats { min-height: 78px; }
.stat-box .label { text-wrap: balance; }
.chip.streak { animation: ta-glow 2.6s ease-in-out infinite; }

/* -- modals -- */
.ta-modal-backdrop { animation: ta-fade .18s ease-out; backdrop-filter: blur(2px); }
.ta-modal { animation: ta-pop .26s var(--ease); max-height: 90dvh; overscroll-behavior: contain; }

/* -- entrance animations: only during the first moments after a page opens,
      so lists never re-animate when they quietly refresh later -- */
.ta-boot .hero > * { animation: ta-in .5s var(--ease) backwards; }
.ta-boot .hero > :nth-child(2) { animation-delay: .06s; }
.ta-boot .hero > :nth-child(3) { animation-delay: .12s; }
.ta-boot .hero > :nth-child(4) { animation-delay: .18s; }
.ta-boot .hero > :nth-child(5) { animation-delay: .24s; }
.ta-boot .hero > :nth-child(n+6) { animation-delay: .3s; }
.ta-boot .game-card, .ta-boot .stat-box { animation: ta-pop .4s var(--ease) backwards; animation-delay: .08s; }
.ta-boot .game-card:nth-child(2), .ta-boot .stat-box:nth-child(2) { animation-delay: .14s; }
.ta-boot .game-card:nth-child(3), .ta-boot .stat-box:nth-child(3) { animation-delay: .2s; }
.ta-boot .game-card:nth-child(4) { animation-delay: .26s; }
.ta-boot .game-card:nth-child(5) { animation-delay: .32s; }
.ta-boot .game-card:nth-child(n+6) { animation-delay: .38s; }
.ta-boot .board-row { animation: ta-row .4s var(--ease) backwards; }
.ta-boot .board-row:nth-child(2) { animation-delay: .04s; }
.ta-boot .board-row:nth-child(3) { animation-delay: .08s; }
.ta-boot .board-row:nth-child(4) { animation-delay: .12s; }
.ta-boot .board-row:nth-child(5) { animation-delay: .16s; }
.ta-boot .board-row:nth-child(6) { animation-delay: .2s; }
.ta-boot .board-row:nth-child(7) { animation-delay: .24s; }
.ta-boot .board-row:nth-child(n+8) { animation-delay: .28s; }

/* -- laptop -- */
@media (min-width: 900px) {
  :root { --max-width: 900px; }
  .main { padding-top: var(--space-7); }
}
@media (min-width: 860px) {
  .hero { display: grid; grid-template-columns: minmax(0, 1fr) 360px; column-gap: var(--space-7); align-items: start; }
  .hero > * { grid-column: 1; }
  .hero > .stamp { justify-self: start; }
  .hero > .login-card { grid-column: 2; grid-row: 1 / span 6; margin-top: var(--space-2); }
  html[data-auth='in'] .hero { grid-template-columns: minmax(0, 1fr); }
}

/* -- phone -- */
@media (max-width: 640px) {
  .main { padding-bottom: var(--space-7); }
  .footer { padding-bottom: calc(var(--space-5) + 64px + env(safe-area-inset-bottom, 0px)); }
  .nav-links { padding-top: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .nav-links li { flex: 1; }
  .nav-links a { display: block; padding: var(--space-3) 0; min-height: 48px; }
  .nav-links a.active::before {
    content: ''; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
    background: var(--accent); animation: ta-bar .35s var(--ease) backwards;
  }
  .profile-stats { gap: var(--space-2); }
}
@media (max-width: 400px) {
  .nav-row { padding: var(--space-3); gap: var(--space-2); }
  .nav-brand { font-size: 1rem; }
  .nav-actions { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
/* -------------------------------------------------------------------
   Suggestion pill (games page) — paste at the END of style.css
   ------------------------------------------------------------------- */
@keyframes ta-pill-in { from { opacity: 0; transform: translateY(24px) scale(.96); } }
@keyframes ta-pill-float { 50% { transform: translateY(-5px); } }
/* slow glow: two soft pulses, then rest for most of the cycle */
@keyframes ta-pill-buzz {
  0%, 32%, 100% { box-shadow: 0 10px 28px var(--shadow), 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); }
  10%, 24%      { box-shadow: 0 10px 28px var(--shadow), 0 0 22px 6px color-mix(in srgb, var(--accent) 45%, transparent); }
  17%           { box-shadow: 0 10px 28px var(--shadow), 0 0 10px 2px color-mix(in srgb, var(--accent) 20%, transparent); }
}

#game-suggest:empty { display: none; }

.ta-pill {
  position: fixed;
  left: 0; right: 0;
  margin-inline: auto;
  bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  width: max-content;
  max-width: min(560px, calc(100vw - 24px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2) var(--space-2) var(--space-5);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 28px var(--shadow);
  animation:
    ta-pill-in .5s var(--ease) both,
    ta-pill-float 6s ease-in-out 1s infinite,
    ta-pill-buzz 7s ease-in-out 1.2s infinite;
}
.ta-pill p { margin: 0; font-size: .88rem; line-height: 1.35; }
.ta-pill .btn { border-radius: var(--radius-pill); box-shadow: none; white-space: nowrap; flex-shrink: 0; }
.ta-pill-x {
  flex-shrink: 0;
  width: 30px; height: 30px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem; line-height: 1;
  cursor: pointer;
}
@media (hover: hover) { .ta-pill-x:hover { background: var(--bg-grain); color: var(--text); } }

/* sit above the bottom tab bar on phones */
@media (max-width: 640px) {
  .ta-pill {
    bottom: calc(48px + var(--space-4) + env(safe-area-inset-bottom, 0px));
    padding-left: var(--space-4);
  }
}
