:root {
  --bg: #121016;
  --panel: #1a1720;
  --line: #2a2533;
  --text: #e7e3ee;
  --muted: #9b93ab;
  --accent: #b69cf2;
  --app-h: 100vh;
}
@supports (height: 100dvh) { :root { --app-h: 100dvh; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.5 "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; }
.mono { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; }
.hidden { display: none !important; }

#app {
  display: flex; flex-direction: column;
  height: var(--app-h);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.home { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 600; }
.home img { width: 24px; height: 24px; }
.stats { display: flex; gap: 16px; margin-left: auto; color: var(--muted); white-space: nowrap; }
.stats b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.stats .best b { color: var(--accent); }
.lives { display: inline-flex; gap: 2px; align-items: center; }
.lives img { width: 17px; height: 17px; transition: opacity 0.3s, filter 0.3s; }
.lives img.lost { opacity: 0.22; filter: grayscale(1); }
.stats .goal.open b { color: #e9d5ff; animation: gate 1s ease-in-out infinite; }
.stats .goal.boss b { color: #fb7185; letter-spacing: 1px; }
.slow-chip { color: #a5f3fc; font-weight: 600; }
@keyframes gate { 50% { opacity: 0.55; } }
.icon {
  display: grid; place-items: center;
  width: 34px; height: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.icon svg { width: 18px; height: 18px; fill: none; stroke: var(--text); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

#stage { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; padding: 10px; touch-action: none; }
#board {
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  border-radius: 6px;
  box-shadow: 0 0 0 1px var(--line), 0 18px 50px rgba(0, 0, 0, 0.5);
}

.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(10, 8, 14, 0.62);
}
.card {
  width: min(420px, 100%);
  padding: 22px 22px 18px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}
.card h1 { margin: 0 0 8px; font: 600 28px/1.15 "IBM Plex Sans", sans-serif; letter-spacing: -0.4px; }
.card p { margin: 0 0 14px; color: var(--muted); }
.score-line { color: var(--text) !important; font-size: 15px; }
.score-line b { color: var(--accent); }
.play {
  min-width: 150px;
  padding: 10px 22px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #1a1030;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
}
.play:hover { filter: brightness(1.08); }
.keys { margin: 12px 0 0 !important; font-size: 12px; }
body.touch .mouse-only, body:not(.touch) .touch-only { display: none; }

@media (max-width: 520px) {
  .top { gap: 10px; padding: 8px 10px; }
  .home span, .stats .best, .stats .owlets { display: none; }
  .stats { gap: 12px; }
}
