:root {
  --bg: #f7edd5; --panel: #fffaf0; --ink: #2e2c30; --muted: #6a6254; --honey: #f7c21b; --honey-dark: #c99600;
  --btn: #fff3c4; --line: #e4d3a0; --shade: rgba(46, 44, 48, 0.45); --err-bg: #fde3df; --err-ink: #7a1f14;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17140e; --panel: #2a2519; --ink: #f3e8cc; --muted: #b9ad92; --honey: #f7c21b; --honey-dark: #f7c21b; --btn: #3a3322; --line: #4a4129; --shade: rgba(0, 0, 0, 0.6); --err-bg: #4a1f19; --err-ink: #ffd6cf; }
  .btn.primary { color: #25222a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 18px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow: hidden; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.hidden { display: none !important; }
.screen { position: fixed; inset: 0; }

/* ----- home ----- */
#home { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(env(safe-area-inset-top) + 20px) calc(env(safe-area-inset-right) + 16px) calc(env(safe-area-inset-bottom) + 24px) calc(env(safe-area-inset-left) + 16px); }
.wrap { max-width: 560px; margin: 0 auto; }
h1 { font-size: 1.9rem; line-height: 1.15; margin: 8px 0 6px; }
.lead { font-size: 1.15rem; margin: 0 0 18px; }
.samples { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.sample { width: 100%; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sample small { font-weight: 500; color: var(--muted); }
.offline { background: var(--panel); color: var(--ink); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; margin: -6px 0 16px; font-size: 0.95rem; font-weight: 600; }
.sample:disabled { opacity: 0.6; cursor: default; border-color: var(--line); }
.sample:disabled:active { transform: none; }
.note { color: var(--muted); font-size: 0.95rem; margin: 12px 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.error { background: var(--err-bg); color: var(--err-ink); border-radius: 12px; padding: 12px 14px; margin-top: 14px; font-weight: 600; -webkit-user-select: text; user-select: text; }
body.dropping #home { outline: 4px dashed var(--honey-dark); outline-offset: -12px; }

.btn { min-height: 44px; min-width: 44px; padding: 10px 16px; border-radius: 14px; border: 2px solid var(--ink); background: var(--btn); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--honey-dark); outline-offset: 2px; }
.btn.primary { background: var(--honey); border-color: #25222a; color: #25222a; }
.btn.big { min-height: 64px; min-width: 220px; font-size: 1.5rem; border-radius: 20px; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }

/* ----- play ----- */
#stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
#bar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 10px) 8px calc(env(safe-area-inset-left) + 10px); pointer-events: none; }
#bar > * { pointer-events: auto; }
#stats { display: flex; gap: 14px; align-items: baseline; font-size: 1.05rem; }
#stats .lab { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
#stats b { font-variant-numeric: tabular-nums; font-size: 1.25rem; }
.chip { position: absolute; left: calc(env(safe-area-inset-left) + 12px); top: calc(env(safe-area-inset-top) + 62px); background: var(--panel); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 14px; font-weight: 700; pointer-events: none; }
.offline-chip { position: absolute; left: calc(env(safe-area-inset-left) + 12px); bottom: calc(env(safe-area-inset-bottom) + 100px); max-width: min(340px, calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right))); background: var(--panel); color: var(--ink); border: 2px solid var(--line); border-radius: 14px; padding: 4px 12px; font-size: 0.9rem; font-weight: 600; line-height: 1.3; pointer-events: none; }
#actions { position: absolute; left: 0; right: 0; bottom: 0; height: calc(env(safe-area-inset-bottom) + 92px); display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 12px env(safe-area-inset-bottom); pointer-events: none; }
#actions > * { pointer-events: auto; }
#clear { position: absolute; right: calc(env(safe-area-inset-right) + 12px); bottom: calc(env(safe-area-inset-bottom) + 24px); }

.overlay { position: absolute; inset: 0; background: var(--shade); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 5; }
.panel { background: var(--panel); color: var(--ink); border: 3px solid var(--ink); border-radius: 22px; padding: 20px 22px; width: min(100%, 460px); max-height: 100%; overflow: auto; text-align: center; }
.panel h2 { font-size: 2rem; margin: 4px 0 8px; }
.panel h3 { margin: 14px 0 6px; font-size: 1.05rem; }
.panel .row { justify-content: center; }
.fin-line { font-size: 1.3rem; margin: 6px 0; font-weight: 700; }
#top-list { margin: 0 auto; padding-left: 1.6em; display: inline-block; text-align: left; font-variant-numeric: tabular-nums; }
#top-list li.you { font-weight: 800; background: var(--honey); color: #25222a; border-radius: 6px; padding: 0 6px; }
#how-list { text-align: left; font-size: 1.3rem; line-height: 1.4; padding-left: 1.2em; margin: 8px 0; }
#how-list li { margin: 8px 0; }


@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }

#release h2 { font-size: 18px; margin: 18px 0 8px; }

/* Shared page: code gate and notes */
.code { font: 700 1.6rem/1.2 ui-monospace, Menlo, monospace; text-align: center; letter-spacing: 0.08em; padding: 12px; border-radius: 14px; border: 2px solid var(--ink); background: var(--panel); color: var(--ink); width: min(100%, 320px); -webkit-user-select: text; user-select: text; }
#notes-text { width: 100%; box-sizing: border-box; font: inherit; padding: 10px; border-radius: 12px; border: 2px solid var(--ink); background: var(--bg); color: var(--ink); -webkit-user-select: text; user-select: text; }
body.share #menu, body.share #fin-menu { display: none; }
