/* Layout de Videojuego Arcade Fijo: Cero Saltos de Pantalla, Estética Cartoon Arcade */
:root {
  --bg-game: #0F172A;
  --arcade-surface: #1E293B;
  --arcade-card: #FFFFFF;
  --border-comic: #000000;
  --primary-blue: #0284C7;
  --accent-yellow: #FACC15;
  --danger-red: #EF4444;
  --success-green: #22C55E;
  --text-dark: #0F172A;
  --text-muted: #64748B;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --shadow-comic: 4px 4px 0px #000000;
  --shadow-comic-lg: 6px 6px 0px #000000;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background-color: var(--bg-game);
  background-image: radial-gradient(#1E293B 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  color: #F8FAFC;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

/* Contenedor Principal de Pantalla de Juego */
.arcade-container {
  width: 96vw;
  max-width: 1320px;
  height: 94vh;
  max-height: 860px;
  background: #334155;
  border: 4px solid var(--border-comic);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6), var(--shadow-comic-lg);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  gap: 0.8rem;
  overflow: hidden;
}

/* Cabecera Superior Arcade */
.arcade-header {
  background: #0F172A;
  border: 3px solid var(--border-comic);
  border-radius: 14px;
  padding: 0.6rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-comic);
  flex-shrink: 0;
}

.header-left-col {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.header-title {
  font-size: 1.25rem;
  font-weight: 900;
  color: #38BDF8;
  letter-spacing: -0.3px;
  text-transform: uppercase;
  line-height: 1.1;
  white-space: nowrap;
}

.header-subrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #94A3B8;
  letter-spacing: 0.2px;
}

.topic-text {
  color: #38BDF8;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.sub-sep {
  color: #475569;
  font-weight: 900;
}

.header-signature {
  color: #CBD5E1;
}

.brand-handle {
  color: #FACC15;
  font-weight: 800;
}

.question-pill {
  background: #0284C7;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.84rem;
  padding: 0.25rem 0.8rem;
  border-radius: 12px;
  border: 2px solid var(--border-comic);
  box-shadow: 2px 2px 0px #000;
  white-space: nowrap;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

/* Medidor de 10 Fallos estilo Luces de Feria */
.fail-tracker {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #1E293B;
  border: 2px solid var(--border-comic);
  padding: 0.35rem 0.8rem;
  border-radius: 12px;
  flex-shrink: 0;
}

.fail-tracker-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: #FB7185;
  text-transform: uppercase;
}

.fail-bulbs {
  display: flex;
  gap: 5px;
}

.bulb {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #475569;
  border: 1.5px solid var(--border-comic);
  transition: all 0.2s ease;
}

.bulb.lit {
  background: #EF4444;
  box-shadow: 0 0 8px #EF4444;
  transform: scale(1.15);
}

.fail-tracker-count {
  font-size: 0.85rem;
  font-weight: 800;
  color: #F43F5E;
}

/* Botones de Control de Sonido y Música */
.audio-toggles {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.audio-btn {
  background: #0F172A;
  color: #F8FAFC;
  border: 2px solid var(--border-comic);
  border-radius: 10px;
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0px #000;
  transition: all 0.1s ease;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.audio-btn:hover {
  background: #1E293B;
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0px #000;
}

.audio-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 0px 0px 0px #000;
}

.audio-btn.muted {
  opacity: 0.6;
  background: #475569;
}

/* Layout Central de Dos Columnas (100% Altura Fija) */
.arcade-body {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

/* Columna Izquierda: Consola de Preguntas */
.console-column {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  height: 100%;
  min-height: 0;
}

/* Tarjeta de Pregunta (Fija) */
.question-panel {
  background: var(--arcade-card);
  border: 3px solid var(--border-comic);
  border-radius: 16px;
  padding: 1.2rem 1.4rem;
  box-shadow: var(--shadow-comic);
  color: var(--text-dark);
  flex: 0 0 auto;
  min-height: 135px;
  display: flex;
  align-items: center;
}

.question-text {
  font-size: 1.25rem;
  line-height: 1.55;
  font-weight: 700;
  color: #0F172A;
}

/* Botones de Respuesta Grandes */
.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  flex: 0 0 auto;
}

.arcade-btn {
  border: 3px solid var(--border-comic);
  border-radius: 14px;
  padding: 0.95rem 0.8rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  box-shadow: var(--shadow-comic);
  transition: all 0.1s ease;
}

.arcade-btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0px #000;
}

.arcade-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px #000;
}

.arcade-btn:disabled {
  cursor: default;
  opacity: 0.85;
}

.btn-choice-true {
  background: #DCFCE7;
  color: #15803D;
}

.btn-choice-true:hover:not(:disabled) {
  background: #BBF7D0;
}

.btn-choice-false {
  background: #FFE4E6;
  color: #BE123C;
}

.btn-choice-false:hover:not(:disabled) {
  background: #FECDD3;
}

.btn-main-label {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.3px;
}

.btn-sub-label {
  font-size: 0.82rem;
  font-weight: 800;
  opacity: 0.85;
}

.btn-selected-correct {
  background: #22C55E !important;
  color: #000000 !important;
}

.btn-selected-wrong {
  background: #EF4444 !important;
  color: #FFFFFF !important;
}

/* Panel de Diálogo y Explicación Resaltada (Fijo sin saltos) */
.dialog-panel {
  background: #0F172A;
  border: 3px solid var(--border-comic);
  border-radius: 16px;
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-comic);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.6rem;
}

.dialog-idle-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: #94A3B8;
  gap: 0.4rem;
}

.dialog-content {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
  min-height: 0;
}

.verdict-banner {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.35;
}

.verdict-banner.correct {
  color: #4ADE80;
}

.verdict-banner.wrong {
  color: #F87171;
}

/* Caja de Explicación Ampliada y Resaltada */
.explanation-box {
  background: #FFFFFF;
  color: #0F172A;
  border: 3px solid var(--border-comic);
  padding: 1rem 1.2rem;
  border-radius: 12px;
  font-size: 1.15rem;
  line-height: 1.6;
  font-weight: 500;
  box-shadow: var(--shadow-comic);
  overflow-y: auto;
  flex: 1;
}

.explanation-box strong {
  color: #0369A1;
  font-weight: 800;
}

.btn-continue {
  background: #22C55E;
  color: #000000;
  border: 3px solid var(--border-comic);
  border-radius: 12px;
  padding: 0.8rem 1.2rem;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-comic);
  transition: all 0.1s ease;
  width: 100%;
  flex-shrink: 0;
}

.btn-continue:hover {
  background: #4ADE80;
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0px #000;
}

.btn-continue:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0px #000;
}

/* Columna Derecha: Escenario Arcade del Tanque */
.stage-column {
  background: #0F172A;
  border: 3px solid var(--border-comic);
  border-radius: 16px;
  padding: 0.6rem;
  box-shadow: var(--shadow-comic);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
  min-height: 0;
}

.canvas-frame {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  max-height: 100%;
  border: 3px solid var(--border-comic);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: #9BDAFF;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
}

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

.hidden {
  display: none !important;
}

/* --- RESPONSIVIDAD Y OPTIMIZACIÓN MÓVIL (TABLETS Y SMARTPHONES) --- */

@media (max-width: 980px) {
  html, body {
    overflow-y: auto;
    height: auto;
    min-height: 100%;
  }

  .arcade-container {
    width: 98vw;
    max-width: 100%;
    height: auto;
    min-height: 100vh;
    max-height: none;
    border-radius: 14px;
    padding: 0.6rem;
    gap: 0.6rem;
    box-shadow: none;
    border-width: 3px;
  }

  /* Cabecera Móvil: Línea 1 (Título + Pill), Línea 2 (Subtítulo y Firma completa), Línea 3 (Tracker + Audio) */
  .arcade-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.7rem 0.8rem;
  }

  .header-left-col {
    width: 100%;
    gap: 0.35rem;
  }

  .header-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.5rem;
  }

  .header-title {
    font-size: 1.08rem;
    white-space: nowrap;
  }

  .header-subrow {
    font-size: 0.75rem;
    width: 100%;
    white-space: normal; /* NUNCA SE TRUNCA NI SE CORTA */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.4rem;
  }

  .question-pill {
    font-size: 0.78rem;
    padding: 0.22rem 0.55rem;
    flex-shrink: 0;
  }

  .header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 0.4rem;
  }

  .fail-tracker {
    padding: 0.3rem 0.6rem;
    gap: 0.4rem;
  }

  .bulb {
    width: 10px;
    height: 10px;
  }

  .fail-tracker-label {
    font-size: 0.72rem;
  }

  .fail-tracker-count {
    font-size: 0.80rem;
  }

  .audio-btn {
    padding: 0.3rem 0.55rem;
    font-size: 0.75rem;
  }

  /* EN MÓVIL: Ocultar los textos de 'Pulsa "V"' / 'Pulsa "F"' y atajos de teclado */
  .btn-sub-label {
    display: none !important;
  }

  .btn-continue-shortcut {
    display: none !important;
  }

  .arcade-btn {
    padding: 0.95rem 0.6rem;
  }

  .btn-main-label {
    font-size: 1.25rem;
  }

  /* Cuerpo Central en una columna */
  .arcade-body {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    gap: 0.8rem;
  }

  .console-column {
    height: auto;
    gap: 0.6rem;
  }

  .question-panel {
    min-height: 100px;
    padding: 1rem 1.1rem;
  }

  .question-text {
    font-size: 1.12rem;
  }

  .dialog-panel {
    min-height: 160px;
    padding: 0.9rem;
  }

  .explanation-box {
    font-size: 1.05rem;
    max-height: 220px;
  }

  .stage-column {
    height: auto;
    min-height: 360px;
  }

  .canvas-frame {
    max-width: 480px;
    max-height: 480px;
    margin: 0 auto;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 0.96rem;
  }

  .header-subrow {
    font-size: 0.70rem;
  }

  .question-pill {
    font-size: 0.72rem;
    padding: 0.2rem 0.45rem;
  }

  .fail-tracker-label {
    display: none; /* Ahorra espacio en pantallas muy estrechas */
  }

  .bulb {
    width: 9px;
    height: 9px;
  }

  .audio-btn {
    padding: 0.25rem 0.45rem;
    font-size: 0.70rem;
  }
}
