:root {
  --bg: #08121f;
  --panel: #111c2e;
  --ink: #e7ecf5;
  --muted: #9aa6bf;
  --accent: #4ade80;
  --accent2: #ffd166;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  overscroll-behavior: none;
}
#app {
  height: 100%;
  /* The host stage goes fullscreen on a desktop; 560px would pin the board to
     a quarter of the screen there. Cap wide, let the flex column decide. */
  max-width: min(860px, 100%);
  margin: 0 auto;
  padding: 6px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.topbar { display: flex; align-items: center; gap: 8px; min-height: 18px; }
.title { font-weight: 800; font-size: 14px; letter-spacing: 0.02em; white-space: nowrap; }
.hud { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.hud b { color: var(--accent2); font-variant-numeric: tabular-nums; }
.hud .opt { opacity: 0.85; }
.lives { color: #f87171; letter-spacing: 1px; font-size: 13px; }
.bar { height: 5px; border-radius: 3px; background: #1b2740; overflow: hidden; }
.bar i { display: block; height: 100%; width: 100%; background: var(--accent); transition: width 0.12s linear, background 0.2s linear; }
#stage-wrap { position: relative; flex: 1 1 auto; min-height: 0; }
canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
  background: var(--bg);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.actions { display: flex; align-items: center; gap: 6px; }
.btn {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid #2a3550;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 28px;
  flex: 0 0 auto;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06240f; }
.btn:active { transform: translateY(1px); }
#status { font-size: 11px; color: var(--muted); line-height: 1.25; overflow: hidden; }
#touchpad { display: none; grid-template-columns: repeat(4, 1fr); gap: 8px; }
html.touch #touchpad { display: grid; }
.tbtn {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid #2a3550;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  min-height: 40px;
  cursor: pointer;
  touch-action: manipulation;
}
.tbtn:active { background: #1b2a44; }
#toast {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #111c2e;
  color: var(--ink);
  border: 1px solid #2a3550;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; }

@media (max-height: 430px) {
  #app { gap: 4px; padding: 4px 6px 6px; }
  .title { font-size: 13px; }
  .hud { font-size: 11px; gap: 8px; }
  .tbtn { min-height: 34px; font-size: 14px; }
  .btn { min-height: 26px; padding: 4px 10px; }
}
