
:root {
  --text: #fff6ea;
  --muted: #d8d4cb;
  --panel: rgba(12, 10, 9, 0.62);
  --border: rgba(255, 255, 255, 0.16);
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --blue: #3f9dff;
  --red: #e84b41;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #130f0d;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.panel {
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.hud-left {
  position: fixed; top: 18px; left: 18px; z-index: 5; width: 176px;
  display: flex; flex-direction: column; gap: 10px;
}
.lap-panel, .pos-panel { padding: 10px 14px; }
.label { font-size: 0.78rem; font-weight: 900; letter-spacing: 0.08em; opacity: 0.95; }
.value { margin-top: 4px; font-size: 1.05rem; font-weight: 900; }
.racers-panel { display: flex; flex-direction: column; gap: 10px; }
.racer-card {
  display: grid; grid-template-columns: 34px 60px minmax(0, 1fr); align-items: center;
  gap: 10px; min-height: 80px; padding: 9px 10px;
  background: rgba(0, 0, 0, 0.52); border: 2px solid rgba(255,255,255,0.17);
  border-radius: 18px; box-shadow: var(--shadow);
}
.racer-card.player { background: linear-gradient(180deg, rgba(56, 142, 255, 0.95), rgba(32, 95, 192, 0.95)); }
.racer-card.cpu { background: linear-gradient(180deg, rgba(232, 75, 65, 0.95), rgba(178, 45, 40, 0.95)); }
.place { font-size: 1.9rem; font-weight: 900; line-height: 1; text-align: center; }
.avatar {
  width: 60px; height: 60px; border-radius: 14px; position: relative;
  background: linear-gradient(180deg, rgba(64,55,49,0.95), rgba(34,26,22,0.95));
  border: 2px solid rgba(255,255,255,0.45); box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12);
  background-repeat: no-repeat; background-position: center; background-size: 82%;
}
.avatar.player { box-shadow: inset 0 0 0 3px rgba(64, 173, 255, 0.85); background-image: url('assets/poky_portrait.png'); }
.avatar.cpu { box-shadow: inset 0 0 0 3px rgba(255, 111, 102, 0.85); background-image: url('assets/hygge_portrait.png'); }
.meta { min-width: 0; display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.name { font-size: 1.08rem; font-weight: 900; line-height: 1.08; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { margin-top: 4px; font-size: 0.80rem; opacity: 0.96; white-space: nowrap; }
.hud-right { position: fixed; top: 18px; right: 18px; z-index: 5; }
.timer-panel { display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-radius: 18px; }
.clock-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,0.12); font-size: 1.2rem; }
.timer-value { font-size: 1.95rem; font-weight: 900; letter-spacing: -0.03em; }
.hud-top-center {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5; text-align: center;
  pointer-events: none; text-shadow: 0 3px 14px rgba(0, 0, 0, 0.35);
}
.game-title { font-size: clamp(1rem, 2vw, 1.4rem); font-weight: 900; letter-spacing: -0.03em; }
.subtitle { font-size: 0.85rem; color: var(--muted); }
.boost-wrap { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 5; width: min(340px, calc(100vw - 36px)); padding: 10px 12px; }
.boost-header { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; font-weight: 800; color: var(--muted); margin-bottom: 8px; }
.boost-bar { width: 100%; height: 13px; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,0.12); }
#boostFill { width: 100%; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #4cb0ff, #9ddaff); }
.minimap { position: fixed; right: 18px; bottom: 18px; z-index: 5; padding: 8px; width: 222px; }
.mini-title { margin: 2px 0 6px 4px; font-size: 0.8rem; color: var(--muted); font-weight: 800; }
#minimap { display: block; width: 206px; height: 150px; border-radius: 12px; background: rgba(255,255,255,0.06); }
.help { position: fixed; right: 18px; bottom: 184px; z-index: 5; width: 222px; padding: 10px 12px; font-size: 0.84rem; color: var(--muted); line-height: 1.45; }
.help-small { margin-top: 6px; font-size: 0.75rem; opacity: 0.86; }
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  background: rgba(14, 10, 8, 0.38); padding: 18px;
}
.card {
  width: min(680px, 100%); padding: 28px; text-align: center; border-radius: 26px;
  background: rgba(12, 10, 9, 0.84); border: 2px solid rgba(255,255,255,0.15); box-shadow: 0 28px 90px rgba(0,0,0,0.45);
}
.card-badge { display: inline-block; padding: 6px 12px; border-radius: 999px; background: rgba(255,255,255,0.10); font-weight: 800; font-size: 0.82rem; letter-spacing: 0.04em; }
.card h1 { margin: 14px 0 8px; font-size: clamp(2rem, 4vw, 3rem); }
.card p { margin: 0 auto 22px; max-width: 46ch; color: var(--muted); font-size: 1.05rem; line-height: 1.5; }
.card button {
  border: 0; border-radius: 16px; padding: 14px 24px; cursor: pointer; color: white; font-weight: 900; font-size: 1rem;
  background: linear-gradient(180deg, #4ba8ff, #2576dc); box-shadow: 0 14px 30px rgba(37,118,220,0.35);
}
.countdown {
  position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; pointer-events: none;
  font-size: clamp(4rem, 12vw, 8rem); font-weight: 1000; color: white;
  text-shadow: 0 10px 30px rgba(0,0,0,0.45), 0 0 25px rgba(255,205,80,0.35);
}
.countdown.hidden { display: none; }
.touch-controls { display: none; }
@media (max-width: 800px) {
  .hud-left { width: 142px; top: 12px; left: 12px; gap: 8px; }
  .racer-card { grid-template-columns: 26px 48px minmax(0, 1fr); min-height: 68px; padding: 8px; gap: 8px; }
  .place { font-size: 1.7rem; }
  .avatar { width: 48px; height: 48px; }
  .name { font-size: 0.98rem; }
  .sub { font-size: 0.72rem; }
  .hud-right { top: 12px; right: 12px; }
  .timer-value { font-size: 1.65rem; }
  .minimap { right: 12px; bottom: 12px; width: 174px; }
  #minimap { width: 158px; height: 116px; }
  .help { right: 12px; bottom: 144px; width: 174px; font-size: 0.76rem; }
  .boost-wrap { bottom: 12px; width: min(280px, calc(100vw - 24px)); }
  .touch-controls {
    position: fixed; left: 12px; bottom: 12px; z-index: 8; display: grid; grid-template-columns: repeat(3, 58px); gap: 8px;
  }
  .touch-controls button {
    border: 0; border-radius: 14px; background: rgba(20,20,20,0.62); color: white; min-height: 54px; font-weight: 900;
    border: 2px solid rgba(255,255,255,0.16); box-shadow: var(--shadow); backdrop-filter: blur(8px);
  }
  .touch-controls button[data-action="up"] { grid-column: 2; }
  .touch-controls button[data-action="left"] { grid-column: 1; grid-row: 2; }
  .touch-controls button[data-action="down"] { grid-column: 2; grid-row: 2; }
  .touch-controls button[data-action="right"] { grid-column: 3; grid-row: 2; }
  .touch-controls button[data-action="boost"] { grid-column: span 3; background: rgba(57,128,255,0.72); }
}
