:root {
  --ink: #f3ecdd;
  --ink-2: rgba(243, 236, 221, 0.95);
  --ink-3: rgba(243, 236, 221, 0.85);
  --line: rgba(243, 236, 221, 0.36);
  --panel: rgba(18, 34, 27, 0.42);
  --panel-solid: #1d3329;
  --gold: #e8cf8f;
  --cream: #ead9b0;
  --heart: #e8a28f;
  --serif: "Shippori Mincho", "Hiragino Mincho ProN", Georgia, serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --pad: clamp(14px, 2.4vw, 28px);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1c2a22; color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
canvas#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin: 0 1px; border: 1px solid var(--line); border-radius: 5px; font: 600 10px/1 var(--sans); color: var(--ink-2); background: rgba(243, 236, 221, 0.05); }

.label { font-size: 10px; font-weight: 600; letter-spacing: 0.22em; color: var(--ink-3); }

/* ------------------------------------------------------------------ HUD */
.hud { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 900ms var(--ease); text-shadow: 0 1px 2px rgba(10, 20, 15, 0.35), 0 0 14px rgba(10, 20, 15, 0.35); }
.hud.live { opacity: 1; }
.hud button { pointer-events: auto; }

.brand { position: absolute; top: var(--pad); left: var(--pad); display: flex; gap: 12px; align-items: center; }
.emblem { width: 34px; height: 34px; color: var(--ink); }
.brand-name { font: 600 15px/1 var(--serif); letter-spacing: 0.32em; }
.brand-sub { margin-top: 6px; font-size: 10px; letter-spacing: 0.2em; color: var(--ink-3); }

.top-center { position: absolute; top: var(--pad); left: 50%; transform: translateX(-50%); display: grid; justify-items: center; gap: 8px; }
.compass { position: relative; width: 220px; height: 30px; overflow: hidden; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); mask-image: linear-gradient(90deg, transparent, #000 22%, #000 78%, transparent); }
.compass-strip { position: absolute; top: 0; left: 50%; height: 100%; display: flex; align-items: center; white-space: nowrap; will-change: transform; }
.compass-strip span { flex: none; width: 22px; text-align: center; font-size: 9px; font-weight: 600; color: var(--ink-3); }
.compass-strip span.cardinal { color: var(--ink); font-size: 11px; }
.compass-needle { position: absolute; left: 50%; top: 4px; width: 1px; height: 6px; background: var(--gold); }
.hint { font-size: 11px; color: var(--ink-2); letter-spacing: 0.04em; transition: opacity 600ms; }

.tools { position: absolute; top: var(--pad); right: var(--pad); display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid transparent; background: transparent; transition: background 200ms, border-color 200ms, transform 120ms; }
.icon-btn:hover { background: var(--panel); border-color: var(--line); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
#btnSound .off { display: none; }
#btnSound.sound-off .off { display: inline; }
#btnSound.sound-off .on { opacity: 0.45; }

.score { position: absolute; left: var(--pad); top: 22vh; }
.gauges { position: absolute; right: var(--pad); top: 22vh; text-align: right; display: grid; justify-items: end; }
.big { margin: 6px 0 16px; font: 600 30px/1 var(--serif); font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.big small { margin-left: 5px; font: 500 11px var(--sans); color: var(--ink-3); letter-spacing: 0.08em; }
.spark { margin-left: 6px; font-size: 16px; color: var(--gold); vertical-align: 4px; }
.score .big { margin-bottom: 8px; }
.sub { font-size: 10px; font-weight: 600; letter-spacing: 0.16em; color: var(--ink-3); }
.sub.time { margin-top: 6px; }
.sub.time span { color: var(--ink); font-variant-numeric: tabular-nums; }
.hearts { margin-top: 12px; display: flex; gap: 6px; }
.hearts i { width: 14px; height: 13px; background: var(--heart); -webkit-mask: var(--heart-mask) center/contain no-repeat; mask: var(--heart-mask) center/contain no-repeat; transition: opacity 300ms, transform 300ms var(--ease); }
.hearts i.lost { opacity: 0.18; transform: scale(0.8); }
:root { --heart-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath d='M12 21.5 10.3 20C4.2 14.6 0 10.9 0 6.5 0 2.9 2.8 0 6.4 0c2 0 4 1 5.6 2.6C13.6 1 15.6 0 17.6 0 21.2 0 24 2.9 24 6.5c0 4.4-4.2 8.1-10.3 13.5Z'/%3E%3C/svg%3E"); }

.journey { position: absolute; left: var(--pad); bottom: calc(var(--pad) + 40px); display: flex; gap: 10px; align-items: center; }
.journey svg { width: 22px; height: 22px; fill: none; stroke: var(--ink-2); stroke-width: 1.3; }
.j-title { font: 600 13px var(--serif); }
.j-sub { margin-top: 3px; font-size: 10px; color: var(--ink-3); font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }

.progress { position: absolute; left: 50%; bottom: calc(var(--pad) + 44px); width: min(480px, 44vw); transform: translateX(-50%); }
.track { position: relative; height: 2px; background: var(--line); border-radius: 1px; }
.track i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, rgba(232, 207, 143, 0.4), var(--gold)); border-radius: 1px; }
.track b { position: absolute; z-index: 2; top: 50%; left: 0; width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px rgba(232, 207, 143, 0.8); }
.tick { position: absolute; z-index: 1; top: 50%; left: var(--at); width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%; background: rgba(243, 236, 221, 0.45); transition: background 400ms; }
.tick.reached { background: var(--gold); }
.stops { list-style: none; margin: 0; padding: 0; position: relative; height: 26px; }
.stops li { position: absolute; left: var(--at); top: 10px; transform: translateX(-50%); font-size: 9.5px; letter-spacing: 0.06em; color: var(--ink-3); white-space: nowrap; transition: color 400ms; }
.stops li.reached { color: var(--ink); }

.chapter-card { position: absolute; right: var(--pad); bottom: calc(var(--pad) + 40px); text-align: right; }
.c-name { margin-top: 6px; font: 600 24px/1.1 var(--serif); }

.footer { position: absolute; left: var(--pad); right: var(--pad); bottom: var(--pad); display: flex; justify-content: space-between; align-items: center; font-size: 10px; color: var(--ink-3); letter-spacing: 0.06em; }
.footer .sep { display: inline-block; width: 14px; }
.best span { color: var(--ink-2); margin-left: 6px; font-variant-numeric: tabular-nums; }
.link-btn { padding: 6px 0; border: 0; background: none; font-size: 11px; color: var(--ink-2); letter-spacing: 0.04em; }
.link-btn:hover { color: var(--ink); }

.toast { position: absolute; left: 50%; top: 31vh; transform: translate(-50%, 8px); padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; opacity: 0; transition: opacity 300ms, transform 500ms var(--ease); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast b { color: var(--gold); margin-right: 6px; font-family: var(--serif); font-size: 14px; }
.toast.bad b { color: var(--heart); }

.banner { position: absolute; left: 50%; top: 40vh; transform: translate(-50%, -50%); text-align: center; opacity: 0; transition: opacity 1200ms var(--ease); }
.banner.show { opacity: 1; }
.b-eyebrow { font-size: 10px; font-weight: 600; letter-spacing: 0.32em; color: var(--ink-2); }
.b-title { margin-top: 10px; font: 600 clamp(30px, 5vw, 54px)/1.1 var(--serif); text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35); }

.boost-btn { display: none; position: absolute; right: var(--pad); bottom: 120px; width: 68px; height: 68px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); font-size: 10px; font-weight: 700; letter-spacing: 0.18em; }
.boost-btn.active { background: rgba(232, 207, 143, 0.3); }

/* ------------------------------------------------------------------ overlays */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; background: radial-gradient(ellipse at center, rgba(14, 28, 21, 0.25), rgba(10, 20, 15, 0.62)); opacity: 0; visibility: hidden; transition: opacity 600ms var(--ease), visibility 0s 600ms; }
.overlay.show { opacity: 1; visibility: visible; transition: opacity 600ms var(--ease); }
#intro { background: radial-gradient(ellipse at center, rgba(14, 28, 21, 0.1), rgba(10, 20, 15, 0.55)); }

.intro { text-align: center; display: grid; justify-items: center; }
.eyebrow { font-size: 10px; font-weight: 600; letter-spacing: 0.3em; color: var(--ink-3); }
.intro .eyebrow { margin-top: 0; }
.intro h1 { margin: 12px 0 26px; font: 600 clamp(34px, 6vw, 64px)/1.08 var(--serif); letter-spacing: -0.01em; text-shadow: 0 2px 40px rgba(0, 0, 0, 0.3); }
.loading { margin: 10px 0 0; font-size: 11px; color: var(--ink-3); }
.loading:empty { display: none; }

.primary, .secondary { min-width: 220px; height: 46px; padding: 0 24px; border-radius: 12px; font-size: 13px; font-weight: 600; letter-spacing: 0.03em; transition: transform 120ms var(--ease), background 200ms, opacity 200ms; }
.primary { border: 0; background: var(--cream); color: #1d2b22; }
.primary:hover { background: #f3e5c2; }
.primary:active, .secondary:active { transform: scale(0.97); }
.primary:disabled { opacity: 0.4; cursor: default; }
.primary span { margin-left: 6px; }
.secondary { border: 1px solid var(--line); background: rgba(243, 236, 221, 0.05); }

/* the mode buttons: on hover one lifts, warms to gold (faded in on a layer, since a gradient can't
   transition), a shimmer sweeps across and its icon turns once; nothing flashes or pulses */
.begin { position: relative; isolation: isolate; overflow: hidden; min-width: 240px; height: 52px; padding: 0 30px; border-radius: 999px; font-size: 14px; letter-spacing: 0.05em;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 450ms var(--ease), box-shadow 450ms var(--ease); }
.begin::after { content: ""; position: absolute; inset: 0; z-index: -2; border-radius: inherit; background: linear-gradient(135deg, #f8ecc8, #e6c97f); opacity: 0; transition: opacity 350ms var(--ease); }
.begin::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(110deg, transparent 25%, rgba(255, 255, 255, 0.7) 50%, transparent 75%); transform: translateX(-130%); }
.begin .label-txt { margin-left: 0; }
.begin .arrow { display: inline-block; margin-left: 8px; transition: transform 700ms var(--ease); }
.begin:hover { background: var(--cream); transform: translateY(-3px) scale(1.03);
  box-shadow: 0 0 0 1px rgba(255, 236, 190, 0.7), 0 0 36px rgba(255, 210, 130, 0.5), 0 18px 44px rgba(0, 0, 0, 0.32); }
.begin:hover::after { opacity: 1; }
.begin:hover::before { transform: translateX(130%); transition: transform 1000ms var(--ease); }
.begin:hover .arrow { transform: rotate(360deg) scale(1.15); }
.begin:active { transform: translateY(-1px) scale(0.98); }
@media (prefers-reduced-motion: reduce) {
  .begin:hover, .begin:hover .arrow { transform: none; }
  .begin:hover::before { transition: none; }
}
.secondary:hover { background: rgba(243, 236, 221, 0.1); }

.card { position: relative; width: min(400px, 100%); padding: 28px 26px 24px; border: 1px solid var(--line); border-radius: 18px; background: rgba(29, 51, 41, 0.82); backdrop-filter: blur(22px) saturate(140%); -webkit-backdrop-filter: blur(22px) saturate(140%); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35); display: grid; gap: 10px; transform: translateY(10px) scale(0.98); transition: transform 600ms var(--ease); }
.card.wide { width: min(480px, 100%); }
.overlay.show .card { transform: none; }
.card h2 { margin: 2px 0 6px; font: 600 28px/1.2 var(--serif); }
.card .primary, .card .secondary { width: 100%; }
.stats { margin: 0 0 12px; font-size: 12px; line-height: 1.8; color: var(--ink-2); }
.stats b { color: var(--ink); font-weight: 700; }
.close { position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border: 0; border-radius: 50%; background: transparent; font-size: 20px; color: var(--ink-2); }
.close:hover { background: rgba(243, 236, 221, 0.08); }
/* endless flight has no score to show */
.hud.endless .score { display: none; }
/* mode-specific bits of the HUD */
.score .sub i { font-style: normal; }
.hud.hunt .rings-only, .hud:not(.hunt) .hunt-only { display: none; }
.fire-btn { bottom: 200px; }
.hud:not(.hunt) .fire-btn { display: none !important; }
/* the three modes sit side by side, stacking on narrow screens */
.modes { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.modes .begin { min-width: 200px; }
@media (max-width: 720px) { .modes { flex-direction: column; align-items: center; gap: 12px; } .modes .begin { min-width: 240px; } }
/* opt-in autopilot that eases you back onto the lantern line, tucked in the opening screen's corner */
.assist-toggle { position: absolute; right: var(--pad); bottom: calc(var(--pad) + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(243, 236, 221, 0.06); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; color: var(--ink-2); cursor: pointer; }
.assist-toggle input { width: 15px; height: 15px; margin: 0; accent-color: var(--cream); cursor: pointer; }
.veil { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, #f4f6f2, #e6ebe6); opacity: 0; transition: opacity 1300ms ease-in-out; }
.veil.on { opacity: 1; }

/* save-your-score prompt and the board */
.save { display: grid; gap: 8px; padding: 14px; margin-bottom: 4px; border: 1px solid var(--line); border-radius: 14px; background: rgba(243, 236, 221, 0.04); }
.save[hidden], .board-wrap[hidden] { display: none; }
.save-q { margin: 0; font-size: 13px; color: var(--ink); }
.google { display: flex; align-items: center; justify-content: center; gap: 10px; height: 44px; border: 0; border-radius: 12px; background: #fff; color: #1f1f1f; font-size: 13px; font-weight: 600; transition: transform 120ms var(--ease), box-shadow 200ms; }
.google:hover { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
.google:active { transform: scale(0.97); }
.google:disabled { opacity: 0.6; cursor: default; }
.google svg { width: 18px; height: 18px; flex: none; }
.save-links { display: flex; justify-content: center; gap: 18px; }
.save-links .link-btn[hidden] { display: none; }
.save-msg { margin: 0; min-height: 0; font-size: 12px; color: var(--ink-2); text-align: center; }
.save-msg:empty { display: none; }
.board-wrap { display: grid; gap: 8px; margin-bottom: 6px; }
.board { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow: auto; }
.board li { display: grid; grid-template-columns: 22px 28px 1fr auto; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; font-size: 13px; }
.board li.me { background: rgba(232, 207, 143, 0.16); box-shadow: inset 0 0 0 1px rgba(232, 207, 143, 0.4); }
.board .rk { color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: right; }
.board .av { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: rgba(243, 236, 221, 0.15); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.board .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .sc { font: 600 15px var(--serif); font-variant-numeric: tabular-nums; color: var(--gold); }
.board .empty { display: block; text-align: center; color: var(--ink-3); }


/* ------------------------------------------------------------------ phones */
@media (max-width: 720px), (max-height: 520px) {
  .brand-sub, .hint, .footer .keys, .footer .best, .stops, .journey { display: none; }
  .compass { display: none; }   /* the name needs the top edge on a phone */
  .brand-name { font-size: 13px; letter-spacing: 0.24em; }
  .tools { gap: 0; }
  .score, .gauges { top: 70px; }
  .big { font-size: 22px; margin-bottom: 10px; }
  .gauges .label:nth-of-type(n+3), .gauges .big:nth-of-type(2) { }
  .progress { bottom: calc(var(--pad) + 4px + env(safe-area-inset-bottom)); width: 46vw; left: var(--pad); transform: none; }
  .chapter-card { bottom: calc(var(--pad) + 14px + env(safe-area-inset-bottom)); }
  .c-name { font-size: 16px; }
  .footer { bottom: auto; top: calc(var(--pad) + 42px); justify-content: flex-end; left: auto; }
  .footer .link-btn { display: none; }
  .boost-btn { display: block; bottom: calc(96px + env(safe-area-inset-bottom)); }
  .fire-btn { bottom: calc(176px + env(safe-area-inset-bottom)); }
}
@media (hover: none) and (pointer: coarse) { .boost-btn { display: block; } .footer .keys { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .hud, .overlay, .card, .toast, .banner { transition-duration: 1ms; }
}
