:root {
  --ink: #33323d;
  --cream: #fff6e5;
  --coral: #ff5d73;
  --sun: #ffd166;
  --mint: #6ede8a;
  --sky: #4cc9f0;
  --grape: #9b5de5;
  --white: #ffffff;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  background: var(--cream);
  background-image:
    linear-gradient(rgba(51, 50, 61, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(51, 50, 61, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: 'Nunito', sans-serif;
  color: var(--ink);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--white);
  border-bottom: 3px solid var(--ink);
}

.logo-btn { background: none; border: none; padding: 0; cursor: pointer; }

.logo {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--coral);
  text-shadow: 2px 2px 0 var(--sun);
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.streak { display: flex; align-items: center; gap: 4px; }
.streak canvas { width: 24px; height: 32px; image-rendering: pixelated; }
.streak-num { font-family: 'Press Start 2P', monospace; font-size: 12px; color: #ff9f43; }

.xp { font-family: 'Press Start 2P', monospace; font-size: 9px; color: var(--grape); }

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  position: relative;
  overflow: hidden;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: 4px;
  box-shadow: 6px 6px 0 rgba(51, 50, 61, 0.9);
  padding: 18px;
}

.card.note { background: var(--sun); }

.card h2 { font-family: 'Press Start 2P', monospace; font-size: 12px; margin: 0 0 14px; }
.card h3 { font-family: 'Press Start 2P', monospace; font-size: 10px; margin: 0 0 10px; }
.card p { font-size: 15px; line-height: 1.5; margin: 0 0 12px; }

.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--ink);
  background: var(--sun);
  border: 3px solid var(--ink);
  border-radius: 3px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 12px 18px;
  cursor: pointer;
  display: block;
  margin: 0 auto;
}

.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--mint); }
.btn.small { font-size: 7px; padding: 7px 9px; box-shadow: 3px 3px 0 var(--ink); margin: 0; }

.btn-col { display: flex; flex-direction: column; gap: 14px; }
.btn-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn-row .btn { margin: 0; }

/* ---------- home ---------- */
.unit-row { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }

.unit-scene {
  width: 96px;
  height: 96px;
  image-rendering: pixelated;
  flex-shrink: 0;
  border: 2px solid var(--ink);
  border-radius: 3px;
  background: var(--cream);
}

.unit-info { min-width: 0; }
.unit-info h2 { font-size: 10px; line-height: 1.6; }

.dots { display: flex; gap: 5px; margin-bottom: 8px; }
.dots.center { justify-content: center; margin: 12px 0; }
.dot { width: 10px; height: 10px; border: 2px solid var(--ink); background: var(--cream); }
.dot.on { background: var(--mint); }
.dot.big { width: 14px; height: 14px; }

.unit-sub { font-family: 'Press Start 2P', monospace; font-size: 7px; line-height: 1.7; color: rgba(51, 50, 61, 0.7); }

/* ---------- lesson ---------- */
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.lesson-top .progressbar { flex: 1; margin-bottom: 0; }

.progressbar {
  height: 16px;
  border: 3px solid var(--ink);
  border-radius: 3px;
  background: var(--cream);
  margin-bottom: 16px;
  overflow: hidden;
}

.progressbar .fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--mint) 0 8px, #5cc97a 8px 16px);
  transition: width 0.3s;
}

.prompt { font-size: 17px; }

.big-term {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  margin: 6px 0 18px;
}

.say-btn {
  font-size: 16px;
  background: var(--sky);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 10px;
  cursor: pointer;
}

.say-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }

.opts { display: flex; flex-direction: column; gap: 10px; }

.opt {
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-align: left;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 12px 14px;
  cursor: pointer;
}

.opt:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.opt.good { background: var(--mint); }
.opt.bad { background: var(--coral); color: var(--white); }

.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mcol { display: flex; flex-direction: column; gap: 10px; }

.chip {
  font-family: 'Nunito', sans-serif;
  font-size: 16px;
  font-weight: 700;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 3px;
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 14px;
  cursor: pointer;
}

.chip:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.chip.used { opacity: 0.25; pointer-events: none; box-shadow: none; }
.chip.picked { background: var(--sky); }
.chip.m { text-align: center; }
.chip.m.sel { background: var(--sun); }
.chip.m.lock { background: var(--mint); pointer-events: none; opacity: 0.65; box-shadow: none; }

.answer-row {
  min-height: 54px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 3px dashed rgba(51, 50, 61, 0.35);
  margin-bottom: 14px;
}

.bank { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }

.check-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.check-row .btn { margin: 0; }

.feedback { font-family: 'Press Start 2P', monospace; font-size: 10px; }
.feedback.good { color: #2f9e57; }
.feedback.bad { color: var(--coral); }

.tipcard {
  background: var(--sun);
  border: 2px solid var(--ink);
  border-radius: 3px;
  padding: 14px;
  margin-bottom: 18px;
}

.tipcard p { margin: 0; font-size: 16px; }

/* ---------- complete ---------- */
#complete-card { text-align: center; }

.scene-wrap { display: flex; justify-content: center; padding: 8px 0 6px; }

#complete-scene {
  width: 240px;
  height: 240px;
  image-rendering: pixelated;
}

.stage-label { font-family: 'Press Start 2P', monospace; font-size: 9px; line-height: 1.8; }
.xp-gain { font-family: 'Press Start 2P', monospace; font-size: 11px; color: var(--grape); }

.confetti { position: absolute; inset: 0; pointer-events: none; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake { animation: shake 0.35s; }
