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

:root {
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --danger: #f87171;
  --cyan: #38bdf8;
  --bg: #05070f;
  --panel: rgba(8, 12, 24, 0.92);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: #e2e8f0;
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  background: radial-gradient(ellipse at 50% 120%, #0b1226 0%, #05070f 60%);
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: linear-gradient(to bottom, rgba(5, 7, 15, 0.85), transparent);
  pointer-events: none;
  user-select: none;
  z-index: 5;
}

.hud-group { display: flex; gap: 22px; align-items: center; }

.hud-item {
  display: inline-flex;
  gap: 8px;
  align-items: baseline;
  font-size: 18px;
  font-weight: bold;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.hud-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: #64748b;
  text-shadow: none;
}

.lives { color: var(--danger); text-shadow: 0 0 8px rgba(248, 113, 113, 0.6); font-size: 18px; letter-spacing: 3px; }

.charges { transition: color 0.2s ease; }
.charges.charging {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.8);
  animation: pulse-cyan 0.7s ease-in-out infinite alternate;
}
@keyframes pulse-cyan {
  from { opacity: 1; }
  to { opacity: 0.55; }
}

.hud-btn {
  pointer-events: auto;
  background: transparent;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 4px 9px;
  cursor: pointer;
  font-size: 14px;
}
.hud-btn:hover { border-color: var(--accent); }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 5, 10, 0.72);
  backdrop-filter: blur(3px);
  z-index: 10;
}

.panel {
  background: var(--panel);
  border: 1px solid #1e293b;
  border-radius: 14px;
  padding: 42px 56px;
  text-align: center;
  box-shadow: 0 0 60px rgba(56, 189, 248, 0.12), inset 0 0 30px rgba(56, 189, 248, 0.03);
  max-width: 92vw;
}

.logo {
  font-size: clamp(40px, 8vw, 72px);
  letter-spacing: 8px;
  color: #f1f5f9;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.7);
}
.logo span { color: var(--accent); text-shadow: 0 0 18px rgba(74, 222, 128, 0.7); }

.tagline { margin-top: 12px; color: #94a3b8; font-size: 15px; }

.howto {
  list-style: none;
  margin: 26px auto;
  text-align: left;
  display: inline-block;
  color: #cbd5e1;
  font-size: 14px;
  line-height: 2;
}
.howto b { color: var(--cyan); }

.btn {
  margin-top: 8px;
  font-family: inherit;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 3px;
  color: #052e16;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 14px 44px;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(74, 222, 128, 0.45);
  transition: transform 0.08s ease, box-shadow 0.2s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 0 34px rgba(74, 222, 128, 0.7); }
.btn:active { transform: translateY(0); }

.hint { margin-top: 14px; color: #64748b; font-size: 13px; }
kbd {
  background: #1e293b;
  border: 1px solid #334155;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 7px;
  font-family: inherit;
  color: #e2e8f0;
}

.credit { margin-top: 26px; font-size: 12px; color: #475569; }
.credit a { color: #64748b; }

/* ---------- lobby panel (chat + leaderboard) ---------- */
.callsign-row {
  margin: 18px auto 4px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.callsign-row label {
  font-size: 11px;
  letter-spacing: 2px;
  color: #64748b;
}
.callsign-row input {
  background: #0b1226;
  border: 1px solid #334155;
  border-radius: 6px;
  color: var(--cyan);
  font-family: inherit;
  font-size: 15px;
  padding: 7px 12px;
  width: 200px;
  outline: none;
}
.callsign-row input:focus { border-color: var(--cyan); box-shadow: 0 0 8px rgba(56, 189, 248, 0.35); }

.net-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  width: 270px;
  background: var(--panel);
  border: 1px solid #1e293b;
  border-radius: 10px;
  z-index: 8;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  font-size: 13px;
}

.net-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.9);
  border: none;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 9px 12px;
  cursor: pointer;
}
.net-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}
.net-dot.online { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.net-dot.connecting { background: #fbbf24; animation: pulse-cyan 0.7s ease-in-out infinite alternate; }
.net-dot.offline { background: #64748b; }
.net-online { margin-left: auto; color: #64748b; letter-spacing: 0; }
#net-chevron { color: #475569; }

.net-body { display: flex; flex-direction: column; max-height: 340px; }
.net-panel.collapsed .net-body { display: none; }

.net-section { padding: 8px 12px; border-top: 1px solid #1e293b; }
.net-label { font-size: 10px; letter-spacing: 2px; color: #64748b; margin-bottom: 6px; }

.net-scores { list-style: none; margin: 0; padding: 0; }
.net-scores li {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  color: #cbd5e1;
}
.net-scores li b { color: var(--accent); font-weight: 600; }
.net-scores li .wpm { color: #64748b; font-size: 11px; margin-left: 8px; }
.net-scores li.muted, .chat-log li.muted { color: #475569; font-style: italic; }

.chat { display: flex; flex-direction: column; }
.chat-log {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  height: 110px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.chat-log li { padding: 2px 0; color: #cbd5e1; word-break: break-word; }
.chat-log li .who { color: var(--cyan); font-weight: 600; }
.chat-log li.sys { color: #64748b; font-style: italic; font-size: 12px; }

/* briefing: pilots ready to battle */
.briefing {
  margin: 14px auto 2px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}
.pilot-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #1e293b;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  color: #e2e8f0;
}
.pilot-chip.me { border-color: var(--accent); box-shadow: 0 0 10px rgba(74, 222, 128, 0.25); }
.ready-chip {
  font-size: 10px;
  letter-spacing: 1px;
  color: #052e16;
  background: var(--accent);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: bold;
  animation: ready-pulse 1.2s ease-in-out infinite alternate;
}
@keyframes ready-pulse {
  from { opacity: 1; box-shadow: 0 0 4px rgba(74, 222, 128, 0.8); }
  to { opacity: 0.65; box-shadow: 0 0 12px rgba(74, 222, 128, 0.4); }
}
.brief-others { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }

/* backup HUD */
.hud-item.backup { color: #7dd3fc; }
.hud-item.backup.ready {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.9);
  animation: pulse-cyan 0.6s ease-in-out infinite alternate;
}

/* voice panel */
.voice { display: flex; flex-direction: column; gap: 7px; }
.chat-log li.pilot { color: #cbd5e1; }
.mic-btn {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.mic-btn:hover:not(:disabled) { border-color: var(--accent); }
.mic-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.mic-btn.live {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.3);
}

/* leaderboard rows */
.net-scores li.me { background: rgba(74, 222, 128, 0.08); border-radius: 4px; }
.net-scores li .rank { width: 24px; color: #64748b; font-size: 12px; }
.net-scores li .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-scores li.me .pname { color: var(--accent); }

.chat-form { display: flex; gap: 6px; }
.chat-form input {
  flex: 1;
  min-width: 0;
  background: #0b1226;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  padding: 6px 9px;
  outline: none;
}
.chat-form input:focus { border-color: var(--accent); }
.chat-form button {
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #052e16;
  font-size: 14px;
  width: 34px;
  cursor: pointer;
}

h2 {
  font-size: 40px;
  letter-spacing: 6px;
  color: var(--cyan);
  text-shadow: 0 0 16px rgba(56, 189, 248, 0.6);
}
.gameover-title { color: var(--danger); text-shadow: 0 0 16px rgba(248, 113, 113, 0.6); }

.stats {
  margin: 26px auto 10px;
  border-collapse: collapse;
  font-size: 16px;
}
.stats td { padding: 7px 18px; border-bottom: 1px solid #1e293b; }
.stats td:first-child { text-align: left; color: #94a3b8; }
.stats td:last-child { text-align: right; color: var(--accent); font-weight: bold; }
