:root {
  --bg: #080b14;
  --panel: rgba(14, 20, 35, 0.92);
  --panel-2: rgba(25, 34, 58, 0.94);
  --line: rgba(124, 183, 255, 0.22);
  --text: #eaf2ff;
  --muted: #90a4c2;
  --blue: #53a6ff;
  --cyan: #35e3ff;
  --gold: #ffd166;
  --red: #ff5e74;
  --green: #71f2a6;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #1c3158 0, transparent 35%),
              radial-gradient(circle at 90% 60%, #33132a 0, transparent 28%),
              linear-gradient(135deg, #070911, #111a2e 60%, #090b13);
}

#shell {
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 272px;
  grid-template-rows: 78px 1fr;
  gap: 14px;
  padding: 14px;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: linear-gradient(180deg, rgba(20, 29, 50, .92), rgba(11, 16, 29, .92));
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.32), inset 0 1px rgba(255,255,255,.08);
}
.brand { display: flex; gap: 14px; align-items: center; }
.sigil {
  width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 14px; font-size: 28px; color: var(--cyan);
  background: radial-gradient(circle, rgba(53,227,255,.24), rgba(83,166,255,.08));
  border: 1px solid rgba(83,166,255,.36);
  box-shadow: 0 0 28px rgba(53,227,255,.16);
}
h1 { margin: 0; font-size: 22px; letter-spacing: .04em; text-transform: uppercase; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.resources { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.resources span {
  min-width: 92px; text-align: center; padding: 9px 12px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
  color: var(--muted); font-size: 13px;
}
.resources b { color: var(--text); font-size: 15px; }
#wave { color: var(--gold); }
.mute-btn {
  min-width: 96px; padding: 9px 12px; border-radius: 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12);
  color: var(--text); cursor: pointer; font-weight: 700;
}
.mute-btn:hover { border-color: rgba(53,227,255,.55); filter: brightness(1.1); }

.game-wrap {
  position: relative;
  min-height: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #05070d;
  box-shadow: 0 22px 80px rgba(0,0,0,.42);
}
#game { width: 100%; height: 100%; display: block; cursor: crosshair; }
.toast {
  position: absolute; left: 18px; bottom: 18px; max-width: 520px;
  padding: 12px 14px; border-radius: 14px;
  background: rgba(3, 7, 14, .72); border: 1px solid rgba(83,166,255,.28);
  color: #dbeaff; font-size: 14px; backdrop-filter: blur(10px);
  transition: opacity .35s, transform .35s;
}
.toast.hide { opacity: 0; transform: translateY(8px); }

.command-card {
  min-height: 0;
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--panel), rgba(8,12,23,.94));
  border: 1px solid var(--line);
  box-shadow: 0 22px 80px rgba(0,0,0,.36), inset 0 1px rgba(255,255,255,.06);
}
.command-card section { padding: 12px; border-radius: 14px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.06); }
h3 { margin: 0 0 8px; color: #f4f8ff; font-size: 15px; }
p { line-height: 1.45; }
.command-card p { margin: 0; color: var(--muted); font-size: 13px; }
.command-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cmd {
  height: 84px; padding: 9px; border: 1px solid rgba(83,166,255,.22);
  border-radius: 14px; background: linear-gradient(180deg, rgba(43,67,111,.68), rgba(12,18,33,.74));
  color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  gap: 2px; box-shadow: inset 0 1px rgba(255,255,255,.07); transition: transform .12s, border-color .12s, filter .12s;
}
.cmd:hover { transform: translateY(-1px); border-color: rgba(53,227,255,.58); filter: brightness(1.1); }
.cmd:disabled { opacity: .38; cursor: not-allowed; filter: grayscale(.6); transform: none; }
.cmd span { font-size: 20px; color: var(--cyan); }
.cmd b { font-size: 13px; }
.cmd small { color: var(--muted); font-size: 11px; }
.help { margin-top: auto; }
#minimap { width: 100%; height: 150px; border-radius: 14px; background: #060914; border: 1px solid rgba(255,255,255,.08); cursor: grab; }
#minimap:active { cursor: grabbing; }

.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(7, 14, 28, .42), rgba(2, 4, 8, .78));
  backdrop-filter: blur(3px); z-index: 5;
}
.overlay.hidden { display: none; }
.panel {
  width: min(620px, 88%); padding: 28px; border-radius: 24px;
  background: linear-gradient(180deg, rgba(19, 30, 54, .96), rgba(8, 12, 24, .96));
  border: 1px solid rgba(83,166,255,.32); box-shadow: 0 30px 90px rgba(0,0,0,.58), inset 0 1px rgba(255,255,255,.09);
}
.intro h2 { margin: 0 0 10px; font-size: 34px; }
.intro p { margin: 0 0 18px; color: #b8c8e4; }
.keys { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.keys span { padding: 7px 10px; border-radius: 999px; color: #cfe0ff; font-size: 12px; background: rgba(83,166,255,.1); border: 1px solid rgba(83,166,255,.18); }
#startBtn, #restartBtn, #resumeBtn, #pauseRestartBtn {
  border: 0; padding: 13px 18px; border-radius: 14px; color: #06101f; font-weight: 800; cursor: pointer;
  background: linear-gradient(135deg, var(--cyan), var(--gold)); box-shadow: 0 14px 36px rgba(53,227,255,.24);
}
#pauseRestartBtn.secondary-btn {
  margin-left: 10px; color: var(--text); background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.16); box-shadow: none;
}

@media (max-width: 980px) {
  #shell { grid-template-columns: 1fr; grid-template-rows: 72px minmax(0, 1fr) auto; overflow: auto; }
  body { overflow: auto; }
  .command-card { grid-row: 3; }
  .game-wrap { min-height: 560px; }
  .resources span { min-width: auto; }
}
