:root { --fg: #f4f1ea; --dim: rgba(244,241,234,.6); --accent: #ff8a2a; --cool: #7cc4ff; }
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; overflow: hidden; background: #0b0a16; color: var(--fg); font-family: Inter, system-ui, sans-serif; }
#c, #lines { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#lines { pointer-events: none; }
.hidden { display: none !important; }

#hud { position: fixed; inset: 0; pointer-events: none; font-family: 'Barlow Condensed', sans-serif; }
.tl { position: absolute; top: 22px; left: 26px; }
.rings { display: flex; align-items: center; gap: 10px; font-size: 44px; font-style: italic; font-weight: 800; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.chipicon { width: 30px; height: 30px; border-radius: 50%; background: #c3262e; border: 5px dashed #f4efe6; box-shadow: 0 0 0 2px #c3262e, 0 0 10px rgba(255,90,60,.5); }
.time { margin-top: 2px; padding: 3px 12px; display: inline-block; font-size: 22px; font-weight: 700; letter-spacing: .04em;
  background: rgba(10,10,22,.55); border-radius: 999px; backdrop-filter: blur(6px); }
.bl { position: absolute; left: 26px; bottom: 26px; width: 300px; }
.speed { display: flex; align-items: baseline; gap: 6px; }
.speed b { font-size: 46px; font-style: italic; font-weight: 800; }
.speed span { font-size: 18px; color: var(--dim); font-weight: 600; }
.speed em { margin-left: auto; font-style: italic; font-weight: 800; font-size: 22px; color: var(--cool); text-transform: uppercase; letter-spacing: .06em; }
.gauge { position: relative; height: 14px; border-radius: 999px; background: rgba(10,10,22,.6); overflow: hidden; border: 1px solid rgba(255,255,255,.15); }
.gauge div { position: absolute; inset: 0; transform-origin: left; background: linear-gradient(90deg, #3a8cff, var(--cool)); }
.gauge span { position: absolute; right: 8px; top: -1px; font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }

#reticle { position: absolute; left: 0; top: 0; width: 64px; height: 64px; display: none; animation: spin 1.2s linear infinite; }
#reticle i { position: absolute; width: 18px; height: 18px; border: 4px solid var(--accent); }
#reticle i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; }
#reticle i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; }
#reticle i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; }
#reticle i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; }
@keyframes spin { to { rotate: 90deg; } }

#toast { position: absolute; top: 22%; left: 50%; translate: -50% 0; font-size: 34px; font-style: italic; font-weight: 800; letter-spacing: .05em;
  text-transform: uppercase; opacity: 0; transition: opacity .25s; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
#toast.on { opacity: 1; }
/* title cards (a world as you come out of its tunnel, a boss as it shows up) and the chase meter */
#tcard { position: absolute; left: 0; right: 0; top: 27%; text-align: center; pointer-events: none; opacity: 0; }
#tcard.on { animation: tcard 2.8s ease both; }
#tcard b { display: block; font: italic 800 clamp(44px, 7.5vw, 104px)/.95 'Barlow Condensed', sans-serif; color: #f4f2ec; text-shadow: 0 6px 30px rgba(0,0,0,.55); }
#tcard span { display: inline-flex; align-items: center; gap: 14px; margin-top: 8px; font-size: 14px; font-weight: 700; letter-spacing: .32em; text-transform: uppercase; color: #ffd27a; text-shadow: 0 2px 10px rgba(0,0,0,.6); }
#tcard span::before, #tcard span::after { content: ''; width: 46px; height: 2px; background: currentColor; opacity: .7; }
#tcard.on b { animation: tcardB 2.8s cubic-bezier(.2,.7,.2,1) both; }
@keyframes tcard { 0% { opacity: 0; } 12% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes tcardB { 0% { letter-spacing: .25em; } 30% { letter-spacing: 0; } 100% { letter-spacing: -.01em; } }
#chase { position: absolute; left: 50%; bottom: 15%; translate: -50% 0; display: none; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 999px;
  background: rgba(12,10,20,.55); border: 2px solid rgba(255,255,255,.2); backdrop-filter: blur(8px); font: 700 13px Inter, sans-serif; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
#chase.on { display: flex; }
#chase i { font: italic 800 22px/1 'Barlow Condensed', sans-serif; font-style: normal; }
#chase em { width: 110px; height: 8px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; }
#chase u { display: block; height: 100%; background: var(--accent); }
#chase.close { border-color: var(--accent); border-style: dashed; animation: chasePulse .35s ease-in-out infinite alternate; }
@keyframes chasePulse { to { transform: scale(1.06); } }

.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at center, rgba(11,10,22,.35), rgba(11,10,22,.85)); }
.card { padding: 30px 34px; border-radius: 22px; background: rgba(20,18,36,.62); border: 1px solid rgba(255,255,255,.12); backdrop-filter: blur(18px); min-width: 380px; }
.card h1 { font-family: 'Barlow Condensed', sans-serif; font-style: italic; font-weight: 800; font-size: 64px; line-height: .9; letter-spacing: .02em; }
.sub { color: var(--dim); margin: 6px 0 18px; font-size: 14px; }
.card table { width: 100%; border-collapse: collapse; font-size: 14px; }
.card td { padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.07); }
.card td:last-child { text-align: right; color: var(--dim); font-weight: 500; }
.pad { margin-top: 12px; font-size: 12px; color: var(--dim); }
.card button { margin-top: 20px; width: 100%; padding: 13px; border: 0; border-radius: 999px; background: var(--fg); color: #111; font-weight: 600; font-size: 15px; cursor: pointer; }
.card button:hover { background: #fff; }
.card button:disabled { opacity: .55; cursor: default; }
.lil-gui.root { position: fixed; top: 12px; right: 12px; }

#results td:last-child { font-family: 'Barlow Condensed', sans-serif; font-size: 22px; font-weight: 700; color: var(--fg); }
.alt { margin-top: 12px; text-align: center; font-size: 13px; }
.alt a { color: var(--dim); }

.tr { position: absolute; top: 22px; right: 26px; text-align: right; }
.score span { display: block; font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); }
.score b { font-size: 34px; font-style: italic; font-weight: 800; }
#popup { position: absolute; left: 50%; top: 34%; translate: -50% 0; font-size: 30px; font-style: italic; font-weight: 800; color: #ffc23a;
  opacity: 0; transition: opacity .2s, transform .5s; text-shadow: 0 2px 8px rgba(0,0,0,.6); }
#popup.on { opacity: 1; transform: translateY(-14px); }
.card { max-width: calc(100vw - 32px); }
.levels { display: grid; gap: 8px; margin: 4px 0 4px; }
.lv { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; border-radius: 14px; border: 1px solid rgba(255,255,255,.12);
  color: var(--fg); text-decoration: none; background: rgba(255,255,255,.03); }
.lv span { font-size: 12px; color: var(--dim); }
.lv.on { border-color: rgba(255,194,58,.7); background: rgba(255,194,58,.08); }
details { margin-top: 14px; font-size: 13px; color: var(--dim); }
summary { cursor: pointer; }
details table { margin-top: 8px; color: var(--fg); }
.ghost-btn { background: transparent !important; color: var(--fg) !important; border: 1px solid rgba(255,255,255,.25) !important; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.row2 button { margin-top: 8px !important; }
.rank-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.rank { font-family: 'Barlow Condensed', sans-serif; font-style: italic; font-weight: 800; font-size: 96px; line-height: 1; color: #ffc23a;
  width: 110px; height: 110px; display: grid; place-items: center; border: 3px solid currentColor; border-radius: 22px; }
.results tr.total td { border-top: 1px solid rgba(255,255,255,.25); font-weight: 700; }
.record { margin-top: 10px; min-height: 18px; font-size: 13px; color: #ffc23a; text-align: center; }
.settings { margin-top: 16px; display: grid; gap: 10px; font-size: 13px; }
.settings label { display: flex; justify-content: space-between; align-items: center; gap: 12px; color: var(--dim); }
.settings select, .settings input[type=range] { accent-color: #ffc23a; }
.settings select { background: rgba(255,255,255,.06); color: var(--fg); border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 4px 8px; }
@media (max-width: 520px) { .card { min-width: 0; padding: 22px 20px; } .rank { font-size: 64px; width: 80px; height: 80px; } .card h1 { font-size: 48px; } }

/* phone controls */
#touch { position: fixed; inset: 0; display: none; pointer-events: none; touch-action: none; user-select: none; -webkit-user-select: none; }
#touch.on { display: block; }
#touch .stick-zone { position: absolute; left: 0; top: 30%; bottom: 0; width: 45%; pointer-events: auto; }
#touch .look-zone { position: absolute; right: 0; top: 0; bottom: 0; width: 55%; pointer-events: auto; }
#touch .stick { position: absolute; left: 0; top: 0; width: 112px; height: 112px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.06); opacity: 0; transition: opacity .15s; }
#touch .stick.on { opacity: 1; }
#touch .stick i { position: absolute; left: 34px; top: 34px; width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.55); }
#touch .tb { position: absolute; pointer-events: auto; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.4); background: rgba(20,18,36,.45);
  color: var(--fg); font: 700 13px Inter, sans-serif; letter-spacing: .04em; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#touch .tb.down { background: rgba(255,194,58,.5); border-color: #ffc23a; }
#touch .t-jump { right: 22px; bottom: 34px; width: 84px; height: 84px; }
#touch .t-boost { right: 118px; bottom: 26px; width: 70px; height: 70px; }
#touch .t-act { right: 34px; bottom: 132px; width: 60px; height: 60px; }
#touch .t-ql { right: 186px; bottom: 30px; width: 48px; height: 48px; font-size: 22px; }
#touch .t-qr { right: 112px; bottom: 112px; width: 48px; height: 48px; font-size: 22px; }
#touch .t-trick { right: 104px; bottom: 176px; width: 58px; height: 58px; font-size: 13px; }
#touch .t-pause { left: 50%; top: 14px; translate: -50% 0; width: 44px; height: 44px; font-size: 12px; }
body.touch .bl { bottom: auto; top: 96px; width: 200px; }
body.touch .speed b { font-size: 30px; }
body.touch .rings { font-size: 32px; }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; mix-blend-mode: screen; }
.rings.bump b { animation: bump .18s ease-out; display: inline-block; }
@keyframes bump { 50% { transform: scale(1.25); } }

.flychip { position: fixed; width: 22px; height: 22px; border-radius: 50%; pointer-events: none; z-index: 5;
  border: 4px dashed #f4efe6; transform: translate(-50%, -50%); transition: left .38s cubic-bezier(.5,0,.8,.4), top .38s cubic-bezier(.5,0,.8,.4), transform .38s; }
.flychip.v1 { background: #ece6da; border-color: #2a3550; } .flychip.v5 { background: #c3262e; } .flychip.v25 { background: #1d8a4e; } .flychip.v100 { background: #141418; border-color: #e6b54a; }

/* style meter: shows while a chain of clean moves is running; the bar is the time left */
.style { margin-top: 6px; text-align: right; opacity: 0; transform: translateY(-4px); transition: opacity .2s, transform .2s; }
.style.on { opacity: 1; transform: none; }
.style span { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-right: 6px; }
.style b { font-size: 26px; font-style: italic; font-weight: 800; color: #ffd27a; }
.style i { display: block; height: 3px; margin-top: 3px; margin-left: auto; width: 100%; max-width: 120px; background: #ffd27a; border-radius: 2px; transform-origin: right; }

/* main menu: one run */
.card .best { margin: 14px 0 10px; font-size: 15px; font-weight: 700; letter-spacing: .04em; color: var(--dim); }
.card .practice { display: block; margin-top: 12px; font-size: 13px; color: var(--dim); text-decoration: underline; text-underline-offset: 3px; }

/* player name + leaderboard */
.who { display: block; margin: 16px 0 4px; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); text-align: left; }
.who input { display: block; width: 100%; box-sizing: border-box; margin-top: 6px; padding: 10px 12px; font: 600 16px/1.2 inherit; letter-spacing: 0; text-transform: none; color: inherit; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.18); border-radius: 10px; outline: none; }
.who input:focus { border-color: rgba(255,210,122,.7); }
.who.need input { border-color: #ff9a3c; }
.board { margin-top: 16px; text-align: left; }
.board .tabs { display: flex; gap: 6px; margin-bottom: 8px; }
.board .tabs button { flex: 1; padding: 6px 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; background: transparent; color: var(--dim); border: 1px solid rgba(255,255,255,.14); border-radius: 8px; cursor: pointer; }
.board .tabs button.on { color: inherit; border-color: rgba(255,255,255,.4); background: rgba(255,255,255,.06); }
.board ol { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow: auto; }
.board li { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 10px; align-items: baseline; padding: 5px 4px; font-size: 14px; border-bottom: 1px solid rgba(255,255,255,.06); }
.board li .pos { color: var(--dim); font-weight: 700; }
.board li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li .tt { color: var(--dim); font-variant-numeric: tabular-nums; font-size: 12px; }
.board li b { font-variant-numeric: tabular-nums; }
.board li.me { background: rgba(255,210,122,.12); border-radius: 6px; }
.board li.me .nm::after { content: ' (you)'; color: var(--dim); }
.board li.empty { display: block; color: var(--dim); }
.board .place { margin: 8px 0 0; font-size: 13px; color: var(--dim); }
.board.compact ol { max-height: 170px; }

/* finale: the results card sits to the side over a light veil, so the celebration stays in view */
#results.finale { background: linear-gradient(90deg, rgba(11,10,22,0) 35%, rgba(11,10,22,.55)); place-items: center end; padding-right: 6vw; animation: resIn .6s ease both; }
@keyframes resIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
@media (max-width: 720px) { #results.finale { place-items: end center; padding: 0 16px 16px; background: linear-gradient(180deg, rgba(11,10,22,0) 30%, rgba(11,10,22,.6)); } }

/* the run's three legs against your best: ▲ faster, ▼ slower (arrow + sign, not colour alone) */
.splits { width: 100%; margin: 6px 0 2px; font-size: 13px; color: var(--dim); }
.splits td { padding: 2px 0; }
.splits td:nth-child(2) { text-align: right; font-variant-numeric: tabular-nums; color: var(--fg); }
.splits td.d { text-align: right; width: 84px; font-variant-numeric: tabular-nums; }
.card .practice a { color: inherit; }
#results .splits td { font-family: inherit; font-size: 13px; font-weight: 600; color: var(--dim); }
#results .splits td:nth-child(2) { color: var(--fg); }

/* start: fly-in title (lower left) and the 3-2-1-GO count */
#intro { position: fixed; left: 6vw; bottom: 9vh; pointer-events: none; animation: introIn 1s ease both; }
#intro b { display: block; font: italic 800 clamp(48px, 9vw, 120px)/0.9 'Barlow Condensed', sans-serif; letter-spacing: -.01em; color: #f4f2ec; text-shadow: 0 6px 30px rgba(0,0,0,.5); }
#intro span { display: block; margin-top: 6px; font-size: 15px; font-weight: 700; letter-spacing: .3em; text-transform: uppercase; color: #ffd27a; }
#intro em { display: block; margin-top: 16px; font-style: normal; font-size: 12px; color: rgba(255,255,255,.55); }
@keyframes introIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
#count { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; font: italic 800 clamp(90px, 18vw, 220px)/1 'Barlow Condensed', sans-serif; color: #fff; text-shadow: 0 8px 40px rgba(0,0,0,.55); opacity: 0; }
#count.on { animation: countPop .6s ease-out both; }
@keyframes countPop { 0% { opacity: 0; transform: scale(1.6); } 25% { opacity: 1; transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(.92); } }

/* shop */
#shopBtn { width: 100%; }
#shop, #missions { z-index: 10; }   /* over the menu card */
.card.shop { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto; }
.shop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.shop .wallet { margin: 0; font-size: 14px; color: var(--dim); }
.shop .wallet b { font-size: 22px; color: #ffd27a; }
.shop h3 { margin: 16px 0 8px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--dim); }
.shop .row { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.shop .it { display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; padding: 10px; border-radius: 10px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.04); color: inherit; cursor: pointer; }
.shop .it i { grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); }
.shop .it span { font-size: 14px; font-weight: 700; }
.shop .it em { font-style: normal; font-size: 12px; color: var(--dim); }
.shop .it.on { border-color: #ffd27a; background: rgba(255,210,122,.1); }
.shop .it.on em::before { content: '✓ '; }
.shop .it:disabled { opacity: .45; cursor: default; }
.shop .it.locked em::before { content: '⚠ '; }
/* missions: a list per world, ✓ for the done ones */
.mis { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.mis li { display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); font-size: 14px; }
.mis li b { font-size: 15px; color: #ffd27a; }
.mis li em { font-style: normal; font-size: 12px; color: var(--dim); white-space: nowrap; }
.mis li.done { border-color: rgba(255,210,122,.35); }
.mis li.done span { color: var(--dim); }
/* the banner when a mission or an achievement is done (top right, under the score) */
#mbanner { position: absolute; right: 24px; top: 110px; display: grid; gap: 2px; padding: 10px 16px 11px; border-radius: 14px; background: rgba(12,10,20,.6); border: 1px solid rgba(255,210,122,.45);
  backdrop-filter: blur(10px); text-align: right; opacity: 0; translate: 16px 0; transition: opacity .3s, translate .3s; pointer-events: none; max-width: min(360px, 70vw); }
#mbanner.on { opacity: 1; translate: 0 0; }
#mbanner small { font-size: 11px; font-weight: 700; letter-spacing: .2em; text-transform: uppercase; color: #ffd27a; }
#mbanner small::before { content: '✓ '; }
#mbanner b { font-size: 15px; }
#mbanner em { font-style: normal; font-size: 12px; color: var(--dim); }
#shopClose { margin-top: 18px; width: 100%; }
.wallet-note { margin: 4px 0 0; font-size: 13px; color: #ffd27a; }

/* mode picker */

/* the trailer camera (?cine=1): nothing over the picture */
body.cine #hud, body.cine .overlay, body.cine #flash, body.cine #intro, body.cine #count { display: none !important; }
