:root {
  --bg: #0e1a21;
  --panel: rgba(16, 24, 28, 0.92);
  --accent: #18c3a8;
  --accent-2: #f2b13f;
  --text: #e9f7f5;
  --danger: #ed5454;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, #204857 0%, var(--bg) 45%, #091015 100%);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

#ui-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: min(640px, 88vw);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 2px solid #3f6972;
  border-radius: 16px;
  padding: 18px;
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.panel.hidden,
.hidden {
  display: none !important;
}

.panel h1,
.panel h2 {
  margin: 0 0 12px;
}

.subtitle {
  margin: 0 0 16px;
  opacity: 0.86;
}

.selection-detail {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-left: 3px solid #5dcdb8;
  border-radius: 8px;
  background: rgba(13, 31, 39, 0.58);
  font-size: 13px;
  color: #d9f4ee;
}

.car-customizer {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #3f6972;
  border-radius: 12px;
  background: rgba(13, 31, 39, 0.58);
}

.car-customizer h3 {
  margin: 0 0 10px;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 10px;
}

.preset-btn {
  padding: 8px 6px;
  font-size: 13px;
}

.preset-btn.active {
  background: linear-gradient(130deg, #f2b13f, #d7801f);
  color: #1e1400;
}

#car-preview-canvas {
  display: block;
  width: 100%;
  height: 170px;
  margin: 0 0 12px;
  border: 1px solid #3f6972;
  border-radius: 10px;
  background: radial-gradient(circle at 35% 30%, #284f60 0%, #0c1f28 58%, #07151c 100%);
}

.custom-summary {
  margin: 10px 0 0;
  font-size: 13px;
  color: #d4efea;
}

.controls-help {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 3px solid #f2b13f;
  border-radius: 10px;
  background: rgba(15, 32, 40, 0.68);
}

.controls-help h3 {
  margin: 0 0 8px;
}

.controls-help p {
  margin: 6px 0;
  font-size: 13px;
  color: #d8f2ee;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid #5f7c83;
  border-bottom-width: 2px;
  border-radius: 6px;
  background: #162b35;
  color: #e9f7f5;
  font-size: 12px;
  line-height: 1.2;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

select,
button,
input[type="range"],
input[type="color"] {
  width: 100%;
}

select,
button {
  border: 0;
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
}

input[type="color"] {
  height: 42px;
  border: 0;
  border-radius: 10px;
  padding: 4px;
  background: #fff;
}

button {
  background: linear-gradient(130deg, var(--accent), #1f8f86);
  color: #042019;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(1.05);
}

.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
}

.actions {
  margin-top: 16px;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.actions.vertical {
  flex-direction: column;
}

#hud {
  position: absolute;
  inset: 0;
  padding: 14px;
  pointer-events: none;
}

#top-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 700;
}

#lap-banner {
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
}

#split,
#item-indicator,
#drift-indicator {
  margin-top: 8px;
  font-weight: 700;
  text-shadow: 0 1px 2px #000;
}

#item-indicator {
  color: var(--accent-2);
}

#drift-indicator {
  color: #8de5ff;
}

#minimap {
  position: absolute;
  right: 16px;
  top: 16px;
  width: 180px;
  height: 180px;
  border: 2px solid #33535a;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
}

@media (max-width: 760px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .panel {
    min-width: 92vw;
  }

  #minimap {
    width: 130px;
    height: 130px;
  }

  #car-preview-canvas {
    height: 145px;
  }

  .preset-row {
    grid-template-columns: 1fr;
  }
}
