/* Soonyang Nightshift — UI styles */
:root {
  --bg: #07050f;
  --panel: rgba(12, 9, 26, 0.78);
  --panel-solid: #0e0b1f;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f1eefb;
  --muted: #a39cc2;
  --pink: #ff2bd6;
  --cyan: #2bd4ff;
  --amber: #ffb000;
  --green: #40ff8a;
  --red: #ff3456;
  --font: 'Chakra Petch', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --tscale: 1;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; overscroll-behavior: none; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#app { position: fixed; inset: 0; }
#stage, #stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
button { font-family: var(--font); color: inherit; cursor: pointer; }

/* ---------------------------------------------------------------- loading */
.loading { position: absolute; inset: 0; z-index: 60; background: radial-gradient(ellipse at 50% 60%, #1b0f33 0%, #07050f 70%); display: none; flex-direction: column; align-items: center; justify-content: center; gap: 22px; }
.loading.show { display: flex; }
.logo-small { text-align: center; letter-spacing: 0.4em; font-size: 14px; color: var(--muted); }
.logo-small b { display: block; letter-spacing: 0.06em; font-size: 46px; font-style: italic; color: #fff; text-shadow: 0 0 18px var(--pink), 0 0 40px rgba(255, 43, 214, 0.5); }
.load-bar { width: min(340px, 70vw); height: 4px; background: rgba(255, 255, 255, 0.08); overflow: hidden; }
.load-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); box-shadow: 0 0 12px var(--pink); transition: width 0.25s; }
.load-text { color: var(--muted); font-size: 13px; letter-spacing: 0.15em; text-transform: uppercase; }
.fatal { position: absolute; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px; background: var(--bg); line-height: 1.6; }

/* ---------------------------------------------------------------- generic screen */
#ui { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.screen.noanim { animation: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; padding: calc(18px + var(--safe-t)) calc(22px + var(--safe-r)) calc(18px + var(--safe-b)) calc(22px + var(--safe-l)); display: flex; flex-direction: column; animation: fadeIn 0.25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.scrim { background: linear-gradient(90deg, rgba(7, 5, 15, 0.92) 0%, rgba(7, 5, 15, 0.55) 45%, rgba(7, 5, 15, 0) 75%); }
.scrim-full { background: rgba(5, 3, 12, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.topbar { display: flex; align-items: center; gap: 14px; min-height: 44px; }
.topbar h2 { margin: 0; font-size: 26px; font-style: italic; letter-spacing: 0.04em; text-transform: uppercase; }
.topbar h2 small { display: block; font-size: 11px; letter-spacing: 0.3em; color: var(--pink); font-style: normal; }
.topbar .spacer { flex: 1; }
.wallet { display: flex; gap: 10px; }
.chip { padding: 7px 12px; background: var(--panel); border: 1px solid var(--line); font-weight: 600; font-size: 14px; white-space: nowrap; clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
.chip.cr { color: var(--amber); }
.chip.rep { color: var(--cyan); }
.back { width: 44px; height: 44px; border: 1px solid var(--line); background: var(--panel); font-size: 20px; clip-path: polygon(10px 0, 100% 0, 100% 100%, 0 100%, 0 10px); }
.back:hover { border-color: var(--pink); }

.btn { position: relative; border: 0; padding: 13px 26px; background: rgba(255, 255, 255, 0.07); color: #fff; font-weight: 700; font-size: 15px; letter-spacing: 0.12em; text-transform: uppercase; clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%); transition: background 0.15s, transform 0.1s; }
.btn:hover, .btn:focus-visible { background: rgba(255, 43, 214, 0.25); outline: none; }
.btn:active { transform: scale(0.97); }
.btn.primary { background: linear-gradient(90deg, #ff2bd6, #8a5cff); box-shadow: 0 0 24px rgba(255, 43, 214, 0.45); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.cyan { background: linear-gradient(90deg, #11a8d8, #2bd4ff); color: #001018; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }
.btn.small { padding: 9px 16px; font-size: 13px; }

/* ---------------------------------------------------------------- title */
.title-screen { align-items: center; justify-content: flex-end; padding-bottom: calc(10vh + var(--safe-b)); background: linear-gradient(0deg, rgba(7, 5, 15, 0.9) 0%, rgba(7, 5, 15, 0) 55%); }
.logo { text-align: center; margin-bottom: 4vh; }
.logo .pre { letter-spacing: 0.6em; font-size: clamp(12px, 1.6vw, 18px); color: var(--muted); }
.logo h1 { margin: 6px 0 0; font-size: clamp(46px, 9vw, 120px); line-height: 0.9; font-style: italic; font-weight: 700; letter-spacing: 0.02em; color: #fff; text-shadow: 0 0 20px var(--pink), 0 0 60px rgba(255, 43, 214, 0.55), 4px 4px 0 rgba(43, 212, 255, 0.55); }
.logo .tag { margin-top: 10px; font-size: clamp(12px, 1.4vw, 16px); letter-spacing: 0.5em; color: var(--cyan); }
.press { font-size: 15px; letter-spacing: 0.3em; animation: pulse 1.6s infinite; text-transform: uppercase; }
@keyframes pulse { 50% { opacity: 0.35; } }

/* ---------------------------------------------------------------- main menu */
.main-menu { justify-content: center; }
.menu-list { display: flex; flex-direction: column; gap: 6px; width: min(380px, 80vw); margin-top: 16px; }
.menu-item { text-align: left; border: 0; background: transparent; padding: 10px 18px; font-size: clamp(20px, 3vw, 30px); font-weight: 700; font-style: italic; letter-spacing: 0.04em; text-transform: uppercase; color: rgba(255, 255, 255, 0.72); transition: all 0.15s; position: relative; }
.menu-item small { display: block; font-size: 11px; font-style: normal; letter-spacing: 0.25em; color: var(--muted); font-weight: 500; }
.menu-item::before { content: ''; position: absolute; left: 0; top: 12%; bottom: 12%; width: 4px; background: var(--pink); transform: scaleY(0); transition: transform 0.15s; box-shadow: 0 0 12px var(--pink); }
.menu-item:hover, .menu-item:focus-visible, .menu-item.sel { color: #fff; padding-left: 26px; outline: none; background: linear-gradient(90deg, rgba(255, 43, 214, 0.22), transparent); }
.menu-item:hover::before, .menu-item:focus-visible::before, .menu-item.sel::before { transform: scaleY(1); }
.menu-logo { font-size: clamp(30px, 5vw, 54px); font-style: italic; font-weight: 700; line-height: 0.9; text-shadow: 0 0 18px var(--pink); }
.menu-logo small { display: block; font-size: 12px; letter-spacing: 0.5em; color: var(--muted); font-style: normal; text-shadow: none; margin-bottom: 4px; }
.menu-footer { position: absolute; bottom: calc(16px + var(--safe-b)); left: calc(24px + var(--safe-l)); right: calc(24px + var(--safe-r)); display: flex; justify-content: space-between; align-items: flex-end; color: var(--muted); font-size: 12px; letter-spacing: 0.1em; pointer-events: none; }
.car-plate { text-align: right; }
.car-plate b { display: block; font-size: 22px; font-style: italic; color: #fff; letter-spacing: 0.04em; }

/* ---------------------------------------------------------------- panels / lists */
.panel { background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.cols { display: flex; gap: 16px; flex: 1; min-height: 0; margin-top: 14px; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; scrollbar-width: thin; scrollbar-color: rgba(255, 43, 214, 0.5) transparent; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 0; padding: 9px 16px; background: rgba(255, 255, 255, 0.05); font-weight: 600; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%); }
.tab.on { background: var(--pink); color: #fff; box-shadow: 0 0 18px rgba(255, 43, 214, 0.5); }
.tab.locked { opacity: 0.5; }

/* career */
.district-head { padding: 14px 16px; border-left: 3px solid var(--pink); margin-bottom: 10px; }
.district-head h3 { margin: 0; font-size: 22px; font-style: italic; text-transform: uppercase; }
.district-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.events { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; padding: 2px 4px 10px 2px; }
.ev { text-align: left; border: 1px solid var(--line); background: rgba(10, 8, 22, 0.82); padding: 12px 14px; position: relative; transition: border-color 0.15s, transform 0.12s; clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 0 100%); }
.ev:hover { border-color: var(--pink); transform: translateY(-2px); }
.ev.sel { border-color: var(--pink); box-shadow: inset 0 0 0 1px var(--pink), 0 0 22px rgba(255, 43, 214, 0.25); }
.ev .mode { font-size: 11px; letter-spacing: 0.22em; color: var(--cyan); text-transform: uppercase; }
.ev h4 { margin: 4px 0 6px; font-size: 17px; font-style: italic; }
.ev .meta { font-size: 12px; color: var(--muted); }
.ev .reward { color: var(--amber); font-weight: 600; }
.ev .badge { position: absolute; top: 10px; right: 18px; font-size: 11px; letter-spacing: 0.12em; padding: 3px 7px; }
.badge.won { background: var(--amber); color: #120900; }
.badge.done { background: rgba(43, 212, 255, 0.2); color: var(--cyan); }
.badge.lock { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.ev.locked { opacity: 0.5; }
.ev.boss { border-color: rgba(255, 176, 0, 0.5); }
.detail { width: min(360px, 38vw); padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.detail h3 { margin: 0; font-size: 24px; font-style: italic; text-transform: uppercase; line-height: 1.05; }
.detail p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.45; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv span { color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; align-self: center; }
.kv b { text-align: right; }
.detail .grow { flex: 1; }

/* quick race */
.form { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; align-items: center; padding: 18px; }
.form label { color: var(--muted); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); padding: 8px 12px; font-size: 13px; font-weight: 600; }
.seg button.on { background: var(--cyan); color: #001018; border-color: var(--cyan); }
.seg button[disabled] { opacity: 0.35; }

/* garage */
.garage-ui { pointer-events: none; }
.garage-ui > * { pointer-events: auto; }
.garage-side { position: absolute; right: calc(16px + var(--safe-r)); top: calc(74px + var(--safe-t)); bottom: calc(16px + var(--safe-b)); width: min(400px, 42vw); display: flex; flex-direction: column; }
.garage-side .tabs { padding: 10px; }
.garage-side .body { flex: 1; padding: 6px 12px 12px; }
.opt-title { font-size: 11px; letter-spacing: 0.22em; color: var(--muted); text-transform: uppercase; margin: 14px 0 8px; }
.opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
.opt { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); padding: 9px 8px; font-size: 12px; font-weight: 600; text-align: left; position: relative; min-height: 46px; }
.opt small { display: block; color: var(--amber); font-weight: 500; margin-top: 2px; }
.opt small.owned { color: var(--green); }
.opt.on { border-color: var(--pink); background: rgba(255, 43, 214, 0.18); }
.opt.preview { border-color: var(--cyan); }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; }
.sw { aspect-ratio: 1; border: 2px solid rgba(255, 255, 255, 0.15); border-radius: 50%; padding: 0; }
.sw.on { border-color: #fff; box-shadow: 0 0 0 2px var(--pink), 0 0 14px var(--pink); }
.garage-foot { padding: 12px; border-top: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.garage-foot .msg { flex: 1; font-size: 13px; color: var(--muted); }
.carcard { border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); padding: 12px; margin-bottom: 8px; text-align: left; width: 100%; display: block; }
.carcard.on { border-color: var(--pink); background: rgba(255, 43, 214, 0.12); }
.carcard .brand { font-size: 11px; letter-spacing: 0.22em; color: var(--muted); text-transform: uppercase; }
.carcard h4 { margin: 2px 0 4px; font-size: 19px; font-style: italic; }
.carcard .row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.carcard .price { color: var(--amber); font-weight: 700; }
.carcard .lock { color: var(--red); }
.stats { padding: 4px 0; }
.stat { display: grid; grid-template-columns: 92px 1fr 70px; gap: 8px; align-items: center; font-size: 12px; margin: 5px 0; }
.stat span { color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; font-size: 11px; }
.stat .bar { height: 7px; background: rgba(255, 255, 255, 0.07); position: relative; overflow: hidden; }
.stat .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); }
.stat .bar i.next { background: var(--green); opacity: 0.65; }
.stat b { text-align: right; font-size: 12px; }
.stat b em { color: var(--green); font-style: normal; }
.upg { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.upg h5 { margin: 0; font-size: 15px; }
.upg p { margin: 0; font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.pips { display: flex; gap: 4px; align-items: center; }
.pips i { width: 18px; height: 6px; background: rgba(255, 255, 255, 0.12); transform: skewX(-20deg); }
.pips i.on { background: var(--pink); box-shadow: 0 0 8px var(--pink); }
.garage-left { position: absolute; left: calc(18px + var(--safe-l)); bottom: calc(18px + var(--safe-b)); width: min(360px, 40vw); padding: 14px 16px; }
.garage-left h3 { margin: 0; font-size: 26px; font-style: italic; line-height: 1; }
.garage-left .brand { font-size: 11px; letter-spacing: 0.3em; color: var(--pink); text-transform: uppercase; }
.garage-left p { margin: 6px 0 4px; font-size: 12px; color: var(--muted); line-height: 1.4; }
.garage-hint { position: absolute; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); font-size: 11px; color: var(--muted); letter-spacing: 0.2em; pointer-events: none; }

/* settings */
.settings { max-width: 760px; width: 100%; margin: 14px auto 0; padding: 8px 18px 18px; }
.set-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.set-row label { font-weight: 600; }
.set-row label small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 200px; height: 4px; background: rgba(255, 255, 255, 0.15); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; background: var(--pink); border-radius: 50%; box-shadow: 0 0 10px var(--pink); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; background: var(--pink); border: 0; border-radius: 50%; }
.toggle { width: 52px; height: 28px; border-radius: 14px; background: rgba(255, 255, 255, 0.12); border: 0; position: relative; }
.toggle::after { content: ''; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.15s; }
.toggle.on { background: var(--pink); }
.toggle.on::after { transform: translateX(24px); }

/* controls guide */
.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }
.guide .panel { padding: 16px; }
.guide h4 { margin: 0 0 10px; font-style: italic; text-transform: uppercase; color: var(--cyan); }
.keys { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; font-size: 14px; align-items: center; }
kbd { display: inline-block; min-width: 28px; padding: 3px 7px; border: 1px solid rgba(255, 255, 255, 0.3); border-bottom-width: 3px; border-radius: 4px; font-family: var(--font); font-size: 12px; text-align: center; background: rgba(255, 255, 255, 0.05); margin-right: 3px; }

/* pause */
.pause { align-items: center; justify-content: center; }
.pause h2 { font-size: 48px; font-style: italic; margin: 0 0 18px; letter-spacing: 0.06em; text-shadow: 0 0 20px var(--pink); }
.pause .menu-list { align-items: stretch; }

/* results */
.results { align-items: center; justify-content: flex-start; overflow-y: auto; touch-action: pan-y; }
.results .card { margin: auto 0; }
.results .card { width: min(760px, 100%); padding: 22px 24px; }
.res-title { text-align: center; }
.res-title .big { font-size: clamp(44px, 8vw, 84px); font-weight: 700; font-style: italic; line-height: 1; letter-spacing: 0.03em; }
.res-title .big.win { color: #fff; text-shadow: 0 0 22px var(--amber), 0 0 60px rgba(255, 176, 0, 0.5); }
.res-title .big.lose { color: #fff; text-shadow: 0 0 22px var(--cyan); }
.res-title .sub { letter-spacing: 0.3em; color: var(--muted); font-size: 13px; text-transform: uppercase; margin-top: 6px; }
.res-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.res-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.res-table tr.me td { background: rgba(255, 43, 214, 0.16); font-weight: 700; }
.res-table td:first-child { width: 40px; font-weight: 700; color: var(--pink); }
.res-table td.t { text-align: right; font-variant-numeric: tabular-nums; }
.res-table td.t i { color: var(--muted); font-size: 11px; }
.rewards { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 10px 0; }
.reward { padding: 10px 16px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); text-align: center; min-width: 120px; }
.reward small { display: block; font-size: 10px; letter-spacing: 0.25em; color: var(--muted); }
.reward b { font-size: 22px; }
.reward.cr b { color: var(--amber); }
.reward.rep b { color: var(--cyan); }
.reward.bonus b { color: var(--green); }
.unlocks { text-align: center; color: var(--green); font-size: 14px; line-height: 1.6; }
.res-actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.tier { display: inline-block; padding: 4px 12px; font-weight: 700; letter-spacing: 0.2em; margin-top: 8px; }
.tier.gold { background: linear-gradient(90deg, #ffcf40, #ffb000); color: #1a1000; }
.tier.silver { background: linear-gradient(90deg, #e6ebf2, #9fa8b4); color: #101418; }
.tier.bronze { background: linear-gradient(90deg, #e08a4a, #a5562a); color: #1a0800; }

/* toasts */
#toasts { position: absolute; bottom: calc(18px + var(--safe-b)); left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: rgba(12, 9, 26, 0.92); border: 1px solid var(--pink); padding: 10px 18px; font-size: 14px; box-shadow: 0 0 22px rgba(255, 43, 214, 0.35); animation: toastIn 0.3s ease, toastOut 0.4s ease 3.2s forwards; clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%); }
.toast b { color: var(--amber); }
.toast.err { border-color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-12px); } }

/* ---------------------------------------------------------------- HUD */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; font-variant-numeric: tabular-nums; }
#hud button { pointer-events: auto; }
.hud-tl { position: absolute; left: calc(16px + var(--safe-l)); top: calc(12px + var(--safe-t)); display: flex; gap: 14px; align-items: flex-start; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); }
.hud-pos { font-size: 64px; font-weight: 700; font-style: italic; line-height: 0.9; color: #fff; text-shadow: 0 0 18px var(--pink), 0 2px 6px #000; }
.hud-pos small { font-size: 24px; color: var(--muted); }
.hud-times { padding-top: 4px; }
.hud-lap { font-size: 22px; font-weight: 700; font-style: italic; }
.hud-lap small { font-size: 12px; color: var(--pink); letter-spacing: 0.2em; font-style: normal; }
.hud-time { font-size: 20px; font-weight: 600; }
.hud-best, .hud-cp { font-size: 13px; color: var(--muted); letter-spacing: 0.08em; }
.hud-cp { color: var(--cyan); }
.hud-driftbox { position: absolute; left: calc(16px + var(--safe-l)); top: calc(12px + var(--safe-t)); text-shadow: 0 2px 8px #000; }
.hud-timer { font-size: 46px; font-weight: 700; font-style: italic; line-height: 1; }
.hud-dtotal small { display: block; font-size: 11px; letter-spacing: 0.25em; color: var(--pink); }
.hud-dtotal span { font-size: 28px; font-weight: 700; }
#hud[data-mode=drift] .hud-tl { left: calc(140px + var(--safe-l)); }
.hud-standings { position: absolute; left: calc(16px + var(--safe-l)); top: calc(118px + var(--safe-t)); font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.st-row { display: flex; gap: 8px; padding: 2px 10px 2px 6px; background: rgba(8, 6, 20, 0.55); min-width: 110px; border-left: 2px solid transparent; }
.st-row b { color: var(--muted); width: 12px; }
.st-row.me { border-left-color: var(--pink); background: rgba(255, 43, 214, 0.25); font-weight: 700; }
.hud-tr { position: absolute; right: calc(14px + var(--safe-r)); top: calc(12px + var(--safe-t)); }
#hud-map { width: 150px; height: 150px; display: block; }
.hud-pause, .hud-cam { position: absolute; top: calc(12px + var(--safe-t)); width: 42px; height: 42px; border: 1px solid var(--line); background: rgba(8, 6, 20, 0.55); border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 0; }
.hud-pause { right: calc(176px + var(--safe-r)); }
.hud-cam { right: calc(226px + var(--safe-r)); color: #fff; }
.hud-pause svg { width: 18px; fill: #fff; }
.hud-cam svg { width: 20px; }
.hud-center { position: absolute; left: 0; right: 0; top: 18%; text-align: center; }
.hud-banner { font-size: clamp(40px, 9vw, 110px); font-weight: 700; font-style: italic; letter-spacing: 0.02em; opacity: 0; transform: scale(1.4); transition: opacity 0.15s, transform 0.25s cubic-bezier(.2, 1.6, .4, 1); text-shadow: 0 0 24px var(--pink), 0 0 70px rgba(255, 43, 214, 0.5); }
.hud-banner.show { opacity: 1; transform: none; }
.hud-banner.go { color: var(--green); text-shadow: 0 0 24px var(--green), 0 0 70px rgba(64, 255, 138, 0.5); }
.hud-banner.small { font-size: clamp(26px, 5vw, 54px); }
.hud-sub { font-size: 16px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--cyan); opacity: 0; transition: opacity 0.2s; margin-top: 6px; text-shadow: 0 2px 6px #000; }
.hud-sub.show { opacity: 1; }
.hud-warn { display: none; margin: 10px auto 0; width: max-content; padding: 6px 18px; background: rgba(255, 52, 86, 0.85); font-weight: 700; letter-spacing: 0.3em; animation: pulse 0.6s infinite; }
.hud-warn.show { display: block; }
.hud-hint { display: none; margin: 10px auto 0; width: max-content; padding: 6px 14px; background: rgba(8, 6, 20, 0.75); font-size: 14px; }
.hud-hint.show { display: block; }
.hud-shift { opacity: 0; margin-top: 12px; font-size: 26px; font-weight: 700; font-style: italic; letter-spacing: 0.08em; transition: opacity 0.15s; }
.hud-shift.show { opacity: 1; }
.hud-shift.q-perfect { color: var(--green); text-shadow: 0 0 16px var(--green); }
.hud-shift.q-good { color: var(--cyan); }
.hud-shift.q-early, .hud-shift.q-late { color: var(--red); }
.hud-drift { position: absolute; left: 50%; bottom: calc(26% + var(--safe-b)); transform: translateX(-50%) scale(0.9); text-align: center; opacity: 0; transition: opacity 0.15s, transform 0.2s; text-shadow: 0 2px 10px #000; }
.hud-drift.show { opacity: 1; transform: translateX(-50%) scale(1); }
.hud-drift-row { display: flex; gap: 10px; align-items: baseline; justify-content: center; }
.hud-drift-row span { font-size: 40px; font-weight: 700; font-style: italic; color: #fff; text-shadow: 0 0 16px var(--amber); }
.hud-drift-row b { font-size: 30px; color: var(--amber); font-style: italic; }
.hud-drift small { letter-spacing: 0.3em; color: var(--amber); font-size: 12px; }
.hud-feed { position: absolute; left: 50%; bottom: calc(36% + var(--safe-b)); transform: translateX(-50%); display: flex; flex-direction: column-reverse; align-items: center; gap: 4px; }
.feed-item { font-size: 18px; font-weight: 700; font-style: italic; letter-spacing: 0.06em; color: #fff; text-shadow: 0 0 10px var(--pink), 0 2px 6px #000; animation: feedIn 0.25s ease; transition: opacity 0.4s, transform 0.4s; }
.feed-item.good { color: var(--green); text-shadow: 0 0 10px var(--green), 0 2px 6px #000; }
.feed-item.bad { color: var(--red); text-shadow: 0 0 10px var(--red), 0 2px 6px #000; }
.feed-item.cyan { color: var(--cyan); text-shadow: 0 0 10px var(--cyan), 0 2px 6px #000; }
.feed-item.out { opacity: 0; transform: translateY(-14px); }
@keyframes feedIn { from { opacity: 0; transform: scale(1.3); } }
.hud-br { position: absolute; right: calc(14px + var(--safe-r)); bottom: calc(8px + var(--safe-b)); width: 210px; height: 210px; }
.hud-gauge { position: absolute; inset: 0; width: 100%; height: 100%; }
.hud-gauge circle { fill: none; stroke-linecap: butt; }
.g-bg { stroke: rgba(255, 255, 255, 0.1); stroke-width: 10; }
.g-red { stroke: rgba(255, 52, 86, 0.55); stroke-width: 10; }
.g-rpm { stroke: url(#rpmGrad); stroke-width: 10; filter: drop-shadow(0 0 6px rgba(255, 43, 214, 0.7)); transition: stroke-dashoffset 0.05s linear; }
.g-rpm.red { filter: drop-shadow(0 0 10px rgba(255, 52, 86, 1)); }
.hud-speed { position: absolute; left: 0; right: 0; top: 64px; text-align: center; text-shadow: 0 2px 10px #000; }
.hud-speed span { display: block; font-size: 54px; font-weight: 700; font-style: italic; line-height: 1; }
.hud-speed small { font-size: 11px; letter-spacing: 0.3em; color: var(--muted); }
.hud-gear { position: absolute; left: 0; right: 0; top: 138px; text-align: center; font-size: 30px; font-weight: 700; color: var(--pink); text-shadow: 0 0 12px var(--pink); }
.hud-nitro { position: absolute; left: 30px; right: 30px; bottom: 6px; display: flex; gap: 8px; align-items: center; font-size: 11px; font-weight: 700; color: var(--cyan); }
.hud-nitro .bar { flex: 1; height: 8px; background: rgba(255, 255, 255, 0.1); transform: skewX(-20deg); overflow: hidden; }
.hud-nitro .bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #2b6cff, #2bd4ff); box-shadow: 0 0 10px var(--cyan); }
.hud-nitro .bar i.active { background: linear-gradient(90deg, #8af0ff, #fff); }
.hud-nitro .bar i.low { background: rgba(255, 52, 86, 0.8); }
.hud-shiftlight { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); display: none; gap: 5px; }
#hud[data-mode=drag] .hud-shiftlight { display: flex; }
.hud-shiftlight i { width: 16px; height: 16px; border-radius: 50%; background: rgba(255, 255, 255, 0.1); }
.hud-shiftlight.ready i:nth-child(-n+2) { background: var(--green); box-shadow: 0 0 10px var(--green); }
.hud-shiftlight.go i { background: var(--green); box-shadow: 0 0 14px var(--green); }
.hud-shiftlight.over i { background: var(--red); box-shadow: 0 0 14px var(--red); animation: pulse 0.15s infinite; }
.hud-fps { position: absolute; left: 50%; bottom: calc(6px + var(--safe-b)); transform: translateX(-50%); font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- touch controls */
#touch { position: absolute; inset: 0; z-index: 12; pointer-events: none; touch-action: none; }
.tbtn { pointer-events: auto; touch-action: none; position: absolute; border: 2px solid rgba(255, 255, 255, 0.22); background: rgba(10, 8, 24, 0.38); color: #fff; font-weight: 700; letter-spacing: 0.08em; font-size: calc(13px * var(--tscale)); display: flex; align-items: center; justify-content: center; border-radius: 50%; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); transition: background 0.08s, transform 0.08s; }
.tbtn.pressed { background: rgba(255, 43, 214, 0.5); border-color: var(--pink); transform: scale(0.94); }
.tbtn svg { width: 46%; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.t-left .steer { width: calc(96px * var(--tscale)); height: calc(96px * var(--tscale)); bottom: calc(26px + var(--safe-b)); }
.t-left .steer[data-ctl=left] { left: calc(22px + var(--safe-l)); }
.t-left .steer[data-ctl=right] { left: calc(22px + var(--safe-l) + 112px * var(--tscale)); }
.t-right .gas { width: calc(104px * var(--tscale)); height: calc(104px * var(--tscale)); right: calc(22px + var(--safe-r)); bottom: calc(26px + var(--safe-b)); background: rgba(64, 255, 138, 0.18); border-color: rgba(64, 255, 138, 0.6); }
.t-right .brake { width: calc(80px * var(--tscale)); height: calc(80px * var(--tscale)); right: calc(22px + var(--safe-r) + 118px * var(--tscale)); bottom: calc(22px + var(--safe-b)); background: rgba(255, 52, 86, 0.18); border-color: rgba(255, 52, 86, 0.6); }
.t-right .nitro { width: calc(70px * var(--tscale)); height: calc(70px * var(--tscale)); right: calc(36px + var(--safe-r)); bottom: calc(26px + var(--safe-b) + 118px * var(--tscale)); background: rgba(43, 212, 255, 0.2); border-color: rgba(43, 212, 255, 0.7); }
.t-right .drift { width: calc(70px * var(--tscale)); height: calc(70px * var(--tscale)); right: calc(22px + var(--safe-r) + 124px * var(--tscale)); bottom: calc(26px + var(--safe-b) + 92px * var(--tscale)); background: rgba(255, 176, 0, 0.18); border-color: rgba(255, 176, 0, 0.6); }
.t-right .small { width: 46px; height: 46px; right: calc(22px + var(--safe-r) + 206px * var(--tscale)); bottom: calc(30px + var(--safe-b)); font-size: 20px; }
.t-right .shift { display: none; width: calc(84px * var(--tscale)); height: calc(84px * var(--tscale)); right: calc(22px + var(--safe-r) + 210px * var(--tscale)); bottom: calc(80px + var(--safe-b)); border-radius: 18px; font-size: 12px; }
#touch.drag .shift { display: flex; }
body.touch .hud-br { transform: translateX(-50%) scale(0.62); transform-origin: center bottom; bottom: calc(-4px + var(--safe-b)); left: 50%; right: auto; }
body.touch .hud-feed { bottom: 48%; }
body.touch .hud-drift { bottom: 40%; }
body.touch #hud-map { width: 110px; height: 110px; }
body.touch .hud-pause { right: calc(132px + var(--safe-r)); }
body.touch .hud-cam { right: calc(182px + var(--safe-r)); }
body.touch .hud-standings { display: none; }

/* ---------------------------------------------------------------- responsive */
@media (max-height: 520px) {
  .menu-footer > div:first-child { display: none; }
  .menu-list { gap: 0; margin-top: 6px; }
  .menu-item small { display: none; }
  .res-table td { padding: 4px 8px; font-size: 13px; }
  .res-title .big { font-size: 40px; }
  .reward b { font-size: 17px; }
  .hud-pos { font-size: 46px; }
  .hud-pos small { font-size: 18px; }
  .hud-lap { font-size: 17px; }
  .hud-time { font-size: 16px; }
  .topbar h2 { font-size: 20px; }
  .menu-item { font-size: 20px; padding: 6px 16px; }
  .garage-side { top: calc(60px + var(--safe-t)); }
  .garage-left { display: none; }
  .logo h1 { font-size: 54px; }
}
@media (max-width: 760px) {
  .cols { flex-direction: column; }
  .detail { width: 100%; }
  .garage-side { left: calc(10px + var(--safe-l)); right: calc(10px + var(--safe-r)); width: auto; top: 46%; }
  .garage-left { display: none; }
  .form { grid-template-columns: 1fr; }
  .hud-standings { display: none; }
  .scrim { background: linear-gradient(0deg, rgba(7, 5, 15, 0.92) 0%, rgba(7, 5, 15, 0.5) 60%, rgba(7, 5, 15, 0.2) 100%); }
  .main-menu { justify-content: flex-end; }
}
@media (orientation: portrait) {
  body.touch .hud-br { left: auto; right: calc(4px + var(--safe-r)); top: calc(112px + var(--safe-t)); bottom: auto; transform: scale(0.5); transform-origin: right top; }
  body.touch #hud-map { width: 96px; height: 96px; }
  body.touch .hud-pause { right: calc(112px + var(--safe-r)); }
  body.touch .hud-cam { right: calc(160px + var(--safe-r)); }
  .t-left .steer { width: calc(76px * var(--tscale)); height: calc(76px * var(--tscale)); bottom: calc(20px + var(--safe-b)); }
  .t-left .steer[data-ctl=right] { left: calc(22px + var(--safe-l) + 86px * var(--tscale)); }
  .t-right .gas { width: calc(84px * var(--tscale)); height: calc(84px * var(--tscale)); right: calc(16px + var(--safe-r)); bottom: calc(20px + var(--safe-b)); }
  .t-right .brake { width: calc(64px * var(--tscale)); height: calc(64px * var(--tscale)); right: calc(16px + var(--safe-r) + 92px * var(--tscale)); bottom: calc(20px + var(--safe-b)); }
  .t-right .nitro { width: calc(58px * var(--tscale)); height: calc(58px * var(--tscale)); right: calc(22px + var(--safe-r)); bottom: calc(28px + var(--safe-b) + 90px * var(--tscale)); }
  .t-right .drift { width: calc(58px * var(--tscale)); height: calc(58px * var(--tscale)); right: calc(24px + var(--safe-r) + 70px * var(--tscale)); bottom: calc(28px + var(--safe-b) + 76px * var(--tscale)); }
  .t-right .small { right: calc(22px + var(--safe-r)); bottom: calc(40px + var(--safe-b) + 150px * var(--tscale)); }
  .t-right .shift { right: calc(16px + var(--safe-r) + 96px * var(--tscale)); bottom: calc(30px + var(--safe-b) + 150px * var(--tscale)); width: calc(70px * var(--tscale)); height: calc(56px * var(--tscale)); }
  .hud-center { top: 24%; }
  .hud-pos { font-size: 40px; }
}

/* ================================================================ v1.1 visual polish */
/* panels: deep glass with a neon hairline along the top edge */
.panel { background: linear-gradient(90deg, rgba(255, 43, 214, 0) 0%, rgba(255, 43, 214, 0.75) 20%, rgba(43, 212, 255, 0.75) 80%, rgba(43, 212, 255, 0) 100%) top / 100% 2px no-repeat, linear-gradient(180deg, rgba(22, 14, 46, 0.82) 0%, rgba(9, 7, 22, 0.86) 100%); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06); }
.tab.on { background: linear-gradient(90deg, #ff2bd6, #9a4dff); }
.tab:not(.on):hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.opt-title { display: flex; align-items: center; gap: 8px; color: #cfc6ee; }
.opt-title::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent); }

/* option cards with pictograms */
.opt { transition: border-color 0.15s, background 0.15s, transform 0.1s; clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 9px, 100% 100%, 0 100%); }
.opt:hover { border-color: rgba(43, 212, 255, 0.55); background: rgba(43, 212, 255, 0.08); }
.opt:active { transform: scale(0.97); }
.opt.on { background: linear-gradient(160deg, rgba(255, 43, 214, 0.28), rgba(138, 92, 255, 0.14)); box-shadow: inset 0 0 0 1px rgba(255, 43, 214, 0.6), 0 0 16px rgba(255, 43, 214, 0.25); }
.opt.preview { background: rgba(43, 212, 255, 0.1); box-shadow: inset 0 0 0 1px rgba(43, 212, 255, 0.55); }
.opts:has(.has-ico) { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
.opt.has-ico { text-align: center; padding: 8px 6px 7px; }
.opt .ico { display: flex; justify-content: center; height: 34px; margin-bottom: 5px; }
.opt .ico svg { height: 100%; width: auto; max-width: 100%; overflow: visible; }
.opt .lbl { display: block; font-size: 12px; line-height: 1.15; }
.opt.has-ico small { font-size: 11px; }
.ico .body { fill: rgba(255, 255, 255, 0.1); stroke: rgba(220, 214, 255, 0.55); stroke-width: 0.9; }
.ico .win { fill: #2bd4ff; stroke: rgba(220, 214, 255, 0.45); stroke-width: 0.6; }
.ico .tyre { fill: #0a0b10; stroke: rgba(220, 214, 255, 0.6); stroke-width: 1.1; }
.ico .acc { fill: none; stroke: var(--cyan); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 0 2px rgba(43, 212, 255, 0.8)); }
.ico .acc.fat { stroke-width: 2; }
.ico .acc.thin { stroke-width: 0.9; }
.ico .dec { fill: none; stroke: var(--cyan); stroke-width: 1; }
.ico .dec.thin { stroke-width: 0.7; }
.ico .decf { fill: var(--cyan); }
.ico .num { font: 700 4.4px var(--font); fill: #0a0b10; }
.ico .spl { font: italic 700 6px var(--font); fill: var(--cyan); }
.ico .ground { stroke: rgba(255, 255, 255, 0.25); stroke-width: 0.8; }
.opt.on .acc, .opt.on .dec { stroke: #ff6ae4; filter: drop-shadow(0 0 2px rgba(255, 43, 214, 0.9)); }
.opt.on .decf, .opt.on .spl { fill: #ff6ae4; }
.ico-wheel svg, .ico-finish svg { filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6)); }

/* glossy paint swatches */
.sw { position: relative; overflow: hidden; box-shadow: inset 0 -6px 10px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.5); transition: transform 0.12s; }
.sw::after { content: ''; position: absolute; left: 14%; top: 8%; width: 55%; height: 34%; border-radius: 50%; background: linear-gradient(180deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0)); pointer-events: none; }
.sw:hover { transform: scale(1.08); }
.sw.on { transform: scale(1.06); }

/* buttons: sheen sweep on primary actions */
.btn.primary { overflow: hidden; }
.btn.primary::after { content: ''; position: absolute; top: 0; bottom: 0; width: 40%; left: -60%; background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.35), transparent); animation: sheen 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes sheen { 0%, 60% { left: -60%; } 100% { left: 130%; } }

/* HUD readability: soft backing behind the top-left race info */
.hud-tl { padding: 6px 14px 8px 8px; margin: -6px 0 0 -8px; background: linear-gradient(90deg, rgba(6, 4, 16, 0.55), rgba(6, 4, 16, 0)); }
.hud-pos { background: linear-gradient(180deg, #ffffff 30%, #ffc2f3 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 0 10px rgba(255, 43, 214, 0.75)); text-shadow: none; }
.hud-pos small { -webkit-text-fill-color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .btn.primary::after { animation: none; display: none; } }
