:root {
  --pn-vh: 1vh;
  --bg: #080e1c;
  --panel: #101c30;
  --ink: #e8f1f5;
  --muted: #8fa7b5;
  --accent: #ffd166;
  --good: #2ec4b6;
  --bad: #ef476f;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}
#app {
  min-height: calc(var(--pn-vh) * 100);
  display: flex;
  flex-direction: column;
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 12px 12px;
}
.topbar, #statusbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar { padding: 4px 2px 8px; }
.title { font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.title small { color: var(--muted); font-weight: 500; font-size: 11px; margin-left: 4px; }
.spacer { flex: 1; }
.hud { display: flex; gap: 7px; align-items: baseline; font-size: 12px; }
.hud .opt { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.hud b { color: var(--accent); font-variant-numeric: tabular-nums; }
#stage { position: relative; width: 100%; }
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 900 / 620;
  background: var(--bg);
  border-radius: 10px;
  touch-action: none;
  user-select: none;
}
#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(6, 15, 24, .55);
  border-radius: 10px;
}
.card, .modal-card {
  background: var(--panel);
  border: 1px solid #24455c;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.card { min-width: 260px; text-align: center; }
.card-label { font-size: 20px; font-weight: 800; color: var(--good); }
.card-body { display: flex; justify-content: center; gap: 18px; margin: 12px 0; }
.card-body div { display: flex; flex-direction: column; }
.card-body span { color: var(--muted); font-size: 11px; text-transform: uppercase; }
.card-body b { color: var(--ink); font-size: 16px; font-variant-numeric: tabular-nums; }
#meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 2px; }
.meter-label { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; text-transform: uppercase; margin-bottom: 3px; }
.bar { position: relative; height: 12px; border-radius: 6px; background: #173149; overflow: hidden; }
.fill { position: absolute; left: 0; top: 0; height: 100%; width: 0; background: var(--good); transition: width .08s linear, background .12s; }
.fill.hot { background: var(--bad); }
.safe { position: absolute; top: 0; height: 100%; border-right: 2px dashed rgba(255,255,255,.55); }
#statusbar { margin-top: 6px; }
#status { flex: 1 1 100%; color: var(--muted); font-size: 13px; }
#status[data-tone="ok"] { color: var(--good); }
#status[data-tone="bad"] { color: var(--bad); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  appearance: none; border: 1px solid #2d4c62; background: #152a40; color: var(--ink);
  font: inherit; font-size: 13px; border-radius: 8px; min-height: 44px; padding: 0 12px;
  cursor: pointer; touch-action: manipulation; user-select: none;
}
.btn:hover { border-color: var(--good); }
.btn:active, .btn.held { background: #1d4a55; }
.btn.primary { background: #1d5b55; border-color: var(--good); font-weight: 700; }
.btn.icon { min-width: 48px; font-size: 18px; }
.btn.wide { flex: 1 1 160px; font-size: 15px; }
.hint { flex: 1 1 100%; color: var(--muted); font-size: 11px; line-height: 1.5; }
#modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(6,15,24,.75); padding: 20px; z-index: 10; }
.modal-card { max-width: 560px; max-height: 90vh; overflow: auto; line-height: 1.5; }
.modal-card h2 { margin-top: 0; color: var(--accent); }
.modal-card ol { padding-left: 20px; }
.modal-card li { margin: 8px 0; }
.muted { color: var(--muted); font-size: 12px; }
.hidden { display: none !important; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1d5b55; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 20;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (max-width: 520px) {
  .hud { flex-wrap: wrap; }
  .actions { gap: 5px; }
  .btn { padding: 0 9px; }
}
