@charset "UTF-8";
/* ---------------------------------------------------------------
   More or Less — game styles
   The @charset rule above must stay the literal first bytes of this file
   (no BOM, nothing before it, not even a comment) -- it's what fixes the
   ★ in .new-best::before rendering as "â˜…" on the live server. CSS's
   default fallback encoding (unlike HTML5, which defaults to UTF-8) is
   historically Latin-1/ISO-8859-1, so without this the browser only gets
   the right encoding if the server's Content-Type header happens to
   declare charset=utf-8 for .css -- many NAS/shared-host web servers
   don't. This rule takes precedence over that regardless of what the
   server sends.
   No external fonts/CDNs: system font stack only (Poki: no external
   requests). Palette chosen to be distinguishable under deuteranopia/
   protanopia/tritanopia; every state also carries a shape/icon cue,
   never color alone (spec section 9).
   ----------------------------------------------------------------*/

:root {
  --bg: #10151f;
  --panel: #1a2233;
  --panel-2: #222c42;
  --text: #f4f6fb;
  --text-dim: #9aa5b8;
  --more: #3b82f6;      /* blue  */
  --more-dim: #1e3a63;
  --less: #f59e0b;      /* amber */
  --less-dim: #5c3d10;
  --good: #22c55e;
  --bad: #ef4444;
  --highlight: #22d3ee;  /* cyan -- the specific number being challenged, distinct from more/less/good/bad */
  --bonus: #e879f9;      /* fuchsia -- Swap Question only; deliberately its own hue, not reused
                            from --highlight, so it doesn't dilute the "number being challenged" cue */
  --bonus-dim: #4a1f52;
  --radius: 14px;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  /* WCAG AA baseline: body text on --bg exceeds 4.5:1 */
}

.stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 14px 16px 20px;
  overflow: hidden;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.hud-streak, .hud-best { display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.hud-label { font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim); }
.hud-value { font-size: 1.6rem; font-weight: 700; }
.icon-btn {
  background: var(--panel);
  border: 1px solid #2c3750;
  color: var(--text-dim);
  border-radius: 999px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); }

/* ---------- Board ---------- */
.board {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  min-height: 0;
}

.card {
  background: var(--panel);
  border: 1px solid #2c3750;
  border-radius: var(--radius);
  padding: 28px 22px;
  text-align: center;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.card-flag { font-size: 3.2rem; line-height: 1; }
.card-name { font-size: 1.3rem; font-weight: 600; margin-top: 8px; }
.card-year { font-size: 0.85rem; color: var(--text-dim); margin-top: 2px; }
.card-tag { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }

.statement {
  font-size: 1.3rem;
  margin: 10px 0 2px;
}
.statement strong { font-size: 1.5rem; letter-spacing: 0.02em; color: var(--highlight); }

.reveal-row {
  margin-top: 10px;
  font-size: 1rem;
  color: var(--text-dim);
  border-top: 1px solid #2c3750;
  padding-top: 10px;
}
.reveal-row strong { color: var(--text); }
.reveal-row.hidden { display: none; }

.card.reveal-correct { border-color: var(--good); background: #16281c; }
.card.reveal-wrong   { border-color: var(--bad);  background: #2a1616; }

.prompt {
  text-align: center;
  font-size: 0.95rem;
  color: var(--text-dim);
  margin: 10px 0 4px;
}
.prompt strong { color: var(--text); }

/* ---------- Swap Question (unlocks past streak 5 -- see main.js) ----------
   First pass (cyan + gentle pulse) still got missed -- a static-colored
   button below the fold of a player's attention (which is on the card
   above, not the controls) needs something louder than idle styling.
   Three layers now, loudest first:
     1. swapToast -- a banner that pops in near the HUD the instant the
        button becomes available, independent of whether the player is
        looking at the button at all.
     2. swap-btn-enter -- a one-shot bounce-in on the button itself when
        it first appears (or upgrades to the ad version).
     3. swap-pulse -- the ongoing idle breathing glow, for anyone who
        looks away and back later.
   Color moved off --highlight (cyan) to its own hue (--bonus, fuchsia) --
   reusing --highlight here would have diluted its one existing job
   (marking the specific number being challenged). Fuchsia doesn't
   collide with any other state color in the palette (more=blue,
   less=amber, good=green, bad=red), so it reads as "this is a distinct,
   special thing," which is exactly the point. */
.swap-btn {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid var(--bonus);
  background: rgba(232, 121, 249, 0.16);
  color: #fbcfff;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
  animation: swap-pulse 1.8s ease-in-out infinite;
}
/* Ad-gated version deliberately looks and behaves LESS exciting than the
   free swap, not just differently colored -- same muted, no-glow
   treatment as the existing revive-btn ("watch ad" already means this
   look elsewhere in the app). Using a lighter shade of the same fuchsia
   would read as "another free bonus, just fancier," which is exactly
   the ambiguity to avoid: a player should be able to tell at a glance,
   before reading the label, that this one is going to ask for an ad. */
.swap-btn.swap-btn-reward {
  border-color: #3c4a68;
  background: transparent;
  color: var(--text);
  animation: none !important;
  box-shadow: none !important;
}
.swap-btn.swap-btn-enter {
  animation: swap-enter 550ms cubic-bezier(0.34, 1.56, 0.64, 1) 1, swap-pulse 1.8s ease-in-out infinite 550ms;
}
@keyframes swap-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 121, 249, 0.55); transform: scale(1); }
  50%      { box-shadow: 0 0 0 10px rgba(232, 121, 249, 0); transform: scale(1.025); }
}
@keyframes swap-enter {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.swap-btn:disabled { opacity: 0.5; cursor: default; animation: none; box-shadow: none; }
.swap-btn.hidden { display: none; }

/* Banner that fires the moment Swap Question becomes available -- catches
   attention even if the player isn't looking at the controls yet. */
.swap-toast {
  position: absolute;
  left: 50%;
  top: 58px;
  transform: translateX(-50%) translateY(-14px);
  background: linear-gradient(135deg, var(--bonus), #a855f7);
  color: #2a0a30;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 9px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(232, 121, 249, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease, transform 260ms ease;
  z-index: 20;
  white-space: nowrap;
}
.swap-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Confetti (streak milestones -- every 5, see main.js) ----------
   Falls from the stage's top edge and must be fully faded out by 35% of
   the stage's height -- the layer itself IS that top-35% band (height:35%
   of .stage, which is position:relative), so animating a piece's
   translateY from 0 to the layer's own pixel height (set per-piece via
   --fall in JS, since percentage-based transforms don't support this
   directly) lands it exactly at the bottom edge of the band at the same
   moment opacity reaches 0. overflow:hidden is a belt-and-suspenders
   clip in case any piece's rotation pushes it a pixel past that edge. */
.confetti-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 35%;
  overflow: hidden;
  pointer-events: none;
  z-index: 30;
}
.confetti-piece {
  position: absolute;
  top: 0;
  left: var(--x);
  width: var(--w);
  height: var(--h);
  background: var(--color);
  border-radius: 2px;
  opacity: 1;
  transform: translate(0, 0) rotate(var(--rotate-start));
  animation: confetti-fall var(--duration) linear var(--delay) forwards;
}
@keyframes confetti-fall {
  0%   { transform: translate(0, 0) rotate(var(--rotate-start)); opacity: 1; }
  100% { transform: translate(var(--drift), var(--fall)) rotate(var(--rotate-end)); opacity: 0; }
}

/* ---------- Controls (shape-coded, not color-only) ---------- */
.controls {
  display: flex;
  gap: 14px;
  margin-top: 10px;
}
.guess-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  color: #08101c;
  min-height: 76px;
}
.guess-more {
  background: var(--more);
  border-radius: 999px; /* circle-family shape = "More" */
}
.guess-less {
  background: var(--less);
  border-radius: 10px;  /* square-family shape = "Less" */
}
.guess-btn:active { transform: scale(0.97); }
.guess-btn:disabled { opacity: 0.5; cursor: default; }
.guess-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.source-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-dim);
  margin: 10px 0 0;
}

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.hidden { display: none; }

.overlay-panel {
  background: var(--panel-2);
  border: 1px solid #33405e;
  border-radius: 18px;
  padding: 28px 26px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.overlay-panel h1 { margin: 0 0 6px; font-size: 1.5rem; }
.subtitle { margin: 0 0 4px; color: var(--text-dim); font-weight: 600; }
.subtitle-small { margin: 0 0 18px; color: var(--text-dim); font-size: 0.85rem; }
.overlay-streak { font-size: 1.1rem; margin: 6px 0 2px; }
.overlay-streak span { font-size: 2.2rem; font-weight: 800; display: block; }
.new-best { color: var(--good); font-weight: 700; margin: 4px 0 14px; }
.new-best::before { content: "★ "; }

.play-again-btn, .revive-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 10px;
}
.play-again-btn { background: var(--good); color: #06210f; }
.play-again-btn:disabled { opacity: 0.5; cursor: default; }
.revive-btn {
  background: transparent;
  color: var(--text);
  border: 2px solid #3c4a68;
}
.revive-btn.hidden { display: none; }

.not-saved { font-size: 0.75rem; color: var(--less); margin-top: 12px; }

.credits-panel { max-width: 460px; text-align: left; }
.credits-panel h1 { text-align: center; }
.credits-body { max-height: 40vh; overflow-y: auto; font-size: 0.85rem; line-height: 1.5; margin: 10px 0; }
.credits-body .credit-row { padding: 8px 0; border-bottom: 1px solid #2c3750; }
.credits-body .credit-row:last-child { border-bottom: none; }
.credit-provider { font-weight: 700; }
.credit-meta { color: var(--text-dim); font-size: 0.78rem; }
.disclaimer { font-size: 0.75rem; color: var(--text-dim); }

/* ---------- Responsive: keep single-screen at small sizes ---------- */
@media (max-width: 420px) {
  .card-flag { font-size: 2.4rem; }
  .statement { font-size: 1.1rem; }
  .statement strong { font-size: 1.25rem; }
  .guess-btn { min-height: 64px; font-size: 0.9rem; }
}

@media (max-height: 500px) {
  .card { padding: 8px 14px; }
  .card-flag { font-size: 1.6rem; }
  .controls { margin-top: 6px; }
  .guess-btn { min-height: 56px; padding: 8px; }
}
