/* Wreckfest Demolition Derby 3D - Estilos de consola y simulación */
:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --wreck-bg: #090d14;
  --wreck-surface: #111722;
  --wreck-surface-elevated: #182232;
  --wreck-border: #233044;
  --wreck-border-strong: #334460;

  --wreck-fire: #ff5722;
  --wreck-fire-glow: rgba(255, 87, 34, 0.4);
  --wreck-nitro: #00e5ff;
  --wreck-nitro-glow: rgba(0, 229, 255, 0.4);
  --wreck-danger: #ef4444;
  --wreck-warning: #f59e0b;
  --wreck-success: #10b981;
  --wreck-text: #f1f5f9;
  --wreck-text-dim: #94a3b8;
}

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--wreck-bg);
  color: var(--wreck-text);
  font-family: var(--font-main);
  margin: 0;
}

.tool-layout {
  max-width: 1240px;
  margin: 1.25rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Contenedor del juego y visor 3D */
.game-viewport-card {
  position: relative;
  width: 100%;
  background: #030508;
  border: 1px solid var(--wreck-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  margin-bottom: 1.25rem;
  user-select: none;
}

.game-viewport-card:fullscreen {
  border-radius: 0;
  border: none;
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
}

#game-canvas-container {
  width: 100%;
  height: 560px;
  max-height: 72vh;
  min-height: 380px;
  display: block;
  cursor: grab;
  outline: none;
}

.game-viewport-card:fullscreen #game-canvas-container {
  height: 100vh;
  max-height: 100vh;
}

#game-canvas-container:active {
  cursor: grabbing;
}

#game-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* HUD de consola idéntico a Wreckfest */
.wf-hud-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 10;
}

/* Superior izquierda: Score y Leaderboard */
.wf-hud-top-left {
  position: absolute;
  top: 16px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wf-score-banner {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 2px rgba(0, 0, 0, 0.9);
}

.wf-score-banner span {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: #f8fafc;
}

.wf-leaderboard-card {
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  width: 210px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.wf-lead-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #e2e8f0;
  border-radius: 4px;
  margin-bottom: 2px;
}

.wf-lead-row.is-player {
  background: rgba(30, 64, 175, 0.85);
  color: #67e8f9;
  border-left: 3px solid #38bdf8;
}

.wf-col-pos {
  width: 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  opacity: 0.8;
}

.wf-col-name {
  flex: 1;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  padding: 0 6px;
}

.wf-col-gap {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: #94a3b8;
}

/* Centro izquierda: Minimapa ribbon del circuito */
.wf-hud-mid-left {
  position: absolute;
  top: 155px;
  left: 18px;
}

#wf-ribbon-canvas {
  width: 110px;
  height: 125px;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.7));
}

/* Inferior izquierda: Esquema de daños en alambre naranja y velocímetro de segmentos */
.wf-hud-bottom-left {
  position: absolute;
  bottom: 22px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.wf-damage-wireframe {
  position: relative;
  width: 44px;
  height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 3px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.8));
}

.wf-wire-part {
  border: 2.5px solid #f97316; /* Naranja neon Wreckfest */
  border-radius: 3px;
  transition: all 0.2s ease;
}

.wf-wire-front {
  width: 32px;
  height: 12px;
  border-bottom: none;
  border-radius: 8px 8px 1px 1px;
}

.wf-wire-middle {
  display: flex;
  width: 38px;
  justify-content: space-between;
  align-items: center;
}

.wf-wire-left,
.wf-wire-right {
  width: 6px;
  height: 34px;
}

.wf-wire-engine {
  color: #f97316;
  opacity: 0.9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wf-wire-rear {
  width: 34px;
  height: 12px;
  border-top: none;
  border-radius: 1px 1px 8px 8px;
}

/* Velocímetro con barra de segmentos */
.wf-speedometer-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wf-speed-header {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.wf-speed-digit {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 900;
  color: #ffffff;
  line-height: 1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}

.wf-gear-label {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 800;
  color: #fbbf24;
}

.wf-speed-segments {
  display: flex;
  gap: 3px;
}

.wf-seg {
  width: 10px;
  height: 6px;
  background: rgba(255, 255, 255, 0.22);
  transform: skewX(-20deg);
  border-radius: 1px;
  transition: background-color 0.08s ease;
}

.wf-seg.is-lit {
  background: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.7);
}

/* HUD Superior (Consola deportiva) */
.hud-top-bar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  z-index: 10;
}

.hud-group-left,
.hud-group-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.hud-panel {
  background: rgba(9, 13, 20, 0.82);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hud-health-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.hud-health-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hud-health-bar-bg {
  width: 100%;
  height: 9px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.hud-health-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #10b981 100%);
  transition: width 0.15s ease-out;
}

/* Esquema de silueta de chapa y daños */
.hud-car-schematic {
  position: relative;
  width: 32px;
  height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 2px;
  box-sizing: border-box;
}

.schematic-part {
  background: #10b981;
  border-radius: 2px;
  transition: background-color 0.2s ease;
}

.schematic-front {
  width: 22px;
  height: 8px;
  border-radius: 4px 4px 1px 1px;
}

.schematic-middle {
  display: flex;
  width: 26px;
  justify-content: space-between;
}

.schematic-left,
.schematic-right {
  width: 6px;
  height: 22px;
}

.schematic-center {
  width: 10px;
  height: 22px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 1px;
}

.schematic-rear {
  width: 24px;
  height: 8px;
  border-radius: 1px 1px 4px 4px;
}

/* Indicadores digitales centrales */
.hud-speedo-panel {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-mono);
}

.hud-speed-num {
  font-size: 1.85rem;
  font-weight: 800;
  color: #ffffff;
  line-height: 1;
}

.hud-speed-unit {
  font-size: 0.75rem;
  color: var(--wreck-text-dim);
  font-weight: 600;
}

.hud-gear-badge {
  background: var(--wreck-fire);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  margin-left: 4px;
  letter-spacing: 0.05em;
}

/* Barra de Nitro */
.hud-nitro-box {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 110px;
}

.hud-nitro-label {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--wreck-nitro);
  letter-spacing: 0.08em;
}

.hud-nitro-bar-bg {
  width: 100%;
  height: 7px;
  background: rgba(0, 229, 255, 0.15);
  border-radius: 3px;
  overflow: hidden;
}

.hud-nitro-bar-fill {
  height: 100%;
  width: 100%;
  background: var(--wreck-nitro);
  box-shadow: 0 0 8px var(--wreck-nitro);
  transition: width 0.08s linear;
}

/* Minimapa / Radar de combate */
.hud-radar-box {
  position: absolute;
  bottom: 14px;
  left: 14px;
  width: 120px;
  height: 120px;
  background: rgba(9, 13, 20, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  z-index: 10;
  pointer-events: none;
}

#hud-radar-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Banner de eventos y combos destructivos */
.hud-combo-banner {
  position: absolute;
  top: 90px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.hud-combo-banner.is-active {
  opacity: 1;
  transform: translateX(-50%) scale(1.08);
}

.hud-combo-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8), 0 0 14px var(--wreck-fire);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hud-combo-pts {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
  color: #fbbf24;
}

/* Indicador de objetivo y estado del derby */
.hud-derby-status {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(9, 13, 20, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 87, 34, 0.4);
  border-radius: 20px;
  padding: 5px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  pointer-events: none;
}

.status-badge-rivals {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
}

.status-badge-rivals strong {
  color: var(--wreck-fire);
}

/* Botonera de control táctil (móvil y tablet) */
.touch-controls-deck {
  position: absolute;
  bottom: 12px;
  left: 12px;
  right: 12px;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 15;
}

@media (pointer: coarse), (max-width: 900px) {
  .touch-controls-deck {
    display: flex;
  }
}

.touch-cluster {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touch-btn {
  width: 58px;
  height: 58px;
  min-height: 48px;
  background: rgba(17, 23, 34, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  color: #ffffff;
  font-size: 1.25rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  user-select: none;
  transition: transform 0.08s ease, background-color 0.08s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.touch-btn:active,
.touch-btn.is-pressed {
  transform: scale(0.92);
  background: var(--wreck-fire);
  border-color: #ff8a65;
}

.touch-btn-gas {
  background: rgba(16, 185, 129, 0.35);
  border-color: rgba(16, 185, 129, 0.6);
  font-size: 0.85rem;
}

.touch-btn-brake {
  background: rgba(239, 68, 68, 0.35);
  border-color: rgba(239, 68, 68, 0.6);
  font-size: 0.85rem;
}

.touch-btn-handbrake {
  background: rgba(245, 158, 11, 0.35);
  border-color: rgba(245, 158, 11, 0.6);
  font-size: 0.8rem;
}

.touch-btn-nitro {
  background: rgba(0, 229, 255, 0.35);
  border-color: rgba(0, 229, 255, 0.6);
  color: #fff;
  font-size: 0.8rem;
}

/* Barra de control inferior del simulador */
.game-controls-deck {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  background: var(--wreck-surface);
  border: 1px solid var(--wreck-border);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 2rem;
}

.deck-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.deck-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--wreck-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

/* Botones arcade */
.btn-wreck {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-heading);
  font-size: 0.88rem;
  font-weight: 700;
  padding: 8px 15px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 40px;
  box-sizing: border-box;
}

.btn-wreck-primary {
  background: linear-gradient(135deg, #ff5722 0%, #d84315 100%);
  color: #ffffff;
  border-color: #ff7043;
  box-shadow: 0 4px 14px rgba(255, 87, 34, 0.35);
}

.btn-wreck-primary:hover {
  background: linear-gradient(135deg, #ff7043 0%, #e64a19 100%);
  transform: translateY(-1px);
}

.btn-wreck-secondary {
  background: var(--wreck-surface-elevated);
  color: #ffffff;
  border-color: var(--wreck-border-strong);
}

.btn-wreck-secondary:hover {
  background: #233044;
  border-color: #475d82;
}

.btn-wreck-outline {
  background: transparent;
  color: var(--wreck-text);
  border-color: var(--wreck-border);
}

.btn-wreck-outline:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--wreck-text-dim);
}

.btn-wreck.is-active {
  background: rgba(255, 87, 34, 0.18);
  border-color: var(--wreck-fire);
  color: #ffab91;
}

.btn-wreck-sm {
  font-size: 0.8rem;
  padding: 6px 11px;
  min-height: 34px;
}

/* Modales arcade de fin de combate y pausa */
.game-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(4, 7, 12, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.game-modal-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.game-modal-card {
  background: var(--wreck-surface);
  border: 1px solid var(--wreck-border-strong);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  padding: 2rem;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.7);
  text-align: center;
  transform: scale(0.94);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-modal-overlay.is-open .game-modal-card {
  transform: scale(1);
}

.game-modal-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.game-modal-title {
  font-family: var(--font-heading);
  font-size: 1.85rem;
  font-weight: 800;
  margin: 0 0 0.5rem;
  color: #ffffff;
}

.game-modal-subtitle {
  color: var(--wreck-text-dim);
  font-size: 0.92rem;
  margin: 0 0 1.5rem;
  line-height: 1.5;
}

.game-modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 1.75rem;
}

.modal-stat-box {
  background: rgba(9, 13, 20, 0.6);
  border: 1px solid var(--wreck-border);
  border-radius: 10px;
  padding: 10px 8px;
}

.modal-stat-label {
  font-size: 0.72rem;
  color: var(--wreck-text-dim);
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 4px;
}

.modal-stat-val {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.game-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Selector de coche */
.car-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 1.25rem 0 1.5rem;
}

.car-card-option {
  background: var(--wreck-surface-elevated);
  border: 2px solid var(--wreck-border);
  border-radius: 10px;
  padding: 10px 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.car-card-option:hover {
  border-color: var(--wreck-border-strong);
  background: #1c2738;
}

.car-card-option.is-selected {
  border-color: var(--wreck-fire);
  background: rgba(255, 87, 34, 0.12);
}

.car-card-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}

.car-card-name {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
}

.car-card-trait {
  font-size: 0.72rem;
  color: var(--wreck-text-dim);
}

/* Modificaciones responsive */
@media (max-width: 768px) {
  #game-canvas-container {
    height: 420px;
  }

  .hud-top-bar {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .hud-panel {
    padding: 6px 10px;
    gap: 8px;
  }

  .hud-speed-num {
    font-size: 1.4rem;
  }

  .hud-radar-box {
    width: 90px;
    height: 90px;
    bottom: 80px;
    left: 8px;
  }

  .game-controls-deck {
    flex-direction: column;
    align-items: stretch;
  }

  .deck-group {
    justify-content: center;
  }

  .car-selector-grid {
    grid-template-columns: 1fr;
  }
}
