* {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html { height: 100%; overflow: hidden; }

body {
  background: #03030a;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
  font-family: 'Courier New', monospace;
  color: #aaccff;
  padding:
    env(safe-area-inset-top,    0px)
    env(safe-area-inset-right,  0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left,   0px);
}

/* Canvas — sized by JS, never upscaled */
#gameCanvas {
  display: block;
  touch-action: none;
  border: 1px solid rgba(0, 160, 255, 0.18);
  box-shadow:
    0 0 20px rgba(0, 140, 255, 0.15),
    0 0 60px rgba(0,  80, 180, 0.08),
    inset 0 0 40px rgba(0, 0, 20, 0.6);
}

/* ── Mobile controls ────────────────────────────────────────── */
#mobile-controls {
  position: fixed;
  bottom: max(14px, env(safe-area-inset-bottom, 14px));
  right:  max(14px, env(safe-area-inset-right,  14px));
  display: flex;
  gap: 10px;
  z-index: 30;
}
#mobile-controls button {
  width: 46px; height: 46px;
  background: rgba(0, 15, 35, 0.72);
  border: 1px solid rgba(0, 140, 255, 0.28);
  border-radius: 10px;
  color: #aaccff;
  font-size: 20px;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.15s;
}
#mobile-controls button:active { background: rgba(0, 60, 120, 0.8); }

/* ── Landscape warning ──────────────────────────────────────── */
#rotate-hint {
  display: none;
  position: fixed; inset: 0;
  background: #03030a;
  z-index: 999;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
  color: #aaccff;
  text-align: center;
}
#rotate-hint .icon { font-size: 52px; margin-bottom: 8px; }
#rotate-hint div   { font-size: 16px; }
#rotate-hint .sub  { font-size: 12px; color: #445566; margin-top: 4px; }

@media (orientation: landscape) and (max-height: 480px) {
  #rotate-hint { display: flex; }
}

/* ── Leaderboard overlay ────────────────────────────────────── */
#lb-overlay {
  position: fixed; inset: 0;
  background: rgba(2, 2, 18, 0.92);
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
#lb-overlay.hidden { display: none; }

#lb-panel {
  background: #07071a;
  border: 1px solid rgba(0, 140, 255, 0.28);
  border-radius: 14px;
  padding: 22px 20px 20px;
  width: min(400px, 95vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 0 50px rgba(0, 100, 255, 0.18);
  font-family: 'Courier New', monospace;
}

#lb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
#lb-header h2 {
  font-size: 18px;
  letter-spacing: 0.12em;
  color: #22ccff;
  text-shadow: 0 0 12px #0088ff;
}
#lb-close {
  background: none; border: none;
  color: #557799; font-size: 18px;
  cursor: pointer; padding: 4px 6px;
}
#lb-close:hover { color: #aaccff; }

#lb-name-row {
  margin-bottom: 14px;
}
#lb-name-row.hidden { display: none; }
#lb-name-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  color: #446688;
  margin-bottom: 7px;
}
#lb-name-input-wrap {
  display: flex; gap: 8px; align-items: center;
}
#lb-name-input {
  flex: 1;
  background: rgba(0,10,30,0.8);
  border: 1px solid rgba(0,140,255,0.4);
  border-radius: 6px;
  color: #22ccff;
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.2em;
  padding: 7px 10px;
  text-transform: uppercase;
  outline: none;
  caret-color: #22ccff;
}
#lb-name-input:focus {
  border-color: rgba(0,200,255,0.7);
  box-shadow: 0 0 8px rgba(0,180,255,0.2);
}
#lb-name-input::placeholder { color: #223344; }

.lb-btn {
  background: rgba(0,40,90,0.7);
  border: 1px solid rgba(0,140,255,0.35);
  border-radius: 8px;
  color: #aaccff;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  padding: 8px 14px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.15s;
}
.lb-btn:hover, .lb-btn:active { background: rgba(0,80,160,0.7); }
.lb-btn.accent {
  background: rgba(0,80,40,0.7);
  border-color: rgba(0,200,100,0.4);
  color: #44ffaa;
}
.lb-btn.small { padding: 5px 10px; font-size: 11px; }

#lb-submit-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
#lb-submit-row.hidden { display: none; }
#lb-submit-status { font-size: 11px; color: #44ffaa; }

#lb-loading { color: #445566; font-size: 13px; padding: 12px 0; text-align: center; }

#lb-table { width: 100%; border-collapse: collapse; }
#lb-table.hidden { display: none; }
#lb-table th {
  text-align: left; font-size: 10px;
  color: #446688; border-bottom: 1px solid #112233;
  padding: 4px 6px; letter-spacing: 0.08em;
}
#lb-table td { padding: 6px 6px; font-size: 13px; color: #aaccff; }
#lb-table tr:first-child td { color: #ffcc44; }
#lb-table tr:nth-child(2) td { color: #cccccc; }
#lb-table tr:nth-child(3) td { color: #cc8844; }
#lb-table tr.mine td { color: #44ffaa; }
.lb-rank { color: #446688; font-size: 11px; width: 20px; }
.lb-score-val { font-weight: bold; text-align: right; }
.lb-wave-val  { text-align: right; color: #667788; font-size: 11px; }
