*{box-sizing:border-box}

/* Shop overlay */
.shop{ max-width:900px; width:min(94vw,900px); display:flex; flex-direction:column; gap:16px }
.shop h2{ margin:0 0 6px 0; font-size:22px; text-align:center }
.shop .shop-layout{ display:flex; gap:16px; align-items:flex-start }
.shop .shop-left{ flex:1 1 auto; min-width: 420px; }
.shop .shop-avatar{ flex:0 0 auto; width:260px; display:flex; flex-direction:column; align-items:center; gap:10px; border-left:1px solid rgba(255,255,255,0.14); padding-left:14px }
.shop .shop-avatar .avatar-title{ font-weight:900; letter-spacing:.3px; color:#ffd166 }
.shop #shopAvatar{ width:220px; height:260px; background:rgba(255,255,255,0.06); border-radius:10px; border:1px solid rgba(255,255,255,0.14) }
.shop .shop-tabs{ display:flex; gap:8px; flex-wrap:wrap; margin-bottom:6px }
.shop .shop-tab{ background:#2b2b2b; border:1px solid #444; border-radius:8px; padding:6px 10px; font-weight:800; color:#fff }
.shop .shop-tab.selected{ background:#3a3a3a; border-color:#666 }
.shop .section{ display:flex; flex-direction:column; gap:10px; padding:10px 0; border-bottom:1px solid rgba(255,255,255,0.14) }
.shop .section:last-of-type{ border-bottom:none }
.shop .section strong{ font-size:14px; opacity:.9 }
.shop .items{ display:grid; grid-template-columns: repeat( auto-fill, minmax(160px, 1fr) ); gap:10px }
.shop .item{ position:relative; display:flex; align-items:center; gap:8px; padding:10px; border:1px solid rgba(255,255,255,0.16); border-radius:10px; background:rgba(255,255,255,0.04); cursor:pointer }
.shop .item:hover{ background:rgba(255,255,255,0.07) }
.shop .item.selected{ border-color:#ffd166; background:rgba(255,209,102,0.12) }
.shop .item.owned{ border-color:#3ecf8e }
.shop .item .badges{ margin-left:auto; display:flex; gap:6px; align-items:center }
.shop .badge{ font-size:11px; padding:2px 6px; border-radius:999px; border:1px solid rgba(255,255,255,0.18); background:rgba(255,255,255,0.08); color:#fff; font-weight:800; letter-spacing:.2px }
.shop .badge.owned{ background:rgba(62,207,142,0.18); border-color:#3ecf8e; color:#caffdf }
.shop .badge.equipped{ background:rgba(255,209,102,0.18); border-color:#ffd166; color:#fff3cd }
.shop .badge.equip{ background:rgba(207,231,255,0.16); border-color:#86baf0; color:#d7ecff }
.shop .item.selected .badge.equip{ display:none }
.shop .item:not(.owned) .badge.owned{ display:none }
.shop .item.selected .badge.equipped{ display:inline-flex }
.shop .item:not(.selected) .badge.equipped{ display:none }
.shop .colors{ display:flex; flex-wrap:wrap; gap:12px; align-items:center }
.shop .colors label{ display:flex; align-items:center; gap:8px }
html,body{height:100%;margin:0;padding:0;font-family:'Inter',system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-weight:600}
body{background:#0f0f0f;color:#f5f5f5;overflow:hidden}

/* Fullscreen canvas */
canvas#game{position:fixed;inset:0;width:100vw;height:100vh;display:block;background:#4b1f0e}

/* Overlays */
.overlay{position:fixed;z-index:10;padding:16px 18px;background:rgba(16,16,16,0.7);backdrop-filter:blur(6px);border:1.5px solid rgba(255,255,255,0.16);border-radius:14px;box-shadow:0 6px 24px rgba(0,0,0,0.35)}
.top-left{top:10px;left:10px}
.top-right{top:10px;right:10px}
.center{top:50%;left:50%;transform:translate(-50%,-50%)}

/* Top bar HUD */
.top-bar{top:10px;left:10px;right:auto;width:320px;display:flex;flex-direction:column;align-items:stretch;gap:10px}
.top-bar.overlay{background:transparent;border:none;box-shadow:none;padding:0}
.hud{line-height:1.8;max-width:none;font-size:16px;letter-spacing:.2px}
.hud .hud-group{display:flex;flex-direction:column;row-gap:6px;align-items:flex-start}
.hud .hud-row{margin-bottom:8px}
.hud .help{opacity:.92;font-size:13px;margin-top:6px;color:#cfd8dc}
.hud strong{font-weight:900;color:#ffd166;letter-spacing:.3px}
.hud #distance, .hud #goal{font-weight:900}
.hud #boost{font-weight:800;color:#3ecf8e}
.hud #wallet{font-weight:800;color:#cfe1ff}
.racer-names{font-weight:700;letter-spacing:.2px}
.player-name{color:#ffd166}
.npc-name{color:#cfe1ff}

.menu{min-width:300px;max-width:480px;display:flex;flex-direction:column;gap:16px}
.menu h1{margin:0 0 6px 0;font-size:38px;font-family:'Bebas Neue',cursive;letter-spacing:.6px;color:#ffffff}
.menu .subtitle{font-size:17px;opacity:.95;margin-top:-4px;color:#cfe1ff;font-weight:800}
.menu .tagline{font-size:15px;opacity:.9;margin-top:-6px;color:#ffd166;font-weight:800}
.menu .controls{display:flex;gap:12px;align-items:center;flex-wrap:wrap;padding-bottom:10px;border-bottom:1px solid rgba(255,255,255,0.14)}
.menu .controls.buttons{justify-content:space-between;gap:12px}
.menu .hint{opacity:.9;font-size:13px;margin-top:2px;color:#cfd8dc}
label{font-weight:900;letter-spacing:.35px;color:#e0e0e0}

button,select{background:#333;color:#fff;border:1px solid #454545;border-radius:8px;padding:8px 12px;font-weight:900}
button:hover{background:#3a3a3a}

/* Menu button (when menu hidden) */
.menu-button{padding:10px 12px;border-radius:999px;font-size:20px;line-height:1;box-shadow:0 4px 16px rgba(0,0,0,0.35)}

/* Results overlay */
.results{ text-align:center; max-width:480px; }
.results h2{ margin-top:0; margin-bottom:8px; font-family:'Bebas Neue',cursive; font-size:32px; letter-spacing:.7px }
.leaderboard{ list-style: decimal; list-style-position: inside; padding:0; margin:10px auto 10px auto; text-align:left; border-top:1px solid rgba(255,255,255,0.14); padding-top:10px }
.leaderboard li{ padding:6px 10px; font-weight:800; display:flex; justify-content:space-between; align-items:center }
.leaderboard li:nth-child(odd){ background: rgba(255,255,255,0.04) }
.leaderboard li:nth-child(1){ color:#ffd166 }
.leaderboard li:nth-child(2){ color:#cfe1ff }
.leaderboard li:nth-child(3){ color:#c3f0ca }
.analytics{ text-align:center; margin-top:10px; line-height:1.7; border-top:1px solid rgba(255,255,255,0.14); padding-top:10px; font-weight:800; color:#e0e0e0 }
.analytics strong{ color:#ffd166 }
.results .controls.buttons{ justify-content:center; gap:12px; }

/* Responsive design */
@media (max-width: 480px) {
  .overlay{ padding:12px 14px; border-radius:12px }
  .top-bar{ width: 260px; gap:8px }
  .hud{ font-size:15px; line-height:1.7 }
  .hud .hud-group{ row-gap:4px }
  .hud .help{ font-size:12px; margin-top:4px }
  .menu{ min-width: 260px; max-width: 340px; gap:12px }
  .menu h1{ font-size:32px; margin-bottom:4px }
  .menu .subtitle{ font-size:15px }
  .menu .tagline{ font-size:12px }
  .menu .controls{ gap:10px }
  button,select{ padding:7px 10px; border-radius:7px }
  .results{ max-width: 340px }
  .leaderboard{ margin:8px auto }
}

@media (min-width: 481px) and (max-width: 768px) {
  .top-bar{ width: 300px }
  .menu{ max-width: 380px }
  .results{ max-width: 380px }
}

@media (min-width: 1440px) {
  .overlay{ padding:18px 22px }
  .top-bar{ width: 360px }
  .hud{ font-size:16px }
  .menu{ max-width: 560px }
  .menu h1{ font-size:40px }
  .menu .subtitle{ font-size:18px }
  .menu .tagline{ font-size:15px }
  .results{ max-width: 560px }
  .leaderboard li{ padding:6px 0 }
}
