:root {
  --bg: #07080d; --panel: #11141f; --line: #232838; --text: #e8ebf5; --dim: #8a91a8;
  --accent: #22d3ee; --accent2: #8b5cf6; --bad: #fb7185;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1200px 700px at 50% -10%, #1a1440 0%, var(--bg) 60%) fixed var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#app { height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 8px 8px 10px; gap: 8px; }
header { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 6px; flex: none; }
.row { display: flex; align-items: center; gap: 10px; }
h1 {
  margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .02em;
  background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.stats { margin-left: auto; display: flex; gap: 14px; }
.stats div { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.stats span { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.stats b { font-size: 15px; font-variant-numeric: tabular-nums; }
.hearts { color: var(--bad); letter-spacing: 1px; min-width: 1em; text-align: right; }
.btns { gap: 6px; flex-wrap: wrap; }
button {
  font: inherit; font-size: 13px; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px; cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s;
}
button:hover { border-color: #3a4260; background: #171b2a; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[aria-pressed="true"] { border-color: var(--accent); color: #06121a; background: var(--accent); font-weight: 600; }
#b-auto[aria-pressed="true"] { box-shadow: 0 0 16px rgba(34, 211, 238, .45); }
#b-new { margin-left: auto; }

#stage { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; display: flex; justify-content: center; align-items: flex-start; }
canvas {
  display: block; border-radius: 14px; border: 1px solid var(--line); background: #0b0d14;
  box-shadow: 0 0 0 1px rgba(139, 92, 246, .12), 0 18px 60px rgba(0, 0, 0, .6), 0 0 80px rgba(139, 92, 246, .12);
  touch-action: none; cursor: none;
}
#fx { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; pointer-events: none; max-width: 96%; }
.pill {
  position: relative; overflow: hidden; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: rgba(17, 20, 31, .85); border: 1px solid rgba(34, 211, 238, .5); color: var(--text); white-space: nowrap;
}
.pill.bad { border-color: rgba(251, 113, 133, .6); }
.pill i { position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--accent); transform-origin: left; }
.pill.bad i { background: var(--bad); }

dialog {
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px;
  max-width: min(560px, 94vw); max-height: 88dvh; overflow: auto; -webkit-user-select: text; user-select: text;
}
dialog::backdrop { background: rgba(3, 4, 8, .7); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog h3 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
dialog p { margin: 0 0 8px; color: #c9cee0; }
.guide { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; }
.guide li { display: grid; grid-template-columns: 44px 1fr; gap: 8px; align-items: center; }
.guide canvas { border: 0; border-radius: 0; box-shadow: none; background: none; cursor: default; width: 44px; height: 24px; }
.guide b { display: block; font-size: 13px; }
.guide span { display: block; font-size: 12px; color: var(--dim); line-height: 1.25; }
kbd { background: #1b2030; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; font: inherit; font-size: 12px; }
dialog .close { margin-top: 14px; text-align: right; }
@media (max-width: 480px) {
  h1 { font-size: 17px; }
  .stats { gap: 9px; }
  .stats b { font-size: 13px; }
  button { padding: 5px 9px; font-size: 12px; }
  .guide { grid-template-columns: 1fr; }
}
