:root {
  color-scheme: dark;
  --bg-1: #071018;
  --bg-2: #0f1d26;
  --panel: rgba(10, 16, 22, 0.72);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f2f6fb;
  --muted: #9db0bf;
  --accent: #ffb000;
  --accent-2: #7cf6ff;
  --danger: #ff455e;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(42, 89, 123, 0.38), transparent 35%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

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

.topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.badge, .status, .panel, .control {
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
}

.badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(14, 19, 27, 0.82);
  color: var(--accent-2);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

.status {
  display: flex;
  gap: 16px;
  align-items: center;
  background: rgba(9, 14, 20, 0.8);
  padding: 12px 16px;
  border-radius: 18px;
  min-width: 220px;
  justify-content: space-between;
}

#raceStatus {
  color: var(--accent);
}

.panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.98);
  width: min(420px, calc(100vw - 28px));
  padding: 22px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(14, 18, 26, 0.94), rgba(8, 11, 16, 0.86));
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.panel.visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.title h1,
.panel h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.02em;
}

.title h1 {
  font-size: clamp(40px, 8vw, 64px);
  line-height: 0.95;
  margin: 8px 0 10px;
  text-shadow: 0 0 30px rgba(124, 246, 255, 0.18);
}

.eyebrow {
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 700;
  font-size: 12px;
}

.title p,
.hint,
#resultText {
  color: var(--muted);
  line-height: 1.5;
}

.actions {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

button, select {
  font: inherit;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

button.primary {
  background: linear-gradient(180deg, #ffd36b, #ff8f1f);
  color: #18120a;
  font-weight: 800;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.ghost {
  background: rgba(255, 255, 255, 0.08);
}

.field {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

select {
  width: 100%;
  appearance: none;
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

#controls {
  position: absolute;
  inset: auto 16px 16px 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.control {
  pointer-events: auto;
  width: min(38vw, 200px);
  height: 88px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.12em;
  border-radius: 26px;
  text-transform: uppercase;
}

.gas {
  background: linear-gradient(180deg, rgba(255, 182, 56, 0.95), rgba(205, 106, 0, 0.92));
}

.brake {
  background: linear-gradient(180deg, rgba(255, 95, 119, 0.95), rgba(156, 28, 56, 0.92));
}

.start-lights {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 999px;
  background: rgba(8, 11, 16, 0.76);
  border: 1px solid var(--panel-border);
}

.start-lights span {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.start-lights span.active.red { background: #ff304f; box-shadow: 0 0 24px rgba(255, 48, 79, 0.9); }
.start-lights span.active.amber { background: #ffad2f; box-shadow: 0 0 24px rgba(255, 173, 47, 0.9); }
.start-lights span.active.green { background: #4cff8a; box-shadow: 0 0 24px rgba(76, 255, 138, 0.9); }

.hidden {
  display: none !important;
}

@media (max-width: 700px) {
  .topbar {
    top: 10px;
    left: 10px;
    right: 10px;
  }

  .status {
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .control {
    width: min(42vw, 170px);
    height: 76px;
  }
}
