/* The 2048 Tile Game — styles, built on the gamekit design tokens (gamekit.css,
 * loaded first). Mobile-first, fluid board, automatic dark mode via the token
 * system, motion that respects prefers-reduced-motion. A warm gold palette and
 * the classic 2048 tile ramp on a taupe board, wrapped in the shared shell. */

:root {
  /* Reskin the gamekit accent to a warm gold so the whole UI (buttons, nav,
   * avatars, leaderboard highlights) inherits the 2048 brand hue. */
  --gk-accent: #c98a15;
  --gk-accent-strong: #a06e0f;
  --gk-accent-contrast: #ffffff;
  --gk-accent-soft: #f7ecd2;

  /* Warm cream surfaces (light theme) echoing the classic 2048 background. */
  --gk-bg: #faf8ef;
  --gk-surface: #ffffff;
  --gk-surface-2: #f2ece0;
  --gk-ink: #2b2620;
  --gk-ink-soft: #6f665a;
  --gk-line: #ece3d4;
  --gk-line-strong: #dcccb2;

  /* Alias gamekit tokens to the local names used throughout this sheet. */
  --accent: var(--gk-accent);
  --accent-dark: var(--gk-accent-strong);
  --accent-soft: var(--gk-accent-soft);
  --ink: var(--gk-ink);
  --ink-soft: var(--gk-ink-soft);
  --bg: var(--gk-bg);
  --card: var(--gk-surface);
  --line: var(--gk-line);
  --radius: var(--gk-radius);
  --shadow: var(--gk-shadow);
  --shadow-sm: var(--gk-shadow-sm);
  --font: var(--gk-font-sans);
  --display: var(--gk-font-display);
  --maxw: var(--gk-maxw);

  /* Board surfaces (the taupe board and its empty cells). */
  --board-bg: #bbada0;
  --cell-bg: rgba(238, 228, 218, 0.45);

  /* Fluid board: as large as fits one mobile viewport (leaving room for the
   * header, score row and controls), capped for desktop. Always 1:1. */
  --board-size: min(90vw, 58dvh, 520px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --gk-accent: #e6b34d;
    --gk-accent-strong: #f0c46e;
    --gk-accent-contrast: #2a1c02;
    --gk-accent-soft: #3a2c12;

    --gk-bg: #14120d;
    --gk-surface: #1e1a13;
    --gk-surface-2: #29231a;
    --gk-ink: #f2ece1;
    --gk-ink-soft: #b6a891;
    --gk-line: #322a1d;
    --gk-line-strong: #453924;

    --board-bg: #372f2a;
    --cell-bg: rgba(255, 255, 255, 0.06);
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  font-size: 17px;
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
}

h1, h2, h3 { line-height: 1.15; color: var(--ink); font-family: var(--display); }
h1 { font-size: var(--gk-fs-2xl); margin: 0 0 0.4em; letter-spacing: -0.01em; }
h2 { font-size: var(--gk-fs-xl); margin: 1.6em 0 0.5em; }
h3 { font-size: var(--gk-fs-lg); margin: 1.2em 0 0.3em; }

a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--ink-soft); }
.small { font-size: var(--gk-fs-sm); }
.section-lead { font-size: var(--gk-fs-lg); color: var(--ink-soft); max-width: 60ch; }
.gk-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip-link { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--gk-accent-contrast); padding: 8px 14px; border-radius: 0 0 8px 0; z-index: 100; }
.skip-link:focus { left: 0; }

/* Header / nav */
.site-header {
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  padding-top: env(safe-area-inset-top);
}
.header-inner { display: flex; align-items: center; gap: var(--gk-space-3); min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; font-size: 1.15rem; font-family: var(--display); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 40px; height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #edc22e, #d9a41c);
  color: #fff;
  font-weight: 800;
  font-size: 0.72rem;
  letter-spacing: -0.03em;
}
.site-nav { display: flex; gap: 2px; align-items: center; margin-left: auto; }
.site-nav a { color: var(--ink-soft); padding: 8px 12px; border-radius: 8px; font-weight: 600; font-size: 0.96rem; }
.site-nav a:hover { background: var(--accent-soft); color: var(--accent-dark); text-decoration: none; }
.site-nav a.active { color: var(--accent-dark); background: var(--accent-soft); }

.header-account { display: flex; align-items: center; }
.header-account[hidden] { display: none; }
.gk-auth-btn { padding: 6px 12px; min-height: var(--gk-tap); }
.gk-auth-btn .gk-avatar { width: 30px; height: 30px; }

.nav-toggle { display: none; background: none; border: 0; cursor: pointer; padding: 8px; min-width: var(--gk-tap); min-height: var(--gk-tap); }
.nav-toggle span { display: block; width: 24px; height: 2px; background: var(--ink); margin: 5px 0; border-radius: 2px; transition: transform .2s; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); margin-top: var(--gk-space-7); background: var(--card); }
.footer-inner { padding: 24px 20px calc(34px + env(safe-area-inset-bottom)); }
.footer-note { color: var(--ink-soft); font-size: 0.85rem; max-width: 70ch; }
.footer-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 18px 24px; margin-bottom: 18px; }
.footer-col h2 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 0 0 8px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.footer-col a { color: var(--ink-soft); font-size: 0.95rem; }

/* Buttons (site variants mirror gamekit's .gk-btn). */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--gk-tap);
  border: 1px solid transparent;
  border-radius: var(--gk-radius);
  padding: 10px 18px;
  font: inherit; font-weight: 600; font-size: 0.98rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--gk-transition-fast), border-color var(--gk-transition-fast), transform var(--gk-transition-fast), box-shadow var(--gk-transition-fast);
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--gk-accent-contrast); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); text-decoration: none; }
.btn-ghost { background: var(--card); color: var(--accent-dark); border-color: var(--gk-line-strong); }
.btn-ghost:hover { background: var(--accent-soft); text-decoration: none; }
.btn-lg { padding: 14px 30px; font-size: 1.1rem; }
.gk-btn--sm { min-height: 34px; padding: 6px 14px; font-size: var(--gk-fs-sm); }

/* Sections */
.play-section { padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
.play-head { text-align: center; margin-bottom: 14px; }
.play-head h1, .play-head h2 { margin: 0 0 0.15em; }
.copy-section { padding: 24px 20px; max-width: 820px; }
.copy-section.slim { max-width: 720px; }
.copy-section p, .copy-section li { max-width: 68ch; }
.cta-line { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.feature-list, .how-steps { padding-left: 1.2em; }
.feature-list li, .how-steps li { margin: 0.5em 0; }
.game-controls-extra { display: flex; gap: 10px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.crumb { margin: 0 0 6px; }

/* Size / shape cards */
.sizes-section { padding: 16px 20px 28px; }
.size-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-top: 12px; }
.size-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; color: var(--ink); box-shadow: var(--shadow-sm);
  transition: transform var(--gk-transition-fast), box-shadow var(--gk-transition-fast), border-color var(--gk-transition-fast);
}
.size-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); text-decoration: none; }
.size-card-title { font-weight: 800; font-size: 1.2rem; color: var(--accent-dark); font-family: var(--display); }
.size-card-meta { font-size: 0.85rem; color: var(--ink-soft); font-weight: 600; }
.size-card-blurb { font-size: 0.9rem; color: var(--ink-soft); }

.size-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.size-tab { min-height: var(--gk-tap); display: inline-flex; align-items: center; padding: 8px 16px; border-radius: var(--gk-radius-pill); background: var(--card); border: 1px solid var(--gk-line-strong); color: var(--accent-dark); font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.size-tab:hover { background: var(--accent-soft); text-decoration: none; }
.size-tab.current { background: var(--accent); color: var(--gk-accent-contrast); border-color: var(--accent); }

/* ===== 2048 board ===== */
.t2048 { display: flex; flex-direction: column; align-items: center; gap: var(--gk-space-3); width: 100%; margin: 0 auto; }
.t2048-hud { display: flex; align-items: center; justify-content: space-between; gap: var(--gk-space-4); width: var(--board-size); max-width: 100%; }
.t2048-scores { display: flex; gap: var(--gk-space-3); }
.t2048-score { display: flex; flex-direction: column; align-items: center; min-width: 84px; padding: 6px 14px; background: var(--board-bg); border-radius: var(--gk-radius); color: #fff; }
.t2048-score-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; }
.t2048-score-val { font-weight: 800; font-size: 1.4rem; font-variant-numeric: tabular-nums; line-height: 1.1; }
.t2048-controls { display: flex; gap: 8px; }
.t2048-btn { padding: 8px 14px; }

.t2048-boardwrap {
  position: relative;
  width: var(--board-size);
  max-width: 100%;
  aspect-ratio: 1 / 1;
  /* --gap and --cell are set (in px) by the client once the board is measured,
   * so the absolutely-positioned tile layer aligns exactly with the CSS-grid
   * background across every board size and viewport. The percentage fallbacks
   * only style the empty grid before the script runs. */
  --gap: 3%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.t2048-grid {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(var(--size), 1fr);
  grid-template-rows: repeat(var(--size), 1fr);
  gap: var(--gap);
  padding: var(--gap);
  background: var(--board-bg);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.t2048-cell { background: var(--cell-bg); border-radius: 8px; }

.t2048-tiles { position: absolute; inset: 0; z-index: 2; }
.t2048-tiles:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 12px; }

.t2048-tile {
  position: absolute; top: 0; left: 0;
  width: var(--cell); height: var(--cell);
  display: grid; place-items: center;
  border-radius: 8px;
  font-family: var(--display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: calc(var(--cell) * 0.42);
  background: #eee4da; color: #776e65;
  transform: translate(calc(var(--gap) + var(--col) * (var(--cell) + var(--gap))), calc(var(--gap) + var(--row) * (var(--cell) + var(--gap))));
  transition: transform 0.11s ease-in-out;
  will-change: transform;
}
.t2048-tile[data-len="3"] { font-size: calc(var(--cell) * 0.36); }
.t2048-tile[data-len="4"] { font-size: calc(var(--cell) * 0.30); }
.t2048-tile[data-len="5"] { font-size: calc(var(--cell) * 0.24); }

/* Classic value ramp. */
.t2048-tile.tile-2    { background: #eee4da; color: #776e65; }
.t2048-tile.tile-4    { background: #ede0c8; color: #776e65; }
.t2048-tile.tile-8    { background: #f2b179; color: #fff; }
.t2048-tile.tile-16   { background: #f59563; color: #fff; }
.t2048-tile.tile-32   { background: #f67c5f; color: #fff; }
.t2048-tile.tile-64   { background: #f65e3b; color: #fff; }
.t2048-tile.tile-128  { background: #edcf72; color: #fff; box-shadow: 0 0 18px 3px rgba(243, 215, 116, 0.35); }
.t2048-tile.tile-256  { background: #edcc61; color: #fff; box-shadow: 0 0 20px 4px rgba(243, 215, 116, 0.45); }
.t2048-tile.tile-512  { background: #edc850; color: #fff; box-shadow: 0 0 22px 5px rgba(243, 215, 116, 0.55); }
.t2048-tile.tile-1024 { background: #edc53f; color: #fff; box-shadow: 0 0 24px 6px rgba(243, 200, 90, 0.6); }
.t2048-tile.tile-2048 { background: #edc22e; color: #fff; box-shadow: 0 0 26px 7px rgba(243, 200, 90, 0.7); }
.t2048-tile.tile-super { background: #3c3a32; color: #fff; box-shadow: 0 0 26px 7px rgba(60, 58, 50, 0.6); }

.t2048-tile.is-new { animation: t2048-appear 0.14s ease-in-out; }
.t2048-tile.is-merged { animation: t2048-pop 0.16s ease-in-out; z-index: 3; }
@keyframes t2048-appear { 0% { opacity: 0; transform: translate(calc(var(--gap) + var(--col) * (var(--cell) + var(--gap))), calc(var(--gap) + var(--row) * (var(--cell) + var(--gap)))) scale(0.2); } 100% { opacity: 1; } }
@keyframes t2048-pop {
  0% { transform: translate(calc(var(--gap) + var(--col) * (var(--cell) + var(--gap))), calc(var(--gap) + var(--row) * (var(--cell) + var(--gap)))) scale(1); }
  50% { transform: translate(calc(var(--gap) + var(--col) * (var(--cell) + var(--gap))), calc(var(--gap) + var(--row) * (var(--cell) + var(--gap)))) scale(1.16); }
  100% { transform: translate(calc(var(--gap) + var(--col) * (var(--cell) + var(--gap))), calc(var(--gap) + var(--row) * (var(--cell) + var(--gap)))) scale(1); }
}

/* Floating "+N" score popup near the board. */
.t2048-pop-layer { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.t2048-pop { position: absolute; top: 6%; left: 50%; transform: translateX(-50%); font-weight: 800; font-size: 1.5rem; font-variant-numeric: tabular-nums; color: var(--accent-dark); text-shadow: 0 1px 2px rgba(0,0,0,0.18); animation: t2048-float 0.8s ease-out forwards; }
@keyframes t2048-float { 0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -42px) scale(1.05); } }

.t2048-hint { text-align: center; }

/* Board overlay (win / game over). */
.t2048-overlay {
  position: absolute; inset: 0; z-index: 8;
  display: flex; align-items: center; justify-content: center;
  padding: 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--board-bg) 82%, transparent);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.t2048-overlay[hidden] { display: none; }
.t2048-overlay-card {
  position: relative; overflow: hidden;
  background: var(--card); border-radius: var(--gk-radius-lg);
  padding: 22px 22px; max-width: 340px; width: 100%;
  max-height: 100%; overflow-y: auto; text-align: center;
  box-shadow: var(--gk-shadow-lg); animation: t2048-rise 0.25s ease;
}
@keyframes t2048-rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.t2048-overlay-card h2 { margin: 0 0 0.1em; color: var(--accent-dark); font-size: var(--gk-fs-2xl); }
.t2048-overlay-sub { color: var(--ink-soft); margin: 0 0 14px; font-size: 0.95rem; }
.t2048-overlay-stats { display: flex; justify-content: center; gap: 22px; margin: 0 0 16px; }
.t2048-overlay-stats div { display: flex; flex-direction: column; }
.t2048-overlay-stats dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.t2048-overlay-stats dd { margin: 2px 0 0; font-weight: 800; font-size: 1.4rem; font-variant-numeric: tabular-nums; color: var(--ink); }
.t2048-overlay-actions { display: flex; flex-direction: column; gap: 8px; }
.t2048-share-status { min-height: 1.2em; font-size: 0.85rem; color: var(--accent-dark); margin: 10px 0 0; }
.t2048-noscript { background: color-mix(in srgb, var(--gk-warn) 18%, var(--card)); border: 1px solid var(--gk-warn); padding: 14px; border-radius: 10px; color: var(--ink); max-width: var(--board-size); }

/* Confetti on win. */
.t2048-cheer { position: absolute; top: 0; left: 0; right: 0; height: 0; pointer-events: none; }
.t2048-cheer span { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; opacity: 0; }
.t2048-cheer span:nth-child(1) { left: 24%; background: #edc22e; }
.t2048-cheer span:nth-child(2) { left: 50%; background: #f2b179; }
.t2048-cheer span:nth-child(3) { left: 74%; background: var(--gk-ok); }
.t2048-overlay.win .t2048-cheer span { animation: t2048-confetti 1.1s ease-in forwards; }
.t2048-overlay.win .t2048-cheer span:nth-child(2) { animation-delay: .12s; }
.t2048-overlay.win .t2048-cheer span:nth-child(3) { animation-delay: .22s; }
@keyframes t2048-confetti { 0% { opacity: 0; transform: translateY(0) rotate(0); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(220px) rotate(320deg); } }

/* Leaderboard panel (post-game) + standalone page — points, higher is better. */
.t2048-lb-panel { text-align: left; margin: 4px 0 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.t2048-lb-panel[hidden] { display: none; }
.t2048-lb-title { margin: 0 0 8px; font-size: var(--gk-fs-lg); color: var(--ink); text-align: center; }
.t2048-lb-signin { text-align: center; color: var(--ink-soft); font-size: var(--gk-fs-sm); margin: 0 0 12px; }
.t2048-lb-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t2048-lb-table th { text-align: left; font-size: var(--gk-fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); padding: 6px 10px; border-bottom: 1px solid var(--line); }
.t2048-lb-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: var(--gk-fs-sm); }
.t2048-lb-table tbody tr:last-child td { border-bottom: 0; }
.t2048-lb-rank { font-weight: 700; color: var(--accent-dark); white-space: nowrap; }
.t2048-lb-name { max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t2048-lb-score { font-weight: 700; text-align: right; }
.t2048-lb-table th:last-child { text-align: right; }
.t2048-lb-you { background: var(--accent-soft); }
.t2048-lb-own { display: flex; gap: 10px; align-items: center; margin-top: var(--gk-space-2); padding: 8px 10px; border-radius: var(--gk-radius-sm); background: var(--accent-soft); font-size: var(--gk-fs-sm); font-variant-numeric: tabular-nums; }
.t2048-lb-own .t2048-lb-name { flex: 1; font-weight: 600; }
.t2048-lb-state { padding: var(--gk-space-5) var(--gk-space-3); text-align: center; color: var(--ink-soft); font-size: var(--gk-fs-sm); }
.t2048-lb-error { color: var(--gk-danger); }

/* Leaderboard page */
.lb-page { padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); max-width: 720px; }
.lb-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--gk-space-4); margin: 16px 0; }
.lb-sizes { margin: 0; }
.lb-date-field { display: flex; flex-direction: column; gap: 4px; }
.lb-date-label { font-size: var(--gk-fs-sm); font-weight: 600; color: var(--ink-soft); }
.lb-date { max-width: 200px; }
.lb-list { min-height: 120px; margin-top: 8px; padding: 6px 4px; }
.lb-disabled { color: var(--ink-soft); }

/* FAQ */
.faq-section { padding: 20px; max-width: 820px; }
.faq { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.faq-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.faq-item summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; float: right; color: var(--accent); font-weight: 700; }
.faq-item[open] summary::after { content: "\2212"; }
.faq-answer { padding: 0 18px 14px; }
.faq-answer p { margin: 0; color: var(--ink-soft); max-width: none; }

/* Tips */
.tips { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-top: 12px; }
.tip { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.tip h3 { margin: 0 0 0.3em; color: var(--accent-dark); font-size: 1rem; }
.tip p { margin: 0; color: var(--ink-soft); font-size: 0.95rem; }

/* Archive */
.archive-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.archive-list a { display: block; text-align: center; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-weight: 600; box-shadow: var(--shadow-sm); }
.archive-list a:hover { border-color: var(--accent); background: var(--accent-soft); text-decoration: none; }
.day-nav { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }

.error-section { text-align: center; padding: 50px 20px; }

/* Puzzle library */
.library-section { padding: 20px; border-top: 1px solid var(--line); }
.library-section:first-of-type { border-top: 0; }
.library-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin-bottom: 8px; }
.library-head h2 { margin: 0; }
.puzzle-num-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 8px; margin-top: 12px; }
.puzzle-num { display: inline-flex; align-items: center; justify-content: center; min-height: var(--gk-tap); padding: 8px; border-radius: var(--gk-radius); background: var(--card); border: 1px solid var(--gk-line-strong); color: var(--accent-dark); font-weight: 700; font-variant-numeric: tabular-nums; }
.puzzle-num:hover { background: var(--accent-soft); text-decoration: none; }
.library-more { margin-top: 10px; }
.puzzle-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.puzzle-nav .spacer { flex: 1; }

/* Strategy guide */
.strategy-section { margin-top: 22px; }
.strategy-section h2 { margin-bottom: 0.3em; }

@media (prefers-reduced-motion: reduce) {
  .t2048-tile { transition: none; }
  .t2048-tile.is-new, .t2048-tile.is-merged, .t2048-pop, .t2048-overlay.win .t2048-cheer span { animation: none; }
}

/* Desktop: a touch more breathing room. */
@media (min-width: 1024px) {
  :root { --board-size: min(46vw, 62dvh, 560px); }
}

/* Mobile nav */
@media (max-width: 860px) {
  body { font-size: 16px; }
  .nav-toggle { display: block; order: 3; }
  .header-account { order: 2; margin-left: auto; }
  .site-nav {
    order: 4; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; align-items: stretch; margin-left: 0;
    background: var(--card); border-bottom: 1px solid var(--line);
    padding: 8px 16px 14px; gap: 2px; display: none; box-shadow: var(--shadow);
  }
  .site-header.nav-open .site-nav { display: flex; }
  .site-nav a { padding: 12px 10px; }
}
