:root {
  color-scheme: dark;
  font-family: "Bahnschrift", "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  --background: #0c1015;
  --panel: #131b23;
  --panel-deep: #10171f;
  --line: #2b3946;
  --text: #edf4f8;
  --muted: #a6b6c3;
  --cyan: #7be6e7;
  --gold: #f4c68d;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 0;
  color: var(--text);
  background: radial-gradient(ellipse at 37% 0%, #1a2a34 0%, #10171f 35%, var(--background) 78%) fixed;
}
button, summary { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, canvas:focus-visible, summary:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.shell { width: min(100% - 48px, 1380px); margin: 26px auto 42px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.brand { display: flex; flex: 1 0 auto; align-items: center; gap: 14px; }
.brand-mark {
  display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid #4b7a80; border-radius: 11px;
  color: var(--cyan); background: #17353e; font-size: 30px; box-shadow: inset 0 0 14px #7be6e720;
}
h1 { font-size: clamp(23px, 3.5vw, 38px); line-height: 1; font-weight: 650; letter-spacing: -.04em; }
h1 span { color: var(--cyan); }
.brand p { color: var(--muted); margin-top: 6px; font-size: .9rem; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(90px, 1fr)); gap: 10px; font-variant-numeric: tabular-nums; }
.stats > div { position: relative; display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px 10px; background: #151f28; }
.stats strong { font-size: 1.27rem; font-weight: 650; line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .82rem; }
.gold { color: var(--gold); }
.meter { position: absolute; inset: auto 8px 4px; border-radius: 3px; height: 2px; background: var(--cyan); transform-origin: left; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.arena, .panel { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); box-shadow: 0 14px 40px #0003; }
.arena { overflow: hidden; }
.arena-head, .arena-foot { min-height: 55px; padding: 10px 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.arena-head h2, .panel h2 { font-size: 1.1rem; font-weight: 650; }
.phase { color: var(--cyan); font-size: .86rem; line-height: 1; }
.phase.active { color: var(--gold); }
.viewport { position: relative; background: #0d151e; border-block: 1px solid var(--line); }
canvas { display: block; width: 100%; aspect-ratio: 780 / 674; touch-action: manipulation; }
canvas:focus-visible { outline-offset: -3px; }
.board-legend { position: absolute; inset: auto 13px 12px; display: flex; flex-wrap: wrap; gap: 12px; pointer-events: none; }
.board-legend > span { display: flex; align-items: center; gap: 6px; color: #bfced6; font-size: .81rem; }
.board-legend i { width: 10px; height: 3px; background: var(--cyan); }
.board-legend span:nth-child(2) i { background: var(--gold); }
.board-legend span:nth-child(3) i { background: #ff7f79; }
#notice { font-size: .88rem; line-height: 1.35; color: var(--muted); }
#notice.error { color: #ffada5; }
.sidebar { display: grid; gap: 12px; }
.panel { padding: 15px; }
.panel-title { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; }
#wave-number { color: var(--gold); font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.wave-panel p, .hint, .inspector p, .help p { color: var(--muted); font-size: .9rem; line-height: 1.45; }
.wave-panel p { margin-top: 8px; }
.enemy-list { display: flex; gap: 6px; flex-wrap: wrap; padding: 0; margin: 10px 0 13px; list-style: none; }
.enemy-list li { display: flex; gap: 6px; align-items: center; border: 1px solid #35424d; border-radius: 5px; font-size: .82rem; padding: 3px 6px; color: #d2dee6; }
.enemy-list li i { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--enemy); }
.primary, .secondary { border-radius: 7px; min-height: 39px; padding: 7px 10px; border: 1px solid #405360; font-weight: 600; }
.primary { width: 100%; color: #082327; border-color: #9cedea; background: #8be2e1; }
.primary:hover:not(:disabled) { background: #b7f4ef; }
.secondary { background: #1b2935; font-size: .85rem; }
.secondary:hover:not(:disabled) { border-color: #7fa1a9; }
.secondary.quiet { background: transparent; color: #c0ccd5; }
.secondary[aria-pressed="true"] { color: var(--cyan); border-color: #6bcacc; background: #1a383e; }
.wave-panel .wave-report { color: var(--cyan); margin: 0 0 12px; }
.tools { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 13px; }
.tool { display: grid; grid-template-columns: 20px 1fr auto; gap: 5px; align-items: center; min-height: 45px; border: 1px solid #354653; border-radius: 7px; background: #18232d; text-align: left; padding: 6px; }
.tool:hover:not(:disabled) { border-color: #76939f; }
.tool[aria-pressed="true"] { border-color: #75c8ca; background: #1a343b; }
.tool-icon { color: var(--tool); text-align: center; font-size: 18px; }
.tool-name { font-size: .78rem; }
.tool-cost { color: var(--gold); font-variant-numeric: tabular-nums; font-size: .8rem; }
.routing { width: 100%; margin-top: 8px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
kbd { font-family: inherit; min-width: 1.3em; padding: 1px 4px; border: 1px solid #51616b; border-radius: 4px; font-size: .76rem; color: #c4d2da; text-align: center; }
.hint { margin-top: 9px; min-height: 2.6em; }
.inspector { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.inspector h3 { font-size: .95rem; }
.inspector .panel-title > span { font-size: .8rem; color: #b4c3cb; }
.inspector p { margin: 5px 0 8px; }
.inspector-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.placement-actions { margin-top: 7px; }
.help summary { cursor: pointer; color: #c5d2da; }
.help p { margin-top: 9px; }
.controls { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: .8rem; color: var(--muted); }
.ending { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; background: #0a1119bb; }
.ending-card { width: min(100%, 320px); background: #182632; border: 1px solid #56747e; border-radius: 12px; text-align: center; padding: 25px; box-shadow: 0 25px 60px #0008; }
.ending-card p { color: var(--muted); margin: 10px 0 20px; }
@media (max-width: 930px) {
  .shell { width: min(100% - 28px, 940px); }
  .layout { grid-template-columns: minmax(0, 1fr) 305px; gap: 10px; }
  .panel { padding: 11px; }
}
@media (max-width: 715px) {
  .shell { width: min(100% - 20px, 640px); margin-top: 12px; }
  .topbar { flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
  .stats { width: 100%; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: contents; }
  .wave-panel { grid-row: 3; }
  .arena { grid-row: 1; }
  .arena-head, .arena-foot { padding: 7px 10px; min-height: 42px; }
  .board-legend { inset: auto 7px 5px; gap: 7px; }
  .board-legend > span { font-size: .7rem; }
  .hint { min-height: auto; }
}


@media (max-width: 350px) {
  .shell { width: calc(100% - 16px); }
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .stats > div { padding-inline: 8px; }
}
