@import url("/tokens.css");

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink-900); color: var(--cream); font-family: var(--font-body); overscroll-behavior: none; }
body { position: fixed; inset: 0; width: 100%; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; image-rendering: pixelated; }
[hidden] { display: none !important; }

/* HUD */
#hud { position: fixed; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 0 calc(10px + env(safe-area-inset-left)); pointer-events: none; }
.pill { background: rgba(12, 10, 36, .62); border: 1px solid rgba(142, 124, 255, .35); border-radius: 999px; padding: 6px 14px; display: flex; align-items: baseline; gap: 5px; font-family: var(--font-display); }
.pill .big { font-size: 26px; font-weight: 700; line-height: 1; color: var(--cream); font-variant-numeric: tabular-nums; }
.pill .small { font-size: 12px; color: var(--muted); }
#hud-score .big { color: var(--mint); }
#hud-time { margin-left: auto; }
#hud-time.low .big { color: var(--danger); }
.round { pointer-events: auto; width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(142, 124, 255, .5); background: rgba(12, 10, 36, .62); color: var(--cream); font: 700 18px var(--font-display); letter-spacing: 1px; touch-action: none; }
#practice-tag { position: fixed; top: calc(76px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: rgba(255, 122, 47, .18); border: 1px solid var(--clementine); color: var(--clementine); border-radius: 999px; padding: 4px 12px; font-size: 12px; pointer-events: none; white-space: nowrap; }

/* compass arrow to the nearest undelivered house */
#compass { position: fixed; left: 0; top: 0; width: 56px; height: 56px; pointer-events: none; display: flex; flex-direction: column; align-items: center; will-change: transform; }
#compass svg { width: 36px; height: 36px; fill: var(--mint); filter: drop-shadow(0 0 6px rgba(91, 227, 180, .9)); }
#compass span { font: 700 12px var(--font-display); color: var(--mint); text-shadow: 0 1px 3px #000; margin-top: -2px; }

#popups { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.popup { position: absolute; font: 700 28px var(--font-display); color: var(--mint); text-shadow: 0 2px 6px rgba(0, 0, 0, .7); transform: translate(-50%, -50%); animation: pop .9s ease-out forwards; }
@keyframes pop { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -60px; } }

#countdown { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; font: 700 min(30vw, 180px) var(--font-display); color: var(--cream); text-shadow: 0 4px 24px rgba(142, 124, 255, .8); pointer-events: none; }

/* controls: one floating-free analog stick, bottom left */
#controls { position: fixed; inset: 0; pointer-events: none; }
#stick { position: fixed; left: calc(18px + env(safe-area-inset-left)); bottom: calc(22px + env(safe-area-inset-bottom)); width: 132px; height: 132px; border-radius: 50%; background: rgba(12, 10, 36, .45); border: 2px solid rgba(142, 124, 255, .5); pointer-events: auto; touch-action: none; }
#stick::before, #stick::after { content: ""; position: absolute; background: rgba(142, 124, 255, .28); }
#stick::before { left: 50%; top: 14px; bottom: 14px; width: 2px; margin-left: -1px; }
#stick::after { top: 50%; left: 14px; right: 14px; height: 2px; margin-top: -1px; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--lilac), var(--ink-600)); border: 2px solid var(--cream); box-shadow: 0 4px 14px rgba(0, 0, 0, .5); }
.gift { width: 18px; height: 16px; background: var(--cream); border-radius: 2px; position: relative; display: block; align-self: center; }
.gift::before { content: ""; position: absolute; left: 7px; top: 0; width: 3px; height: 100%; background: var(--clementine); }
.gift::after { content: ""; position: absolute; top: 6px; left: 0; height: 3px; width: 100%; background: var(--clementine); }
#hud-sack { gap: 6px; }
#hud-sack.empty .big { color: var(--clementine); animation: blink .6s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
@media (max-height: 420px) { #stick { width: 110px; height: 110px; bottom: 12px; } #stick-knob { width: 48px; height: 48px; margin: -24px 0 0 -24px; } .pill .big { font-size: 22px; } }

/* quest banner + toast */
#quest { position: fixed; left: 50%; transform: translateX(-50%); top: calc(76px + env(safe-area-inset-top)); width: min(340px, calc(100vw - 20px)); background: rgba(12, 10, 36, .78); border: 1px solid var(--gold, #ffd45e); border-radius: 14px; padding: 8px 12px 10px; pointer-events: none; display: grid; gap: 2px; text-align: left; }
#quest b { font: 700 15px var(--font-display); color: #ffd45e; }
#quest span { font-size: 13px; color: var(--cream); line-height: 1.3; }
#quest i { display: block; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .15); margin-top: 4px; overflow: hidden; }
#quest u { display: block; height: 100%; width: 100%; background: #ffd45e; text-decoration: none; transform-origin: left; }
#quest.low u { background: var(--danger); }
#toast { position: fixed; left: calc(170px + env(safe-area-inset-left)); right: 10px; bottom: calc(26px + env(safe-area-inset-bottom)); width: auto; background: rgba(12, 10, 36, .85); border: 1px solid var(--mint); color: var(--cream); font: 600 15px var(--font-display); padding: 8px 12px; border-radius: 14px; pointer-events: none; text-align: left; line-height: 1.25; }
#toast.gold { border-color: #ffd45e; color: #ffd45e; }
@media (max-height: 420px) { #toast { left: 140px; bottom: 12px; } #quest { top: 62px; } }

/* overlays */
.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 14px; background: radial-gradient(ellipse at 50% 30%, rgba(34, 28, 82, .55), rgba(12, 10, 36, .86)); overflow-y: auto; touch-action: pan-y; }
.card { width: min(420px, 100%); max-height: 100%; background: rgba(22, 18, 58, .94); border: 1px solid rgba(142, 124, 255, .45); border-radius: 20px; padding: 22px 20px; text-align: center; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); user-select: text; -webkit-user-select: text; }
.card h1 { margin: 0 0 6px; font: 700 40px var(--font-display); color: var(--clementine); }
.card h2 { margin: 0 0 10px; font: 700 28px var(--font-display); color: var(--cream); }
.lead { margin: 0 0 8px; color: var(--cream); line-height: 1.4; font-size: 15px; }
.how { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.how b { color: var(--mint); }
.field { display: block; text-align: left; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.field input { display: block; width: 100%; margin-top: 4px; height: 48px; border-radius: 12px; border: 1px solid var(--ink-600); background: var(--ink-900); color: var(--cream); font: 16px var(--font-body); padding: 0 12px; }
.field input:focus { outline: 2px solid var(--mint); }
.note { color: var(--cream-dim); font-size: 14px; line-height: 1.4; margin: 0 0 12px; }
.note.err { color: var(--danger); }
.note.warn { color: var(--clementine); }
.primary { display: block; width: 100%; min-height: 56px; border: 0; border-radius: 14px; background: linear-gradient(var(--clementine), var(--clementine-deep)); color: #fff; font: 700 20px var(--font-display); margin: 6px 0; touch-action: manipulation; }
.primary:active { transform: scale(.98); }
.row { display: flex; justify-content: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.link { min-height: 48px; padding: 0 14px; display: inline-flex; align-items: center; background: none; border: 0; color: var(--lilac); font: 600 15px var(--font-body); text-decoration: underline; cursor: pointer; touch-action: manipulation; }
.score { margin: 4px 0 10px; font-family: var(--font-display); }
.score span { display: block; font-size: 72px; font-weight: 700; color: var(--mint); line-height: 1; }
.score small { color: var(--muted); font-size: 14px; }
@media (max-height: 430px) { .card { padding: 12px 16px; } .card h1 { font-size: 28px; margin: 0; } .lead, .how { font-size: 12px; margin-bottom: 6px; } .field { margin-bottom: 6px; } .field input { height: 40px; } .primary { min-height: 56px; } .score span { font-size: 48px; } }
