:root {
  color-scheme: light dark;
  --bg: #e6f2fb;
  --bg-2: #c9e4f7;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-solid: #fbfdff;
  --ink: #17233a;
  --muted: #5b6b85;
  --line: rgba(23, 35, 58, 0.12);
  --accent: #38a3e8;
  --accent-deep: #1f7fc0;
  --accent-ink: #ffffff;
  --gold: #f2b51c;
  --gold-dim: rgba(23, 35, 58, 0.16);
  --bad: #e0483b;
  --water: #6fb6ee;
  --radius: 18px;
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --display-weight: 400; /* the weight hub/game.css gives display text */
  --text: Rubik, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: rgba(30, 45, 80, 0.2);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1428;
    --bg-2: #15233f;
    --panel: rgba(28, 38, 62, 0.82);
    --panel-solid: #1a2440;
    --ink: #e5ecfa;
    --muted: #94a3c2;
    --line: rgba(220, 230, 255, 0.11);
    --accent: #4fb3f0;
    --accent-deep: #2b8fd2;
    --accent-ink: #04182a;
    --gold: #f6c945;
    --gold-dim: rgba(220, 230, 255, 0.16);
    --bad: #ff6457;
    --water: #0f1d38;
    --shadow: rgba(0, 0, 0, 0.5);
  }
}
html { -webkit-text-size-adjust: 100%; height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  height: 100dvh;
  background: radial-gradient(120% 70% at 50% -10%, var(--bg-2), var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font: 500 15px/1.4 var(--text);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

.app {
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(6px, env(safe-area-inset-top)) 12px max(8px, env(safe-area-inset-bottom));
}

/* ---------------------------------------------------------------- header */
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding: 2px 0 6px; }
.logo {
  margin: 0;
  font: 400 32px/1 var(--display);
  letter-spacing: 0.5px;
  color: var(--accent-deep);
  text-shadow: 0 2px 0 var(--shadow);
}
@media (prefers-color-scheme: dark) { .logo { color: var(--accent); } }
.day { margin: 2px 0 0; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.2px; }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- hud */
.hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  margin-bottom: 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.tries { display: flex; gap: 4px; align-items: center; }
.tr {
  display: grid;
  place-items: center;
  min-width: 26px;
  height: 22px;
  padding: 0 4px;
  border-radius: 6px;
  border: 1.5px dashed var(--line);
  font: 700 12px/1 var(--text);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  transition: transform 0.2s, background 0.2s;
}
.tr.next { border: 1.5px solid var(--accent-deep); }
.tr.live { border: 0; background: var(--accent); color: var(--accent-ink); animation: bob 0.9s ease-in-out infinite; }
.tr.used { border: 0; background: var(--gold-dim); color: var(--ink); }
.inf { font: 400 20px/1 var(--display); color: var(--muted); margin-left: 4px; }
@keyframes bob { 50% { transform: translateY(-2px); } }
.clock { text-align: center; }
.clock b { display: block; font: 400 26px/1 var(--display); font-variant-numeric: tabular-nums; letter-spacing: 0.5px; min-width: 4.4ch; }
.clock small, .marks span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }
.marks { display: flex; flex-direction: column; align-items: flex-end; gap: 0; }
.marks b { font: 600 13px/1.2 var(--text); color: var(--ink); text-transform: none; letter-spacing: 0; font-variant-numeric: tabular-nums; margin-left: 3px; }

/* ---------------------------------------------------------------- stage */
.stage {
  position: relative;
  flex: 1;
  min-height: 240px;
  display: flex;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius);
}
.stage { cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; }
#cv {
  display: block;
  border-radius: var(--radius);
  box-shadow: 0 10px 30px -12px var(--shadow), 0 0 0 1px var(--line);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  background: var(--water);
}
.prompt {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translate(-50%, -8px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(12, 24, 14, 0.72);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
}
.prompt.on { opacity: 1; transform: translate(-50%, 0); }
.prompt.gold { background: rgba(60, 40, 0, 0.75); color: #ffe48a; }
.card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100% - 32px));
  padding: 18px 18px 16px;
  border-radius: 20px;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.45);
  text-align: center;
  animation: pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.card[hidden] { display: none; }
@media (prefers-color-scheme: dark) { .cd-kicker { color: var(--accent); } }
.cd-time small { font-size: 22px; color: var(--muted); }
.cd-stars, .res-stars { display: flex; justify-content: center; gap: 4px; margin: 6px 0 0; font-size: 28px; line-height: 1; }
.cd-stars span, .res-stars span { color: var(--gold-dim); }
.cd-stars span.on, .res-stars span.on { color: var(--gold); animation: star 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes star { from { transform: scale(0.2) rotate(-40deg); opacity: 0; } }

.foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; min-height: 44px; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.foot .btn + .btn { margin-left: 0; }
.foot .btn { flex: none; }
#btnToday { margin-left: auto; }
.hint .tc { display: none; }
@media (pointer: coarse) { .hint .kb { display: none; } .hint .tc { display: inline; } }

/* ---------------------------------------------------------------- buttons */
.btn:active { transform: scale(0.97); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost:hover { background: var(--panel); }
.btn.wide { margin-top: 14px; }
.btn:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--water); outline-offset: 2px; }

/* ---------------------------------------------------------------- dialogs */
@keyframes pop { from { opacity: 0; transform: translate(var(--tx, 0), var(--ty, 0)) scale(0.94); } }
.card { --tx: -50%; --ty: -50%; }
.close:focus { outline: none; }
.close:focus-visible { outline: 3px solid var(--water); }
.how-list li { display: grid; grid-template-columns: 52px 1fr; gap: 10px; align-items: center; font-size: 14px; }
.mini { position: relative; width: 52px; height: 36px; border-radius: 10px; overflow: hidden; background: linear-gradient(#8fcaf5, #e3f3ff); }
.mini.warm { background: linear-gradient(#8fcaf5, #ffe3c2); }
.mini.cool { background: linear-gradient(#7a8aa8, #c9d3e6); }
.mini i { position: absolute; }
.mini .pl { left: 14px; top: 13px; width: 24px; height: 10px; background: #fff; clip-path: polygon(100% 50%, 0 0, 18% 60%, 0 100%); filter: drop-shadow(0 1px 0 rgba(30, 40, 60, 0.4)); }
.mini .pl.up { animation: pitch 1.6s ease-in-out infinite; }
.mini .pl.dn { transform: rotate(14deg); }
.mini .dot { width: 3px; height: 3px; border-radius: 50%; background: #f0a050; bottom: 0; animation: rise 1.5s linear infinite; }
.mini .d1 { left: 10px; } .mini .d2 { left: 26px; animation-delay: 0.5s; } .mini .d3 { left: 40px; animation-delay: 1s; }
.mini .rain { width: 1.5px; height: 6px; background: #4a5a80; top: 0; animation: fall 0.9s linear infinite; }
.mini .r1 { left: 12px; } .mini .r2 { left: 38px; animation-delay: 0.45s; }
@keyframes pitch { 50% { transform: rotate(-16deg) translateY(-3px); } }
@keyframes rise { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-36px); opacity: 0; } }
@keyframes fall { from { transform: translateY(0); } to { transform: translateY(40px); } }
.section-h { margin: 16px 0 6px; font: 700 12px/1 var(--text); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.keys { margin: 10px 0 0; font-size: 13px; color: var(--muted); line-height: 1.9; }
.kicker { color: var(--muted); }
.res-hero { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 10px 0 2px; flex-wrap: wrap; }
.res-time { font: 400 44px/1 var(--display); font-variant-numeric: tabular-nums; }
.res-line { margin: 4px 0 0; text-align: center; color: var(--muted); font-weight: 600; font-size: 14px; }
.res-unit { font: 600 15px/1 var(--text); color: var(--muted); margin-left: -8px; align-self: flex-end; padding-bottom: 6px; }
.res-line.small { font-size: 12px; font-weight: 500; }
.cd-unit { margin: 2px 0 0; color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.8px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.wd.today i { border: 2px dashed var(--accent-deep); }
.wd.s3 i { background: var(--gold); color: #2a1d00; border-color: transparent; }
.wd.s2 i { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.wd.s1 i { background: color-mix(in srgb, var(--accent) 40%, transparent); border-color: transparent; }
.wd.lost i { color: var(--bad); }
.legend { margin: 6px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.lg { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 3px 0 8px; vertical-align: -1px; }
.lg.s3 { background: var(--gold); }
.lg.s2 { background: var(--accent); }
.lg.s1 { background: color-mix(in srgb, var(--accent) 40%, transparent); }

.toast { z-index: 10; }

@media (max-width: 380px) {
  .app { padding-left: 8px; padding-right: 8px; }
  .clock b { font-size: 22px; }
  .tr { min-width: 22px; }
  .hint { font-size: 11px; }
}
/* the same for the site-wide Reduce motion setting (hub/prefs.js) */
