:root {
  --bg-deep: #030712;
  --panel-bg: rgba(15, 23, 42, 0.95);
  --panel-border: #38bdf8;
  --north-red: #ef4444;
  --south-blue: #0284c7;
  --accent-neon: #38bdf8;
  --gold-accent: #f59e0b;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #000;
  font-family: 'Courier New', Courier, monospace;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

#game-app {
  width: 100vw;
  max-width: 440px;
  height: 100%;
  height: 100dvh;
  background: var(--bg-deep);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.95);
  border: 1px solid #1e293b;
}

.view-panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 12px;
  z-index: 10;
  overflow: hidden;
}

.view-panel.active {
  display: flex;
}

.side-band {
  position: absolute;
  bottom: 0;
  width: 12px;
  height: 65%;
  z-index: 1;
}
.band-blue { left: 0; background: var(--south-blue); box-shadow: 0 0 20px var(--south-blue); }
.band-red { right: 0; background: var(--north-red); box-shadow: 0 0 20px var(--north-red); }

.auth-modal {
  margin: auto;
  background: var(--panel-bg);
  border-radius: 20px;
  padding: 20px;
  width: 92%;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8);
  border: 2px solid #334155;
  z-index: 2;
}

.game-logo {
  font-size: 24px;
  color: #fff;
  letter-spacing: 4px;
  font-weight: 900;
  text-shadow: 0 0 12px var(--accent-neon);
}

.tagline {
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 2px;
  margin-bottom: 12px;
}

#auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#auth-form label {
  font-size: 10px;
  font-weight: bold;
  color: #94a3b8;
}

#auth-form input[type="text"],
#auth-form input[type="password"] {
  background: #090d16;
  color: #fff;
  border: 1px solid #334155;
  padding: 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
}

.auth-remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.auth-remember-row input[type="checkbox"] {
  accent-color: var(--accent-neon);
  width: 14px;
  height: 14px;
}

.auth-remember-row label {
  font-size: 10px !important;
  color: #cbd5e1 !important;
  cursor: pointer;
}

.auth-btn-group {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.planets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 8px;
}

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

.user-name {
  font-size: 12px;
  font-weight: bold;
  color: var(--accent-neon);
}

.user-conquered {
  font-size: 10px;
  color: #facc15;
}

.btn-mini-danger {
  background: #7f1d1d;
  color: #fff;
  border: 1px solid #ef4444;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: bold;
  cursor: pointer;
}

.dialog-card {
  background: rgba(15, 23, 42, 0.85);
  border-left: 4px solid var(--accent-neon);
  border-radius: 8px;
  padding: 10px 12px;
  color: #cbd5e1;
  font-size: 11px;
  line-height: 1.4;
  margin-bottom: 8px;
}

.planet-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.planet-card {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.planet-card:hover, .planet-card:active {
  border-color: var(--accent-neon);
  background: rgba(30, 41, 59, 0.9);
}

.planet-card.completed {
  filter: grayscale(100%) opacity(40%);
}

.planet-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset -6px -6px 10px rgba(0,0,0,0.8), 0 0 8px rgba(255,255,255,0.1);
}

.planet-info-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.planet-info-block strong {
  font-size: 12px;
  color: #fff;
}

.planet-tag {
  font-size: 9px;
  color: var(--accent-neon);
}

#screen-briefing {
  background: radial-gradient(circle at top, #0f172a 0%, #030712 100%);
  justify-content: space-between;
  padding: 14px;
}

.briefing-hud {
  background: var(--panel-bg);
  border: 1px solid #334155;
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 72vh;
}

.briefing-header {
  border-bottom: 1px dashed #475569;
  padding-bottom: 6px;
}

.briefing-header h2 {
  font-size: 18px;
  color: #fff;
  letter-spacing: 2px;
  text-shadow: 0 0 10px var(--accent-neon);
}

.planet-data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.data-cell {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid #1e293b;
  border-radius: 6px;
  padding: 6px;
}

.data-label {
  font-size: 8px;
  color: #64748b;
  display: block;
  text-transform: uppercase;
}

.data-value {
  font-size: 10px;
  font-weight: bold;
  color: #e2e8f0;
}

.ship-tactical-card {
  background: rgba(2, 132, 199, 0.1);
  border: 1px solid var(--south-blue);
  border-radius: 8px;
  padding: 8px 10px;
}

.ship-tactical-card h4 {
  font-size: 11px;
  color: var(--accent-neon);
  margin-bottom: 2px;
}

.briefing-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  align-items: center;
}

.btn-retro {
  background: #0f172a;
  color: #fff;
  width: 100%;
  max-width: 320px;
  padding: 12px 16px;
  border: 1px solid #475569;
  border-radius: 10px;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-retro:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  border-color: #38bdf8;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.btn-secondary {
  background: #1e293b;
  border-color: #334155;
  color: #94a3b8;
}

#screen-gameplay {
  padding: 0;
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

.hud-bar {
  position: absolute;
  top: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  text-shadow: 0 0 8px #000;
  z-index: 20;
}

.mag-gauge-container {
  position: absolute;
  right: 8px;
  top: 60px;
  bottom: 120px;
  width: 14px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid #475569;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2px;
  z-index: 20;
}

.mag-gauge-fill {
  width: 100%;
  height: 20%;
  background: #22c55e;
  border-radius: 4px;
  transition: height 0.05s ease;
}

.mag-label {
  position: absolute;
  bottom: -16px;
  left: -1px;
  font-size: 8px;
  color: #94a3b8;
  font-weight: bold;
}

/* DOCK INFERIOR FIXADO (Resolve a quebra visual da imagem 2) */
.gameplay-bottom-dock {
  position: absolute;
  bottom: 8px;
  left: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
}

.touch-action-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  pointer-events: auto;
}

.t-btn {
  height: 48px;
  border-radius: 10px;
  color: #fff;
  font-weight: 900;
  border: 1.5px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  cursor: pointer;
}

.t-btn:active {
  transform: scale(0.95);
}

.t-btn-polarity {
  width: 90px;
  font-size: 11px;
  background: var(--south-blue);
  border-color: #38bdf8;
}

.t-btn-action {
  width: 90px;
  font-size: 11px;
  background: #059669;
  border-color: #34d399;
}

.mission-timer-container {
  width: 100%;
  height: 18px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid #475569;
  border-radius: 6px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.mission-timer-bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  transition: width 1s linear;
  z-index: 1;
}

.mission-timer-text {
  position: relative;
  z-index: 2;
  font-size: 9px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 0 4px #000;
  letter-spacing: 1px;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 18, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

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

.modal-body {
  background: rgba(15, 23, 42, 0.98);
  border-radius: 16px;
  padding: 18px;
  width: 100%;
  max-width: 360px;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  border: 2px solid #334155;
}

.tips-box {
  border-color: var(--accent-neon);
  text-align: left;
}

.tips-list {
  font-size: 11px;
  line-height: 1.5;
  color: #cbd5e1;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gameover-box {
  border: 2px solid var(--north-red);
  box-shadow: 0 0 30px rgba(239, 68, 68, 0.35);
}

.gameover-title {
  color: var(--north-red);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
}

.victory-box {
  border: 2px solid #22c55e;
  box-shadow: 0 0 30px rgba(34, 197, 94, 0.35);
}

.victory-title {
  color: #22c55e;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 2px;
}

.modal-telemetry {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #334155;
  border-radius: 8px;
  width: 100%;
  padding: 10px;
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.5;
}

/* LINHA DE CONTROLES INFERIORES: VIDAS À ESQUERDA, BOTÕES À DIREITA */
.dock-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  pointer-events: auto;
}

/* CONTAINER DAS VIDAS (CANTO INFERIOR ESQUERDO) */
.lives-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 6px 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.life-magnet-slot {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.4));
}

.life-magnet-icon {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Vida perdida: fica cinza, opaca e menor */
.life-magnet-slot.lost {
  opacity: 0.18;
  filter: grayscale(100%);
  transform: scale(0.8);
}

@media (orientation: landscape) and (max-height: 600px), (max-height: 480px) {
  .lives-container {
    padding: 3px 6px;
    gap: 4px;
  }
  .life-magnet-slot {
    width: 18px;
    height: 18px;
  }
}

/* Modo responsivo */
@media (orientation: landscape) and (max-height: 600px), (max-height: 480px) {
  /* Libera o Canvas para preencher toda a largura da tela em modo paisagem */
  #game-app {
    max-width: 100vw;
    width: 100vw;
    border: none;
    border-radius: 0;
  }

  .side-band {
    width: 8px;
  }

  /* TELA DE AUTENTICAÇÃO: Layout horizontal em duas colunas */
  .auth-modal {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    max-width: 580px;
    width: 95%;
    gap: 20px;
    padding: 12px 18px;
  }

  .avatar-hero-container {
    width: 85px !important;
    height: 95px !important;
    margin-bottom: 0 !important;
  }

  .game-logo {
    font-size: 18px;
    letter-spacing: 2px;
  }

  .tagline {
    font-size: 8px;
    margin-bottom: 0;
  }

  #auth-form {
    flex: 1;
    gap: 4px;
  }

  #auth-form input[type="text"],
  #auth-form input[type="password"] {
    padding: 6px 10px;
    font-size: 11px;
  }

  #auth-form label {
    font-size: 9px;
  }

  .auth-btn-group {
    margin-top: 4px;
  }

  .auth-btn-group .btn-retro {
    padding: 8px;
    font-size: 10px;
  }

  /* SELEÇÃO DE PLANETAS: Grade com múltiplas colunas */
  #screen-planets {
    padding: 8px 16px;
  }

  .planets-header {
    padding: 4px 10px;
    margin-bottom: 6px;
  }

  .dialog-card {
    padding: 6px 10px;
    font-size: 10px;
    margin-bottom: 6px;
  }

  .planet-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 6px;
  }

  .planet-card {
    padding: 6px 8px;
  }

  .planet-icon {
    width: 32px;
    height: 32px;
  }

  /* BRIEFING TÁTICO */
  #screen-briefing {
    padding: 8px 16px;
  }

  .briefing-hud {
    max-height: 68vh;
    padding: 8px 12px;
    gap: 6px;
  }

  .briefing-header h2 {
    font-size: 15px;
  }

  .planet-data-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }

  .briefing-actions {
    flex-direction: row;
    justify-content: center;
    gap: 12px;
  }

  .briefing-actions .btn-retro {
    max-width: 200px;
    padding: 8px 12px;
    font-size: 11px;
  }

  /* GAMEPLAY: HUD E CONTROLES COMPACTADOS */
  .hud-bar {
    top: 6px;
    left: 12px;
    right: 12px;
    font-size: 10px;
  }

  .mag-gauge-container {
    top: 32px;
    bottom: 50px;
    right: 8px;
    width: 10px;
  }

  .gameplay-bottom-dock {
    bottom: 6px;
    left: 12px;
    right: 12px;
    gap: 4px;
  }

  .touch-action-row {
    gap: 8px;
  }

  .t-btn {
    height: 38px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  }

  .t-btn-polarity,
  .t-btn-action {
    width: 76px;
    font-size: 10px;
  }

  .mission-timer-container {
    height: 14px;
  }

  .mission-timer-text {
    font-size: 8px;
  }

  /* MODAIS TÁTICOS EM LANDSCAPE */
  .modal-body {
    max-width: 500px;
    max-height: 94vh;
    padding: 10px 14px;
    gap: 6px;
  }

  .tips-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    font-size: 10px;
    padding-left: 12px;
  }

  .gameover-title, .victory-title {
    font-size: 16px;
  }

  .modal-telemetry {
    font-size: 9px;
    padding: 6px;
  }
}