/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #0a0a12;
  color: #fff;
  font-family: 'Courier New', 'Consolas', monospace;
  overflow: hidden;
  user-select: none;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
}
.screen.active { display: flex; }

/* ── Menu ──────────────────────────────────────────────────── */
.menu-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
#menu-bg-canvas {
  width: 100%; height: 100%;
  opacity: 0.35;
}

.menu-center {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.game-title {
  font-size: 80px;
  font-weight: 900;
  line-height: 0.9;
  text-align: center;
  letter-spacing: 6px;
  text-transform: uppercase;
  color: #fff;
  text-shadow:
    0 0 20px #FF6600,
    0 0 60px #FF6600aa,
    0 0 120px #FF440055;
}
.game-title span {
  color: #FF6600;
  text-shadow:
    0 0 20px #fff,
    0 0 40px #FF6600;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 280px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  padding: 14px 28px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:hover  { transform: scale(1.04); }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: #FF6600;
  color: #fff;
  box-shadow: 0 0 16px #FF660088;
}
.btn-primary:hover  { background: #FF8822; box-shadow: 0 0 24px #FF6600bb; }

.btn-secondary {
  background: transparent;
  color: #FF6600;
  border: 2px solid #FF6600;
}
.btn-secondary:hover { background: #FF660022; }

.btn-back {
  background: transparent;
  color: #888;
  border: 1px solid #555;
  font-size: 14px;
  padding: 10px 20px;
}
.btn-back:hover { color: #ccc; border-color: #888; }

/* ── Forms ─────────────────────────────────────────────────── */
.join-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 280px;
}
.join-form input {
  padding: 12px 16px;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 4px;
  text-transform: uppercase;
  background: #1a1a2a;
  border: 2px solid #444;
  color: #fff;
  border-radius: 4px;
  outline: none;
  text-align: center;
}
.join-form input:focus { border-color: #FF6600; box-shadow: 0 0 8px #FF660066; }
.hidden { display: none !important; }

.error-msg {
  color: #FF4444;
  font-size: 14px;
  text-align: center;
  letter-spacing: 1px;
}

/* ── Lobby ─────────────────────────────────────────────────── */
.lobby-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px 20px;
  max-width: 700px;
  width: 100%;
}

.lobby-top { text-align: center; }
.lobby-top h2 { font-size: 22px; letter-spacing: 2px; color: #aaa; }
.room-code {
  font-size: 36px;
  letter-spacing: 8px;
  color: #FF6600;
  text-shadow: 0 0 12px #FF660088;
  cursor: pointer;
}
.lobby-hint { font-size: 13px; color: #666; margin-top: 4px; }

.ship-select-label, .players-label {
  font-size: 13px;
  letter-spacing: 3px;
  color: #888;
  margin-bottom: 10px;
  text-align: center;
}

.ship-grid {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.ship-card {
  width: 110px;
  padding: 14px 8px 10px;
  background: #14141e;
  border: 2px solid #333;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ship-card:hover { border-color: #888; }
.ship-card.selected { border-color: #FF6600; box-shadow: 0 0 14px #FF660066; }
.ship-card canvas { display: block; margin: 0 auto 8px; }
.ship-card .ship-name { font-size: 12px; font-weight: 700; letter-spacing: 1px; }
.ship-card .ship-stats { font-size: 10px; color: #888; line-height: 1.5; margin-top: 4px; }

.lobby-players {
  width: 100%;
  max-width: 400px;
}
#player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #14141e;
  border-radius: 4px;
  border-left: 3px solid #444;
}
.player-row.ready { border-left-color: #44FF44; }
.player-row .pname { flex: 1; font-size: 16px; }
.player-row .pship { font-size: 12px; color: #888; }
.player-row .pstatus { font-size: 12px; color: #555; }
.player-row.ready .pstatus { color: #44FF44; }

.lobby-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* ── Countdown ─────────────────────────────────────────────── */
#screen-countdown { background: #00000088; }
.countdown-number {
  font-size: 180px;
  font-weight: 900;
  letter-spacing: -10px;
  color: #FF6600;
  text-shadow:
    0 0 40px #FF6600,
    0 0 80px #FF440088;
  animation: countPulse 0.8s ease-out;
}
@keyframes countPulse {
  from { transform: scale(1.4); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ── Game Canvas ───────────────────────────────────────────── */
#screen-playing { background: #0a0a12; }
#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Scoreboard ────────────────────────────────────────────── */
.scoreboard-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 50px 30px;
  background: #0d0d1a;
  border: 1px solid #333;
  border-radius: 8px;
  min-width: 460px;
}
.scoreboard-wrapper h2 {
  font-size: 28px;
  letter-spacing: 4px;
  color: #FF6600;
}
.winner-banner {
  font-size: 18px;
  font-weight: 700;
  color: #FFD700;
  letter-spacing: 2px;
  text-shadow: 0 0 12px #FFD70088;
}
#scoreboard-table {
  width: 100%;
  border-collapse: collapse;
}
#scoreboard-table th {
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: 2px;
  color: #888;
  border-bottom: 1px solid #333;
  text-align: left;
}
#scoreboard-table td {
  padding: 10px 14px;
  font-size: 16px;
  border-bottom: 1px solid #1a1a2a;
}
#scoreboard-table tr:first-child td { color: #FFD700; }

/* ── Solo Screen ───────────────────────────────────────────── */
.solo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 36px 24px;
  background: #0d0d1a;
  border: 1px solid #333;
  border-radius: 8px;
  max-width: 680px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
}
.solo-title {
  font-size: 26px;
  letter-spacing: 4px;
  color: #FF6600;
  margin-bottom: 20px;
}
.solo-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.solo-form input {
  padding: 12px 16px;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: #1a1a2a;
  border: 2px solid #444;
  color: #fff;
  border-radius: 4px;
  outline: none;
  text-align: center;
  width: 280px;
}
.solo-form input:focus { border-color: #FF6600; box-shadow: 0 0 8px #FF660066; }
.diff-label {
  font-size: 12px;
  letter-spacing: 3px;
  color: #888;
  margin-top: 6px;
}
.diff-buttons {
  display: flex;
  gap: 10px;
}
.diff-btn {
  padding: 10px 22px;
  font-size: 14px;
  letter-spacing: 2px;
  background: #1a1a2a;
  color: #888;
  border: 2px solid #333;
  border-radius: 4px;
}
.diff-btn.selected { color: #FF6600; border-color: #FF6600; box-shadow: 0 0 10px #FF660055; }
.diff-hint {
  font-size: 11px;
  color: #555;
  letter-spacing: 1px;
  min-height: 16px;
}
.solo-play-btn { width: 200px; margin-top: 6px; }

/* ── Leaderboard ───────────────────────────────────────────── */
.lb-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
}
.lb-tab {
  padding: 8px 18px;
  font-size: 13px;
  letter-spacing: 2px;
  background: #1a1a2a;
  color: #888;
  border: 1px solid #333;
  border-radius: 4px;
}
.lb-tab.active { color: #FF6600; border-color: #FF6600; }
#lb-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 400px;
}
#lb-table th {
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 2px;
  color: #888;
  border-bottom: 1px solid #333;
  text-align: left;
}
#lb-table td {
  padding: 8px 12px;
  font-size: 14px;
  border-bottom: 1px solid #1a1a2a;
}
#lb-table tr:first-child td { color: #FFD700; }

/* ── Solo End ──────────────────────────────────────────────── */
.solo-stats {
  font-size: 16px;
  color: #ccc;
  letter-spacing: 1px;
  line-height: 2;
  text-align: center;
}

/* ── Utility ───────────────────────────────────────────────── */
.glow-orange { text-shadow: 0 0 10px #FF6600; }
