/* Layout: one centered column. Home is a winding path of hexagon mission badges between colored
   unit banners. Lessons and practice are focused full-screen sessions with a progress bar on top
   and a big action bar at the bottom. Buttons are chunky and press down like real keys. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #e9eef7;
  --ink: #172033;
  --muted: #56637a;
  --line: #d9e0ec;
  --line-strong: #c1cbdc;

  --orange: #ff8a2b;
  --orange-deep: #d9680a;
  --orange-ink: #2b1300;
  --orange-soft: #ffe8d4;
  --violet: #8e63f5;
  --violet-deep: #6a3dd9;
  --violet-ink: #ffffff;
  --violet-soft: #ece4ff;
  --teal: #14b8a6;
  --teal-deep: #0b8d7f;
  --teal-ink: #03221f;
  --teal-soft: #d4f5ef;
  --gold: #ffc531;
  --gold-deep: #d99e00;
  --gold-soft: #fff3cc;
  --ok: #26b562;
  --ok-deep: #178a47;
  --ok-soft: #ddf7e7;
  --ok-text: #0d5b2e;
  --bad: #f0454b;
  --bad-deep: #c22a30;
  --bad-soft: #ffe3e3;
  --bad-text: #8c1c21;
  --locked: #dde3ee;
  --locked-deep: #c2cbda;
  --locked-ink: #7d8aa1;
  --link: #5a33c9;

  --stage: #111a2b;
  --stage-ink: #f1f5fb;
  --stage-muted: #a1b0c7;
  --stage-chip: rgba(255, 255, 255, 0.07);
  --term-bg: #0b1119;
  --term-fg: #d9e4f1;
  --term-prompt: #ffa24f;
  --term-dim: #8291a8;
  --term-err: #ff9393;
  --term-key: #1a2433;
  --term-edge: #222e40;

  --font-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --gutter: max(16px, env(safe-area-inset-left, 0px));
  --press: 4px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1522;
    --surface: #182133;
    --surface-2: #212c42;
    --ink: #eaf0f8;
    --muted: #9eabc1;
    --line: #2a3650;
    --line-strong: #3a4865;
    --orange-soft: #3c2513;
    --violet-soft: #2b2247;
    --teal-soft: #0f302c;
    --gold-soft: #3a3010;
    --ok-soft: #10301e;
    --ok-text: #92e6b3;
    --bad-soft: #3b1618;
    --bad-text: #ffb4b6;
    --locked: #28334a;
    --locked-deep: #1b2435;
    --locked-ink: #74829b;
    --link: #b49cff;
    --stage: #0a1220;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--font-body);
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top, 0px);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 3px;
}

.boot {
  padding: 40px var(--gutter);
  text-align: center;
  color: var(--muted);
}

.icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  flex: none;
}

.icon svg {
  width: 100%;
  height: 100%;
}

.eyebrow {
  font: 800 12px/1.2 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 14px;
}

/* ---------- tones ---------- */

.tone-orange {
  --tone: var(--orange);
  --tone-deep: var(--orange-deep);
  --tone-ink: var(--orange-ink);
  --tone-soft: var(--orange-soft);
}

.tone-violet {
  --tone: var(--violet);
  --tone-deep: var(--violet-deep);
  --tone-ink: var(--violet-ink);
  --tone-soft: var(--violet-soft);
}

.tone-teal {
  --tone: var(--teal);
  --tone-deep: var(--teal-deep);
  --tone-ink: var(--teal-ink);
  --tone-soft: var(--teal-soft);
}

/* ---------- buttons ---------- */

.btn {
  --face: var(--surface);
  --deep: var(--line-strong);
  --on: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 12px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--face);
  color: var(--on);
  box-shadow: 0 var(--press) 0 var(--deep);
  font: 700 16px/1.1 var(--font-body);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
  margin-bottom: var(--press);
}

.btn:active:not(:disabled) {
  transform: translateY(var(--press));
  box-shadow: 0 0 0 var(--deep);
}

.btn .icon {
  width: 20px;
  height: 20px;
}

.btn-primary {
  --face: var(--orange);
  --deep: var(--orange-deep);
  --on: var(--orange-ink);
}

.btn-white {
  --face: var(--surface);
  --deep: var(--line-strong);
  --on: var(--ink);
  outline: 2px solid var(--line-strong);
  outline-offset: -2px;
}

.btn-on-tone {
  --face: rgba(255, 255, 255, 0.24);
  --deep: rgba(0, 0, 0, 0.18);
  --on: var(--tone-ink);
}

.btn-danger {
  --face: var(--bad);
  --deep: var(--bad-deep);
  --on: #ffffff;
}

.btn:disabled {
  --face: var(--locked);
  --deep: var(--locked-deep);
  --on: var(--locked-ink);
  outline: 0;
  cursor: not-allowed;
}

.btn-small {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 15px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.icon-btn .icon {
  width: 26px;
  height: 26px;
}

/* ---------- top bar ---------- */

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  background: var(--bg);
  z-index: 11;
}

.topbar {
  position: sticky;
  top: env(safe-area-inset-top, 0px);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 12px;
  padding-inline: max(var(--gutter), calc(50% - 320px));
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 800 20px/1 var(--font-display);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  color: var(--orange);
  --shield-mark: #ffffff;
}

.stats {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: 800 17px/1 var(--font-display);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stat-streak.is-lit {
  color: var(--orange-deep);
}

.stat-streak.is-lit .icon {
  color: var(--orange);
}

.stat-xp {
  color: var(--ink);
}

.stat-xp .icon {
  color: var(--violet);
}

@media (max-width: 400px) {
  .brand > span:not(.icon) {
    display: none;
  }
}

/* ---------- home ---------- */

.home {
  max-width: 640px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  padding-block: 20px calc(48px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 28px;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 20px;
  padding: 20px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 20px;
}

.summary-rank,
.summary-goal {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
}

.rank-name {
  font: 800 28px/1.1 var(--font-display);
}

.goal-num {
  font-size: 15px;
  color: var(--muted);
}

.goal-num strong {
  font: 800 28px/1.1 var(--font-display);
  color: var(--ink);
}

.meter {
  height: 14px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--orange);
  transition: width 0.5s;
}

.meter-goal .meter-fill {
  background: var(--teal);
}

.meter-label {
  font-size: 14px;
  color: var(--muted);
}

.summary-go,
.summary-done {
  grid-column: 1 / -1;
}

.summary-done {
  color: var(--muted);
}

@media (max-width: 480px) {
  .summary {
    grid-template-columns: 1fr;
  }
}

/* path */

.path {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.unit {
  align-self: stretch;
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--tone);
  color: var(--tone-ink);
  box-shadow: 0 5px 0 var(--tone-deep);
  margin-block: 14px 8px;
}

.unit-num {
  font: 800 13px/1.2 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.85;
}

.unit-title {
  font: 800 26px/1.1 var(--font-display);
}

.unit-blurb {
  font-size: 16px;
  opacity: 0.92;
}

.node-row {
  position: relative;
  display: grid;
  place-items: center;
  transform: translateX(var(--x));
}

.node-row:has(.bubble) {
  margin-top: 40px;
}

@media (max-width: 420px) {
  .node-row {
    transform: translateX(calc(var(--x) * 0.65));
  }
}

.node {
  position: relative;
  display: grid;
  place-items: center;
  width: 86px;
  height: 76px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--tone-ink);
  cursor: pointer;
  margin-bottom: 7px;
}

.node::before,
.node::after {
  content: "";
  position: absolute;
  inset: 0;
  clip-path: polygon(25% 2%, 75% 2%, 100% 50%, 75% 98%, 25% 98%, 0 50%);
}

.node::before {
  background: var(--tone-deep);
  transform: translateY(7px);
}

.node::after {
  background: var(--tone);
  transition: transform 0.08s;
}

.node .icon {
  position: relative;
  z-index: 1;
  width: 34px;
  height: 34px;
  transition: transform 0.08s;
}

.node:active::after,
.node:active .icon {
  transform: translateY(7px);
}

.node:focus-visible {
  outline-offset: 10px;
  border-radius: 14px;
}

.node-locked {
  --tone: var(--locked);
  --tone-deep: var(--locked-deep);
  --tone-ink: var(--locked-ink);
}

.node-current {
  animation: glow 2.2s ease-in-out infinite;
}

.bubble {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--tone);
  color: var(--tone-ink);
  font: 800 13px/1 var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  animation: bob 1.8s ease-in-out infinite;
}

.bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  width: 12px;
  height: 12px;
  background: var(--tone);
  transform: translate(-50%, -7px) rotate(45deg);
  z-index: -1;
}

.node-card {
  width: min(100%, 460px);
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--tone);
  color: var(--tone-ink);
  box-shadow: 0 6px 0 var(--tone-deep);
  animation: pop 0.25s ease both;
}

.node-card h3 {
  font: 800 23px/1.15 var(--font-display);
}

.node-card-kicker {
  font: 800 12px/1.3 var(--font-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.node-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.node-card-actions .btn {
  flex: 1 1 auto;
}

.node-card-locked {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.node-card-status {
  font-size: 14px;
  opacity: 0.9;
}

/* cards under the path */

.card {
  display: grid;
  gap: 12px;
  padding: 20px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 20px;
}

.card h2 {
  font: 800 22px/1.2 var(--font-display);
}

.real-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.real-list li {
  display: grid;
  gap: 2px;
}

.real-list a {
  font-weight: 700;
  color: var(--link);
}

.real-list span {
  color: var(--muted);
  font-size: 15px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 700;
  font-size: 15px;
  color: var(--muted);
}

.field select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}

.field-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.field-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--orange);
}

.field-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.reset {
  display: grid;
  gap: 8px;
}

.reset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legal {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
}

/* ---------- sessions (learn + practice) ---------- */

.session-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-block: 12px;
}

.bar {
  height: 16px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
}

.bar-fill {
  position: relative;
  width: 0;
  height: 100%;
  border-radius: 99px;
  background: var(--orange);
  transition: width 0.4s ease;
}

.bar-fill::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 8px;
  right: 8px;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.35);
}

.seg {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
}

.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 9px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

.seg-btn .icon {
  width: 18px;
  height: 18px;
}

.seg-btn[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--line-strong);
}

/* learn */

.learn {
  max-width: 780px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  padding-bottom: calc(130px + env(safe-area-inset-bottom, 0px));
  display: grid;
  gap: 16px;
}

.learn-head {
  display: grid;
  gap: 2px;
}

.learn-head h1 {
  font: 800 clamp(24px, 5vw, 32px) / 1.1 var(--font-display);
}

.learn-watch {
  display: grid;
  gap: 16px;
}

.stage {
  min-height: 320px;
  display: grid;
  padding: clamp(18px, 4vw, 32px);
  border-radius: 22px;
  background: var(--stage);
  color: var(--stage-ink);
  box-shadow: 0 6px 0 var(--tone-deep);
  overflow: hidden;
}

.slide {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
  animation: slide-in 0.35s ease both;
}

.slide-count {
  font: 600 13px/1 var(--font-mono);
  color: var(--stage-muted);
}

.slide-title {
  font: 800 clamp(22px, 4.6vw, 34px) / 1.1 var(--font-display);
}

.v-big {
  display: grid;
  gap: 10px;
  padding-block: 12px;
}

.v-big-text {
  font: 800 clamp(40px, 10vw, 76px) / 1 var(--font-display);
  letter-spacing: -0.02em;
  color: var(--tone);
  overflow-wrap: anywhere;
}

.v-big-sub {
  font-size: clamp(16px, 2.6vw, 20px);
  color: var(--stage-muted);
}

.v-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.v-list li {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--stage-chip);
  font-size: clamp(16px, 2.8vw, 20px);
  animation: pop 0.4s calc(var(--i) * 0.12s) ease both;
}

.v-list li::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  margin-top: 0.5em;
  border-radius: 3px;
  background: var(--tone);
}

.v-term,
.v-transform code {
  font: 400 clamp(13px, 2.2vw, 16px) / 1.6 var(--font-mono);
  background: var(--term-bg);
  color: var(--term-fg);
  border-radius: 14px;
}

.v-term {
  padding: 14px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-width: 0;
}

.v-term > div {
  animation: pop 0.35s calc(var(--i) * 0.18s) ease both;
}

.v-term-prompt {
  color: var(--term-prompt);
}

.v-term-cmd {
  color: #ffffff;
}

.v-term-out {
  color: var(--term-dim);
}

.v-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.v-col {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  background: var(--stage-chip);
  min-width: 0;
}

.v-col h3 {
  font: 800 clamp(17px, 3vw, 22px) / 1.2 var(--font-display);
  color: var(--stage-muted);
}

.v-col-1 h3 {
  color: var(--tone);
}

.v-col ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: clamp(15px, 2.6vw, 18px);
}

@media (max-width: 420px) {
  .v-compare {
    grid-template-columns: 1fr;
  }
}

.v-flow {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.v-flow li {
  counter-increment: step;
  flex: 1 1 140px;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--stage-chip);
  font-size: clamp(15px, 2.6vw, 18px);
  animation: pop 0.4s calc(var(--i) * 0.15s) ease both;
}

.v-flow li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--tone);
  color: var(--tone-ink);
  font: 800 15px/1 var(--font-display);
}

.v-transform {
  display: grid;
  gap: 10px;
  justify-items: start;
  min-width: 0;
}

.v-transform code {
  padding: 10px 14px;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.v-to {
  color: var(--tone) !important;
}

.v-arrow span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 600 13px/1 var(--font-mono);
  color: var(--stage-muted);
}

.v-arrow span::before {
  content: "";
  width: 10px;
  height: 10px;
  border-right: 3px solid var(--tone);
  border-bottom: 3px solid var(--tone);
  transform: rotate(45deg) translate(-2px, -2px);
}

.caption {
  min-height: 3em;
  font-size: clamp(18px, 3.2vw, 22px);
  font-weight: 700;
  line-height: 1.45;
}

.no-voice {
  font-size: 15px;
  color: var(--muted);
}

.learn-listen {
  display: grid;
  gap: 18px;
}

.listen-art {
  display: grid;
  place-items: center;
  width: 120px;
  height: 120px;
  margin: 8px auto 4px;
  border-radius: 34px;
  background: var(--tone);
  color: var(--tone-ink);
  box-shadow: 0 6px 0 var(--tone-deep);
}

.listen-art .icon {
  width: 60px;
  height: 60px;
}

.transcript {
  display: grid;
  gap: 18px;
  padding: 18px;
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: 20px;
}

.transcript-part {
  display: grid;
  gap: 6px;
}

.transcript-part h2 {
  font: 800 18px/1.2 var(--font-display);
}

.line {
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.2s;
}

.line:hover {
  background: var(--surface-2);
}

.line.is-now {
  background: var(--orange-soft);
  box-shadow: 0 0 0 3px var(--orange-soft);
}

.learn-controls {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 2px solid var(--line);
}

.play-btn {
  display: grid;
  place-items: center;
  width: 70px;
  height: 70px;
  border: 0;
  border-radius: 50%;
  background: var(--orange);
  color: var(--orange-ink);
  box-shadow: 0 5px 0 var(--orange-deep);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
  margin-bottom: 5px;
}

.play-btn:active {
  transform: translateY(5px);
  box-shadow: 0 0 0 var(--orange-deep);
}

.play-btn .icon {
  width: 32px;
  height: 32px;
}

.done-card {
  position: fixed;
  inset: auto 0 0;
  z-index: 20;
  display: grid;
  gap: 10px;
  padding: 22px var(--gutter) calc(22px + env(safe-area-inset-bottom, 0px));
  background: var(--ok-soft);
  border-top: 2px solid var(--ok);
  animation: sheet-up 0.3s ease both;
}

.done-card > * {
  width: 100%;
  max-width: 780px;
  margin-inline: auto;
}

.done-title {
  font: 800 26px/1.1 var(--font-display);
  color: var(--ok-text);
}

.done-sub {
  color: var(--ok-text);
}

.done-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 6px;
}

.done-actions .btn {
  flex: 1 1 200px;
}

/* practice */

.practice {
  max-width: 780px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  padding-bottom: calc(210px + env(safe-area-inset-bottom, 0px));
}

.hearts {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--bad);
  font: 800 19px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}

.hearts .icon {
  width: 26px;
  height: 26px;
}

.ex {
  display: grid;
  gap: 16px;
  padding-top: 10px;
}

.ex-kicker {
  font: 800 13px/1.2 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--violet-deep);
}

@media (prefers-color-scheme: dark) {
  .ex-kicker {
    color: var(--violet);
  }
}

.ex-q {
  font: 800 clamp(22px, 4.5vw, 30px) / 1.2 var(--font-display);
}

.ex-task {
  font-size: 18px;
}

.ex-code {
  margin: 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  font: 15px/1.5 var(--font-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.choices {
  display: grid;
  gap: 12px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--line-strong);
  border-bottom-width: 5px;
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.06s;
}

.choice:active:not(:disabled) {
  transform: translateY(2px);
}

.choice-key {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border: 2px solid var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
  font: 700 14px/1 var(--font-mono);
}

.choice-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.choice[aria-pressed="true"] {
  border-color: var(--violet);
  background: var(--violet-soft);
}

.choice[aria-pressed="true"] .choice-key {
  border-color: var(--violet);
  color: var(--violet);
}

.choice.is-right {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ok-text);
}

.choice.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad-text);
}

.choice:disabled {
  cursor: default;
}

.checkbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  padding: 16px var(--gutter) calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 2px solid var(--line);
  transition: background 0.2s;
}

.checkbar-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 18px;
}

.sheet-msg {
  flex: 1 1 320px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.sheet-msg:empty {
  display: none;
}

.sheet-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
}

.sheet-title {
  font: 800 20px/1.2 var(--font-display);
}

.sheet-detail {
  font-size: 16px;
}

.btn-check {
  flex: 1 1 180px;
  max-width: 100%;
  margin-left: auto;
}

@media (min-width: 640px) {
  .btn-check {
    flex: 0 0 200px;
  }
}

.checkbar.is-right {
  background: var(--ok-soft);
  border-top-color: transparent;
}

.checkbar.is-right .sheet-title,
.checkbar.is-right .sheet-detail,
.checkbar.is-right .sheet-icon {
  color: var(--ok-text);
}

.checkbar.is-right .btn-check {
  --face: var(--ok);
  --deep: var(--ok-deep);
  --on: #04230f;
}

.checkbar.is-wrong {
  background: var(--bad-soft);
  border-top-color: transparent;
}

.checkbar.is-wrong .sheet-title,
.checkbar.is-wrong .sheet-detail,
.checkbar.is-wrong .sheet-icon {
  color: var(--bad-text);
}

.checkbar.is-wrong .btn-check {
  --face: var(--bad);
  --deep: var(--bad-deep);
  --on: #ffffff;
}

.checkbar.is-right,
.checkbar.is-wrong {
  animation: sheet-up 0.25s ease both;
}

/* terminal */

.term {
  min-width: 0;
  border-radius: 16px;
  background: var(--term-bg);
  color: var(--term-fg);
  font: 14px/1.5 var(--font-mono);
  box-shadow: 0 5px 0 #04080d;
  overflow: hidden;
}

.term-out {
  height: clamp(220px, 38vh, 360px);
  overflow-y: auto;
  padding: 14px 16px 6px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.term-dim {
  color: var(--term-dim);
}

.term-err {
  color: var(--term-err);
}

.term-echo {
  color: #ffffff;
  margin-top: 6px;
}

.term-prompt {
  color: var(--term-prompt);
  white-space: nowrap;
}

.term-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 12px;
  border-top: 1px solid var(--term-edge);
}

.term-line:focus-within {
  box-shadow: inset 0 0 0 2px rgba(255, 162, 79, 0.45);
}

.term-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #ffffff;
  font: 16px/1.4 var(--font-mono);
  caret-color: var(--term-prompt);
}

.term-keys {
  display: flex;
  gap: 6px;
  padding: 0 12px 12px;
  overflow-x: auto;
}

.term-key {
  flex: none;
  min-width: 42px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--term-edge);
  border-radius: 9px;
  background: var(--term-key);
  color: var(--term-fg);
  font: 600 15px/1 var(--font-mono);
  cursor: pointer;
}

@media (pointer: fine) and (min-width: 701px) {
  .term-keys {
    display: none;
  }
}

.answer-row {
  display: grid;
  gap: 6px;
}

.answer-label {
  font: 800 13px/1.2 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.answer {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.3 var(--font-mono);
}

.answer:focus {
  outline: 0;
  border-color: var(--violet);
  box-shadow: 0 0 0 3px var(--violet-soft);
}

.answer-note {
  color: var(--bad-text);
  font-weight: 700;
}

.answer-note:empty {
  display: none;
}

.hint-row {
  display: flex;
}

.hints {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 22px;
}

.hints:empty {
  display: none;
}

.hints li {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--gold-soft);
}

.how-cmds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.how-cmd {
  max-width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--term-bg);
  color: var(--term-fg);
  font: 13px/1.4 var(--font-mono);
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
}

/* quit dialog */

.quit {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: rgba(8, 12, 20, 0.55);
}

.quit-card {
  width: 100%;
  max-width: 400px;
  display: grid;
  gap: 12px;
  padding: 22px;
  border-radius: 20px;
  background: var(--surface);
}

.quit-title {
  font: 800 22px/1.2 var(--font-display);
}

.quit-actions {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

/* ---------- end screens ---------- */

.end {
  position: relative;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: 32px var(--gutter) calc(32px + env(safe-area-inset-bottom, 0px));
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  text-align: center;
}

.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.end-badge {
  display: grid;
  place-items: center;
  width: 124px;
  height: 124px;
  border-radius: 36px;
  background: var(--tone);
  color: var(--tone-ink);
  box-shadow: 0 7px 0 var(--tone-deep);
  --shield-mark: var(--tone);
  animation: pop 0.5s ease both;
}

.end-badge .icon {
  width: 66px;
  height: 66px;
}

.end-badge-fail {
  background: var(--bad-soft);
  color: var(--bad);
  box-shadow: 0 7px 0 var(--line-strong);
}

.end h1 {
  font: 800 clamp(30px, 7vw, 44px) / 1.1 var(--font-display);
}

.end-sub {
  color: var(--muted);
  font-size: 18px;
}

.tiles {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 8px;
}

.tile {
  --t: var(--gold);
  --t-deep: var(--gold-deep);
  border: 2px solid var(--t);
  border-radius: 16px;
  overflow: hidden;
  background: var(--surface);
}

.tile-acc {
  --t: var(--ok);
  --t-deep: var(--ok-deep);
}

.tile-hearts {
  --t: var(--bad);
  --t-deep: var(--bad-deep);
}

.tile-label {
  padding: 6px 4px;
  background: var(--t);
  color: #1a1204;
  font: 800 12px/1.2 var(--font-body);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tile-hearts .tile-label {
  color: #ffffff;
}

.tile-num {
  padding: 12px 4px;
  font: 800 26px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}

.end-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
}

.end-note .icon {
  color: var(--orange);
}

.end-rank {
  color: var(--link);
}

.end-actions {
  width: 100%;
  max-width: 380px;
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

/* ---------- toast ---------- */

#toast {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: 50%;
  z-index: 50;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--ink);
  color: var(--bg);
  font-weight: 700;
  opacity: 0;
  transform: translate(-50%, -12px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- motion ---------- */

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(30%);
    opacity: 0.6;
  }
}

@keyframes bob {
  0%,
  100% {
    transform: translate(-50%, 0);
  }
  50% {
    transform: translate(-50%, -5px);
  }
}

@keyframes glow {
  0%,
  100% {
    filter: drop-shadow(0 0 0 transparent);
  }
  50% {
    filter: drop-shadow(0 0 12px var(--tone));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
