:root {
  --bg: #070b12;
  --panel: #111826;
  --border: #26354d;
  --text: #e6edf3;
  --muted: #8b9bb4;
  --gold: #f5b942;
  --cyan: #58d5ff;
  --red: #f85149;
  --green: #3fb950;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: radial-gradient(circle at top, #132036 0%, var(--bg) 72%);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  user-select: none;
}
.shell { width: 100%; max-width: 960px; display: flex; flex-direction: column; gap: 8px; }
.hud {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 15px; }
.brand { font-weight: 900; letter-spacing: 0.16em; color: var(--gold); }
.stat { display: flex; align-items: center; gap: 6px; }
.lbl { font-size: 0.7rem; font-weight: 800; color: var(--muted); }
.val { font-family: ui-monospace, monospace; font-size: 1rem; font-weight: 800; }
.gold { color: var(--gold); }
.cyan { color: var(--cyan); }
.red { color: var(--red); }
.icon-btn { background: #1a2538; border: 1px solid var(--border); color: var(--text); border-radius: 6px; width: 34px; height: 30px; cursor: pointer; font-weight: 800; }
.icon-btn.wide { width: 42px; color: var(--cyan); }

.arena-wrap {
  position: relative; background: #080d16; border: 2px solid var(--border);
  border-radius: 12px; overflow: hidden; aspect-ratio: 940 / 500;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
#gameCanvas { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }

.toolbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
.palette { display: flex; gap: 6px; flex-wrap: wrap; }
.tbtn {
  background: #172133; color: var(--text); border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 11px; font-weight: 800; font-size: 0.78rem; cursor: pointer;
}
.tbtn span { color: var(--gold); margin-left: 3px; font-family: monospace; }
.tbtn.active { border-color: var(--cyan); background: rgba(88, 213, 255, 0.16); }
.sel-controls { display: flex; align-items: center; gap: 6px; }
.sel-info { font-size: 0.78rem; color: var(--cyan); font-weight: 700; }
.danger-btn { background: rgba(248, 81, 73, 0.2); color: #ff8c86; border: 1px solid var(--red); border-radius: 6px; padding: 6px 10px; font-weight: 800; font-size: 0.74rem; cursor: pointer; }
.wave-btn { background: var(--gold); color: #090e16; border: none; border-radius: 7px; padding: 8px 14px; font-weight: 900; font-size: 0.78rem; cursor: pointer; }

.overlay {
  position: absolute; inset: 0; background: rgba(7, 11, 18, 0.86); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 10;
}
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 24px; max-width: 470px; width: 100%; max-height: 100%; overflow-y: auto;
  text-align: center; display: flex; flex-direction: column; gap: 10px;
}
.card h1 { color: var(--gold); letter-spacing: 0.12em; }
.card p { font-size: 0.84rem; color: var(--muted); line-height: 1.4; }
.stats-box { background: #080d16; border: 1px solid var(--border); border-radius: 8px; padding: 8px; font-family: monospace; font-size: 0.84rem; }
.lb-panel { background: #080d16; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; text-align: left; }
.lb-head { display: flex; justify-content: space-between; font-size: 0.72rem; font-weight: 800; color: var(--gold); margin-bottom: 5px; }
.lb-list { display: flex; flex-direction: column; gap: 3px; font-family: monospace; font-size: 0.77rem; color: var(--muted); }
.lb-row { display: flex; justify-content: space-between; }
.lb-submit { display: flex; gap: 6px; margin-top: 7px; }
.lb-submit input { flex: 1; background: #111826; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 8px; font-size: 0.8rem; }
.ok-btn { background: var(--green); color: #05160a; border: none; border-radius: 6px; padding: 6px 11px; font-weight: 800; cursor: pointer; font-size: 0.74rem; }
.actions { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.primary-btn, .sec-btn { width: 100%; max-width: 260px; border-radius: 8px; padding: 10px 18px; font-weight: 800; cursor: pointer; }
.primary-btn { background: linear-gradient(90deg, var(--gold), var(--cyan)); color: #070b12; border: none; letter-spacing: 0.08em; }
.sec-btn { background: rgba(88, 213, 255, 0.14); color: var(--cyan); border: 1px solid rgba(88, 213, 255, 0.45); }
.share-out { background: #080d16; color: var(--cyan); border: 1px solid var(--border); border-radius: 6px; padding: 6px; font-size: 0.72rem; font-family: monospace; text-align: center; }
.challenge-box { background: rgba(88, 213, 255, 0.12); border: 1px solid rgba(88, 213, 255, 0.45); color: var(--cyan); padding: 7px; border-radius: 8px; font-size: 0.82rem; font-weight: 700; }
.footer { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--muted); padding: 0 4px; }
.footer a { color: var(--gold); text-decoration: none; font-weight: 700; }
.hidden { display: none !important; }
