:root {
  --bg: #09121d;
  --surface: #132238;
  --panel: #1a2f4c;
  --line: #2a4366;
  --text: #f0f6fc;
  --muted: #94a3b8;
  --teal: #10b981;
  --orange: #f97316;
  --gold: #f59e0b;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Lexend", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

header {
  background: var(--surface);
  border-bottom: 2px solid var(--line);
  padding: 0.75rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.brand-icon {
  font-size: 2rem;
  background: linear-gradient(135deg, #10b981, #047857);
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.brand h1 {
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.brand p {
  font-size: 0.8rem;
  color: var(--muted);
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.controls-bar select {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  cursor: pointer;
  outline: none;
}

.btn-header {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-header:hover {
  background: var(--teal);
  border-color: var(--teal);
}

main {
  flex: 1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

/* HUD */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.6rem 1.2rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.hud-val {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

.speed-val {
  color: var(--gold);
}

.hud-question-box {
  flex: 1;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.8rem;
}

.q-label {
  display: block;
  font-size: 0.72rem;
  color: var(--teal);
  font-weight: 700;
  text-transform: uppercase;
}

.q-text {
  display: block;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}

.hud-streak {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--orange);
  min-width: 50px;
  justify-content: flex-end;
}

/* Track Canvas Arena */
.track-wrapper {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--line);
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
}

canvas {
  width: 100%;
  max-height: 540px;
  aspect-ratio: 800 / 520;
  display: block;
  background: #111;
  cursor: pointer;
}

/* Touch Steering */
.touch-steering {
  display: flex;
  width: 100%;
  gap: 0.5rem;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.btn-steer {
  flex: 1;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 800;
  padding: 0.85rem 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

.btn-steer:active, .btn-steer.active {
  background: var(--teal);
  border-color: var(--teal);
  transform: translateY(2px);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 9, 15, 0.85);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--surface);
  border: 2px solid var(--teal);
  border-radius: 20px;
  padding: 2.2rem 2rem;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-card h2 {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  color: #fff;
}

.modal-card p {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0.6rem 0 1.2rem;
}

.podium-stats {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.stat-pill {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
}

.stat-pill b {
  color: var(--teal);
}

.modal-btn {
  font-family: var(--body);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 1.8rem;
  border-radius: 999px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
  transition: transform 0.2s;
}

.modal-btn:hover {
  transform: translateY(-2px);
}

