/* Colours are the game's own (TipTop/Palette.swift): day in light mode, dusk in dark mode. */
:root {
  --sky-top: #8FC8EA; --sky-bottom: #E4F3FA; --ground: #7FB069;
  --ink: #1F2433; --faint: #4A5468;
  --piece: #FFB066; --outline: #2B2D42; --card: rgba(255, 255, 255, 0.97); --card-ink: #1F2133;
  --gold-soft: #FADB80; --gold: #D6991A; --link: #1D5FA8;
  --font: "Avenir Next", Avenir, "Nunito Sans", ui-rounded, "Segoe UI", system-ui, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --sky-top: #1E2A44; --sky-bottom: #3B5A7A; --ground: #16203A;
    --ink: #F6F1E7; --faint: #B7C3D6;
    --piece: #FFC98B; --link: #A9CCFF;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 17px/1.5 var(--font);
  background: var(--sky-bottom) linear-gradient(var(--sky-top), var(--sky-bottom) 70vh) no-repeat;
}
a { color: var(--link); }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--card); color: var(--card-ink); padding: 8px 12px; border-radius: 10px; z-index: 10; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.top .row { min-height: 56px; }
.brand { font-weight: 800; font-size: 20px; color: var(--ink); text-decoration: none; letter-spacing: 0.01em; }
.top nav { display: flex; gap: 4px; }
.top nav a { color: var(--ink); text-decoration: none; font-weight: 600; padding: 10px 10px; border-radius: 10px; }
.top nav a:hover { text-decoration: underline; }

.hero { padding-top: 8px; padding-bottom: 12px; }
h1 { font-size: clamp(32px, 9vw, 52px); line-height: 1.05; margin: 8px 0 10px; font-weight: 800; letter-spacing: -0.01em; }
.lede { font-size: 18px; color: var(--faint); margin: 0; max-width: 34em; }
h2 { font-size: 24px; line-height: 1.2; margin: 0 0 10px; font-weight: 800; }

/* The demo: full-bleed on a phone so a thumb has the whole width. */
.demo-wrap { padding-top: 4px; }
.stage {
  position: relative; width: 100%; max-width: 560px; margin: 0 auto; border-radius: 22px; overflow: hidden;
  border: 2.5px solid var(--outline); background: var(--sky-bottom);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
@media (max-width: 599px) {
  .demo-wrap { padding-left: 0; padding-right: 0; }
  .stage { border-radius: 0; border-left: 0; border-right: 0; }
}
#game { display: block; width: 100%; touch-action: pan-y; cursor: crosshair; outline: none; }
#game:focus-visible { box-shadow: inset 0 0 0 3px var(--link); }

.hud { position: absolute; inset: 0 0 auto 0; padding: 10px 12px 0; pointer-events: none; z-index: 1; }
.hud-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 8px; }
.hud-left, .hud-right { display: flex; flex-direction: column; font-weight: 700; font-size: 14px; line-height: 1.25; }
.hud-right { text-align: right; align-items: flex-end; }
.faint { color: var(--faint); font-weight: 600; }
.hud-score { font-weight: 800; font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
#goal.met::after {
  content: ""; display: inline-block; width: 13px; height: 13px; margin-left: 5px; vertical-align: -1px;
  background: currentColor;
  /* Lucide "check" */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.spirit-row { grid-template-columns: auto auto; justify-content: center; align-items: center; margin-top: 6px; }
/* Spirit level: the tube spans the seesaw's full tilt; the marked middle is "level" for the balance streak. */
.spirit {
  --tilt: 0; --zone: 0.25;
  position: relative; width: 130px; height: 20px; border-radius: 10px;
  background: rgba(255, 255, 255, 0.9); border: 1.5px solid var(--card-ink);
}
.spirit .zone {
  position: absolute; top: 2.5px; bottom: 2.5px; left: 50%;
  width: calc(var(--zone) * (130px - 20px) + 14px); transform: translateX(-50%);
  background: rgba(250, 219, 128, 0.75); border-left: 2px solid var(--card-ink); border-right: 2px solid var(--card-ink);
  border-radius: 3px;
}
.spirit .bubble {
  position: absolute; top: 2px; left: calc(50% - 7px); width: 13px; height: 13px; border-radius: 50%;
  background: var(--card-ink); transform: translateX(calc(var(--tilt) * (130px - 20px) / 2));
}
.streak { font-weight: 800; font-size: 16px; min-width: 2.2em; }
.caption {
  margin: 8px auto 0; max-width: 22em; text-align: center; font-weight: 600; font-size: 15px; line-height: 1.3;
  min-height: 1.3em; text-wrap: balance;
}

/* Start and end cards, over the seesaw (GameScene's cards: white, rounded). */
.card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  width: min(340px, calc(100% - 24px)); max-height: calc(100% - 16px); overflow: auto; padding: 12px 14px; border-radius: 20px;
  background: var(--card); color: var(--card-ink); border: 1.5px solid #616161; text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.card h3 { margin: 0 0 2px; font-size: 19px; font-weight: 800; }
.card p { margin: 3px 0; }
.card-line { font-size: 14px; color: #3D4253; }
.card-line.strong { color: var(--card-ink); font-weight: 700; }
.card-goal { font-weight: 700; }
.card-score { font-size: 32px; font-weight: 800; line-height: 1; margin: 2px 0 !important; font-variant-numeric: tabular-nums; }
.card-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.card-buttons .btn { flex: 1 1 120px; min-height: 44px; padding: 8px 12px; font-size: 16px; }
.card-buttons .btn.wide { flex-basis: 100%; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 4px 0; }
.star { width: 24px; height: 24px; fill: none; stroke: #9AA0AE; stroke-width: 1.6; stroke-linejoin: round; }
.star.on { fill: var(--gold-soft); stroke: var(--gold); }

/* Buttons look like the pieces: a fill, a dark outline. One primary per screen. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 10px 18px;
  border-radius: 14px; border: 2.5px solid var(--outline); font: 700 17px/1.2 var(--font);
  text-decoration: none; cursor: pointer; color: var(--card-ink);
}
.btn.primary { background: var(--piece); box-shadow: 0 3px 0 var(--outline); }
.btn.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--outline); }
.btn.secondary { background: #FFFFFF; }
.btn.big { font-size: 19px; min-height: 56px; padding: 12px 26px; }
.btn:focus-visible { outline: 3px solid var(--link); outline-offset: 2px; }

.rules { list-style: none; padding: 0; margin: 14px auto 0; max-width: 560px; font-size: 15px; color: var(--faint); }
.rules li { margin: 6px 0; }
.rules strong { color: var(--ink); }
@media (max-width: 599px) { .rules { padding: 0 16px; } }

.beta, .note { padding-top: 36px; }
.cta-row { margin: 18px 0 10px; }
.fine { font-size: 14px; color: var(--faint); }
.sign { font-weight: 700; }

.foot { margin-top: 48px; padding: 18px 0 calc(28px + env(safe-area-inset-bottom)); font-size: 14px; color: var(--faint); border-top: 1.5px solid rgba(127, 127, 127, 0.3); }
.foot a { color: inherit; }

/* Privacy page */
.doc h1 { font-size: clamp(28px, 7vw, 40px); }
.doc section { background: var(--card); color: var(--card-ink); border: 1.5px solid rgba(43, 45, 66, 0.25); border-radius: 18px; padding: 16px 18px; margin: 16px 0; }
.doc section a { color: #1D5FA8; }
.doc ul { padding-left: 20px; }
.doc li { margin: 6px 0; }
.btn[aria-disabled="true"] { opacity: 0.55; cursor: default; box-shadow: none; }
