:root { --ink: #fff; --shade: rgba(14, 20, 32, .82); --card: rgba(255, 255, 255, .07); --line: rgba(255, 255, 255, .14); --gold: #f2c230; --mute: rgba(255, 255, 255, .62); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #8fc6ea; font-family: Rubik, system-ui, sans-serif; color: var(--ink); user-select: none; }
#cv { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
body.menu-on #cv { cursor: grab; } body.menu-on #cv:active { cursor: grabbing; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
/* современный HUD (27.11): без плашек, курсив, тень под текстом, полупрозрачная полоса слева */
.hud-tl { position: absolute; left: 0; top: 14px; padding: 6px 48px 8px 22px; min-width: 150px; background: linear-gradient(90deg, rgba(6,8,14,.62), rgba(6,8,14,.38) 65%, rgba(6,8,14,0)); border-left: 4px solid var(--gold); text-shadow: 0 1px 6px rgba(0,0,0,.55); }
.hud-tl .cap { display: block; font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .65; }
.place { font-style: italic; }
.place b { font-size: 52px; font-weight: 900; line-height: .95; letter-spacing: -.02em; }
.place span { font-size: 22px; font-weight: 800; opacity: .6; margin-left: 2px; }
.lap { font-weight: 800; font-size: 14px; font-style: italic; text-transform: uppercase; letter-spacing: .04em; }
.time { font-size: 14px; font-weight: 600; opacity: .85; font-variant-numeric: tabular-nums; }
.board { position: absolute; right: 0; top: 14px; margin: 0; padding: 8px 20px 8px 44px; background: linear-gradient(270deg, rgba(6,8,14,.62), rgba(6,8,14,.38) 65%, rgba(6,8,14,0)); font-size: 13px; font-weight: 700; font-style: italic; line-height: 1.6; min-width: 180px; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
.board li { white-space: nowrap; }
.board li i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.board li.me { color: var(--gold); }
.board li small { float: right; margin-left: 10px; font-variant-numeric: tabular-nums; opacity: .8; font-size: 12px; }
.board li.wr { opacity: .4; text-decoration: line-through; }
.hud-dash { position: absolute; right: 10px; bottom: 6px; width: min(420px, 38vw); }
.dash { display: block; width: 100%; aspect-ratio: 420 / 300; }
.hud-dash small { display: block; font-size: 11px; opacity: .45; text-align: right; margin: -6px 18px 2px 0; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.spd { font-size: 13px; font-weight: 700; opacity: .85; }
.spd b { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; opacity: 1; }
.mirror { position: absolute; box-sizing: border-box; border: 4px solid #141416; border-radius: 9px; box-shadow: 0 4px 14px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.08); background: linear-gradient(165deg, rgba(255,255,255,.1), rgba(255,255,255,0) 45%); }
.minimap { position: absolute; left: 16px; bottom: 16px; width: 180px; height: 180px; background: rgba(10, 12, 14, .55); border-radius: 16px; }
.bar { height: 9px; border-radius: 5px; background: rgba(255, 255, 255, .15); overflow: hidden; margin-top: 6px; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: #59d36b; transition: width .1s linear; }
.bar.xp i { background: var(--gold); }

#center { position: fixed; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; font-weight: 900; font-size: clamp(40px, 9vw, 104px); text-shadow: 0 4px 0 rgba(0,0,0,.25), 0 10px 30px rgba(0,0,0,.35); letter-spacing: .02em; padding: 0 16px; }
#center small { display: block; font-size: clamp(16px, 2.4vw, 26px); font-weight: 700; margin-top: 6px; }
#center.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#toasts { position: fixed; left: 16px; right: 16px; bottom: 24px; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--shade); padding: 6px 14px; border-radius: 10px; font-weight: 700; font-size: 15px; animation: toast 2.4s forwards; }
@keyframes toast { 0% { opacity: 0; transform: translateY(10px); } 10%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }

/* ---------- панели ---------- */
.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; background: var(--shade); backdrop-filter: blur(6px); border-radius: 22px; padding: 24px 26px; text-align: center; user-select: text; }
.panel.wide { width: min(1040px, calc(100% - 32px)); text-align: left; }
h1 { margin: 0; font-size: clamp(34px, 7vw, 56px); font-weight: 900; letter-spacing: .04em; line-height: 1; }
h1 span { color: var(--gold); }
h2 { margin: 0 0 10px; font-size: 17px; font-weight: 900; letter-spacing: .02em; }
section h2 + p { margin-top: -6px; }
kbd { background: rgba(255,255,255,.16); border-radius: 5px; padding: 1px 6px; font: inherit; font-weight: 700; font-size: .85em; }
button { font: inherit; font-weight: 900; font-size: 20px; padding: 12px 28px; border: 0; border-radius: 14px; background: var(--gold); color: #222; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
button kbd { background: rgba(0,0,0,.12); }
button.sm { font-size: 14px; padding: 7px 12px; border-radius: 10px; min-width: 86px; }
button.link { background: none; color: var(--mute); font-size: 13px; font-weight: 500; padding: 4px 0; text-decoration: underline; }
button.alt { background: rgba(255,255,255,.14); color: var(--ink); }
button.alt kbd { background: rgba(255,255,255,.14); }
.hint { font-size: 13px; opacity: .7; margin: 14px 0 0; line-height: 1.45; }
.mute { color: var(--mute); }
.small { font-size: 12px; }

/* ---------- гараж ---------- */
.g-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.wallet { display: flex; align-items: center; gap: 18px; }
.wallet > b { font-size: 28px; font-weight: 900; color: var(--gold); white-space: nowrap; }
.lvl { font-size: 14px; font-weight: 700; min-width: 170px; }
.lvl small { font-weight: 500; color: var(--mute); font-size: 12px; }
.pick { background: rgba(242, 194, 48, .14); border: 2px solid var(--gold); border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; }
.pick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.perkbtn { display: flex; flex-direction: column; align-items: center; gap: 3px; background: rgba(255,255,255,.1); color: var(--ink); font-size: 15px; padding: 12px 10px; text-align: center; }
.perkbtn span { font-size: 28px; }
.perkbtn small { font-weight: 500; font-size: 12px; color: var(--mute); }
.perkbtn:hover { background: rgba(255,255,255,.2); }
.g-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.g-grid section { background: var(--card); border-radius: 16px; padding: 14px; min-width: 0; }
.g-grid section p { margin: 0 0 10px; font-size: 13px; line-height: 1.35; }
.stat { display: grid; grid-template-columns: 84px 1fr; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 5px; }
.stat .bar { margin: 0; }
.paints { display: flex; gap: 8px; margin: 12px 0 10px; }
.sw { width: 30px; height: 30px; min-width: 0; padding: 0; border-radius: 50%; border: 3px solid transparent; }
.sw.on { border-color: var(--ink); }
.up { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.up:last-child { border-bottom: 0; }
.up b { font-size: 14px; }
.up small { display: block; font-size: 11px; color: var(--mute); }
.up .pips { display: flex; gap: 3px; }
.up button { grid-row: 1 / 3; grid-column: 2; }
.pips i { width: 14px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.15); }
.pips i.on { background: var(--gold); }
.shop { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: center; padding: 10px; border-radius: 12px; margin-bottom: 8px; background: rgba(255,255,255,.05); border: 2px solid transparent; }
.shop.cur { border-color: var(--gold); }
.shop small { grid-column: 1; font-size: 11px; color: var(--mute); line-height: 1.3; }
.shop > button, .shop > .tag { grid-row: 1 / 5; grid-column: 2; }
.shop .sil { grid-column: 1; width: 120px; height: 45px; margin-bottom: 2px; }
.tag { font-size: 12px; font-weight: 700; color: var(--gold); }
.perks, .rivals { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.perk { background: rgba(255,255,255,.1); border-radius: 9px; padding: 4px 8px; font-size: 13px; font-weight: 700; }
.rival { font-size: 13px; font-weight: 700; width: 100%; }
.rival i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.rival small { font-weight: 500; color: var(--mute); }
.g-foot { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: 16px; }
.g-foot .hint { flex: 1; min-width: 240px; margin: 0; }

/* ---------- итоги и пауза ---------- */
table.res { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; text-align: left; }
table.res td { padding: 5px 6px; border-bottom: 1px solid var(--line); }
table.res td:first-child { width: 28px; font-weight: 900; }
table.res td:nth-child(3) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.res td:last-child { width: 40px; text-align: right; }
table.res td i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
table.res td small { color: var(--mute); }
table.res tr.me td { color: var(--gold); font-weight: 700; }
.earnings { background: var(--card); border-radius: 14px; padding: 8px 14px; margin-bottom: 14px; text-align: left; }
.earn { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 14px; }
.earn.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; font-size: 17px; }
.earn.total b { color: var(--gold); }
.col { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

@media (max-width: 900px) { .g-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) {
  .panel { padding: 18px 16px; }
  .g-grid, .pick-row { grid-template-columns: 1fr; }
  .board { display: none; }
  .hud-dash { left: 50%; right: auto; bottom: 2px; width: 210px; transform: translateX(-50%); }
  .hud-dash small { display: none; }
  .minimap { width: 110px; height: 110px; top: 12px; left: auto; right: 12px; bottom: auto; }
}

/* телефон: слева руль (ведение пальцем), справа газ и тормоз, пауза под табличкой места */
#touch { position: fixed; inset: 0; pointer-events: none; z-index: 5; --dashH: 0px; }
#touch > * { pointer-events: auto; touch-action: none; -webkit-tap-highlight-color: transparent; }
.t-steer { position: absolute; left: 0; top: 34%; bottom: 0; width: 46%; }
.t-steer i { position: absolute; width: 150px; height: 6px; margin: -3px 0 0 -75px; border-radius: 3px; background: rgba(255,255,255,.18); display: none; }
.t-steer i::after { content: ''; position: absolute; left: calc(50% + var(--dx, 0px)); top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: rgba(255,255,255,.35); box-shadow: 0 2px 8px rgba(0,0,0,.35); }
.t-steer.on i { display: block; }
#touch button { position: absolute; border: 0; border-radius: 18px; color: #fff; font: 700 14px Rubik, system-ui, sans-serif; background: rgba(14, 20, 32, .55); box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); }
#touch button.on { background: rgba(255,255,255,.32); }
.t-gas { right: 12px; bottom: calc(var(--dashH) + 14px); width: 86px; height: 130px; }
.t-brk { right: 108px; bottom: calc(var(--dashH) + 14px); width: 86px; height: 86px; }
.t-pause { left: 16px; top: 122px; width: 46px; height: 42px; padding: 0; border-radius: 12px !important; font-size: 13px !important; }
body.touch .hud-dash small { display: none; }
@media (min-width: 561px) { body.touch .hud-dash { right: auto; left: 50%; transform: translateX(-50%); width: min(300px, 30vw); } body.touch .minimap { width: 120px; height: 120px; } }
@media (max-height: 560px) { body.touch .board { display: none; } }   /* телефон боком: таблица наезжает на газ */
@media (max-width: 560px) { #touch { --dashH: 0px; } .t-pause { left: calc(50% - 23px); top: 14px; } }

/* машины: силуэт сбоку, паспорт, плюсы и минусы, экран выбора первой машины */
.sil { display: block; width: 100%; height: auto; }
.sil .body { fill: var(--paint, #c8402e); stroke: rgba(0,0,0,.45); stroke-width: .03; }
.shop .sil .body { fill: rgba(255,255,255,.55); }
.sil .glass { fill: rgba(170,210,235,.7); }
.sil .tyre { fill: #151515; } .sil .rim { fill: #c9ccd1; }
.make { font-size: 12px; color: var(--mute); font-weight: 400; }
.orig { font-size: 12px; color: var(--mute); line-height: 1.4; }
.pc { list-style: none; margin: 0 0 10px; padding: 0; font-size: 13px; line-height: 1.45; }
.pc li::before { display: inline-block; width: 16px; font-weight: 700; }
.pc .pro::before { content: '+'; color: #7bd36b; } .pc .con::before { content: '−'; color: #f07a63; }
h2.cls { margin: 6px 0 2px; }
.choose { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 12px; }
.choice { background: var(--card); border-radius: 16px; padding: 14px; min-width: 0; cursor: pointer; border: 2px solid transparent; display: flex; flex-direction: column; }
.choice.on { border-color: var(--gold); }
.choice h3 { margin: 6px 0 0; font-size: 18px; }
.choice p { margin: 6px 0; }
.choice .small { font-size: 12px; line-height: 1.35; }
.choice button { margin-top: auto; }
.choice > small:last-child { text-align: center; margin-top: 4px; font-size: 11px; }
@media (max-width: 900px) { .choose { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .choose { grid-template-columns: 1fr; } }

/* ---------- меню кубка: панель слева, машина справа ---------- */
.panel.menu { left: 16px; top: 16px; bottom: 16px; transform: none; width: min(520px, calc(100% - 32px)); max-height: none; text-align: left; padding: 20px 22px; }
.panel.menu h1 { font-size: clamp(30px, 5vw, 44px); }
.panel.menu section { background: var(--card); border-radius: 16px; padding: 12px 14px; margin-top: 12px; }
.panel.menu section h2 { font-size: 15px; }
.tab { flex: 1; font-size: 14px; padding: 9px 8px; border-radius: 11px; background: none; color: var(--mute); }
.tab.on { background: var(--gold); color: #222; }
.carcard { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; }
.carcard h2 { margin: 0 0 4px; }
.carcard .orig { margin: 0 0 4px; }
.carcard p.small { margin: 0; line-height: 1.35; }
.carcard .gbox { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; max-width: 100%; margin-top: 8px; background: rgba(0,0,0,.25); border-radius: 12px; padding: 3px; }
.carcard .gbox small { padding: 0 6px; }
.carcard .gbox .tab { padding: 6px 8px; font-size: 13px; flex: 0 1 auto; }
.carcard .setup { margin-top: 8px; background: rgba(0,0,0,.25); border-radius: 12px; padding: 6px 8px; }
.carcard .setup summary { cursor: pointer; font-size: 13px; color: var(--mute); }
.carcard .setup[open] summary { margin-bottom: 4px; }
.carcard .srow { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; margin-top: 3px; }
.carcard .srow small { flex: 0 0 116px; color: var(--mute); }
.carcard .srow .tab { flex: 0 1 auto; padding: 4px 8px; font-size: 12px; }
.carcard .srow.pre { margin-top: 8px; }
.carcard .paints { flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.carcard .sw { width: 26px; height: 26px; }
.venue-note { margin-top: 12px; font-size: 14px; }
.venue-note .best { display: block; margin-top: 2px; }
.ctl-btn { display: block; width: 100%; margin-top: 12px; font-size: 15px; padding: 10px 14px; }
.panel.menu section.ctl .gbox { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 6px 0; background: rgba(0,0,0,.25); border-radius: 12px; padding: 3px; }
.panel.menu section.ctl .gbox small { flex: 0 0 150px; padding: 0 6px; }
.panel.menu section.ctl .gbox .tab { flex: 0 1 auto; padding: 6px 10px; font-size: 13px; }
.panel.menu section.ctl p.small { margin: 2px 6px 10px; line-height: 1.4; }
.panel.menu section.ctl .musrow { margin-top: 6px; }
table.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
table.keys th { text-align: left; font-weight: 500; color: var(--mute); padding: 0 6px 4px; }
table.keys td { padding: 5px 6px; border-top: 1px solid var(--line); }
table.keys td:first-child { color: var(--mute); }
@media (max-width: 560px) { .panel.menu section.ctl .gbox small { flex-basis: 100%; } }
#boot { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 40%, #2a3448, #0d121c 70%); color: var(--ink); font-family: Rubik, system-ui, sans-serif; transition: opacity .5s; }
#boot.off { opacity: 0; pointer-events: none; }
.boot-box { width: min(440px, 100%); }
.boot-title { font-weight: 900; font-size: clamp(30px, 8vw, 48px); letter-spacing: .02em; margin-bottom: 18px; text-shadow: 0 4px 0 rgba(0,0,0,.3); }
.boot-title span { color: var(--gold); }
.boot-bar { height: 10px; border-radius: 6px; background: rgba(255,255,255,.1); overflow: hidden; }
/* scaleX, а не width: анимирует компоситор, полоса не застывает, пока главный поток занят сборкой трассы и шейдерами */
.boot-bar i { display: block; height: 100%; background: var(--gold); transform: scaleX(0); transform-origin: 0 50%; transition: transform .2s ease-out; }
.boot-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 10px; font-weight: 700; font-size: 16px; }
.boot-row b { font-variant-numeric: tabular-nums; color: var(--gold); }
.boot-steps { list-style: none; padding: 0; margin: 16px 0 0; font-size: 14px; color: var(--mute); display: grid; gap: 6px; }
.boot-steps li::before { content: '○'; display: inline-block; width: 22px; }
.boot-steps li.on { color: var(--ink); }
.boot-steps li.on::before { content: '◐'; color: var(--gold); }
.boot-steps li.ok::before { content: '✓'; color: #7bd88f; }
#bootDet { display: block; margin-top: 14px; font-size: 12px; color: var(--mute); min-height: 1.3em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#boot.err .boot-bar i { background: #e8453c; }
.wxrow { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 12px; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px 4px 4px 10px; }
.wxrow small { margin-right: 4px; }
.wxrow .tab { padding: 6px 8px; font-size: 12px; }
.wxrow .tyre { flex-basis: 100%; margin: 2px 0 2px; font-size: 12px; opacity: .8; }
.musrow { display: flex; align-items: center; gap: 8px; margin-top: 12px; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px 4px 4px 10px; }
.musrow input[type=range] { flex: 1; min-width: 60px; accent-color: var(--gold); }
.musrow .tab { padding: 6px 10px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 58%; }
.venue-note p { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--mute); }
.venue-note .best { display: block; margin-top: 6px; color: var(--gold); font-size: 13px; }
.credit { font-size: 11px; color: var(--mute); margin: 8px 0 0; }
.credit a { color: inherit; }
.panel.menu .g-foot button:not(.link) { flex: 1; }
.hud-tl .vn { font-size: 12px; opacity: .7; margin-top: 2px; }
@media (max-width: 560px) {
  .panel.menu { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 72%; overflow: auto; padding: 14px; }
  .carcard { grid-template-columns: 110px 1fr; }
}
