/* Golden-ratio system: base unit --u; every size/space below is u * phi^n; type follows Fibonacci px. */
:root {
  --phi: 1.618;
  --u: 8px;
  --s1: var(--u);
  --s2: calc(var(--u) * 1.618);
  --s3: calc(var(--u) * 2.618);
  --s4: calc(var(--u) * 4.236);
  --s5: calc(var(--u) * 6.854);
  --t0: 13px; --t1: 21px; --t2: 34px; --t3: 55px; --t4: 89px;
  --ink: #0d0d0f; --plum: #1a0e26; --amber: #ffb238; --rail: #ff3b3b; --mint: #4fe3b1; --cream: #f5e9d3; --teal: #22b6b0;
  --display: 'Bungee', Impact, 'Arial Black', sans-serif;
  --ui: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  --fast: 0.236s; --settle: 0.382s;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--cream); overflow: hidden; font-family: var(--ui); font-weight: 500; touch-action: none; user-select: none; -webkit-user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
[hidden] { display: none !important; }

/* --- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; padding: max(var(--s1), env(safe-area-inset-top)) max(var(--s1), env(safe-area-inset-right)) var(--s1) max(var(--s1), env(safe-area-inset-left)); text-shadow: 0 2px 0 rgba(13,13,15,.6); }
.hud-tl { position: absolute; left: max(var(--s2), env(safe-area-inset-left)); top: max(var(--s1), env(safe-area-inset-top)); }
.route { display: flex; flex-direction: column; line-height: 1; }
#hud-route { font-family: var(--display); font-size: var(--t0); color: var(--amber); letter-spacing: .08em; }
#hud-name { font-size: var(--t1); font-weight: 700; text-transform: uppercase; margin-top: 3px; }
.stats { display: flex; gap: var(--s2); align-items: baseline; margin-top: var(--s1); font-size: var(--t1); font-weight: 700; font-variant-numeric: tabular-nums; }
#hud-score { color: var(--mint); }
.hud-tc { position: absolute; left: 50%; top: max(var(--s2), env(safe-area-inset-top)); transform: translateX(-50%); width: min(38vw, 377px); text-align: center; }
.track { position: relative; height: 8px; border-radius: 8px; background: rgba(13,13,15,.55); border: 2px solid rgba(245,233,211,.55); }
.track i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, var(--amber), var(--mint)); border-radius: 8px; }
.track b { position: absolute; top: -8px; left: 0; width: 21px; height: 21px; margin-left: -10px; border-radius: 50%; background: var(--cream); border: 3px solid var(--rail); }
#hud-best { margin-top: 13px; font-size: var(--t0); letter-spacing: .12em; opacity: .8; }
#heat { position: absolute; left: 50%; bottom: 21%; transform: translateX(-50%); text-align: center; opacity: 0; transition: opacity var(--fast); }
#heat.on { opacity: 1; }
#heat span { display: block; font-family: var(--display); font-size: var(--t1); color: var(--rail); letter-spacing: .04em; animation: hb .3s steps(2) infinite; }
#heat i { display: block; width: 233px; height: 8px; margin: 8px auto 0; border-radius: 8px; background: rgba(13,13,15,.55); border: 2px solid var(--cream); overflow: hidden; }
#heat s { display: block; height: 100%; background: var(--rail); }
@keyframes hb { 50% { opacity: .35; } }
#cross { position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2px; border-radius: 50%; background: rgba(245,233,211,.7); }
#hud-hint { position: absolute; left: 50%; bottom: max(var(--s1), env(safe-area-inset-bottom)); transform: translateX(-50%); font-size: var(--t0); letter-spacing: .14em; opacity: .5; }
body.touch #hud-hint { display: none; }
#buffs { position: absolute; left: max(var(--s2), env(safe-area-inset-left)); top: 50%; display: flex; flex-direction: column; gap: 8px; }
.buff { display: flex; align-items: center; gap: 8px; font-size: var(--t0); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.buff i { display: block; width: 55px; height: 5px; border-radius: 5px; background: rgba(245,233,211,.25); overflow: hidden; }
.buff i s { display: block; height: 100%; background: currentColor; }
#banner { position: absolute; left: 50%; top: 21%; transform: translate(-50%, -8px) scale(.9); opacity: 0; text-align: center; transition: opacity var(--fast), transform var(--settle) cubic-bezier(.2,1.4,.4,1); }
#banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#banner strong { display: block; font-family: var(--display); font-size: var(--t2); letter-spacing: .04em; color: var(--c, var(--amber)); }
#banner span { font-size: var(--t1); font-weight: 700; text-transform: uppercase; }
#flash { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, rgba(255,59,59,0) 30%, rgba(255,59,59,.85) 100%); opacity: 0; transition: opacity var(--settle); }
#flash.on { opacity: 1; transition: none; }

/* --- buttons: icon row, fs button is the standard sg-fs-btn */
#sg-fs-btn { position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; padding: 0; border: 0; border-radius: 6px; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; z-index: 9999; }
#sg-fs-btn:hover { background: rgba(0,0,0,.7); }
.ib { position: fixed; top: max(8px, env(safe-area-inset-top)); width: 26px; height: 26px; padding: 0; border: 0; border-radius: 6px; background: rgba(0,0,0,.45); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 9999; }
.ib:hover { background: rgba(0,0,0,.7); }
#pause-btn { right: calc(max(8px, env(safe-area-inset-right)) + 34px); }
#mute-btn { right: calc(max(8px, env(safe-area-inset-right)) + 68px); }

/* --- touch controls */
#touch-layer { position: fixed; inset: 0; z-index: 5; display: none; touch-action: none; }
#stick-base { position: fixed; z-index: 6; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 3px solid rgba(245,233,211,.55); background: rgba(13,13,15,.35); display: none; pointer-events: none; }
#stick-base.on { display: block; }
#stick-knob { position: absolute; left: 50%; top: 50%; width: 55px; height: 55px; border-radius: 50%; background: rgba(245,233,211,.6); transform: translate(-50%,-50%); }
#jump-btn { position: fixed; z-index: 7; right: max(var(--s3), env(safe-area-inset-right)); bottom: max(var(--s3), env(safe-area-inset-bottom)); width: 89px; height: 89px; border-radius: 50%; border: 4px solid var(--amber); background: rgba(255,178,56,.28); color: var(--cream); font-family: var(--display); font-size: var(--t0); display: none; touch-action: none; }
#jump-btn.down { background: rgba(255,178,56,.7); transform: scale(.94); }
body.touch.playing #touch-layer, body.touch.playing #jump-btn { display: block; }
body.touch #hud-hint { display: none; }

/* --- screens */
.screen { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: var(--s2); background: radial-gradient(ellipse at 50% 60%, rgba(26,14,38,.15), rgba(13,13,15,.7)); overflow: auto; touch-action: pan-y; }
#pause, #complete, #how, #stats { background: rgba(13,13,15,.72); backdrop-filter: blur(3px); }
.card { margin: auto; text-align: center; max-width: 100%; width: 377px; display: flex; flex-direction: column; align-items: center; gap: var(--s2); }
.card.wide { width: 610px; }
h1 { margin: 0; font-family: var(--display); font-weight: 400; line-height: .9; display: flex; flex-direction: column; text-shadow: 0 5px 0 var(--rail), 0 10px 0 rgba(13,13,15,.5); }
h1 span:first-child { font-size: clamp(34px, 9vh, var(--t3)); color: var(--cream); letter-spacing: .06em; }
h1 span:last-child { font-size: clamp(55px, 15vh, var(--t4)); color: var(--amber); }
h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: var(--t2); color: var(--amber); text-shadow: 0 3px 0 rgba(13,13,15,.6); }
.tag { margin: 0; font-size: var(--t1); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--cream); }
.small { margin: 0; font-size: var(--t0); letter-spacing: .14em; text-transform: uppercase; opacity: .6; }
button { font-family: var(--ui); cursor: pointer; }
button.big { font-family: var(--display); font-size: var(--t1); letter-spacing: .06em; padding: var(--s2) var(--s4); min-width: 233px; border: 4px solid var(--cream); border-radius: 13px; background: var(--rail); color: var(--cream); box-shadow: 0 6px 0 #7d1414; transition: transform var(--fast), box-shadow var(--fast); }
button.big:hover, button.big:focus-visible { transform: translateY(-2px); box-shadow: 0 8px 0 #7d1414; outline: none; }
button.big:active { transform: translateY(4px); box-shadow: 0 2px 0 #7d1414; }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: center; }
.row button, button.sm { font-size: var(--t1); font-weight: 700; letter-spacing: .1em; padding: var(--s1) var(--s2); border: 3px solid rgba(245,233,211,.6); border-radius: 8px; background: rgba(13,13,15,.55); color: var(--cream); }
.row button:hover, button.sm:hover { border-color: var(--amber); color: var(--amber); }
.pick { display: flex; align-items: center; gap: var(--s2); }
.pick div { display: flex; flex-direction: column; align-items: center; min-width: 144px; line-height: 1; }
.pick small { font-size: var(--t0); letter-spacing: .3em; opacity: .7; }
.pick b { font-family: var(--display); font-size: var(--t3); font-weight: 400; color: var(--mint); }
.pick em { font-style: normal; font-size: var(--t1); font-weight: 700; text-transform: uppercase; }
.how { list-style: none; margin: 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: var(--s1); font-size: var(--t1); line-height: 1.2; }
.how b { color: var(--amber); text-transform: uppercase; letter-spacing: .08em; margin-right: 6px; }
body.touch .how .pc { display: none; }
body:not(.touch) .how .tc { display: none; }
.res { display: flex; gap: var(--s3); }
.res div { display: flex; flex-direction: column; line-height: 1; }
.res small { font-size: var(--t0); letter-spacing: .3em; opacity: .7; }
.res b { font-family: var(--display); font-weight: 400; font-size: var(--t2); color: var(--mint); font-variant-numeric: tabular-nums; }
#stats-body { width: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(144px, 1fr)); gap: var(--s1); font-size: var(--t1); font-weight: 700; max-height: 44vh; overflow: auto; text-align: left; }
#stats-body .tot { grid-column: 1 / -1; text-align: center; color: var(--amber); letter-spacing: .08em; }
#stats-body .lv { display: flex; justify-content: space-between; gap: 8px; padding: 5px 13px; border-radius: 8px; background: rgba(245,233,211,.08); font-variant-numeric: tabular-nums; }
#stats-body .lv.no { opacity: .35; }

@media (max-height: 420px) {
  .card { gap: var(--s1); }
  h1 span:first-child { font-size: 26px; } h1 span:last-child { font-size: 42px; }
  .pick b { font-size: var(--t2); }
  button.big { padding: var(--s1) var(--s3); min-width: 180px; }
  .tag { font-size: 16px; } .small { display: none; }
  .how { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { #banner, button.big { transition: none; } }
