@font-face { font-family: "Archivo XC"; src: url(fonts/archivo-xc-800.woff2) format("woff2"); font-weight: 800; font-display: swap; }
@font-face { font-family: Switzer; src: url(fonts/switzer-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Switzer; src: url(fonts/switzer-500.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Switzer; src: url(fonts/switzer-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --teal: #2ee6d6; --amber: #ffb454; --pink: #f72585; --ink: #070b1c; --glass: rgba(9, 15, 34, 0.58);
  --line: rgba(160, 220, 255, 0.16); --text: #eaf6ff; --muted: #a9bad6;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--text); font: 500 15px/1.4 Switzer, -apple-system, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; touch-action: none; -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
canvas#game { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }
button, a { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; }

/* ---------------- touch layer and controls */
#touch { position: fixed; inset: 0; z-index: 5; touch-action: none; }
body:not(.playing) #touch { pointer-events: none; }
#stickbase { position: fixed; left: 0; top: 0; z-index: 6; width: 120px; height: 120px; border-radius: 50%; border: 1.5px solid rgba(160, 255, 248, 0.28); background: radial-gradient(circle, rgba(46, 230, 214, 0.10), rgba(46, 230, 214, 0) 70%); opacity: 0; pointer-events: none; transition: opacity .15s; }
#stickbase.on { opacity: 1; }
#knob { position: absolute; left: 36px; top: 36px; width: 48px; height: 48px; border-radius: 50%; background: rgba(160, 255, 248, 0.35); box-shadow: 0 0 18px rgba(46, 230, 214, 0.5); }
#jumppad { position: fixed; right: calc(22px + var(--sar)); bottom: calc(22px + var(--sab)); z-index: 6; width: 86px; height: 86px; border-radius: 50%; display: none; place-items: center; color: rgba(220, 255, 252, 0.8); border: 1.5px solid rgba(160, 255, 248, 0.3); background: rgba(10, 24, 40, 0.35); pointer-events: none; transition: transform .08s, background .08s; }
#jumppad svg { width: 34px; height: 34px; }
#jumppad.on { transform: scale(0.92); background: rgba(46, 230, 214, 0.25); }
body.touch.playing #jumppad { display: grid; }

/* ---------------- HUD */
#hud { position: fixed; z-index: 8; top: calc(12px + var(--sat)); left: calc(14px + var(--sal)); right: calc(14px + var(--sar)); display: flex; align-items: center; gap: 10px; pointer-events: none; opacity: 0; transform: translateY(-8px); transition: opacity .6s, transform .6s; }
body.playing #hud { opacity: 1; transform: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 11px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); font-variant-numeric: tabular-nums; }
.chip svg { width: 20px; height: 20px; color: var(--teal); }
.chip b { font: 800 19px/1 "Archivo XC", Switzer, sans-serif; color: #fff; }
.chip #total { color: var(--muted); font-size: 14px; margin-left: -4px; }
.chip.clock svg { color: #ffe1a8; width: 18px; height: 18px; }
.chip.clock { margin: 0 auto; font-size: 15px; letter-spacing: .01em; }
#countchip.bump { animation: bump .35s ease-out; }
@keyframes bump { 40% { transform: scale(1.12); box-shadow: 0 0 22px rgba(46, 230, 214, 0.55); } }
.hud-r { display: flex; gap: 8px; pointer-events: auto; position: relative; z-index: 9; }
.ibtn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.ibtn svg { width: 20px; height: 20px; }
#mutebtn .off, #mutebtn.muted .on { display: none; }
#mutebtn.muted .off { display: block; }

/* story cards */
#cards { position: fixed; z-index: 7; top: calc(62px + var(--sat)); left: 50%; transform: translateX(-50%); width: min(380px, 86vw); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.card { padding: 10px 14px 11px; border-radius: 16px; background: rgba(8, 14, 32, 0.74); border: 1px solid rgba(46, 230, 214, 0.28); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 24px rgba(46, 230, 214, 0.12); opacity: 0; transform: translateY(-10px) scale(.98); transition: opacity .35s, transform .45s cubic-bezier(.2, .9, .2, 1.2); }
.card.in { opacity: 1; transform: none; }
.card.out { opacity: 0; transform: translateY(-6px); transition: opacity .5s, transform .5s; }
.c-top { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); letter-spacing: .02em; }
.c-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.c-time { margin-left: auto; font-variant-numeric: tabular-nums; }
.c-q { margin-top: 3px; font-size: 15px; color: #fff; line-height: 1.3; }
.c-a { display: flex; align-items: flex-start; gap: 6px; margin-top: 5px; font-size: 13.5px; color: #9ffcf4; }
.c-a svg { width: 15px; height: 15px; flex: none; margin-top: 2px; }
.card.gold { border-color: rgba(255, 211, 106, 0.75); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 34px rgba(255, 196, 80, 0.4); }
.card.gold .c-dot { background: #ffd36a; box-shadow: 0 0 10px #ffd36a; }
.card.gold .c-a { color: #ffd36a; }
.e-gold { margin-top: 8px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 196, 80, 0.16); color: #ffd36a; font-size: 13.5px; font-weight: 600; }
#hint { position: fixed; z-index: 7; left: 50%; bottom: calc(26px + var(--sab)); transform: translate(-50%, 10px); max-width: min(460px, 70vw); text-align: center; padding: 9px 16px; border-radius: 999px; background: rgba(8, 14, 32, 0.7); border: 1px solid var(--line); font-size: 14px; color: #dff6ff; opacity: 0; transition: opacity .4s, transform .4s; pointer-events: none; }
#hint.on { opacity: 1; transform: translate(-50%, 0); }
#fuel { position: fixed; z-index: 7; left: 50%; bottom: calc(76px + var(--sab)); width: 120px; height: 5px; margin-left: -60px; border-radius: 3px; background: rgba(160, 220, 255, 0.15); opacity: 0; transition: opacity .2s; pointer-events: none; }
#fuel i { position: absolute; inset: 0; border-radius: 3px; background: var(--teal); box-shadow: 0 0 10px var(--teal); transform-origin: left; transform: scaleX(var(--k, 1)); }
#fuel.on { opacity: 1; }
#fade { position: fixed; inset: 0; z-index: 20; background: #050814; opacity: 0; pointer-events: none; transition: opacity .3s; }
#fade.on { opacity: 1; }

/* ---------------- title */
#title { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; padding: calc(24px + var(--sat)) calc(28px + var(--sar)) calc(24px + var(--sab)) calc(28px + var(--sal)); background: linear-gradient(90deg, rgba(4, 7, 20, 0) 0%, rgba(4, 7, 20, 0) 42%, rgba(4, 7, 20, 0.5) 64%, rgba(4, 7, 20, 0.62) 100%); opacity: 0; transition: opacity 1s .2s; }
body.ready #title { opacity: 1; }
#title.gone { opacity: 0 !important; pointer-events: none; transition: opacity .7s; }
.t-wrap { margin-left: auto; width: min(440px, 52vw); }
.t-kicker { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--teal); }
h1 { margin: 10px 0 0; line-height: .9; }
h1 span { display: block; font: 800 clamp(54px, 9vw, 104px)/.86 "Archivo XC", Switzer, sans-serif; letter-spacing: -.01em; color: #fff; text-shadow: 0 0 40px rgba(46, 230, 214, 0.35); }
h1 em { display: block; margin-top: 6px; font: 800 clamp(22px, 3.3vw, 36px)/1 "Archivo XC", Switzer, sans-serif; font-style: normal; color: var(--amber); letter-spacing: .02em; text-transform: uppercase; }
.t-line { margin: 18px 0 22px; font-size: clamp(15px, 1.6vw, 17px); color: #cfe0f5; line-height: 1.5; }
.primary { display: inline-flex; align-items: center; justify-content: center; min-height: 52px; padding: 0 28px; border-radius: 999px; background: var(--teal); color: #04201d; font: 700 16px Switzer, sans-serif; letter-spacing: .01em; box-shadow: 0 0 0 0 rgba(46, 230, 214, 0.5), 0 10px 30px rgba(46, 230, 214, 0.25); text-decoration: none; transition: transform .12s, box-shadow .3s; }
#start { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(46, 230, 214, 0), 0 10px 40px rgba(46, 230, 214, 0.45); } }
.primary:active { transform: scale(.97); }
.ghost { display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1px solid rgba(160, 220, 255, 0.28); background: rgba(10, 18, 40, 0.5); color: #e6f4ff; text-decoration: none; font-size: 15px; }
.t-keys { margin-top: 16px; font-size: 13px; color: var(--muted); }
body.touch .desk-only, body.desk .touch-only { display: none; }
.t-rotate { display: none; margin-top: 10px; font-size: 13px; color: var(--amber); }
body.portrait .t-rotate { display: block; }
.back { position: absolute; top: calc(16px + var(--sat)); left: calc(18px + var(--sal)); padding: 9px 14px; border-radius: 999px; background: rgba(8, 14, 32, 0.5); border: 1px solid var(--line); text-decoration: none; font-size: 14px; color: #dbeaff; }
body.portrait #title { align-items: flex-end; background: linear-gradient(180deg, rgba(4, 7, 20, 0) 30%, rgba(4, 7, 20, 0.85) 60%); }
body.portrait .t-wrap { width: 100%; margin: 0; }

/* ---------------- overlays */
.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(3, 6, 16, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); opacity: 0; pointer-events: none; transition: opacity .4s; padding: 20px; }
.overlay.on { opacity: 1; pointer-events: auto; }
.panel { display: flex; flex-direction: column; gap: 10px; min-width: 260px; padding: 24px; border-radius: 22px; background: rgba(8, 14, 32, 0.85); border: 1px solid var(--line); }
.panel h2 { margin: 0 0 6px; font: 800 26px "Archivo XC", sans-serif; text-transform: uppercase; }
.mute .off, .mute.muted .on { display: none; }
.mute.muted .off { display: inline; }

#end { background: radial-gradient(ellipse at 70% 40%, rgba(255, 170, 110, 0.12), rgba(3, 6, 16, 0.45)); }
.phone { width: min(400px, 92vw); max-height: 92vh; overflow: auto; padding: 16px 18px 20px; border-radius: 30px; background: rgba(250, 247, 242, 0.96); color: #121826; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 7px rgba(10, 14, 26, 0.9); transform: translateY(24px) scale(.97); transition: transform .7s cubic-bezier(.2, .9, .2, 1.1); }
#end.on .phone { transform: none; }
.p-top { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: #475066; padding: 0 4px 10px; }
.p-head { font-weight: 600; color: #121826; }
.bubble { padding: 14px 16px; border-radius: 20px 20px 20px 6px; background: #0c1330; color: #eafcff; font-size: 15px; line-height: 1.45; box-shadow: 0 0 0 1px rgba(46, 230, 214, 0.25); }
.b-hi { font: 800 19px "Archivo XC", sans-serif; color: var(--teal); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .01em; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 6px; }
.stats div { padding: 10px; border-radius: 14px; background: #fff; border: 1px solid #e3e6ec; display: flex; flex-direction: column; gap: 2px; }
.stats b { font: 800 24px/1 "Archivo XC", sans-serif; color: #0c1330; font-variant-numeric: tabular-nums; }
.stats span { font-size: 11.5px; color: #5b6478; line-height: 1.25; }
.stats i { font-style: normal; }
.p-sign { margin: 12px 2px; font-size: 13px; color: #5b6478; }
.p-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.p-btns .ghost { color: #121826; background: #fff; border-color: #d9dee8; min-height: 46px; }
.p-btns .primary { flex: 1 0 100%; }

/* ---------------- loading */
#loading { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; align-content: center; gap: 18px; background: radial-gradient(ellipse at 50% 40%, #101a3c, #050814 70%); transition: opacity .8s; }
#loading.gone { opacity: 0; pointer-events: none; }
.l-logo { width: 96px; filter: drop-shadow(0 0 18px rgba(46, 230, 214, 0.6)); animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.l-bar { width: 180px; height: 4px; border-radius: 2px; background: rgba(160, 220, 255, 0.15); overflow: hidden; }
.l-bar i { display: block; height: 100%; background: var(--teal); transform-origin: left; transform: scaleX(0); transition: transform .3s; box-shadow: 0 0 10px var(--teal); }
#loadmsg { font-size: 13px; color: var(--muted); letter-spacing: .04em; }

@media (max-height: 460px) {
  .chip { height: 36px; } .ibtn { width: 40px; height: 40px; }
  #cards { top: calc(54px + var(--sat)); width: min(340px, 60vw); }
  .card { padding: 8px 12px 9px; } .c-q { font-size: 14px; }
  .t-line { margin: 12px 0 14px; }
}
@media (prefers-reduced-motion: reduce) { #start { animation: none; } }
