:root {
  --bg: #020a14;
  --panel: rgba(4, 18, 34, 0.82);
  --panel-solid: #061a2e;
  --line: rgba(120, 200, 255, 0.22);
  --text: #d8ecff;
  --muted: #7f9bb5;
  --accent: #ffe066;
  --accent2: #62e3ea;
  --danger: #ff7a7a;
  --ok: #5ed66f;
  --font: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

#stage { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; }
#tank { display: block; image-rendering: auto; }

#logo { position: fixed; top: 10px; left: 14px; color: var(--accent2); font-size: 13px; letter-spacing: 0.5px; text-shadow: 0 0 8px rgba(0, 0, 0, 0.8); pointer-events: none; }
#logo b { color: var(--text); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; backdrop-filter: blur(4px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35); }

/* leaderboard */
#board { position: fixed; top: 10px; right: 10px; width: 250px; max-height: calc(100vh - 20px); display: flex; flex-direction: column; }
#board header { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--accent); font-weight: 700; letter-spacing: 1px; }
#board.collapsed ol, #board.collapsed footer { display: none; }
#board.collapsed header { border-bottom: 0; }
#topList { list-style: none; margin: 0; padding: 4px 0; overflow-y: auto; }
#topList li { display: grid; grid-template-columns: 28px 1fr auto; gap: 6px; padding: 3px 10px; cursor: pointer; }
#topList li:hover { background: rgba(98, 227, 234, 0.08); }
#topList li .rk { color: var(--muted); }
#topList li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topList li .sc { color: var(--accent2); }
#topList li.me { background: rgba(255, 224, 102, 0.12); }
#topList li.me .nm { color: var(--accent); }
#topList li:nth-child(1) .rk { color: #ffd700; }
#topList li:nth-child(2) .rk { color: #d0d8e0; }
#topList li:nth-child(3) .rk { color: #e0a060; }
#board footer { padding: 6px 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.icon { background: none; border: 1px solid var(--line); border-radius: 4px; width: 24px; height: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

/* HUD */
#hud { position: fixed; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 10px 14px; min-width: 560px; }
.hud-main { display: grid; grid-template-columns: 1fr 1fr auto; gap: 18px; align-items: center; }
.me-name { color: var(--accent); font-weight: 700; font-size: 16px; }
.me-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.score { font-size: 22px; font-weight: 700; color: var(--accent2); }
.bar { height: 6px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; margin: 4px 0 2px; }
.bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width 0.6s; }
.hud-actions { display: flex; gap: 8px; margin-top: 8px; }

.btn { background: var(--accent2); color: #022; border: 0; border-radius: 4px; padding: 8px 14px; cursor: pointer; font-weight: 700; letter-spacing: 0.5px; }
.btn:hover:not(:disabled) { filter: brightness(1.12); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 400; }
.btn.danger { background: var(--danger); }
.btn.feed { font-size: 18px; min-width: 130px; padding: 12px 18px; background: var(--accent); color: #2a1e00; }
.btn.feed.cooldown { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; text-decoration: underline; margin-top: 12px; }

#joinBtn { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); }

/* modals */
.modal { position: fixed; inset: 0; background: rgba(0, 6, 14, 0.55); display: flex; align-items: center; justify-content: center; z-index: 10; }
.box { background: var(--panel-solid); border: 1px solid var(--line); border-radius: 8px; padding: 22px 26px; width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); }
.box.wide { width: min(980px, calc(100vw - 32px)); }
.box h2 { margin: 0 0 4px; color: var(--accent); font-size: 18px; }
.box h2 span { color: var(--accent2); }
.ascii-logo { color: var(--accent2); margin: 0 0 8px; font-size: 13px; line-height: 1.25; }
.box p { margin: 6px 0 14px; }
#loginForm { display: flex; gap: 8px; flex-wrap: wrap; }
input, select, textarea { background: #021120; border: 1px solid var(--line); border-radius: 4px; padding: 8px 10px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent2); }
#nameInput { flex: 1; min-width: 200px; }
#pinInput, #newPin { width: 130px; }
.err { color: var(--danger); min-height: 1.2em; margin-top: 8px; font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 10px 0 12px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; color: var(--muted); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.card { background: #031424; border: 1px solid var(--line); border-radius: 6px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; min-height: 120px; justify-content: space-between; position: relative; }
.card:hover { border-color: rgba(98, 227, 234, 0.6); }
.card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.card.locked { opacity: 0.5; cursor: not-allowed; }
.card canvas { max-width: 100%; height: auto !important; }
.card .lbl { font-size: 12px; color: var(--text); text-align: center; }
.card .lock { font-size: 11px; color: var(--muted); }
.card .badge { position: absolute; top: 4px; right: 6px; font-size: 11px; color: var(--accent); }
.pick-actions { margin-top: 10px; }
.growth { margin-top: 14px; }
.strip { display: flex; gap: 10px; align-items: flex-end; overflow-x: auto; padding: 6px 0; }
.strip figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.strip figcaption { font-size: 11px; color: var(--muted); }

.swatch { width: 100%; height: 70px; border-radius: 4px; }
.placed { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.chip { background: #031424; border: 1px solid var(--line); border-radius: 12px; padding: 3px 10px; font-size: 12px; display: inline-flex; gap: 6px; align-items: center; }
.chip button { background: none; border: 0; color: var(--danger); cursor: pointer; padding: 0; }
.slots { color: var(--muted); font-size: 12px; margin-bottom: 6px; }

#toasts { position: fixed; top: 46px; left: 14px; display: flex; flex-direction: column; gap: 6px; z-index: 20; pointer-events: none; }
.toast { background: var(--panel-solid); border: 1px solid var(--line); border-left: 3px solid var(--accent2); padding: 8px 12px; border-radius: 4px; max-width: 360px; animation: tin 0.25s ease-out; font-size: 13px; }
.toast.warn { border-left-color: var(--danger); }
.toast.good { border-left-color: var(--accent); }
@keyframes tin { from { transform: translateX(-12px); opacity: 0; } }

#debugStats { position: fixed; left: 14px; bottom: 12px; font-size: 11px; color: #9f9; background: rgba(0, 0, 0, 0.6); padding: 4px 8px; border-radius: 3px; white-space: pre; z-index: 5; }
