:root {
  --bg-color: #11151f;
  --panel-bg: #181d29;
  --panel-border: #262f42;
  --accent-cyan: #7cd9e8;
  --accent-yellow: #f8df8c;
  --accent-pink: #f497a9;
  --accent-green: #90dbaf;
  --accent-purple: #b9aee0;
  --accent-peach: #f7b297;
  --text-primary: #e8ecf4;
  --text-muted: #8e9bb0;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace, Consolas, courier;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: var(--font-body);
}

.app-layout {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-color);
}

/* Header / Scoreboard */
.game-header {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 18px;
  background: rgba(17, 21, 31, 0.96);
  border-bottom: 2px solid var(--panel-border);
  gap: 12px;
  z-index: 10;
}

.branding {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.back-link {
  font-size: 0.75rem;
  color: var(--accent-cyan);
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.2s;
}

.back-link:hover {
  opacity: 0.8;
  text-decoration: underline;
}

.game-header h1 {
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  color: var(--accent-yellow);
  letter-spacing: 1px;
}

.game-header .tag {
  font-size: 0.55rem;
  color: var(--text-muted);
  background: #202737;
  padding: 2px 5px;
  border-radius: 4px;
}

.scoreboard {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #1d2331;
  padding: 6px 12px;
  border-radius: 8px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.score-card.active {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 14px rgba(248, 223, 140, 0.3);
  transform: scale(1.03);
}

.score-card .player-name {
  font-size: 0.8rem;
  font-weight: 600;
}

.score-card .score {
  font-family: var(--font-pixel);
  font-size: 1rem;
  color: var(--accent-cyan);
}

.vs-badge {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--accent-pink);
}

.header-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: #222b3c;
  border: 1px solid #303d54;
  color: var(--text-primary);
  font-size: 1rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.icon-btn:hover {
  background: #2d384d;
  transform: translateY(-2px);
}

.league-btn {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  background: linear-gradient(135deg, rgba(248, 223, 140, 0.15), rgba(247, 178, 151, 0.15));
  border: 1px solid var(--accent-yellow);
  color: var(--accent-yellow);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.league-btn:hover {
  background: linear-gradient(135deg, rgba(248, 223, 140, 0.3), rgba(247, 178, 151, 0.3));
  box-shadow: 0 0 14px rgba(248, 223, 140, 0.35);
  color: #fff;
}

/* Main Workspace: Grid 2 Columnas */
.main-workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 12px;
  padding: 10px 14px 12px;
  overflow: hidden;
}

/* Área de Juego */
.game-area {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--panel-bg);
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.canvas-wrapper {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #262e40;
  position: relative;
  overflow: hidden;
  padding: 6px;
}

.canvas-stage {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #3e4766;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* CRT Scanline Overlay */
.crt-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.22) 50%),
              linear-gradient(90deg, rgba(255, 0, 0, 0.02), rgba(0, 255, 0, 0.01), rgba(0, 0, 255, 0.02));
  background-size: 100% 4px, 6px 100%;
  opacity: 0.6;
  transition: opacity 0.3s;
}

.crt-overlay.disabled {
  opacity: 0;
}

/* Banner Overlay */
.banner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(14, 18, 27, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  transition: opacity 0.3s;
}

.banner-overlay.hidden {
  display: none;
}

.banner-box {
  background: #1c2333;
  border: 3px solid var(--accent-yellow);
  padding: 24px 34px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 0 30px rgba(248, 223, 140, 0.35);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.banner-box h2 {
  font-family: var(--font-pixel);
  font-size: 1.1rem;
  color: var(--accent-yellow);
  margin-bottom: 10px;
}

.banner-box p {
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-bottom: 18px;
}

/* Controls Panel */
.controls-panel {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(18, 23, 33, 0.98);
  border-top: 2px solid var(--panel-border);
  gap: 10px;
  flex-wrap: nowrap;
}

/* Viento */
.wind-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #1f2737;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid #2b364b;
  min-width: 95px;
}

.widget-title {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.wind-display {
  display: flex;
  align-items: center;
  gap: 6px;
}

.wind-arrow {
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--accent-cyan);
  display: inline-block;
  transition: transform 0.3s;
}

.wind-value {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--accent-cyan);
}

/* Formulario de Tiro */
.shot-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}

.turn-indicator {
  font-family: var(--font-pixel);
  font-size: 0.65rem;
  color: var(--accent-yellow);
  background: #232c3f;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.input-group label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group input {
  width: 75px;
  background: #121622;
  border: 1px solid #303d54;
  border-radius: 6px;
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  padding: 5px 8px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-group input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(124, 217, 232, 0.4);
}

.input-group .hint {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: right;
}

/* Botones */
.btn {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  padding: 8px 14px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, filter 0.2s;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(2px);
}

.btn-fire {
  background: linear-gradient(135deg, #f8df8c, #f7b297);
  color: #1a1f2c;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(247, 178, 151, 0.35);
}

.btn-fire:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 16px rgba(247, 178, 151, 0.5);
}

.btn-primary {
  background: var(--accent-cyan);
  color: #11151f;
  font-weight: bold;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 14px rgba(124, 217, 232, 0.4);
}

.btn-secondary {
  background: #232c3f;
  color: var(--text-muted);
  font-size: 0.6rem;
  padding: 4px 8px;
}

.btn-secondary:hover {
  color: var(--text-primary);
  background: #2f3a52;
}

/* Modo de juego */
.mode-widget {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.select-input {
  background: #18202d;
  color: var(--text-primary);
  border: 1px solid #303d54;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  outline: none;
  cursor: pointer;
}

/* ========================================================
   BARRA LATERAL: LABORATORIO DE CINEMÁTICA Y FÍSICA
   ======================================================== */
.physics-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #141824;
  border: 2px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 12px;
  gap: 8px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.physics-lab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  padding-bottom: 6px;
  border-bottom: 1px solid #242f42;
}

.physics-lab-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lab-icon {
  font-size: 1rem;
}

.physics-lab-title h2 {
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 6px;
}

.lab-tag {
  font-family: var(--font-body);
  font-size: 0.58rem;
  background: rgba(124, 217, 232, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(124, 217, 232, 0.3);
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
}

.physics-constants {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.constant-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.65rem;
  background: #1d2433;
  color: var(--text-muted);
  border: 1px solid #2d384d;
  padding: 2px 6px;
  border-radius: 5px;
}

.physics-sidebar-scroll {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: #2b364b transparent;
}

.physics-card {
  background: #19202e;
  border: 1px solid #273347;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.card-caption {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #242f42;
  padding-bottom: 4px;
}

.caption-title {
  font-family: var(--font-pixel);
  font-size: 0.52rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.caption-sub {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--accent-yellow);
}

/* Vector Card & Canvas */
.vector-canvas-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

#vectorCanvas {
  background: #121622;
  border: 1px solid #273347;
  border-radius: 6px;
  cursor: crosshair;
  width: 220px;
  height: 120px;
  display: block;
}

.vector-legend {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  font-family: var(--font-mono, monospace);
  font-size: 0.68rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.legend-item b {
  color: var(--text-primary);
  margin-left: auto;
}

.legend-line {
  display: inline-block;
  width: 12px;
  height: 3px;
  border-radius: 2px;
}

.v0-line { background: var(--accent-yellow); }
.vx-line { background: var(--accent-cyan); }
.vy-line { background: var(--accent-pink); }

/* Formulas Card */
.formulas-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.formula-row {
  background: #121622;
  border: 1px solid #243043;
  border-radius: 6px;
  padding: 5px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.formula-name {
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--accent-purple);
}

.math-eq {
  font-family: var(--font-mono, monospace);
  font-size: 0.66rem;
  color: var(--text-muted);
}

.math-sub {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  color: var(--accent-green);
  font-weight: 600;
}

/* Metrics & Telemetry */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.metric-box {
  background: #121622;
  border: 1px solid #243043;
  border-radius: 6px;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.m-label {
  font-size: 0.6rem;
  color: var(--text-muted);
}

.m-value {
  font-family: var(--font-mono, monospace);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.live-metric {
  color: var(--accent-yellow);
}

#flightStatusBadge {
  background: #232c3f;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.6rem;
  transition: all 0.2s;
}

#flightStatusBadge.in-flight {
  background: rgba(144, 219, 175, 0.2);
  color: var(--accent-green);
  border: 1px solid rgba(144, 219, 175, 0.4);
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

/* Adaptación responsive */
@media (max-width: 1050px) {
  html, body, .app-layout {
    overflow: auto;
    height: auto;
  }
  .main-workspace {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .controls-panel {
    flex-wrap: wrap;
  }
  .canvas-stage {
    max-height: 480px;
  }
}

/* ========================================================
   MODO LIGA & RANKING ARCADE (HALL OF FAME MODAL)
   ======================================================== */
.league-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(10, 14, 22, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.2s ease-out;
}

.league-modal-overlay.hidden {
  display: none !important;
}

.league-modal-box {
  background: #141926;
  border: 2px solid #323f56;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(124, 217, 232, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: popIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.league-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  border-bottom: 1px solid #243043;
  background: #192132;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-badge {
  font-family: var(--font-pixel);
  font-size: 0.52rem;
  background: rgba(248, 223, 140, 0.15);
  color: var(--accent-yellow);
  border: 1px solid rgba(248, 223, 140, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.league-modal-header h2 {
  font-family: var(--font-pixel);
  font-size: 0.78rem;
  color: var(--accent-cyan);
  margin: 0;
  letter-spacing: 0.5px;
}

.close-modal-btn {
  background: #202b3d;
  border: 1px solid #303e57;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.close-modal-btn:hover {
  color: #fff;
  background: #2b3952;
  border-color: var(--accent-pink);
}

/* Sección de Autenticación / Registro */
.league-auth-section {
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-desc {
  font-size: 0.82rem;
  color: #a3b2c9;
  line-height: 1.45;
  margin: 0;
}

.auth-desc strong {
  color: var(--accent-yellow);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #10141f;
  border: 1px solid #243043;
  border-radius: 10px;
  padding: 16px;
}

.auth-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-input-group label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.auth-input-group input {
  background: #171e2c;
  border: 1px solid #2d3b52;
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-mono, monospace);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input-group input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(124, 217, 232, 0.25);
}

.nick-arcade-input {
  letter-spacing: 6px;
  font-weight: 800 !important;
  font-size: 1.3rem !important;
  text-align: center;
  text-transform: uppercase;
  color: var(--accent-yellow) !important;
}

.nick-hint {
  font-size: 0.64rem;
  color: var(--text-muted);
  font-style: italic;
}

.auth-error {
  color: var(--accent-pink);
  font-size: 0.72rem;
  min-height: 16px;
  margin: 0;
  font-weight: 600;
}

.btn-join {
  width: 100%;
  padding: 11px;
  font-size: 0.75rem;
}

/* Sección de Ranking / Hall of Fame */
.league-ranking-section {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ranking-user-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #10141f;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #243043;
}

.player-active-tag {
  font-family: var(--font-mono, monospace);
  font-size: 0.82rem;
  color: var(--accent-green);
  font-weight: 700;
}

.btn-switch {
  font-size: 0.65rem;
  padding: 4px 8px;
}

.table-wrap {
  max-height: 270px;
  overflow-y: auto;
  border: 1px solid #243043;
  border-radius: 8px;
  background: #0f131d;
  scrollbar-width: thin;
  scrollbar-color: #2b364b transparent;
}

.arcade-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  text-align: left;
}

.arcade-table th {
  background: #171f2d;
  color: var(--text-muted);
  font-family: var(--font-pixel);
  font-size: 0.54rem;
  padding: 8px 10px;
  border-bottom: 1px solid #273448;
  letter-spacing: 0.5px;
}

.arcade-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #1a2231;
  color: var(--text-primary);
}

.arcade-table tr:hover {
  background: rgba(124, 217, 232, 0.06);
}

.arcade-table tr.my-row {
  background: rgba(248, 223, 140, 0.12);
  border-left: 3px solid var(--accent-yellow);
}

.arcade-table tr.my-row td {
  font-weight: bold;
}

.rank-col {
  width: 55px;
  color: var(--text-muted);
}

.nick-col {
  width: 80px;
}

.nick-tag {
  display: inline-block;
  background: #1e2738;
  color: var(--accent-yellow);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: 1px;
}

.points-col {
  color: var(--accent-cyan);
}

.points-col b {
  font-size: 0.88rem;
}

.wins-col {
  text-align: center;
  width: 70px;
  color: var(--accent-pink);
  font-weight: 700;
}

.league-rules-tip {
  background: #10141f;
  border: 1px solid #243043;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.35;
}

.league-rules-tip b {
  color: var(--accent-yellow);
}
