/* TRIALS CAT - UI styles. Yellow #ffd200 / black, glassy panels, condensed italic display type. */
:root {
  --y: #ffd200;
  --y-dim: #b89600;
  --ink: #0b0c0f;
  --ink-2: #14161b;
  --glass: rgba(12, 13, 17, 0.72);
  --glass-2: rgba(22, 24, 30, 0.78);
  --line: rgba(255, 255, 255, 0.12);
  --txt: #f4f5f7;
  --mut: #9aa0ab;
  --red: #ff3b2f;
  --green: #52e08a;
  --font: "Bahnschrift", "Barlow Condensed", "Oswald", "Roboto Condensed", "Avenir Next Condensed", "Arial Narrow", "Helvetica Neue", "DejaVu Sans Condensed", system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #0b0c0f; color: var(--txt); font-family: var(--font); overflow: hidden; overscroll-behavior: none; }
body { -webkit-user-select: none; user-select: none; touch-action: none; }
#app { position: fixed; inset: 0; overflow: hidden; background: radial-gradient(120% 100% at 50% 0%, #1a1d26, #08090b); }
#canvas-root { position: absolute; inset: 0; }
#canvas-root canvas { display: block; width: 100% !important; height: 100% !important; }
#ui { position: absolute; inset: 0; pointer-events: none; }
#ui > * { pointer-events: none; }
button { font: inherit; color: inherit; }
i { font-style: italic; }

/* ------------ boot splash ------------ */
#boot { position: absolute; inset: 0; z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; background: #08090b; transition: opacity .6s ease, visibility .6s; }
#boot.done { opacity: 0; visibility: hidden; }
.boot-logo { display: flex; font-size: clamp(44px, 9vw, 96px); font-weight: 900; line-height: .9; text-transform: uppercase; transform: skewX(-8deg); }
.boot-logo .a i { display: block; background: var(--y); color: var(--ink); padding: 0 .16em 0 .1em; }
.boot-logo .b i { display: block; padding: 0 .1em 0 .16em; color: #fff; }
.boot-bar { width: min(320px, 60vw); height: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.boot-bar i { display: block; height: 100%; width: 40%; background: var(--y); animation: bootbar 1.1s ease-in-out infinite; }
@keyframes bootbar { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.boot-status { min-height: 1.3em; margin-top: -10px; font-size: 13px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--mut); text-align: center; }
#boot.determinate .boot-bar i { animation: none; transform: none; transition: width .5s var(--ease); }
#boot.failed .boot-bar i { width: 100%; background: var(--red); animation: none; transform: none; }
#boot.failed .boot-status { color: var(--red); }
.boot-fail { width: min(580px, 90vw); max-height: 56vh; overflow: auto; padding: 18px 22px 20px; background: var(--glass-2); border: 1px solid var(--line); border-left: 4px solid var(--y); text-align: left; user-select: text; -webkit-user-select: text; touch-action: pan-y; }
#boot.failed .boot-fail { border-left-color: var(--red); }
.boot-fail[hidden] { display: none; }
#boot.help { gap: 16px; padding: 12px 0; }
#boot.help .boot-logo { font-size: clamp(30px, 5vw, 52px); }
#boot.help .boot-fail { max-height: calc(100vh - 210px); }
.boot-fail h2 { margin: 0 0 6px; font-size: 22px; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; }
.boot-fail p { margin: 0 0 10px; font-size: 15px; line-height: 1.45; color: var(--txt); }
.boot-fail .boot-fail-lead { margin: 14px 0 4px; color: var(--mut); font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.boot-fail ol { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.5; color: var(--txt); }
.boot-fail li { margin-bottom: 6px; }
.boot-fail code { padding: 1px 6px; border-radius: 3px; background: rgba(255, 255, 255, .09); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; user-select: all; -webkit-user-select: all; }
.boot-fail-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 2px; }
.boot-fail-actions button { cursor: pointer; padding: 9px 18px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: var(--y); color: var(--ink); border: 0; }
.boot-fail-actions button + button { background: transparent; color: var(--txt); border: 1px solid var(--line); }
.boot-fail-actions button:hover { filter: brightness(1.1); }

/* ------------ logo ------------ */
.logo { display: inline-flex; font-weight: 900; text-transform: uppercase; line-height: .86; transform: skewX(-8deg); font-size: clamp(34px, 5vw, 60px); letter-spacing: -.01em; filter: drop-shadow(0 6px 18px rgba(0, 0, 0, .55)); }
.logo.big { font-size: clamp(56px, 9.2vw, 132px); }
.logo-a i { display: block; background: var(--y); color: var(--ink); padding: .04em .16em .02em .1em; clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%); }
.logo-b i { display: block; color: #fff; padding: .04em .1em .02em .16em; background: linear-gradient(#1b1d24, #0b0c0f); clip-path: polygon(8% 0, 100% 0, 100% 100%, 0 100%); box-shadow: inset 0 -.06em 0 var(--y); }
.tagline { margin-top: 14px; font-size: clamp(11px, 1.3vw, 16px); letter-spacing: .42em; color: var(--y); font-weight: 700; opacity: .92; }

/* ------------ screens ------------ */
.screens { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .35s ease, visibility 0s linear .35s; }
.screen.active { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .35s ease, visibility 0s; }

/* buttons */
.btn { position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: 14px; width: 100%; cursor: pointer; text-align: left;
  padding: 14px 28px 14px 22px; margin: 0; border: 0; border-left: 4px solid rgba(255, 210, 0, .0);
  background: linear-gradient(90deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .03));
  clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 100%, 0 100%);
  font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: .08em; font-size: clamp(16px, 1.9vw, 22px); color: var(--txt);
  transition: transform .18s var(--ease), background .18s, color .18s, border-color .18s; outline: none; }
.btn .btn-sub { font-weight: 600; font-size: .62em; letter-spacing: .12em; opacity: .7; font-style: normal; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn.primary { border-left-color: var(--y); background: linear-gradient(90deg, rgba(255, 210, 0, .22), rgba(255, 210, 0, .06)); }
.btn:hover, .btn:focus-visible, .btn:focus { background: var(--y); color: var(--ink); border-left-color: #fff; transform: translateX(10px); }
.btn.ghost { background: rgba(255, 255, 255, .04); color: #d5d8de; }
.btn.small { padding: 10px 22px 10px 16px; font-size: clamp(13px, 1.4vw, 16px); width: auto; }
.btn.danger { color: #ff8a80; }
.btn.danger:hover, .btn.danger:focus { background: var(--red); color: #fff; }
.btn.disabled, .btn:disabled { opacity: .35; cursor: not-allowed; }
.btn:disabled:hover { background: rgba(255, 255, 255, .05); color: var(--txt); transform: none; }

kbd.key { display: inline-block; min-width: 1.9em; padding: .18em .5em; margin: 0 .14em; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .28); border-bottom-width: 3px; background: rgba(255, 255, 255, .1); color: #fff; font-family: var(--font); font-weight: 800; font-size: .92em; text-align: center; font-style: normal; letter-spacing: .04em; }

.pips { display: inline-flex; gap: 4px; }
.pips i { width: 9px; height: 15px; background: rgba(255, 255, 255, .16); transform: skewX(-18deg); display: block; }
.pips i.on { background: var(--y); box-shadow: 0 0 8px rgba(255, 210, 0, .45); }
.stat { display: inline-flex; align-items: center; gap: 6px; margin-right: 14px; font-weight: 800; font-size: 20px; }
.stat b { font-variant-numeric: tabular-nums; }
.medal-ico { display: block; flex: none; }
.medal-ico.earned { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }

/* ------------ main menu ------------ */
.menu-shade { position: absolute; inset: 0; background: linear-gradient(90deg, rgba(6, 7, 9, .92) 0%, rgba(6, 7, 9, .78) 32%, rgba(6, 7, 9, .18) 62%, rgba(6, 7, 9, 0) 100%), linear-gradient(0deg, rgba(6, 7, 9, .7), rgba(6, 7, 9, 0) 34%); }
.menu-left { position: absolute; left: calc(var(--safe-l) + clamp(22px, 5.5vw, 90px)); top: 50%; transform: translateY(-50%); width: min(520px, 88vw); display: flex; flex-direction: column; }
.menu-screen.active .menu-left > * { animation: slidein .6s var(--ease) both; }
.menu-screen.active .menu-left > *:nth-child(2) { animation-delay: .08s; }
.menu-screen.active .menu-left > *:nth-child(3) { animation-delay: .16s; }
.menu-screen.active .menu-left > *:nth-child(4) { animation-delay: .24s; }
.menu-list { display: flex; flex-direction: column; gap: 9px; margin-top: 30px; width: min(380px, 100%); }
.menu-list .btn.primary .btn-sub { font-size: .58em; }
.menu-stats { display: flex; align-items: center; margin-top: 26px; flex-wrap: wrap; }
.stat-note { color: var(--mut); font-size: 13px; letter-spacing: .16em; text-transform: uppercase; font-weight: 700; }
.menu-foot { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 16px); padding: 0 calc(var(--safe-r) + 26px) 0 calc(var(--safe-l) + 26px); display: flex; justify-content: space-between; color: var(--mut); font-size: 13px; letter-spacing: .1em; font-weight: 600; }
.menu-foot .ver { opacity: .6; }
@keyframes slidein { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }

/* ------------ panels ------------ */
.panel { background: var(--glass); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2); border: 1px solid var(--line); border-top: 3px solid var(--y); box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.panel-head { display: flex; align-items: center; gap: 24px; }
.head-title h2, .pause-head h2, .res-head h2 { margin: 0; font-weight: 900; font-size: clamp(28px, 4.2vw, 52px); text-transform: uppercase; letter-spacing: .04em; line-height: 1; }
.head-sub { display: block; margin-top: 6px; color: var(--mut); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; }
.panel-foot { display: flex; gap: 12px; justify-content: flex-end; align-items: center; padding-top: 18px; }
.panel-foot .btn { width: auto; min-width: 180px; }

/* ------------ level select ------------ */
.levels-screen { background: linear-gradient(180deg, rgba(6, 7, 9, .9), rgba(6, 7, 9, .82)); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: flex; flex-direction: column; padding: calc(var(--safe-t) + 22px) calc(var(--safe-r) + clamp(16px, 4vw, 64px)) calc(var(--safe-b) + 14px) calc(var(--safe-l) + clamp(16px, 4vw, 64px)); }
.levels-screen .panel-head { flex: none; padding-bottom: 16px; }
.levels-screen .panel-head .btn { flex: none; }
.lv-medals { margin-left: auto; display: flex; }
.level-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 6px 30px; margin: 0 -6px; scrollbar-width: thin; scrollbar-color: var(--y-dim) transparent; touch-action: pan-y; }
.level-scroll::-webkit-scrollbar { width: 8px; } .level-scroll::-webkit-scrollbar-thumb { background: var(--y-dim); border-radius: 4px; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 17vw, 290px), 1fr)); gap: clamp(12px, 1.6vw, 22px); }
.level-card { position: relative; display: block; padding: 0; text-align: left; cursor: pointer; border: 2px solid rgba(255, 255, 255, .1); background: var(--glass-2); overflow: hidden; outline: none;
  transition: transform .2s var(--ease), border-color .2s, box-shadow .2s; animation: cardin .5s var(--ease) both; }
@keyframes cardin { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
.level-card:hover, .level-card:focus { border-color: var(--y); transform: translateY(-5px); box-shadow: 0 16px 40px rgba(0, 0, 0, .55), 0 0 0 1px var(--y), 0 0 28px rgba(255, 210, 0, .22); }
.level-card.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
.lc-thumb { position: relative; aspect-ratio: 240 / 130; overflow: hidden; background: #222; }
.thumb-svg { display: block; width: 100%; height: 100%; }
.lc-num { position: absolute; left: 0; top: 0; padding: 4px 12px 4px 9px; background: var(--y); color: var(--ink); font-weight: 900; font-style: italic; font-size: 18px; clip-path: polygon(0 0, 100% 0, 84% 100%, 0 100%); }
.lc-theme { position: absolute; right: 8px; top: 8px; font-size: 11px; font-weight: 800; letter-spacing: .16em; padding: 3px 8px; background: rgba(0, 0, 0, .55); color: #fff; border-left: 3px solid var(--accent, var(--y)); }
.lc-body { padding: 10px 14px 12px; }
.lc-name { font-size: clamp(15px, 1.4vw, 20px); font-weight: 800; font-style: italic; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-row { display: flex; align-items: center; justify-content: space-between; margin: 7px 0; }
.lc-medals { display: inline-flex; gap: 3px; }
.lc-best { display: flex; align-items: baseline; gap: 8px; font-variant-numeric: tabular-nums; }
.lc-best-l { font-size: 11px; letter-spacing: .18em; color: var(--mut); font-weight: 700; }
.lc-best b { font-size: 19px; font-weight: 800; color: var(--y); } .lc-best b.dim { color: #d8b400; opacity: .5; }
.lc-faults { margin-left: auto; color: var(--mut); font-size: 12px; font-weight: 700; letter-spacing: .1em; }
.level-card.locked { filter: saturate(.25) brightness(.7); cursor: not-allowed; }
.lc-lock { position: absolute; inset: 0; background: rgba(4, 5, 7, .72); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 14px; text-align: center; }
.lock-ico { font-size: 28px; filter: grayscale(1) brightness(1.6); }
.lock-txt.sub { opacity: .6; font-size: 10px; margin-top: -2px; }
.lock-txt { font-size: 12px; letter-spacing: .1em; color: #ccc; font-weight: 700; text-transform: uppercase; line-height: 1.3; }

/* ------------ settings / controls ------------ */
.settings-screen { display: flex; align-items: center; justify-content: center; background: rgba(4, 5, 7, .6); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.settings-panel, .controls-panel { width: min(720px, 94vw); max-height: 92vh; display: flex; flex-direction: column; padding: 22px clamp(18px, 3vw, 40px) 20px; }
.controls-panel { width: min(860px, 94vw); }
.panel-head.compact { padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.settings-body { overflow-y: auto; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--y-dim) transparent; touch-action: pan-y; }
.group-title { margin: 18px 0 6px; font-size: 13px; letter-spacing: .3em; color: var(--y); font-weight: 800; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); min-height: 44px; }
.row > label { font-weight: 700; letter-spacing: .06em; font-size: 17px; text-transform: uppercase; flex: none; }
.row-ctl { display: flex; align-items: center; gap: 14px; justify-content: flex-end; flex: 1; min-width: 0; }
.row-val { min-width: 48px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--y); } .row-val.wide { min-width: 90px; white-space: nowrap; }
input[type=range] { -webkit-appearance: none; appearance: none; width: min(260px, 100%); height: 26px; background: transparent; cursor: pointer; outline: none; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; background: linear-gradient(90deg, var(--y) var(--p, 50%), rgba(255, 255, 255, .18) var(--p, 50%)); border-radius: 3px; }
input[type=range]::-moz-range-track { height: 6px; background: rgba(255, 255, 255, .18); border-radius: 3px; }
input[type=range]::-moz-range-progress { height: 6px; background: var(--y); border-radius: 3px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; background: #fff; border: 3px solid var(--y); transform: rotate(45deg) scale(.8); transition: transform .15s; }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; background: #fff; border: 3px solid var(--y); border-radius: 0; transform: rotate(45deg) scale(.8); }
input[type=range]:focus::-webkit-slider-thumb, input[type=range]:hover::-webkit-slider-thumb { transform: rotate(45deg) scale(1.05); background: var(--y); border-color: #fff; }
.seg { display: inline-flex; gap: 4px; }
.seg-btn { cursor: pointer; padding: 8px 16px; border: 1px solid var(--line); background: rgba(255, 255, 255, .05); font-weight: 800; letter-spacing: .1em; font-size: 14px; transition: background .15s, color .15s; outline: none; }
.seg-btn.on { background: var(--y); color: var(--ink); border-color: var(--y); }
.seg-btn:hover, .seg-btn:focus { box-shadow: 0 0 0 2px #fff; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 34px; height: 34px; cursor: pointer; border: 2px solid rgba(255, 255, 255, .25); transform: skewX(-12deg); outline: none; transition: transform .15s; }
.swatch.on { border-color: var(--y); box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--y); }
.swatch:hover, .swatch:focus { transform: skewX(-12deg) scale(1.15); border-color: #fff; }
.controls-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 36px; overflow-y: auto; padding-right: 6px; touch-action: pan-y; }
.ctl-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .06); font-size: 15px; }
.ctl-label { color: #d9dce2; font-weight: 600; text-align: right; }
.ctl-keys { white-space: nowrap; }
.tip { color: #c7cbd3; font-size: 14px; line-height: 1.5; font-weight: 500; margin: 6px 0; }

/* ------------ pause ------------ */
.pause-screen { display: flex; align-items: center; justify-content: center; background: radial-gradient(90% 90% at 50% 50%, rgba(4, 5, 7, .55), rgba(4, 5, 7, .82)); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); }
.pause-panel { width: min(440px, 92vw); padding: 26px 30px 30px; }
.pause-head { margin-bottom: 8px; }
.pause-level { margin-top: 8px; color: var(--y); font-weight: 700; letter-spacing: .16em; font-size: 13px; text-transform: uppercase; }
.pause-stats { display: flex; gap: 22px; margin-top: 16px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pause-stats span { display: flex; flex-direction: column; } .pause-stats small { color: var(--mut); letter-spacing: .2em; font-size: 10px; font-weight: 700; } .pause-stats b { font-size: 22px; font-variant-numeric: tabular-nums; }
.pause-panel .menu-list { width: 100%; margin-top: 20px; }

/* ------------ loading ------------ */
.loading-screen { background: radial-gradient(100% 100% at 50% 40%, #191c25, #06070a); display: flex; align-items: center; justify-content: center; }
.load-inner { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }
.load-name { margin-top: 24px; font-size: clamp(24px, 4vw, 44px); font-weight: 900; font-style: italic; letter-spacing: .08em; }
.load-sub { color: var(--y); letter-spacing: .3em; font-size: 13px; font-weight: 700; text-transform: uppercase; }
.load-bar { width: min(340px, 70vw); height: 4px; background: rgba(255, 255, 255, .12); overflow: hidden; margin-top: 8px; }
.load-bar i { display: block; width: 40%; height: 100%; background: var(--y); animation: bootbar 1s ease-in-out infinite; }

/* ------------ results ------------ */
.results-screen { display: flex; align-items: center; justify-content: center; background: radial-gradient(90% 90% at 50% 45%, rgba(4, 5, 7, .45), rgba(4, 5, 7, .86)); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); padding: var(--safe-t) var(--safe-r) var(--safe-b) var(--safe-l); }
.results-panel { width: min(900px, 94vw); max-height: 96vh; overflow: auto; padding: clamp(16px, 2.6vw, 34px) clamp(16px, 3vw, 44px) clamp(16px, 2.4vw, 30px); }
.results-screen.active .results-panel { animation: panelin .6s var(--ease) both; }
@keyframes panelin { from { opacity: 0; transform: translateY(30px) scale(.97); } to { opacity: 1; transform: none; } }
.res-head { position: relative; }
.res-kicker { color: var(--y); letter-spacing: .3em; font-size: 12px; font-weight: 800; margin-bottom: 8px; }
.newbest { position: absolute; right: 0; top: 4px; background: var(--y); color: var(--ink); font-weight: 900; letter-spacing: .12em; padding: 7px 22px 7px 16px; font-size: 16px; clip-path: polygon(0 0, 100% 0, 92% 100%, 0 100%); animation: pulse 1.2s ease-in-out infinite; transform-origin: right; }
@keyframes pulse { 50% { transform: scale(1.06); filter: brightness(1.15); } }
.res-main { display: grid; grid-template-columns: minmax(180px, 34%) 1fr; gap: clamp(14px, 3vw, 44px); margin: clamp(10px, 2vw, 24px) 0; align-items: center; }
.award { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 200px; }
.award-rays { position: absolute; width: 260px; height: 260px; opacity: 0; background: repeating-conic-gradient(from 0deg, rgba(255, 210, 0, .28) 0 8deg, transparent 8deg 24deg); border-radius: 50%; mask-image: radial-gradient(circle, #000 20%, transparent 68%); -webkit-mask-image: radial-gradient(circle, #000 20%, transparent 68%); }
.award.silver .award-rays { background: repeating-conic-gradient(from 0deg, rgba(220, 230, 245, .3) 0 8deg, transparent 8deg 24deg); }
.award.bronze .award-rays { background: repeating-conic-gradient(from 0deg, rgba(220, 140, 80, .3) 0 8deg, transparent 8deg 24deg); }
.award-medal { position: relative; transform: translateY(-160px) scale(2.4) rotate(-25deg); opacity: 0; }
.award-medal svg { width: clamp(90px, 13vw, 140px); height: auto; }
.award-none { font-weight: 900; letter-spacing: .12em; color: var(--mut); border: 3px dashed rgba(255, 255, 255, .25); padding: 26px 20px; transform: rotate(-6deg); }
.award-name { position: relative; margin-top: 10px; font-weight: 900; font-style: italic; letter-spacing: .14em; font-size: clamp(16px, 2vw, 22px); opacity: 0; transform: translateY(10px); }
.award.gold .award-name { color: #ffd200; } .award.silver .award-name { color: #e3e8f0; } .award.bronze .award-name { color: #e79a5c; } .award.none .award-name { color: var(--mut); }
.award.go .award-medal { animation: medalDrop .8s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.award.go .award-rays { animation: raysin 1.2s .3s ease forwards, spin 14s linear infinite; }
.award.go .award-name { animation: fadeUp .5s .5s ease forwards; }
@keyframes medalDrop { 0% { transform: translateY(-160px) scale(2.4) rotate(-25deg); opacity: 0; } 55% { opacity: 1; } 100% { transform: none; opacity: 1; } }
@keyframes raysin { to { opacity: 1; } }
@keyframes spin { to { rotate: 360deg; } }
@keyframes fadeUp { to { opacity: 1; transform: none; } }
.res-table { display: flex; flex-direction: column; gap: 6px; }
.res-row { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.res-l { color: var(--mut); letter-spacing: .22em; font-size: 13px; font-weight: 800; }
.res-v { font-size: clamp(22px, 2.6vw, 30px); font-variant-numeric: tabular-nums; font-weight: 800; } .res-v.pen { color: #ff8a80; }
.res-row.total { border-bottom: 0; padding-top: 2px; } .res-v.big { font-size: clamp(34px, 5vw, 58px); color: var(--y); font-style: italic; }
.res-sep { height: 2px; background: linear-gradient(90deg, var(--y), transparent); margin: 2px 0; }
.res-best { color: #c5c9d1; letter-spacing: .1em; font-size: 13px; font-weight: 600; margin-top: 4px; }
.res-targets { display: flex; gap: 16px; margin-top: 8px; flex-wrap: wrap; }
.tgt { display: inline-flex; align-items: center; gap: 6px; opacity: .45; font-variant-numeric: tabular-nums; font-weight: 700; } .tgt.hit { opacity: 1; }
.res-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.res-buttons .btn { flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 3px; padding-right: 34px; }
.res-buttons .btn .btn-sub { font-size: .55em; }
.res-buttons .btn:hover, .res-buttons .btn:focus { transform: translateY(-3px); }

/* ------------ HUD ------------ */
.hud { position: absolute; inset: 0; opacity: 0; transition: opacity .4s; }
.hud.on { opacity: 1; }
.hud > * { pointer-events: none; position: absolute; }
.timer { top: calc(var(--safe-t) + 10px); left: 50%; transform: translateX(-50%); min-width: 250px; padding: 8px 34px 10px; text-align: center; background: linear-gradient(180deg, rgba(8, 9, 12, .8), rgba(8, 9, 12, .55)); border-bottom: 3px solid var(--y); clip-path: polygon(0 0, 100% 0, calc(100% - 22px) 100%, 22px 100%); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.t-line { font-weight: 900; font-style: italic; font-variant-numeric: tabular-nums; line-height: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, .5); white-space: nowrap; }
.t-main { font-size: clamp(34px, 5vw, 54px); } .t-frac { font-size: clamp(26px, 3.6vw, 40px); color: var(--y); } .t-ms { font-size: clamp(15px, 1.9vw, 22px); color: var(--y-dim); margin-left: 1px; }
.timer.over .t-main { color: #ff8577; }
.t-sub { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 5px; }
.faults { display: inline-flex; align-items: baseline; gap: 6px; font-weight: 800; letter-spacing: .12em; font-size: 12px; color: var(--mut); }
.faults b { font-size: 20px; color: #fff; font-variant-numeric: tabular-nums; } .faults em { font-style: normal; }
.faults.bump b { animation: bump .5s var(--ease); color: var(--red); }
@keyframes bump { 0% { transform: scale(2.2); } 100% { transform: scale(1); } }
.chips { display: inline-flex; gap: 10px; }
.chip { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; transition: opacity .3s, filter .3s; }
.chip.missed { opacity: .32; filter: grayscale(1); text-decoration: line-through; }

.speedo { left: calc(var(--safe-l) + 14px); bottom: calc(var(--safe-b) + 6px); width: clamp(150px, 17vw, 240px); filter: drop-shadow(0 4px 12px rgba(0, 0, 0, .55)); }
.speedo-svg { width: 100%; height: auto; display: block; overflow: visible; }
.arc-bg { stroke: rgba(10, 11, 14, .72); }
.arc-rev { stroke: var(--y); transition: stroke .1s; } .arc-rev.red { stroke: var(--red); }
.arc-ticks line { stroke: rgba(255, 255, 255, .55); stroke-width: 2; } .arc-ticks line.red { stroke: var(--red); }
.speed-num { fill: #fff; font-size: 54px; font-weight: 900; font-style: italic; font-family: var(--font); }
.speed-unit { fill: var(--y); font-size: 14px; letter-spacing: .3em; font-weight: 800; font-family: var(--font); }
.gear-num { fill: rgba(255, 255, 255, .7); font-size: 14px; letter-spacing: .2em; font-weight: 800; font-family: var(--font); }

.progress { left: 50%; bottom: calc(var(--safe-b) + 18px); transform: translateX(-50%); width: min(46vw, 560px); display: flex; align-items: center; gap: 10px; }
.progress .track { position: relative; flex: 1; height: 8px; background: rgba(8, 9, 12, .7); border: 1px solid rgba(255, 255, 255, .25); transform: skewX(-20deg); }
.progress .fill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--y-dim), var(--y)); width: 0; }
.progress .ticks span { position: absolute; top: -5px; bottom: -5px; width: 3px; margin-left: -1px; background: #fff; opacity: .85; }
.progress .marker { position: absolute; top: -8px; width: 14px; height: 22px; margin-left: -7px; background: var(--y); border: 2px solid #111; transform: skewX(20deg); box-shadow: 0 0 10px rgba(255, 210, 0, .7); }
.progress .marker.ghost { background: rgba(255, 255, 255, .5); border-color: rgba(255, 255, 255, .8); box-shadow: none; display: none; }
.progress .flag { font-size: 24px; color: var(--y); text-shadow: 0 2px 4px #000; line-height: 1; }

.hint { left: 50%; top: calc(var(--safe-t) + 172px); transform: translate(-50%, -12px); opacity: 0; transition: opacity .35s, transform .35s var(--ease); display: flex; flex-direction: column; gap: 8px; align-items: center; padding: 12px 24px; background: rgba(8, 9, 12, .68); border-left: 4px solid var(--y); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); font-weight: 700; letter-spacing: .06em; font-size: clamp(14px, 1.6vw, 19px); text-align: center; max-width: 92vw; width: max-content; }
.hint.on { opacity: 1; transform: translate(-50%, 0); }
.hint-row { display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; }
.hint-keys { display: inline-flex; gap: 2px; white-space: nowrap; }
.fps { right: calc(var(--safe-r) + 14px); top: calc(var(--safe-t) + 60px); display: none; font-weight: 800; color: var(--green); font-size: 14px; letter-spacing: .1em; background: rgba(0, 0, 0, .5); padding: 3px 8px; font-variant-numeric: tabular-nums; }
.hud-pause { pointer-events: auto !important; right: calc(var(--safe-r) + 14px); top: calc(var(--safe-t) + 12px); width: 40px; height: 40px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(8, 9, 12, .6); cursor: pointer; font-weight: 900; letter-spacing: 3px; transform: skewX(-12deg); }
.hud-pause span { display: block; transform: skewX(12deg); font-size: 15px; }
.hud-pause:hover { background: var(--y); color: var(--ink); }
.ghost-tag { display: none; left: 50%; top: calc(var(--safe-t) + 96px); transform: translateX(-50%); font-size: 11px; letter-spacing: .3em; font-weight: 800; color: rgba(255, 255, 255, .75); padding: 2px 10px; background: rgba(255, 255, 255, .12); }
.ghost-tag.on { display: block; }

/* ------------ intro / countdown / toast ------------ */
.intro-card { position: absolute; left: calc(var(--safe-l) + clamp(16px, 5vw, 80px)); top: 24%; padding: 18px 34px 18px 26px; min-width: min(420px, 86vw); background: linear-gradient(90deg, rgba(8, 9, 12, .86), rgba(8, 9, 12, .42)); border-left: 6px solid var(--accent, var(--y)); opacity: 0; transform: translateX(-60px); pointer-events: none; clip-path: polygon(0 0, 100% 0, calc(100% - 20px) 100%, 0 100%); }
.intro-card.in { animation: introin .7s var(--ease) both; }
.intro-card.out { animation: introout .5s ease both; }
@keyframes introin { from { opacity: 0; transform: translateX(-60px); } to { opacity: 1; transform: none; } }
@keyframes introout { from { opacity: 1; } to { opacity: 0; transform: translateX(-40px); } }
.ic-kicker { color: var(--accent, var(--y)); letter-spacing: .3em; font-size: 12px; font-weight: 800; }
.ic-name { font-size: clamp(30px, 5vw, 60px); font-weight: 900; text-transform: uppercase; letter-spacing: .03em; line-height: 1.05; margin: 6px 0 10px; text-shadow: 0 3px 0 rgba(0, 0, 0, .5); }
.ic-row { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.ic-targets { display: inline-flex; gap: 14px; font-weight: 800; font-size: 14px; font-variant-numeric: tabular-nums; } .ic-targets span { display: inline-flex; align-items: center; gap: 4px; }

.countdown { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); font-weight: 900; font-style: italic; font-size: clamp(90px, 20vw, 220px); line-height: 1; opacity: 0; color: #fff; text-shadow: 0 0 40px rgba(255, 210, 0, .45), 0 8px 0 rgba(0, 0, 0, .5); -webkit-text-stroke: 3px rgba(0, 0, 0, .55); }
.countdown.go { color: var(--y); font-size: clamp(90px, 22vw, 240px); }
.countdown.pop { animation: cdpop .8s var(--ease) both; }
.countdown.go.pop { animation: cdgo 1.1s var(--ease) both; }
@keyframes cdpop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(2.4); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.85); } }
@keyframes cdgo { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.5); } 20% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 60% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8); } }

.toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 118px); transform: translate(-50%, -20px); opacity: 0; text-align: center; transition: opacity .3s, transform .4s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-title { display: inline-block; font-weight: 900; font-size: clamp(22px, 3.4vw, 38px); letter-spacing: .12em; padding: 6px 30px; background: var(--y); color: var(--ink); clip-path: polygon(0 0, 100% 0, calc(100% - 14px) 100%, 14px 100%); }
.toast-sub { margin-top: 6px; font-weight: 800; letter-spacing: .14em; font-size: 17px; color: #fff; text-shadow: 0 2px 6px #000; font-variant-numeric: tabular-nums; }
.toast.small .toast-title { font-size: 18px; padding: 4px 22px; background: rgba(8, 9, 12, .8); color: #fff; border-bottom: 2px solid var(--y); }
.toast.finish .toast-title { font-size: clamp(34px, 6vw, 68px); padding: 8px 60px; }

.crash-overlay { position: absolute; inset: 0; opacity: 0; transition: opacity .3s; background: radial-gradient(100% 90% at 50% 50%, transparent 40%, rgba(255, 30, 20, .45)); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.crash-overlay.on { opacity: 1; }
.crash-word { font-weight: 900; font-size: clamp(50px, 10vw, 120px); color: #fff; letter-spacing: .08em; -webkit-text-stroke: 3px var(--red); text-shadow: 0 6px 0 rgba(0, 0, 0, .4); transform: translateY(-12vh) rotate(-3deg); }
.crash-overlay.on .crash-word { animation: crashin .35s var(--ease) both; }
.crash-sub { font-weight: 800; letter-spacing: .3em; font-size: 14px; color: #fff; text-shadow: 0 2px 6px #000; transform: translateY(-12vh); }
@keyframes crashin { from { opacity: 0; transform: translateY(-12vh) rotate(-3deg) scale(2); } to { opacity: 1; transform: translateY(-12vh) rotate(-3deg); } }

.fade-overlay { position: absolute; inset: 0; background: #000; opacity: 0; transition: opacity .35s; }
.fade-overlay.on { opacity: 1; }
.flash-overlay { position: absolute; inset: 0; opacity: 0; background: #fff; }
.flash-overlay.black { background: #000; }
.flash-overlay.go { animation: flash .45s ease-out; }
@keyframes flash { 0% { opacity: .75; } 100% { opacity: 0; } }
.error-bar { position: absolute; left: 0; right: 0; top: 0; padding: 10px 16px; background: #a01c14; color: #fff; font-weight: 700; text-align: center; display: none; z-index: 5; }
.error-bar.on { display: block; }

/* ------------ touch controls ------------ */
.touch { position: absolute; inset: 0; display: none; }
.touch.on { display: block; }
.touch > * { position: absolute; bottom: calc(var(--safe-b) + 18px); display: flex; gap: 14px; }
.touch-left { left: calc(var(--safe-l) + 18px); } .touch-right { right: calc(var(--safe-r) + 18px); }
.tbtn { pointer-events: auto; touch-action: none; width: clamp(74px, 12vw, 108px); height: clamp(74px, 12vw, 108px); border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); background: rgba(10, 11, 14, .5); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); font-weight: 900; letter-spacing: .08em; font-size: 15px; color: #fff; }
.tbtn.lean { font-size: 30px; } .tbtn.gas { background: rgba(255, 210, 0, .42); border-color: var(--y); width: clamp(86px, 14vw, 124px); height: clamp(86px, 14vw, 124px); font-size: 18px; }
.tbtn.down { background: var(--y); color: var(--ink); transform: scale(.94); }
#ui.touch-on .speedo { bottom: calc(var(--safe-b) + 140px); width: 120px; left: calc(var(--safe-l) + 10px); }
#ui.touch-on .progress { bottom: auto; top: calc(var(--safe-t) + 96px); width: min(60vw, 420px); }
#ui.touch-on .hint { top: calc(var(--safe-t) + 140px); }

/* ------------ responsive ------------ */
@media (max-width: 820px) {
  .res-main { grid-template-columns: 1fr; }
  .award { min-height: 150px; } .award-rays { width: 200px; height: 200px; }
  .controls-grid { grid-template-columns: 1fr; }
  .timer { min-width: 210px; padding: 6px 24px 8px; } .chips { gap: 6px; } .chip { font-size: 11px; }
  .menu-shade { background: linear-gradient(90deg, rgba(6, 7, 9, .9), rgba(6, 7, 9, .5)); }
  .panel-head { gap: 12px; flex-wrap: wrap; } .head-sub { display: none; }
  .row { flex-wrap: wrap; } .row-ctl { justify-content: flex-start; }
  .progress { width: 60vw; }
  .newbest { position: static; display: inline-block; margin-top: 8px; }
}
@media (max-height: 520px) {
  .menu-list { gap: 5px; margin-top: 14px; } .btn { padding: 8px 22px 8px 16px; }
  .menu-stats { margin-top: 12px; } .tagline { margin-top: 8px; }
  .logo.big { font-size: clamp(40px, 10vh, 70px); }
  .results-panel { padding: 12px 20px; } .res-main { margin: 6px 0; gap: 14px; } .award { min-height: 120px; } .award-medal svg { width: 80px; }
  .award-rays { width: 160px; height: 160px; } .res-row { padding: 2px 0; } .res-v { font-size: 20px; } .res-v.big { font-size: 30px; }
  .ic-name { font-size: 28px; } .intro-card { top: 20%; padding: 10px 26px 10px 20px; }
  .pause-panel { padding: 14px 22px 18px; }
  .speedo { width: 130px; }
  .timer { padding: 4px 26px 6px; } .t-main { font-size: 32px; }
  .settings-panel, .controls-panel { padding: 14px 20px; }
  .row { min-height: 40px; padding: 4px 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* portrait phones: ask for landscape while riding */
.rotate-hint { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; background: rgba(6, 7, 9, .94); z-index: 6; font-weight: 900; font-style: italic; letter-spacing: .12em; font-size: 22px; pointer-events: auto !important; }
.rotate-hint small { display: block; margin-top: 8px; color: var(--y); font-style: normal; font-size: 12px; letter-spacing: .25em; font-weight: 700; text-transform: uppercase; }
.rot-ico { font-size: 64px; color: var(--y); margin-bottom: 10px; }
@media (orientation: portrait) and (max-width: 640px) { #ui.touch-on .rotate-hint { display: flex; } }
