/* Muda Hunt — game UI. Mobile-first, single ~520px column. */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background:
    radial-gradient(120% 90% at 50% -10%, #131a22 0%, var(--bg) 58%) fixed,
    var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button { font-family: inherit; }
.app { max-width: 520px; margin: 0 auto; min-height: 100%; padding: 22px 16px calc(28px + env(safe-area-inset-bottom)); position: relative; }

/* ---------- Brand bits ---------- */
.brandmark {
  font-family: var(--font-mono);
  letter-spacing: .26em; text-transform: uppercase;
  font-size: 11px; color: var(--ink-faint);
}
.dot { color: var(--accent); }

/* Cadence Standard lockup — authentic brand mark + wordmark */
.cs-lockup { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; vertical-align: middle; }
.cs-mark { width: 24px; height: 24px; flex: none; display: grid; place-items: center; background: var(--ink); }
.cs-mark-inner { width: 10px; height: 10px; border: 2px solid var(--bg); }
.cs-word { font-family: var(--font-mono); font-weight: 600; font-size: 13px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--ink); white-space: nowrap; }
.cs-slash { color: var(--brand-terracotta); margin: 0 1px; font-weight: 600; }
a.cs-lockup { transition: opacity var(--fast) var(--ease); }
a.cs-lockup:hover { opacity: .82; }
.start .cs-lockup { margin-bottom: 22px; }
.end-brand { text-align: center; margin-top: 24px; display: flex; flex-direction: column; align-items: center; gap: 9px; }
.end-brand .by { font-size: 10.5px; color: var(--ink-faint); font-family: var(--font-mono); letter-spacing: .22em; text-transform: uppercase; }

/* ---------- Start screen ---------- */
.start { text-align: center; padding-top: 7vh; animation: rise var(--med) var(--ease) both; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 18px; }
.eyebrow .pip { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.title { font-size: clamp(40px, 13vw, 60px); line-height: .98; margin: 6px 0 4px; font-weight: 800; letter-spacing: -.02em; }
.title em { color: var(--accent); font-style: normal; }
.lede { color: var(--ink-dim); font-size: 16px; line-height: 1.5; margin: 14px auto 4px; max-width: 30ch; }
.howline { color: var(--ink-faint); font-size: 13px; margin: 6px auto 26px; max-width: 32ch; }

.scene-choices { display: grid; gap: 13px; }
.scene-btn {
  appearance: none; border: 1px solid var(--line); background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--ink); border-radius: var(--radius); padding: 16px 16px; cursor: pointer;
  display: flex; align-items: center; gap: 14px; text-align: left;
  box-shadow: var(--shadow-soft); transition: transform var(--fast) var(--ease), border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.scene-btn:hover, .scene-btn:focus-visible { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); outline: none; }
.scene-btn:active { transform: translateY(0) scale(.99); }
.scene-btn .ico { font-size: 30px; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0,0,0,.4)); }
.scene-btn .meta { display: flex; flex-direction: column; gap: 2px; }
.scene-btn .nm { font-size: 18px; font-weight: 700; }
.scene-btn .sub { font-size: 13px; color: var(--ink-dim); font-weight: 500; }
.scene-btn .go { margin-left: auto; color: var(--ink-faint); font-size: 20px; transition: transform var(--fast) var(--ease), color var(--fast); }
.scene-btn:hover .go { transform: translateX(3px); color: var(--accent); }
.scene-btn[disabled] { opacity: .55; cursor: default; }
.scene-btn[disabled] .sub { color: var(--ink-faint); }

.best { margin-top: 22px; color: var(--ink-faint); font-size: 12px; font-family: var(--font-mono); letter-spacing: .04em; min-height: 16px; }
.foot { margin-top: 30px; color: var(--ink-faint); font-size: 11px; font-family: var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }

/* ---------- How to play ---------- */
.howto { padding-top: 6vh; animation: rise var(--med) var(--ease) both; }
.howto .eyebrow { display: flex; justify-content: center; }
.howto-title { font-size: clamp(30px, 9vw, 44px); font-weight: 800; letter-spacing: -.02em; text-align: center; margin: 8px 0 26px; }
.howto-title em { color: var(--accent); font-style: normal; }
.steps { display: grid; gap: 12px; }
.step { display: flex; align-items: center; gap: 14px; background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-soft); }
.step .badge { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-size: 24px; background: var(--surface-3); border: 1px solid var(--line); }
.step .step-tx b { display: block; font-size: 16px; margin-bottom: 2px; }
.step .step-tx p { margin: 0; font-size: 13.5px; color: var(--ink-dim); line-height: 1.4; }
.howto-note { text-align: center; color: var(--ink-dim); font-size: 13.5px; line-height: 1.5; margin: 20px auto 4px; max-width: 34ch; }
.howto .actions { margin-top: 14px; }

/* ---------- Countdown ---------- */
.countdown { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(60% 60% at 50% 50%, rgba(13,17,22,.7), rgba(13,17,22,.96)); z-index: 40; }
.countdown b { font-size: clamp(90px, 34vw, 160px); font-weight: 800; color: var(--ink); }
.count-pop { animation: countPop .9s var(--ease) both; }
@keyframes countPop { 0% { transform: scale(.5); opacity: 0; } 35% { opacity: 1; } 100% { transform: scale(1.25); opacity: 0; } }

/* ---------- Play: HUD ---------- */
.hud { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hud .pill { display: inline-flex; align-items: baseline; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-family: var(--font-mono); }
.hud .pill .k { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .14em; }
.hud .pill .v { font-size: 17px; font-weight: 600; color: var(--ink); }
.hud .found .v { color: var(--accent); }
.hud .spacer { flex: 1; }
.hud .quit { appearance: none; border: 1px solid var(--line); background: transparent; color: var(--ink-faint); border-radius: 999px; width: 34px; height: 34px; cursor: pointer; font-size: 16px; }
.hud .quit:hover { color: var(--ink); border-color: var(--line); }

.timebar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-bottom: 12px; }
.timebar > i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 1s linear, background .3s; }
.timebar.low > i { background: linear-gradient(90deg, var(--warn), var(--bad)); }

/* ---------- Play: scene ---------- */
.play { display: flex; flex-direction: column; min-height: calc(100svh - 56px); }
.stage { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); flex: 1 1 auto; min-height: 380px; }
.stage .backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.stage .backdrop.fallback { background:
  linear-gradient(180deg, #1a222c, #141a22),
  repeating-linear-gradient(90deg, transparent 0 38px, rgba(255,255,255,.02) 38px 39px); }
.stage .grain { position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 0%, transparent 60%, rgba(0,0,0,.35)); pointer-events: none; }

.hotspot {
  position: absolute; appearance: none; border: 0; background: transparent; padding: 0; margin: 0; cursor: pointer;
  display: grid; place-items: center; border-radius: 14px;
  transition: transform var(--fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.hotspot img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-user-drag: none;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.45)); }
.hotspot .emoji { font-size: clamp(26px, 9vw, 44px); filter: drop-shadow(0 5px 8px rgba(0,0,0,.5)); }
.hotspot:active { transform: scale(.94); }
.hotspot.found { cursor: default; }
.hotspot.found::after { content: "✓"; position: absolute; top: -6px; right: -6px; width: 24px; height: 24px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); border-radius: 50%; font-size: 14px; font-weight: 800; box-shadow: 0 4px 10px rgba(0,0,0,.4); animation: pop .3s var(--ease) both; }
.hotspot.found img, .hotspot.found .emoji { filter: drop-shadow(0 0 0 transparent) saturate(.5) brightness(.8); opacity: .65; }
.hotspot.found { outline: 2px solid rgba(61,220,151,.7); outline-offset: 2px; }
.hotspot.ping { animation: ping .5s var(--ease); }
@keyframes ping { 0%,100% { transform: scale(1); } 40% { transform: scale(1.12); } }

/* hint flash when player taps empty space too much (optional aid) */
.stage.shake { animation: shake .3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* ---------- Picker (bottom sheet) ---------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(7,10,14,.55); backdrop-filter: blur(2px); z-index: 50; animation: fade var(--fast) ease both; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; margin: 0 auto; max-width: 520px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -20px 50px rgba(0,0,0,.5); animation: sheetUp var(--med) var(--ease) both; }
.sheet .grip { width: 40px; height: 4px; border-radius: 999px; background: var(--line); margin: 2px auto 12px; }
.sheet h3 { margin: 0 0 2px; font-size: 15px; font-weight: 700; text-align: center; }
.sheet p { margin: 0 0 14px; font-size: 12.5px; color: var(--ink-dim); text-align: center; }
.picker-subject { display: flex; align-items: center; gap: 13px; margin: 2px 2px 14px; padding: 10px 12px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 14px; }
.picker-thumb { width: 66px; height: 66px; flex: none; object-fit: contain; background: rgba(0,0,0,.25);
  border-radius: 10px; padding: 5px; filter: drop-shadow(0 4px 8px rgba(0,0,0,.4)); }
.picker-clue { font-size: 14.5px; line-height: 1.35; color: var(--ink); }
.picker-clue::before { content: "You tapped: "; color: var(--ink-faint); }
.waste-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.waste-btn { appearance: none; border: 1px solid var(--line); background: var(--surface-3); color: var(--ink); border-radius: 12px;
  padding: 10px 4px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: transform var(--fast) var(--ease), border-color var(--fast), background var(--fast); }
.waste-btn:hover, .waste-btn:focus-visible { border-color: var(--accent); transform: translateY(-2px); outline: none; }
.waste-btn:active { transform: translateY(0) scale(.96); }
.waste-btn .ltr { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--accent); line-height: 1; }
.waste-btn .nm { font-size: 10.5px; color: var(--ink-dim); text-align: center; line-height: 1.1; }
.sheet .cancel { display: block; width: 100%; margin-top: 10px; background: transparent; border: 0; color: var(--ink-faint); font-size: 13px; padding: 8px; cursor: pointer; }

/* ---------- Feedback toast ---------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 60;
  max-width: 460px; width: calc(100% - 28px); border-radius: 14px; padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start;
  background: var(--surface-2); border: 1px solid var(--line); box-shadow: var(--shadow); animation: toastIn var(--med) var(--ease) both; }
.toast.correct { border-color: rgba(61,220,151,.5); background: linear-gradient(180deg, rgba(61,220,151,.12), var(--surface-2)); }
.toast.wrong { border-color: rgba(245,166,35,.5); background: linear-gradient(180deg, rgba(245,166,35,.1), var(--surface-2)); }
.toast.info { border-color: rgba(47,179,255,.45); }
.toast .ic { font-size: 18px; line-height: 1.3; }
.toast .tx { font-size: 13.5px; line-height: 1.4; }
.toast .tx b { color: var(--ink); }
.toast .tx .pen { color: var(--warn); font-family: var(--font-mono); font-weight: 600; }
.toast.out { animation: toastOut var(--fast) ease forwards; }

/* ---------- End screen ---------- */
.end { animation: rise var(--med) var(--ease) both; padding-top: 6px; }
.end .cap { text-align: center; margin-bottom: 16px; }
.end .grade { font-size: clamp(30px, 9vw, 42px); font-weight: 800; letter-spacing: -.01em; }
.end .grade .em { color: var(--accent); }
.end .sub { color: var(--ink-dim); font-size: 14px; margin-top: 4px; }

.cardwrap { border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); background: #0b0f14; }
.cardwrap canvas { display: block; width: 100%; height: auto; }

.actions { display: grid; gap: 10px; margin-top: 16px; }
.actions .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn { appearance: none; border-radius: 12px; padding: 14px 16px; font-size: 15px; font-weight: 700; cursor: pointer; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); transition: transform var(--fast) var(--ease), border-color var(--fast), background var(--fast); }
.btn:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn:active { transform: translateY(0) scale(.99); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { box-shadow: 0 10px 24px rgba(61,220,151,.3); }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }

/* Email capture */
.capture { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); }
.capture h4 { margin: 0 0 4px; font-size: 15px; }
.capture p { margin: 0 0 12px; font-size: 13px; color: var(--ink-dim); }
.capture form { display: flex; gap: 8px; }
.capture input { flex: 1; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink); border-radius: 10px; padding: 12px 13px; font-size: 15px; }
.capture input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.capture .send { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 0 16px; font-weight: 700; cursor: pointer; }
.capture .ok { color: var(--accent); font-size: 13px; margin: 10px 0 0; }
.capture .err { color: var(--bad); font-size: 13px; margin: 10px 0 0; }

/* Leaderboard */
.leaderboard { margin-top: 18px; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--surface); }
.lb-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 0 12px; font-size: 16px; }
.lb-scene { font-size: 12px; color: var(--ink-faint); font-family: var(--font-mono); letter-spacing: .04em; }
.lb-cta { margin: 0 0 10px; font-size: 13.5px; color: var(--ink-dim); }
.lb-form { display: flex; gap: 8px; }
.lb-form input { flex: 1; min-width: 0; background: var(--bg-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 12px 13px; font-size: 15px; }
.lb-form input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.lb-add { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 0 16px;
  font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.lb-link { display: inline-block; margin-top: 10px; background: none; border: 0; color: var(--accent);
  font-size: 13px; cursor: pointer; padding: 4px 0; }
.lb-you { margin: 0 0 10px; font-size: 14px; font-weight: 700; color: var(--accent); }
.lb-empty, .lb-busy, .lb-err { font-size: 13.5px; color: var(--ink-dim); margin: 4px 0; }
.lb-err { color: var(--bad); }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.lb-row .lb-rank { width: 22px; text-align: right; font-family: var(--font-mono); color: var(--ink-faint); font-weight: 600; }
.lb-row .lb-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row .lb-score { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-dim); }
.lb-row.me { background: rgba(61,220,151,.14); border: 1px solid rgba(61,220,151,.4); }
.lb-row.me .lb-rank, .lb-row.me .lb-score { color: var(--accent); }

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
