:root {
  --bg-color: #0d1117;
  --panel-bg: rgba(22, 27, 34, 0.85);
  --border-glow: rgba(0, 210, 255, 0.4);
  --accent-cyan: #00d2ff;
  --accent-yellow: #ffd166;
  --accent-red: #ef4444;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
}

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

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: radial-gradient(circle at center, #1a1f2c 0%, #0a0d14 100%);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/* Container do Jogo */
.game-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 25px rgba(0, 210, 255, 0.2);
  border-radius: 16px;
  overflow: hidden;
  background: #111;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Canvas da Corrida */
#gameCanvas {
  display: block;
  width: 460px;
  height: 700px;
  max-width: 100vw;
  max-height: 88vh;
  object-fit: contain;
  background-color: #1e3a1e;
}

/* HUD Superior */
.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 10;
}

.hud-card {
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

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

.hud-value {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.hud-card.score .hud-value {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(0, 210, 255, 0.5);
}

.hud-card.highscore .hud-value {
  color: var(--accent-yellow);
}

.hud-card.speed .hud-value {
  color: #4ade80;
}

.hud-actions {
  pointer-events: auto;
}

.btn-icon {
  background: var(--panel-bg);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

/* Modais / Overlays de Tela */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 14, 20, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
  text-align: center;
  z-index: 20;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-title {
  font-size: 2.4rem;
  font-weight: 900;
  margin-bottom: 8px;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, #00d2ff 0%, #3a86ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(0, 210, 255, 0.4);
}

.game-over-title {
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 24px;
  max-width: 320px;
  line-height: 1.4;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 16px 24px;
  width: 80%;
  max-width: 280px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
}

.stat-row .val {
  font-weight: 800;
  font-size: 1.25rem;
}

.stat-row.final-score .val {
  color: var(--accent-cyan);
}

.record-badge {
  background: linear-gradient(90deg, #f59e0b, #eab308);
  color: #111;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 4px;
  display: inline-block;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* Teclas explicativas */
.instructions-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 24px;
  font-size: 0.85rem;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.key-badge {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  padding: 2px 7px;
  font-weight: bold;
  font-family: monospace;
  color: #fff;
}

/* Botão de Ação Primário */
.btn-primary {
  background: linear-gradient(135deg, #00d2ff 0%, #0077ff 100%);
  color: #ffffff;
  border: none;
  padding: 14px 34px;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 162, 255, 0.4);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 162, 255, 0.6);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(1px);
}

.hint-text {
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Controles de Toque (Mobile / Telas Touch) */
.touch-controls {
  position: absolute;
  bottom: 24px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  z-index: 15;
}

.touch-btn {
  pointer-events: auto;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  cursor: pointer;
  transition: background 0.1s ease, transform 0.1s ease;
}

.touch-btn:active, .touch-btn.active {
  background: rgba(0, 210, 255, 0.4);
  border-color: var(--accent-cyan);
  transform: scale(0.92);
}

@media (min-width: 650px) {
  /* Em telas maiores de desktop, oculta os botões touch para ficar limpo, a não ser que o usuário prefira */
  .touch-controls {
    display: none;
  }
}
