:root {
  color-scheme: light;
  --paper: oklch(97.6% 0.011 85); --paper-2: oklch(94% 0.016 85); --paper-3: oklch(89.5% 0.022 85);
  --card: oklch(99.4% 0.004 85);
  --ink: oklch(27% 0.035 215); --ink-2: oklch(40% 0.035 215); --muted: oklch(52% 0.03 215);
  --rule: oklch(88% 0.02 85);
  --accent: oklch(64% 0.1 188); --accent-soft: oklch(92.5% 0.04 188); --accent-ink: oklch(30% 0.06 200);
  --sun: oklch(79% 0.15 72); --sun-soft: oklch(94% 0.05 80);
  --red: oklch(58% 0.17 30);
  --font: "Outfit", system-ui, sans-serif;
  --radius: 18px; --pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --t-sm: 0.875rem; --t-md: 1rem; --t-lg: 1.2rem; --t-xl: 1.6rem; --t-2xl: 2.2rem; --t-3xl: 3.2rem; --t-4xl: 4.4rem;
  --dur: 140ms; --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --page: 30rem;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body { margin: 0; min-height: 100dvh; background: var(--paper); color: var(--ink); font: 400 var(--t-md)/1.5 var(--font); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: clip; }
h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
h1, h2 { font-weight: 800; line-height: 1.02; letter-spacing: -0.02em; text-wrap: balance; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.noscript { padding: var(--s-5); }

.page { max-width: var(--page); margin-inline: auto; padding: calc(var(--s-6) + var(--safe-t)) calc(var(--s-4) + var(--safe-r)) calc(var(--s-7) + var(--safe-b)) calc(var(--s-4) + var(--safe-l)); }
.page--stage { min-height: 100dvh; display: flex; flex-direction: column; gap: var(--s-3); padding-top: calc(var(--s-2) + var(--safe-t)); padding-bottom: calc(var(--s-5) + var(--safe-b)); }

.masthead h1 { font-size: var(--t-3xl); display: flex; align-items: center; gap: 0.18em; }
.masthead h1::after { content: ""; width: 0.42em; height: 0.42em; border-radius: 50%; background: radial-gradient(circle, var(--sun) 0 30%, transparent 31% 52%, var(--accent) 53% 100%); transform: translateY(0.06em); }
.lead { margin-top: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.35; max-width: 32ch; text-wrap: pretty; }

.block { margin-top: var(--s-6); }
.label { display: block; margin-bottom: var(--s-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); line-height: 1.3; }
.note { font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }
.center { text-align: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 48px; padding: var(--s-2) var(--s-5); border: 0; border-radius: var(--pill); background: var(--paper-2); color: var(--ink); font-weight: 600; font-size: var(--t-md); cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear, transform var(--dur) var(--ease); }
.btn:hover { background: var(--paper-3); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover { background: var(--ink-2); }
.btn--quiet { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule); }
.btn--quiet:hover { background: var(--paper-2); }
.btn--wide { width: 100%; }
.btn--big { min-height: 58px; font-size: var(--t-lg); }
.btn--armed, .btn--armed:hover { background: var(--accent); color: var(--accent-ink); }
.link { align-self: flex-start; background: none; border: 0; min-height: 44px; padding: var(--s-2) 0; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 0.25em; cursor: pointer; }
.link:hover { color: var(--ink); }

/* home */
.daily { margin-top: var(--s-6); padding: var(--s-5); border-radius: var(--radius); background: var(--card); box-shadow: 0 1px 2px oklch(27% 0.035 215 / 0.06), inset 0 0 0 1px var(--rule); display: grid; gap: var(--s-3); }
.daily__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.daily__head .label { margin: 0; }
.daily__date { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.daily__target { display: flex; align-items: baseline; gap: var(--s-3); }
.daily__kicker { font-size: var(--t-sm); font-weight: 600; color: var(--accent-ink); }
.daily__target b { font-size: var(--t-3xl); font-weight: 800; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.daily__tiles { display: flex; flex-wrap: wrap; gap: var(--s-1); }
.daily__tiles span { min-width: 2.6em; padding: 2px var(--s-2); border-radius: var(--pill); background: var(--paper-2); text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.daily__status { display: flex; align-items: center; gap: var(--s-2); color: var(--ink-2); min-height: 1.5em; }
.mini-stars { display: inline-flex; gap: 1px; }
.mini-stars .star { width: 18px; height: 18px; }
#free-go { margin-top: var(--s-3); }
#next-home { margin-top: var(--s-3); font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-1); }
.stats div { padding: var(--s-3) var(--s-2); border-radius: 12px; background: var(--paper-2); text-align: center; }
.stats dt { font-size: 0.75rem; font-weight: 600; color: var(--muted); line-height: 1.2; }
.stats dd { font-size: var(--t-xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.bars { list-style: none; padding: 0; margin-top: var(--s-3); display: grid; gap: var(--s-1); }
.bars li { display: grid; grid-template-columns: auto minmax(0, 1fr) 2.2em; align-items: center; gap: var(--s-2); }
.bars__stars { display: inline-flex; gap: 1px; }
.bars__stars .star { width: 15px; height: 15px; }
.bars__track { height: 10px; border-radius: var(--pill); background: var(--paper-2); overflow: hidden; }
.bars__fill { display: block; height: 100%; border-radius: var(--pill); background: var(--accent); }
.bars b { font-size: var(--t-sm); text-align: right; font-variant-numeric: tabular-nums; }

.rules { padding-left: 1.3em; display: grid; gap: var(--s-2); color: var(--ink-2); line-height: 1.4; }
.rules li::marker { color: var(--accent); font-weight: 800; }
.keys-note { margin-top: var(--s-3); display: none; }
@media (hover: hover) and (pointer: fine) { .keys-note { display: block; } }

/* play */
.topline { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.step { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.goal { display: grid; justify-items: center; text-align: center; padding: var(--s-2) 0 var(--s-1); }
.goal__kicker { font-size: var(--t-sm); font-weight: 600; color: var(--accent-ink); }
.goal__number { font-size: var(--t-4xl); font-weight: 800; line-height: 1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.goal__near { margin-top: var(--s-1); font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.tile { position: relative; min-height: 72px; border: 0; border-radius: var(--radius); background: var(--card); box-shadow: 0 1px 2px oklch(27% 0.035 215 / 0.08), inset 0 0 0 1px var(--rule); font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: background-color var(--dur) linear, transform var(--dur) var(--ease), box-shadow var(--dur) linear; }
.tile:active:not(:disabled) { transform: scale(0.96); }
.tile--big { background: var(--accent-soft); box-shadow: inset 0 0 0 1px oklch(85% 0.05 188); }
.tile--made { background: var(--sun-soft); box-shadow: inset 0 0 0 1px oklch(87% 0.07 80); }
.tile--gone { background: transparent; box-shadow: inset 0 0 0 1.5px var(--rule); cursor: default; }
.tile[aria-pressed="true"] { background: var(--ink); color: var(--paper); box-shadow: 0 4px 14px oklch(27% 0.035 215 / 0.25); transform: translateY(-2px); }
.tile--fresh { animation: pop 260ms var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .tile:not(.tile--gone)::before { content: attr(data-pos); position: absolute; top: 6px; left: 10px; font-size: 0.7rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
  .tile[aria-pressed="true"]::before { color: oklch(80% 0.02 215); }
  .tile:hover:not(:disabled):not([aria-pressed="true"]) { box-shadow: 0 1px 2px oklch(27% 0.035 215 / 0.08), inset 0 0 0 2px var(--accent); }
}

.ops { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); }
.op { min-height: 56px; border: 0; border-radius: var(--pill); background: var(--paper-2); font-size: 1.8rem; font-weight: 600; line-height: 1; cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear, opacity var(--dur) linear; }
.op:hover { background: var(--paper-3); }
.op[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.op--idle { opacity: 0.5; }

.msg { min-height: 1.4em; font-size: var(--t-sm); font-weight: 600; text-align: center; color: var(--ink-2); line-height: 1.4; }
.msg--bad { color: var(--red); }
.shake { animation: shake 320ms var(--ease); }

.steps { list-style: none; padding: var(--s-2) var(--s-4); display: grid; align-content: start; gap: 2px; border-radius: var(--radius); background: var(--paper-2); font-size: var(--t-lg); font-weight: 600; font-variant-numeric: tabular-nums; flex: 1; min-height: 104px; max-height: 15.5rem; counter-reset: s; }
.steps li { display: flex; gap: var(--s-3); min-height: 32px; align-items: center; counter-increment: s; }
.steps li::before { content: counter(s); width: 1.1em; font-size: var(--t-sm); color: var(--muted); text-align: right; }
.steps .steps__empty { font-size: var(--t-sm); font-weight: 400; color: var(--muted); }
.steps .steps__empty::before { content: none; }
.steps--flat { flex: none; min-height: 0; }
.steps--sol { background: var(--accent-soft); }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }

/* result */
.stars { display: flex; justify-content: center; gap: var(--s-2); margin-top: var(--s-3); }
.star { width: 52px; height: 52px; fill: var(--paper-3); }
.star.on { fill: var(--sun); }
.stars .star.on { animation: pop 420ms var(--ease) both; }
.stars .star:nth-child(2) { animation-delay: 120ms; }
.stars .star:nth-child(3) { animation-delay: 240ms; }
.title { font-size: var(--t-2xl); text-align: center; }
.outcome { font-size: var(--t-lg); font-weight: 600; line-height: 1.35; padding: var(--s-4) var(--s-5); border-radius: var(--radius); background: var(--accent-soft); color: var(--accent-ink); text-wrap: pretty; text-align: center; }
#res-next { font-variant-numeric: tabular-nums; text-align: center; }
#res-shared { min-height: 1.5em; }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); }

@keyframes pop { from { transform: scale(0.82); } to { transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 22.5rem) { :root { --t-3xl: 2.7rem; --t-4xl: 3.8rem; } .tile { font-size: 1.7rem; min-height: 66px; } .stats dd { font-size: var(--t-lg); } }
#play .row { margin-top: auto; }

/* back to games.el.zone, on the home screen only */
.back-home { display: inline-flex; align-items: center; gap: 2px; align-self: flex-start; min-height: 44px; margin: -12px 0 4px -6px; padding: 0 10px 0 4px; border-radius: 999px; color: inherit; opacity: 0.6; font-size: 0.875rem; font-weight: 600; line-height: 1; text-decoration: none; transition: opacity 140ms linear; }
.back-home:hover, .back-home:focus-visible { opacity: 1; }
.back-home svg { flex: none; }
