:root {
  --ink: #f6efe6; --dim: rgba(246, 239, 230, .64); --faint: rgba(246, 239, 230, .16);
  --gold: #f3c06a; --gold-deep: #e39a3c; --bg: #0d0203;
  --serif: 'Instrument Serif', Georgia, serif; --sans: 'Inter Tight', system-ui, sans-serif;
  --safe-b: max(16px, env(safe-area-inset-bottom)); --safe-t: max(14px, env(safe-area-inset-top));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { opacity: 0 !important; pointer-events: none !important; }

/* loading */
#loading { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; gap: 14px; background: var(--bg); transition: opacity .8s; }
#loading.gone { opacity: 0; pointer-events: none; }
.ld-t { font-family: var(--serif); font-size: 26px; color: var(--dim); text-align: center; }
.ld-bar { width: 180px; height: 2px; background: var(--faint); border-radius: 2px; overflow: hidden; margin: 0 auto; }
.ld-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .3s; }

/* flash between stages */
#flash { position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 50%, #fff3dc 0%, #ffb860 35%, #3a0808 100%); }

/* HUD */
#hud { position: fixed; left: 16px; right: 16px; top: var(--safe-t); z-index: 10; display: flex; justify-content: space-between; align-items: flex-start; pointer-events: none; transition: opacity .6s; }
.hud-k { font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); }
.hud-t { font-family: var(--serif); font-size: clamp(24px, 3.6vw, 36px); line-height: 1; margin-top: 5px; text-shadow: 0 2px 20px rgba(0,0,0,.55); }
.hud-dose { text-align: right; min-width: 120px; }
.hud-dose-row { display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; margin-top: 4px; }
#doseNum { font-family: var(--serif); font-size: clamp(24px, 3.4vw, 34px); color: var(--gold); line-height: 1; font-variant-numeric: tabular-nums; }
#doseM6g { font-size: 11px; color: var(--dim); }
.hud-bar { height: 3px; margin-top: 7px; background: var(--faint); border-radius: 3px; overflow: hidden; }
.hud-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--gold-deep), var(--gold)); transition: width .5s ease; }

#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 74px); transform: translate(-50%, -6px); z-index: 12; pointer-events: none; opacity: 0;
  padding: 9px 14px; border-radius: 999px; font-size: 13px; background: rgba(20, 4, 6, .55); border: 1px solid var(--faint);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: opacity .35s, transform .35s; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* touch controls */
#joy { position: fixed; z-index: 11; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; pointer-events: none; opacity: 0;
  border: 1.5px solid rgba(246, 239, 230, .28); background: radial-gradient(circle, rgba(246,239,230,.06), rgba(246,239,230,0) 70%); transition: opacity .2s; }
#joy.on { opacity: 1; }
#joyKnob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #fff4dc, var(--gold) 55%, var(--gold-deep)); box-shadow: 0 0 22px rgba(243, 192, 106, .5); }
#boost { position: fixed; z-index: 11; right: 18px; bottom: calc(var(--safe-b) + 6px); width: 76px; height: 76px; border-radius: 50%;
  border: 1.5px solid rgba(243, 192, 106, .6); background: rgba(40, 10, 8, .45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); display: none; touch-action: none; }
#boost.cool { opacity: .4; }
#boost.press { transform: scale(.94); background: rgba(243, 192, 106, .22); }
body.touch #boost { display: block; }
body.touch.no-controls #boost { display: none; }

/* title */
#title { position: fixed; z-index: 25; left: 0; right: 0; bottom: 0; padding: 0 20px calc(var(--safe-b) + 12px); transition: opacity .7s;
  background: linear-gradient(to top, rgba(13,2,3,.92) 0%, rgba(13,2,3,.6) 55%, rgba(13,2,3,0) 100%); }
#title > * { max-width: 560px; margin-left: auto; margin-right: auto; }
.title-k { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--dim); padding-top: 60px; }
#title h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(46px, 8vw, 78px); line-height: .95; margin: 10px auto 0; letter-spacing: -.01em; }
#title h1 em { color: var(--gold); }
#title p { font-size: 15px; line-height: 1.5; color: var(--dim); margin: 14px auto 0; }
.title-btns { display: flex; gap: 10px; margin-top: 20px; }
.title-btns button { flex: 1; padding: 14px; border-radius: 999px; border: 1px solid var(--faint); background: rgba(255,255,255,.04); font-size: 16px; font-weight: 600; }
.title-btns .primary { background: var(--gold); color: #2a0c04; border-color: transparent; }
.title-hint { margin-top: 12px; font-size: 12px; color: var(--dim); text-align: center; }
.title-credits { margin-top: 8px; font-size: 11px; color: rgba(246,239,230,.4); text-align: center; }


/* end recap */
#recap { position: fixed; inset: 0; z-index: 26; overflow-y: auto; padding: calc(var(--safe-t) + 20px) 20px calc(var(--safe-b) + 20px); background: rgba(13,2,3,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); transition: opacity .7s; }
#recap > * { max-width: 640px; margin-left: auto; margin-right: auto; }
#recap .title-k { padding-top: 0; }
#recap h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 6vw, 52px); line-height: 1; margin: 8px auto 18px; }
#recap ol { list-style: none; padding: 0; display: grid; gap: 10px; }
#recap li { display: flex; gap: 12px; align-items: center; padding: 8px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid var(--faint); }
#recap .rc-img { flex: 0 0 96px; height: 60px; border-radius: 9px; background: #2a0a0a center / cover; }
#recap li b { display: block; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); font-weight: 500; }
#recap li span { display: block; font-size: 14px; line-height: 1.4; margin-top: 3px; }
