:root {
  --bg: #0b0d12;
  --panel: rgba(14, 17, 24, 0.92);
  --accent: #ff3d2e;
  --accent2: #ffb300;
  --text: #f1f3f7;
  --muted: #9aa3b2;
  --ok: #4cd964;
  --nitro: #3ea6ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; overflow: hidden; overscroll-behavior: none; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif; user-select: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

.overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.35), rgba(0,0,0,0.75)); z-index: 20; }
.panel { background: var(--panel); border: 1px solid rgba(255,255,255,0.08); border-top: 4px solid var(--accent);
  padding: 28px 32px; width: min(92vw, 460px); box-shadow: 0 20px 60px rgba(0,0,0,0.6); border-radius: 6px; }
.panel.wide { width: min(94vw, 820px); max-height: 92vh; overflow: auto; }
h1 { margin: 0 0 4px; font-size: 44px; letter-spacing: 4px; font-weight: 900; font-style: italic; }
h1 span { color: var(--accent); }
h2 { margin: 0 0 12px; letter-spacing: 3px; font-weight: 900; font-style: italic; }
.sub { color: var(--muted); margin: 0 0 18px; }
label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 14px 0 6px; }
input { width: 100%; padding: 10px 12px; font-size: 18px; background: #161a23; color: var(--text);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 4px; outline: none; margin-top: 6px; }
input:focus { border-color: var(--accent); }
button { cursor: pointer; font: inherit; font-weight: 700; letter-spacing: 1px; padding: 10px 18px;
  background: #222a38; color: var(--text); border: 1px solid rgba(255,255,255,0.12); border-radius: 4px; }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: 0.4; cursor: default; filter: none; }
button.primary { background: var(--accent); border-color: var(--accent); margin-top: 18px; width: 100%; font-size: 18px; padding: 14px; }
.row { display: flex; gap: 20px; align-items: flex-start; }
.row.between { justify-content: space-between; align-items: center; }
.row.end { justify-content: flex-end; gap: 10px; }
.row.end button.primary { width: auto; }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors div { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.colors div.sel { border-color: #fff; transform: scale(1.12); }
.controls { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 18px; font-size: 13px; color: var(--muted); }
kbd { display: inline-block; min-width: 20px; padding: 1px 5px; margin-right: 2px; text-align: center; font-size: 11px;
  background: #2a3140; color: #fff; border-radius: 3px; border-bottom: 2px solid #111; }
.status { color: var(--accent2); min-height: 18px; margin: 10px 0 0; font-size: 13px; }
.credits { font-size: 18px; } .credits b { color: var(--accent2); }

.stats { flex: 0 0 220px; font-size: 13px; }
.stats div { margin: 6px 0; display: flex; justify-content: space-between; border-bottom: 1px dashed rgba(255,255,255,0.08); padding-bottom: 3px; }
.stats b { color: var(--accent2); }
.upgrades { flex: 1; }
.up { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.up .n { font-weight: 700; } .up .d { font-size: 12px; color: var(--muted); }
.pips { display: flex; gap: 3px; } .pips i { width: 14px; height: 8px; background: #2a3140; border-radius: 2px; } .pips i.on { background: var(--ok); }
.up button { padding: 6px 10px; font-size: 12px; white-space: nowrap; }

#results-table, #score-table { width: 100%; border-collapse: collapse; font-size: 14px; }
#results-table th, #score-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; padding: 6px 8px; }
#results-table td, #score-table td { padding: 6px 8px; border-top: 1px solid rgba(255,255,255,0.06); }
tr.me td { color: var(--accent2); font-weight: 700; }
td.credit { color: var(--ok); }

/* HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-weight: 700; }
#race-info { position: absolute; top: 16px; left: 18px; text-shadow: 0 2px 6px #000; }
#race-info .big { font-size: 28px; font-style: italic; letter-spacing: 2px; }
#race-info div:last-child { font-size: 16px; color: var(--muted); }
#minimap { position: absolute; top: 14px; right: 14px; background: rgba(0,0,0,0.35); border-radius: 50%; border: 2px solid rgba(255,255,255,0.15); }
#feed { position: absolute; top: 16px; right: 250px; width: 320px; text-align: right; font-size: 14px; }
#feed div { background: rgba(0,0,0,0.45); padding: 4px 8px; margin-bottom: 4px; border-right: 3px solid var(--accent); display: inline-block; animation: fadein 0.2s; }
#feed div.finish { border-color: var(--ok); } #feed div.info { border-color: var(--muted); color: var(--muted); }
#center { position: absolute; top: 28%; left: 0; right: 0; text-align: center; font-size: 52px; font-style: italic; letter-spacing: 4px;
  text-shadow: 0 4px 18px #000; color: #fff; }
#center small { display: block; font-size: 20px; letter-spacing: 1px; color: var(--accent2); }
#toast { position: absolute; bottom: 30%; left: 0; right: 0; text-align: center; font-size: 22px; color: var(--accent2); text-shadow: 0 2px 8px #000; opacity: 0; transition: opacity 0.3s; }
#vitals { position: absolute; left: 18px; bottom: 18px; width: 260px; }
.bar { position: relative; height: 22px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.2); margin-top: 6px; overflow: hidden; transform: skewX(-12deg); }
.bar > div { height: 100%; width: 100%; transition: width 0.15s; }
.bar.hp > div { background: linear-gradient(90deg, #d32f2f, #ff7043); }
.bar.nitro > div { background: linear-gradient(90deg, #1565c0, var(--nitro)); }
.bar span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; letter-spacing: 2px; text-shadow: 0 1px 3px #000; }
#shield { margin-top: 6px; color: #7fe3ff; font-size: 13px; letter-spacing: 3px; text-shadow: 0 0 10px #38c6ff; }
#dash { position: absolute; right: 18px; bottom: 18px; text-align: right; }
#speed { font-size: 56px; font-style: italic; line-height: 1; text-shadow: 0 3px 10px #000; }
#speed small { font-size: 16px; margin-left: 6px; color: var(--muted); }
#weapons { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.w { background: rgba(0,0,0,0.5); padding: 4px 10px; font-size: 13px; border-right: 3px solid transparent; color: var(--muted); min-width: 150px; }
.w.sel { color: #fff; border-color: var(--accent2); background: rgba(0,0,0,0.75); }
.w b { color: var(--accent2); margin-right: 6px; } .w span { float: right; margin-left: 10px; }
#scoreboard { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: rgba(0,0,0,0.8); padding: 14px 18px; min-width: 460px; border-radius: 6px; border-top: 3px solid var(--accent); }
#crosshair { position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border: 2px solid rgba(255,255,255,0.6); border-radius: 50%; }
#damage-flash { position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(255,0,0,0.8); opacity: 0; transition: opacity 0.4s; }
@keyframes fadein { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; } }

/* felszerelés */
label small { text-transform: none; letter-spacing: 0; }
.equipment { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.slot { background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.07); border-radius: 4px; padding: 8px 10px; }
.slot-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.slot-name { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); flex: 1; }
.slot-cur { font-weight: 700; color: var(--accent2); }
.slot .sell { padding: 3px 8px; font-size: 11px; background: #3a2a2a; }
.slot-items { display: flex; flex-wrap: wrap; gap: 4px; }
.slot-items button { padding: 4px 8px; font-size: 12px; font-weight: 600; }
.slot-items button b { color: var(--ok); font-weight: 700; margin-left: 4px; }
.slot-items button:disabled b { color: var(--muted); }
#hud-garage { position: absolute; left: 18px; top: 86px; pointer-events: auto; padding: 6px 12px; font-size: 13px;
  background: rgba(0,0,0,0.55); border-color: rgba(255,255,255,0.25); }
#hud-garage:hover { background: var(--accent); }

/* ---------- mobil / érintés ---------- */
#game { touch-action: none; }
.touch-only { display: none; }
#hud-score { position: absolute; left: 18px; top: 128px; pointer-events: auto; padding: 6px 10px; font-size: 16px; background: rgba(0,0,0,0.55); border-color: rgba(255,255,255,0.25); }
#touch { position: absolute; inset: 0; pointer-events: none; }
#steer-pad { position: relative; width: 240px; height: 96px; border-radius: 48px; background: rgba(0,0,0,0.35);
  border: 2px solid rgba(255,255,255,0.25); pointer-events: auto; touch-action: none; }
#steer-pad span { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; letter-spacing: 2px; color: rgba(255,255,255,0.45); }
#steer-knob { position: absolute; top: 8px; left: 50%; width: 76px; height: 76px; margin-left: -38px; border-radius: 50%; background: rgba(255,255,255,0.35);
  border: 2px solid rgba(255,255,255,0.6); transition: left 0.05s; }
#touch-left { position: absolute; left: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; pointer-events: auto; }
#touch-right { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: auto; }
.trow { display: flex; gap: 10px; align-items: flex-end; }
.tbtn { width: 78px; height: 78px; border-radius: 50%; background: rgba(0,0,0,0.4); border: 2px solid rgba(255,255,255,0.3); color: #fff;
  font-size: 26px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; touch-action: none; pointer-events: auto; user-select: none; -webkit-user-select: none; }
.tbtn small { font-size: 9px; letter-spacing: 1px; margin-top: 2px; }
.tbtn.big { width: 110px; height: 110px; font-size: 34px; }
.tbtn.small { width: 58px; height: 58px; font-size: 20px; }
.tbtn.on { background: var(--accent); border-color: #fff; }
.tbtn[data-act="nitro"].on { background: var(--nitro); }
#rotate-hint { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; text-align: center; padding: 30px;
  background: rgba(0,0,0,0.9); font-size: 22px; }

body.touch .touch-only { display: block; }
body.touch #crosshair { display: none; }
body.touch #vitals { left: 50%; transform: translateX(-50%); bottom: 10px; width: 220px; }
body.touch #minimap { width: 110px; height: 110px; }
body.touch #dash { right: 14px; top: 128px; bottom: auto; }
body.touch #speed { font-size: 32px; }
body.touch #weapons { margin-top: 2px; }
body.touch #weapons .w { display: none; }
body.touch #weapons .w.sel { display: block; min-width: 110px; font-size: 11px; padding: 2px 8px; }
body.touch #feed { right: 140px; top: 10px; }
body.touch #feed { right: 200px; width: 260px; font-size: 12px; }
body.touch #hud-garage { top: 70px; }
body.touch #hud-score { top: 108px; }

@media (max-width: 900px), (max-height: 520px) {
  #race-info .big { font-size: 20px; }
  #race-info div:last-child { font-size: 12px; }
  #minimap { width: 140px; height: 140px; }
  #center { font-size: 34px; top: 22%; }
  #center small { font-size: 14px; }
  #feed { right: 160px; width: 240px; font-size: 12px; }
  .panel { padding: 16px 18px; width: min(96vw, 460px); max-height: 94vh; overflow: auto; }
  .panel.wide { width: 96vw; }
  h1 { font-size: 30px; }
  .row { flex-wrap: wrap; }
  .stats { flex: 1 1 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
  .equipment { grid-template-columns: 1fr; }
  .controls { display: none; }
  button.primary { padding: 12px; font-size: 16px; }
  #scoreboard { min-width: 90vw; font-size: 12px; }
  #speed { font-size: 40px; }
}

#hud-fs { position: absolute; left: 70px; top: 128px; pointer-events: auto; padding: 6px 10px; font-size: 16px; background: rgba(0,0,0,0.55); border-color: rgba(255,255,255,0.25); }
body.touch #hud-fs { top: 108px; left: 66px; }
