/* Games section. To theme for another site, change --accent, --accent-strong and --accent-2. */
:root {
  --accent: #FF4C00;
  --accent-strong: #C93C00; /* accent for small text on light backgrounds */
  --accent-2: #F6C73B;
  --ink: #232425;
  --muted: #6B6F72;
  --bg: #F7F9FA;
  --card: #FFFFFF;
  --line: #EDEFF1;
  --line-strong: #D5D8DA;
  --stage: #18191A;
  --stage-2: #232425;
  --stage-line: #3A3E41;
  --stage-muted: #A4A8AB;
  --stage-text: #F7F9FA;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.dark {
  /* result and leaderboard screens share the games' dark stage */
  --bg: var(--stage); --card: var(--stage-2); --ink: var(--stage-text); --muted: var(--stage-muted);
  --line: var(--stage-line); --line-strong: #4A4F53; --accent-strong: var(--accent);
  background: radial-gradient(ellipse 70% 55% at 50% 30%, rgba(255, 76, 0, 0.13), rgba(255, 76, 0, 0) 70%) fixed, var(--stage);
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- light pages ---------- */
.page {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.page.narrow { max-width: 640px; }
.top { display: flex; align-items: center; justify-content: space-between; min-height: 36px; }
.logo-slot {
  display: flex; align-items: center; justify-content: center;
  width: 112px; height: 36px;
  border: 1px dashed #8C8F91; border-radius: 6px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted);
}
.count { font-size: 13px; font-weight: 600; color: var(--muted); }
.intro { display: flex; flex-direction: column; gap: 6px; }
.intro h1 { font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; }
.intro p { font-size: 14px; line-height: 20px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 20px;
  border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--card); color: var(--ink);
  font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; font-size: 19px; font-weight: 700; }
.btn.wide { width: 100%; min-height: 56px; }
.btn.dark { background: transparent; border-color: var(--stage-line); color: var(--stage-text); }
.icon-btn {
  width: 44px; height: 44px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--ink); cursor: pointer; border-radius: 8px;
}
.icon-btn.boxed { border: 1px solid var(--line-strong); background: var(--card); }

.featured {
  display: grid; grid-template-columns: minmax(0, 1fr);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
}
.featured-art { display: block; width: 100%; border: 0; padding: 0; background: var(--stage); cursor: pointer; }
.featured-art svg, .thumb svg { display: block; width: 100%; height: auto; }
.featured-body { display: flex; flex-direction: column; gap: 4px; padding: 14px; justify-content: center; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-strong); }
.featured-body h2 { font-size: 20px; font-weight: 800; line-height: 24px; }
.featured-body p { font-size: 13px; line-height: 18px; color: var(--muted); }
.featured-body .row { display: flex; gap: 8px; padding-top: 8px; }
.featured-body .row .btn { flex: 1; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.chip-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.card {
  display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.thumb { position: relative; display: block; width: 100%; border: 0; padding: 0; background: var(--stage); cursor: pointer; }
.thumb:disabled { cursor: default; }
.card.soon .thumb svg { opacity: 0.35; }
.badge {
  position: absolute; left: 8px; top: 8px;
  padding: 4px 8px; border-radius: 4px;
  background: var(--accent-2); color: #18191A;
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.meta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 0; }
.meta h3 { font-size: 15px; font-weight: 700; line-height: 20px; }
.meta span { font-size: 12px; line-height: 16px; color: var(--muted); }
.foot { display: flex; align-items: center; justify-content: space-between; min-height: 52px; padding: 4px 4px 4px 12px; }
.foot .best { font-size: 12px; color: var(--muted); }
.foot .best strong { color: var(--ink); font-weight: 700; }
.empty { padding: 28px 16px; text-align: center; font-size: 14px; line-height: 20px; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 12px; }

@media (hover: hover) {
  .card:not(.soon):hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(35, 36, 37, 0.10); }
  .btn.primary:hover { background: #E84500; }
  .btn:not(.primary):not(.dark):hover, .chip-btn[aria-pressed="false"]:hover { border-color: var(--ink); }
}
@media (min-width: 600px) {
  .page { padding: 32px 24px 64px; gap: 24px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .intro h1 { font-size: 36px; }
  .intro p { font-size: 16px; line-height: 24px; }
}
@media (min-width: 820px) {
  .featured { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
  .featured-body { padding: 28px; gap: 8px; }
  .featured-body h2 { font-size: 30px; line-height: 34px; }
  .featured-body p { font-size: 15px; line-height: 22px; }
  .featured-body .row { padding-top: 12px; max-width: 360px; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1080px) {
  .page { padding: 40px 32px 72px; }
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ---------- leaderboard ---------- */
.board-head { display: flex; align-items: center; gap: 14px; }
.board-head .titles { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.board-head h1 { font-size: 24px; font-weight: 800; line-height: 1.15; letter-spacing: -0.01em; }
.board-head .titles span { font-size: 14px; color: var(--muted); }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.tabs button { flex: 1; min-height: 44px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.rows { display: flex; flex-direction: column; gap: 6px; list-style: none; margin: 0; padding: 0; }
.rows li {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 14px;
  border-radius: 12px; background: var(--card); border: 1px solid var(--line);
}
.rows li.first { min-height: 60px; background: #FFF4D6; border-color: var(--accent-2); }
body.dark .rows li.first { background: rgba(246, 199, 59, 0.14); }
.rows .rank { width: 28px; font-size: 18px; font-weight: 800; color: var(--muted); }
.rows li.top3 .rank { color: var(--ink); }
.rows .who { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.rows .who b { font-size: 15px; font-weight: 600; }
.rows .who span { font-size: 12px; color: var(--muted); }
.rows .pts { font-size: 18px; font-weight: 800; }
.note { font-size: 13px; line-height: 19px; color: var(--muted); }

/* ---------- game stage ---------- */
.stage {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(ellipse 70% 55% at 50% 42%, rgba(255, 76, 0, 0.13), rgba(255, 76, 0, 0) 70%),
    var(--stage);
  color: var(--stage-text);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.progress { position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--stage-line); }
.progress i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left center; }
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  padding: 18px 16px 0; pointer-events: none;
}
.hud-btn {
  pointer-events: auto; width: 44px; height: 44px; border-radius: 8px;
  border: 1px solid var(--stage-line); background: var(--stage-2); color: var(--stage-text);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.hud .lbl { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; color: var(--stage-muted); text-transform: uppercase; }
.hud-score { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud-score .val { font-size: 44px; font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.hud-score .chip {
  margin-top: 8px; padding: 5px 10px; border-radius: 6px;
  background: var(--accent-2); color: #18191A; font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.hud-score .val.bump { animation: bump 0.2s ease-out; }
@keyframes bump { 0% { transform: scale(1.22); } 100% { transform: scale(1); } }
.hud-best { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; padding-top: 4px; }
.hud-best .val { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.toast {
  position: absolute; left: 0; right: 0; top: 27%; text-align: center; pointer-events: none;
  font-size: 22px; font-weight: 800; letter-spacing: 0.02em; color: var(--accent);
  text-shadow: 0 2px 14px rgba(24, 25, 26, 0.9); opacity: 0;
}
.toast.show { animation: toast 0.9s ease-out forwards; }
@keyframes toast {
  0% { opacity: 0; transform: translateY(10px) scale(0.85); }
  15% { opacity: 1; transform: translateY(0) scale(1.06); }
  30% { transform: translateY(0) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px) scale(1); }
}
.hint {
  position: absolute; left: 0; right: 0; bottom: 28px; margin: 0 auto;
  width: max-content; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 8px;
  background: var(--stage-2); border: 1px solid var(--stage-line);
  font-size: 14px; font-weight: 500; text-align: center; pointer-events: none;
  transition: opacity 0.5s ease;
}
.hint.gone { opacity: 0; }

.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 24px 16px; background: rgba(24, 25, 26, 0.78); overflow: auto;
}
.panel { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.panel h2 { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.panel p { font-size: 15px; line-height: 22px; color: var(--stage-muted); }
.panel .how {
  padding: 14px 16px; border-radius: 12px; background: var(--stage-2); border: 1px solid var(--stage-line);
  font-size: 15px; line-height: 22px; color: var(--stage-text);
}
.panel .stack { display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }

.overlay.result { background: var(--bg); background: color-mix(in srgb, var(--bg) 90%, transparent); color: var(--ink); align-items: stretch; }
.result-col { width: 100%; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; justify-content: space-between; gap: 24px; }
.result-top { display: flex; align-items: center; justify-content: space-between; }
.result-top b { font-size: 15px; font-weight: 700; }
.result-mid { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.result-badge { padding: 7px 14px; border-radius: 6px; background: var(--accent-2); color: #18191A; font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.result-badge.plain { background: var(--line); color: var(--ink); }
.result-score { font-size: 112px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; color: var(--accent); font-variant-numeric: tabular-nums; }
.result-score.long { font-size: 76px; }
.result-unit { font-size: 16px; color: var(--muted); }
.result-cards { display: flex; gap: 10px; }
.result-cards > div { flex: 1; display: flex; flex-direction: column; gap: 6px; padding: 16px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); text-align: left; }
.result-cards .lbl { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; color: var(--muted); text-transform: uppercase; }
.result-cards .val { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.result-actions { display: flex; flex-direction: column; gap: 10px; }

@media (min-width: 820px) {
  .hud { padding: 24px 28px 0; }
  .hud-score .val { font-size: 56px; }
  .hud-best .val { font-size: 20px; }
  .toast { font-size: 28px; }
  .hint { bottom: 36px; font-size: 15px; }
}
@media (max-height: 520px) {
  .result-score { font-size: 64px; }
  .result-col { gap: 12px; }
  .panel h2 { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
  .toast.show { animation-duration: 0.01s; }
}

/* ---------- Fusion Core (page-element game) ---------- */
.fc {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 124px 16px 84px; pointer-events: none; --fc-font: 36px;
}
.fc-board { position: relative; flex-shrink: 0; border-radius: 16px; background: var(--stage-2); border: 1px solid var(--stage-line); pointer-events: auto; }
.fc-cells, .fc-tiles { position: absolute; inset: 6px; }
.fc-cells { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: repeat(4, 1fr); }
.fc-cells span { margin: 4px; border-radius: 10px; background: #1B1C1D; }
.fc-tile { position: absolute; left: 0; top: 0; width: 25%; height: 25%; transition: transform 0.11s ease-out; }
.fc-face {
  position: absolute; inset: 4px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: var(--fc-font); font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em;
  background: #34383B; color: #D5D8DA;
}
.fc-face.small { font-size: calc(var(--fc-font) * 0.72); }
.fc-face.pop { animation: fc-pop 0.16s ease-out; }
.fc-face.gone { animation: fc-gone 0.2s ease-in forwards; }
@keyframes fc-pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes fc-gone { 100% { transform: scale(0.2) rotate(25deg); opacity: 0; } }
.fc-face.v4 { background: #45494D; color: #F7F9FA; }
.fc-face.v8 { background: #62676C; color: #F7F9FA; }
.fc-face.v16 { background: #7A2600; color: #F7F9FA; }
.fc-face.v32 { background: #C93C00; color: #FFFFFF; }
.fc-face.v64 { background: var(--accent); color: #18191A; }
.fc-face.v128 { background: var(--accent-2); color: #18191A; }
.fc-face.v256 { background: #FFDD6E; color: #18191A; }
.fc-face.v512 { background: #FFF3D1; color: #18191A; box-shadow: 0 0 22px rgba(246, 199, 59, 0.5); }
.fc-face.v1024, .fc-face.v2048 { background: #FFFFFF; color: #18191A; box-shadow: 0 0 28px rgba(255, 255, 255, 0.55); }
.fc.armed .fc-tile { cursor: pointer; }
.fc.armed .fc-face { outline: 2px dashed var(--accent-2); outline-offset: -3px; }
.fc-core {
  width: 100%; max-width: 460px; display: flex; align-items: center; gap: 14px; padding: 12px 14px;
  border-radius: 12px; background: var(--stage-2); border: 1px solid var(--stage-line); pointer-events: auto;
}
.fc-meter { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.fc-meter-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.fc-meter-top span { font-size: 11px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--stage-muted); }
.fc-meter-top b { font-size: 13px; font-weight: 600; }
.fc-bar { height: 8px; border-radius: 4px; background: var(--stage-line); overflow: hidden; }
.fc-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(0); transition: transform 0.2s ease-out; }
.fc-blast {
  min-width: 84px; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--accent-2);
  background: var(--accent-2); color: #18191A; font-size: 15px; font-weight: 700; cursor: pointer;
}
.fc-blast:disabled { background: transparent; border-color: var(--stage-line); color: var(--stage-muted); cursor: default; }
