: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; }
[hidden] { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-tl { position: absolute; left: 16px; top: 14px; background: var(--shade); border-radius: 16px; padding: 8px 16px 10px; min-width: 120px; }
.place b { font-size: 46px; font-weight: 900; line-height: 1; }
.place span { font-size: 20px; font-weight: 700; opacity: .6; }
.lap { font-weight: 700; font-size: 15px; }
.time { font-size: 13px; opacity: .75; font-variant-numeric: tabular-nums; }
.board { position: absolute; right: 16px; top: 14px; margin: 0; padding: 8px 12px 8px 34px; background: var(--shade); border-radius: 14px; font-size: 13px; font-weight: 700; line-height: 1.55; min-width: 150px; }
.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.wr { opacity: .4; text-decoration: line-through; }
.hud-br { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 12px; align-items: flex-end; background: var(--shade); border-radius: 16px; padding: 10px 14px; }
.dmg { width: 42px; height: 70px; }
.meters { width: 180px; }
.spd { font-size: 13px; font-weight: 700; opacity: .85; }
.spd b { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; opacity: 1; }
.meters small { display: block; font-size: 11px; opacity: .55; margin-top: 6px; }
.tacho { display: block; width: 170px; height: 170px; margin: -4px auto 6px; }
.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.hp i { background: linear-gradient(90deg, #e8453c, #f2c230 45%, #59d36b); background-size: 180px 100%; }
.bar.nitro i { background: #3fb6ff; }
.bar.nitro.on i { background: #ff8a1a; box-shadow: 0 0 10px #ff8a1a; }
.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; }
.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 / 3; grid-column: 2; }
.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); }
.lvlup { color: var(--gold); font-weight: 700; margin: 0 0 14px; }
.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-br { left: 16px; right: 16px; justify-content: space-between; }
  .meters { flex: 1; width: auto; }
  .meters small { display: none; }
  .tacho { width: 120px; height: 120px; }
  .minimap { width: 110px; height: 110px; top: 12px; left: auto; right: 12px; bottom: auto; }
}
