:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 600px; height: 600px; overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#app { width: 100%; height: 100%; position: relative; }
.screen { width: 100%; height: 100%; position: absolute; top: 0; left: 0; display: flex; flex-direction: column; }
.screen.hidden { display: none; }
.focusable { transition: all 0.15s ease; border: 2px solid transparent; cursor: pointer; outline: none; }
.focusable:focus { border-color: var(--focus-ring); box-shadow: 0 0 20px var(--focus-glow); }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.hdr {
  padding: 28px 32px 18px;
  flex-shrink: 0;
}
.hdr-title {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--text-primary);
}
.hdr-sub {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 4px;
  color: var(--accent);
  margin-top: 2px;
}
.hdr-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--bg-tertiary);
}
.hdr-row-title {
  font-size: 26px;
  font-weight: 700;
  flex: 1;
}
.back-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 20px;
  font-weight: 600;
  min-height: 48px;
}

/* ---------- Home menu ---------- */
.menu {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 32px;
  justify-content: center;
}
.menu-item {
  display: grid;
  grid-template-columns: 84px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  text-align: left;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  min-height: 96px;
  column-gap: 18px;
}
.mi-dot {
  grid-row: 1 / 3;
  font-size: 34px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-align: center;
}
.mi-label {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}
.mi-desc {
  font-size: 17px;
  color: var(--text-secondary);
}
.home-foot {
  flex-shrink: 0;
  padding: 18px 32px 28px;
  text-align: center;
}
.stat-line {
  font-size: 18px;
  color: var(--text-secondary);
}

/* ---------- Learn chart ---------- */
.learn-hint {
  text-align: center;
  font-size: 17px;
  color: var(--text-secondary);
  padding: 12px 0 8px;
  flex-shrink: 0;
}
.chart {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  padding: 8px 22px 22px;
  overflow-y: auto;
  align-content: start;
}
.chart-key {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 10px 4px;
  min-height: 72px;
}
.ck-char {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.ck-code {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1px;
  line-height: 1;
}
.chart-key.playing {
  background: var(--bg-tertiary);
  border-color: var(--accent-secondary);
  box-shadow: 0 0 18px rgba(0,255,136,0.45);
}

/* ---------- Practice quiz ---------- */
.quiz {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 28px 22px;
}
.streak-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  height: 30px;
}
.streak-flame {
  font-size: 20px;
  color: var(--text-muted);
  transition: color 0.2s ease;
}
.streak-flame.hot { color: var(--accent-secondary); }
.streak-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}
.streak-lbl {
  font-size: 16px;
  color: var(--text-secondary);
}
.score-chip {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 18px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
}
.lamp-wrap {
  height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 6px 0;
}
.lamp {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 2px solid var(--bg-tertiary);
  transition: background 0.04s linear, box-shadow 0.04s linear;
}
.lamp.on {
  background: var(--accent);
  box-shadow: 0 0 30px 6px var(--focus-glow);
}
.pattern {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--accent);
  min-height: 56px;
  line-height: 1;
  text-align: center;
}
.pattern.masked { color: var(--text-muted); letter-spacing: 12px; }
.prompt {
  font-size: 19px;
  color: var(--text-secondary);
  margin: 6px 0 14px;
}
.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  max-width: 460px;
}
.choice {
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 40px;
  font-weight: 800;
  color: var(--text-primary);
  min-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.choice.correct {
  background: rgba(0,255,136,0.18);
  border-color: var(--accent-secondary);
  color: var(--accent-secondary);
}
.choice.wrong {
  background: rgba(255,68,102,0.18);
  border-color: var(--danger);
  color: var(--danger);
}
.quiz-actions {
  display: flex;
  gap: 16px;
  margin-top: 18px;
}
.mini-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-size: 20px;
  font-weight: 600;
  padding: 12px 24px;
  min-height: 52px;
}

/* ---------- Settings ---------- */
.settings-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 28px;
  overflow-y: auto;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 16px 24px;
  min-height: 64px;
}
.set-label {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}
.set-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}
.set-reset {
  margin-top: 10px;
  background: var(--bg-secondary);
  color: var(--danger);
  border-radius: var(--radius-md);
  font-size: 20px;
  font-weight: 700;
  padding: 16px;
  min-height: 60px;
}
