:root {
  --bg: #0b0f1a;
  --bg-2: #121829;
  --panel: #161d30;
  --line: #222b44;
  --text: #e9edf6;
  --muted: #8a94ad;
  --accent: #4ade80;
  --accent-2: #60a5fa;
  --danger: #f87171;
  --gold: #fbbf24;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(1100px 620px at 50% -10%, #1a2340 0%, rgba(26, 35, 64, 0) 60%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px 16px 28px;
}

#app { width: 100%; max-width: 560px; }

.screen { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.screen[hidden] { display: none; }

/* ---------- typography ---------- */
.logo {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: clamp(1.35rem, 6vw, 2.1rem);
  line-height: 1.35;
  margin: 0;
  text-align: center;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(74, 222, 128, 0.35);
}
.logo span { display: block; color: var(--accent-2); text-shadow: 0 0 22px rgba(96, 165, 250, 0.35); }

.brand { text-align: center; }
.tagline { margin: 12px 0 0; color: var(--muted); font-size: 0.92rem; }

h2 {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 1rem;
  line-height: 1.5;
  margin: 0;
  text-align: center;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-weight: 650;
  color: #0b0f1a;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  padding: 11px 22px;
  cursor: pointer;
  transition: filter .12s ease, transform .12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn.big { padding: 14px 40px; font-size: 1.05rem; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn.alt { background: var(--accent-2); }

.mute {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 10;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}
.mute:hover { border-color: var(--muted); }
.mute.off { opacity: .5; }

/* ---------- onboarding ---------- */
.card {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 24px 20px;
}

.dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 22px; }
.dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line); display: block; transition: background .2s ease, width .2s ease;
}
.dots i.on { background: var(--accent); width: 20px; border-radius: 4px; }
.dots i.done { background: var(--muted); }

.ob-body { min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.ob-body h2 { color: var(--text); }
.ob-body p { margin: 0; color: var(--muted); font-size: 0.95rem; line-height: 1.65; max-width: 42ch; }
.ob-body p b { color: var(--text); font-weight: 600; }
.ob-emoji { font-size: 2.6rem; line-height: 1; }

.keycaps { display: grid; grid-template-columns: repeat(3, 42px); gap: 6px; justify-content: center; margin: 4px 0; }
.keycaps kbd {
  font: 600 0.85rem/40px ui-monospace, monospace;
  height: 40px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 8px;
  color: var(--text);
  text-align: center;
}
.keycaps kbd.blank { visibility: hidden; }

.legend { display: flex; flex-direction: column; gap: 10px; text-align: left; margin: 2px 0; }
.legend div { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 0.92rem; }
.legend b { color: var(--text); font-weight: 600; }
.swatch { width: 18px; height: 18px; border-radius: 5px; flex: 0 0 auto; }

.practice-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; }
#obCanvas {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  touch-action: none;
  width: 300px;
  height: 300px;
  max-width: 78vw;
  max-height: 78vw;
}
.practice-status { font-size: 0.88rem; color: var(--muted); min-height: 1.2em; }
.practice-status.ok { color: var(--accent); font-weight: 600; }

.ob-nav { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 20px; }

/* ---------- level list ---------- */
.levels { display: grid; gap: 10px; width: 100%; }

.level-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--lv, var(--accent));
  border-radius: 11px;
  padding: 13px 15px;
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease;
}
.level-card:hover:not(:disabled) { background: var(--panel); border-color: var(--muted); }
.level-card:disabled { cursor: not-allowed; opacity: .45; border-left-color: var(--line); }

.level-num {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 0.8rem;
  color: var(--lv, var(--accent));
  width: 22px;
  flex: 0 0 auto;
}
.level-card:disabled .level-num { color: var(--muted); }
.level-info { flex: 1 1 auto; min-width: 0; }
.level-info b { display: block; font-size: 0.97rem; font-weight: 650; }
.level-info span { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 3px; }
.level-meta { flex: 0 0 auto; text-align: right; color: var(--muted); font-size: 0.78rem; font-variant-numeric: tabular-nums; }
.level-meta b { display: block; color: var(--gold); font-size: 0.92rem; font-weight: 650; }

.menu-actions { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.total { margin: 0; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.audio-hint { margin: 0; color: var(--muted); opacity: .75; font-size: 0.78rem; text-align: center; }
.audio-hint[hidden] { display: none; }

/* ---------- game ---------- */
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 480px;
}
.hud-item {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 4px;
  text-align: center;
}
.hud-item span { display: block; color: var(--muted); font-size: 0.66rem; text-transform: uppercase; letter-spacing: .07em; }
.hud-item b { display: block; margin-top: 3px; font-size: 1rem; font-variant-numeric: tabular-nums; }

.level-name {
  margin: 0;
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 0.72rem;
  color: var(--lv, var(--accent));
  text-align: center;
}

.stage { position: relative; width: 100%; max-width: 480px; aspect-ratio: 1 / 1; }
#board {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: rgba(11, 15, 26, .88);
  border-radius: 12px;
  backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
.overlay p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.6; max-width: 34ch; }
.overlay p b { color: var(--text); }
.ov-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 4px; }

.hint { margin: 0; color: var(--muted); font-size: 0.78rem; text-align: center; }
@media (hover: none) { .hint-keys { display: none; } }
@media (hover: hover) { .hint-touch { display: none; } }

@media (max-width: 420px) {
  .hud-item b { font-size: 0.9rem; }
  .card { padding: 22px 16px 16px; }
  .ob-nav { flex-direction: column-reverse; }
  .ob-nav .btn { width: 100%; }
}
