:root {
  color-scheme: light;
  --paper: oklch(97.6% 0.012 85); --paper-2: oklch(94% 0.018 85); --paper-3: oklch(90% 0.024 85);
  --ink: oklch(26% 0.025 60); --ink-2: oklch(41% 0.025 60); --muted: oklch(53% 0.02 60);
  --rule: oklch(87% 0.022 85);
  --accent: oklch(64% 0.1 172); --accent-soft: oklch(91.5% 0.05 172); --accent-ink: oklch(33% 0.07 172);
  --amber: oklch(76% 0.13 72); --amber-soft: oklch(93% 0.06 80); --amber-ink: oklch(42% 0.09 60);
  --red: oklch(57% 0.17 28); --red-soft: oklch(93% 0.04 28);
  --font: "Figtree", system-ui, sans-serif;
  --radius: 18px; --pill: 999px; --tile: 12px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px;
  --t-xs: 0.75rem; --t-sm: 0.875rem; --t-md: 1rem; --t-lg: 1.25rem; --t-xl: 1.6rem; --t-2xl: 2.2rem;
  --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 { margin: 0; }
h1, h2 { font-weight: 800; line-height: 1.05; 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-5) + var(--safe-t)) calc(var(--s-4) + var(--safe-r)) calc(var(--s-6) + var(--safe-b)) calc(var(--s-4) + var(--safe-l)); }
.page--stage { min-height: 100dvh; display: flex; flex-direction: column; gap: var(--s-4); padding-top: calc(var(--s-3) + var(--safe-t)); }
.page--play { height: 100dvh; display: flex; flex-direction: column; gap: var(--s-2); padding-top: calc(var(--s-2) + var(--safe-t)); padding-bottom: calc(var(--s-3) + var(--safe-b)); }

/* top bar */
.bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 52px; }
.logo { font-size: var(--t-xl); }
.logo::after { content: ""; display: inline-block; width: 0.5em; height: 0.16em; margin-left: 0.1em; border-radius: 2px; background: var(--accent); vertical-align: 0.05em; }
.sub { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.bar__icons { display: flex; gap: var(--s-1); }
.icon { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: none; color: var(--ink-2); cursor: pointer; touch-action: manipulation; }
.icon:hover { background: var(--paper-2); color: var(--ink); }

.meta { display: flex; gap: var(--s-2); font-size: var(--t-sm); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.meta span { padding: 2px var(--s-3); border-radius: var(--pill); background: var(--paper-2); }
.meta b { font-weight: 800; color: var(--ink); }

/* ladder */
.ladder { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-2) 0 0; scrollbar-width: none; }
.ladder.scrolled { -webkit-mask-image: linear-gradient(transparent, #000 var(--s-4)); mask-image: linear-gradient(transparent, #000 var(--s-4)); }
.ladder::-webkit-scrollbar { display: none; }
.rows { list-style: none; padding: 0; display: grid; gap: var(--s-2); justify-content: center; }
.row { position: relative; display: flex; align-items: center; justify-content: center; }
.row__n { position: absolute; right: 100%; margin-right: var(--s-3); width: 2em; text-align: right; font-size: var(--t-xs); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.word { display: grid; grid-template-columns: repeat(4, var(--tw, 52px)); gap: 6px; }
.tile { height: var(--th, 52px); display: grid; place-items: center; border-radius: var(--tile); background: var(--paper-2); font-size: 1.6rem; font-weight: 800; text-transform: uppercase; line-height: 1; letter-spacing: 0; user-select: none; -webkit-user-select: none; }
.row--start .tile { background: var(--ink); color: var(--paper); }
.tile.changed { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.row--hinted .tile.changed { background: var(--amber-soft); color: var(--amber-ink); box-shadow: inset 0 0 0 1.5px var(--amber); }
.row--hinted .row__n::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 4px; border-radius: 50%; background: var(--amber); vertical-align: 0.1em; }
.row--input .tile { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--rule); }
.row--input .tile.filled { box-shadow: inset 0 0 0 2px var(--ink-2); animation: pop 120ms var(--ease); }
.row--input .tile.next { box-shadow: inset 0 0 0 2px var(--accent); }
.row--input.bad .tile.filled { box-shadow: inset 0 0 0 2px var(--red); color: var(--red); }
.row.shake { animation: shake 360ms var(--ease); }
.row--new { animation: rise 260ms var(--ease) both; }
.row--path .tile { background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--rule); color: var(--ink-2); }

.gap { width: 2px; height: 22px; margin: 6px auto 0; background: repeating-linear-gradient(var(--rule) 0 4px, transparent 4px 8px); }
.goal { position: sticky; bottom: 0; z-index: 1; display: flex; justify-content: center; padding: var(--s-2) 0 2px; background: var(--paper); }
.goal .tile { background: var(--paper); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent-ink); }
.goal.reached .tile { background: var(--accent); color: oklch(99% 0.01 172); box-shadow: none; }
.goal.missed .tile { box-shadow: inset 0 0 0 2px var(--rule); color: var(--muted); }

.msg { min-height: 1.5em; text-align: center; font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.msg.bad { color: var(--red); }
.msg.good { color: var(--accent-ink); }

/* controls */
.controls { display: grid; gap: var(--s-3); }
.tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.tools .btn { min-height: 44px; padding-inline: var(--s-2); font-size: var(--t-sm); }
.btn--warn { background: var(--red-soft); box-shadow: inset 0 0 0 1.5px var(--red); color: var(--red); }
.btn--warn:hover { background: var(--red-soft); }
.keys { display: grid; gap: 7px; user-select: none; -webkit-user-select: none; }
.keys__row { display: flex; justify-content: center; gap: 5px; }
.key { flex: 1 1 0; min-width: 0; max-width: 44px; height: 52px; padding: 0; border: 0; border-radius: 10px; background: var(--paper-3); font-size: 1.1rem; font-weight: 600; text-transform: uppercase; cursor: pointer; touch-action: manipulation; transition: background-color var(--dur) linear; }
.key:hover { background: oklch(86% 0.026 85); }
.key:active { background: var(--rule); }
.key--wide { flex-grow: 1.6; max-width: 70px; font-size: var(--t-xs); font-weight: 800; text-transform: none; }
.key--enter { background: var(--ink); color: var(--paper); }
.key--enter:hover, .key--enter:active { background: var(--ink-2); }
.key svg { display: block; margin: auto; }
.finished { display: grid; gap: var(--s-2); }

/* buttons */
.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: 56px; font-size: var(--t-lg); }
.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); }
.link.center-self { align-self: center; justify-self: center; }

/* other screens */
.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; }
.title { font-size: var(--t-2xl); }
.kicker { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); margin-bottom: calc(var(--s-3) * -1); }
.label { display: block; margin-bottom: var(--s-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.note { font-size: var(--t-sm); color: var(--muted); text-wrap: pretty; }
.rules { padding-left: 1.3em; display: grid; gap: var(--s-2); color: var(--ink-2); font-size: var(--t-lg); line-height: 1.35; }
.rules li::marker { color: var(--accent); font-weight: 800; }
.example { display: grid; justify-content: center; gap: 5px; padding: var(--s-4); border-radius: var(--radius); background: var(--paper-2); }
.mini { display: grid; grid-template-columns: repeat(4, 34px); gap: 4px; }
.mini i { height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--paper); font-style: normal; font-weight: 800; text-transform: uppercase; }
.mini:first-child i { background: var(--ink); color: var(--paper); }
.mini i.on { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1.5px var(--accent); }
.mini--goal i { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent-ink); }
.mini--goal i.on { box-shadow: inset 0 0 0 1.5px var(--accent); }
.page--stage > .btn--big:last-child { margin-top: auto; }

.tiles4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-2); }
.tiles4--three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { padding: var(--s-3) var(--s-2); border-radius: var(--radius); background: var(--paper-2); text-align: center; }
.stat b { display: block; font-size: var(--t-xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { display: block; margin-top: 2px; font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); line-height: 1.2; }
.tiles4:not(.tiles4--three) .stat b { font-size: 1.4rem; }
.stat.good { background: var(--accent-soft); }
.stat.good b { color: var(--accent-ink); }
.bars { list-style: none; padding: 0; display: grid; gap: 6px; }
.bars li { display: grid; grid-template-columns: 4.6rem 1fr; align-items: center; gap: var(--s-2); font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.bars .fill { min-width: 2rem; width: var(--w, 0%); height: 28px; padding: 0 var(--s-2); display: flex; align-items: center; justify-content: flex-end; border-radius: 8px; background: var(--paper-3); color: var(--ink); font-variant-numeric: tabular-nums; }
.bars li.now .fill { background: var(--accent); color: oklch(99% 0.01 172); }
.clock { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); text-align: center; font-variant-numeric: tabular-nums; }

.paths { display: grid; gap: var(--s-3); }
.path { padding: var(--s-3) var(--s-4); border-radius: var(--radius); background: var(--paper-2); }
.path h3 { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s-1); }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em; }
.chain .sep { color: var(--muted); font-weight: 400; }
.chain .h { color: var(--amber-ink); }
.stack { display: grid; gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); }

@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes pop { from { transform: scale(0.92); } to { transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (max-width: 22.6rem) { :root { --t-2xl: 1.9rem; } .key { height: 48px; } }
@media (max-height: 700px) { :root { --tw: 46px; --th: 44px; } .tile { font-size: 1.35rem; } .key { height: 46px; } .page--play { gap: 6px; } }

/* 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; }
.back-home--icon { margin: 0 2px 0 -10px; padding: 0 4px; }
.back-home--icon span { display: none; }
.back-home--icon + .bar__title { flex: 1; min-width: 0; }
