@font-face {
  font-family: "BpmfHuninn";
  src: url("../assets/fonts/BpmfHuninn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fff8ec;
  --bg-2: #ffe6c4;
  --ink: #211f1c;
  --muted: #6d6458;
  --accent: #ff7a3d;
  --accent-2: #22a89b;
  --accent-3: #ffd23f;
  --good: #18a06a;
  --bad: #e3483f;
  --card: #fffdf8;
  --line: #211f1c;
  --line-soft: rgba(33, 31, 28, 0.16);
  --shadow: 0 7px 0 rgba(33, 31, 28, 0.14), 0 18px 38px rgba(33, 31, 28, 0.12);
  --shadow-sm: 0 4px 0 rgba(33, 31, 28, 0.16);
  --radius: 24px;
  --radius-sm: 16px;
  --maxw: 1120px;
  --font-body: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --font-display: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-zhuyin: "BpmfHuninn", "PingFang TC", "Noto Sans TC", sans-serif;
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%, color-mix(in srgb, var(--accent-3) 34%, transparent) 0, transparent 34%),
    radial-gradient(circle at 88% 14%, color-mix(in srgb, var(--accent-2) 22%, transparent) 0, transparent 30%),
    radial-gradient(circle at 50% 110%, color-mix(in srgb, var(--accent) 18%, transparent) 0, transparent 45%),
    radial-gradient(rgba(33, 31, 28, 0.07) 1px, transparent 1px);
  background-size: auto, auto, auto, 18px 18px;
  background-attachment: fixed;
  overflow-x: hidden;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
}

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

ol,
ul {
  padding: 0;
  list-style-position: inside;
}

:focus-visible {
  outline: 4px solid var(--accent-2);
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: 0 0 12px 12px;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
}

.skip-link:focus {
  top: 0;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px clamp(12px, 3vw, 28px);
  padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, white);
  border-bottom: 2px solid var(--line-soft);
  backdrop-filter: blur(10px);
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.brand-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: clamp(15px, 2.4vw, 19px);
}

.brand-dot {
  width: 14px;
  height: 14px;
  flex: none;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 2px 2px 0 var(--line-soft);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: none;
  border: 2.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 3px 0 var(--line-soft);
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.icon-btn:hover {
  background: color-mix(in srgb, var(--accent-3) 30%, var(--card));
}

.icon-btn:active {
  transform: translateY(3px);
  box-shadow: none;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: var(--ink);
}

.icon-btn svg.stroke,
.icon-btn svg path.stroke,
.icon-btn svg circle.hole {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-btn svg circle.hole {
  fill: var(--card);
}

.icon-btn .i-off,
.icon-btn[aria-pressed="false"] .i-on {
  display: none;
}

.icon-btn[aria-pressed="false"] .i-off {
  display: block;
}

.icon-btn-zhuyin {
  font-family: var(--font-zhuyin);
  font-size: 21px;
  font-weight: 400;
  padding-top: 2px;
}

.icon-btn-zhuyin[aria-pressed="false"] {
  color: var(--muted);
  background: color-mix(in srgb, var(--card) 70%, var(--bg-2));
  opacity: 0.72;
}

/* ---------- layout ---------- */
main {
  flex: 1 0 auto;
  width: 100%;
}

.screen {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(18px, 3.2vw, 40px) clamp(14px, 3vw, 28px) 28px;
}

.screen-enter {
  animation: screen-in 320ms cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.eyebrow {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.card {
  background: var(--card);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.section-title,
.screen-title {
  font-size: clamp(22px, 3.4vw, 32px);
  font-weight: 900;
  letter-spacing: 0.02em;
}

/* ---------- home ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  align-items: center;
  gap: clamp(16px, 4vw, 44px);
  min-height: min(66vh, 620px);
  padding: 8px 0 18px;
}

.hero-copy {
  position: relative;
  z-index: 1;
}

.hero-title {
  margin: 6px 0 10px;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6vw, 4.1rem);
  font-weight: 900;
  line-height: 1.18;
  letter-spacing: 0.03em;
  text-wrap: balance;
}

.hero-desc {
  max-width: 34em;
  color: var(--muted);
  font-size: clamp(15px, 1.9vw, 18px);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.hero-meta {
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.hero-art {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 280px;
}

.hero-blob {
  position: absolute;
  inset: 8% 4%;
  border: 3px solid var(--line);
  border-radius: 46% 54% 58% 42% / 52% 44% 56% 48%;
  background:
    radial-gradient(circle at 30% 25%, #fff 0, transparent 38%),
    linear-gradient(140deg, color-mix(in srgb, var(--accent-3) 62%, white), color-mix(in srgb, var(--accent) 34%, white));
  box-shadow: var(--shadow);
  transform: rotate(-3deg);
}

.hero-art img {
  position: relative;
  z-index: 1;
  width: min(100%, 470px);
  filter: drop-shadow(0 16px 18px rgba(33, 31, 28, 0.18));
  animation: bob 5s ease-in-out infinite;
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-12px) rotate(1deg);
  }
}

.hero-sticker {
  position: absolute;
  right: 2%;
  bottom: 6%;
  z-index: 2;
  padding: 8px 15px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--accent-3);
  box-shadow: var(--shadow-sm);
  font-family: var(--font-zhuyin);
  font-size: clamp(17px, 2.4vw, 24px);
  font-weight: 400;
  transform: rotate(6deg);
}

.howto {
  margin-bottom: 24px;
  padding: clamp(18px, 3vw, 28px);
}

.howto-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 10px;
  padding-left: 4px;
}

.howto-list li {
  padding-left: 4px;
  font-size: 16px;
}

.howto-tip {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 20px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 5px 0 var(--line);
  font-weight: 900;
  letter-spacing: 0.02em;
  text-align: center;
  transition: transform 110ms ease, box-shadow 110ms ease, background 150ms ease;
  touch-action: manipulation;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 var(--line);
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-soft {
  background: color-mix(in srgb, var(--accent-2) 16%, var(--card));
}

.btn-ghost {
  background: var(--card);
}

.btn-danger {
  background: color-mix(in srgb, var(--bad) 14%, var(--card));
  color: #9d211a;
}

.btn-link {
  min-height: 0;
  padding: 8px 10px;
  border: 0;
  box-shadow: none;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.btn-link:hover {
  transform: none;
  box-shadow: none;
  color: var(--ink);
}

.btn-xl {
  min-height: 58px;
  padding: 12px 28px;
  border-radius: 18px;
  font-size: clamp(17px, 2.2vw, 20px);
}

/* ---------- level select ---------- */
.screen-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(10px, 1.6vw, 16px);
}

.level-card {
  position: relative;
  display: grid;
  align-content: space-between;
  gap: 6px;
  min-height: 132px;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition: transform 130ms ease, box-shadow 130ms ease;
}

.level-card:not(:disabled):hover {
  transform: translateY(-3px) rotate(-0.4deg);
  box-shadow: 0 8px 0 rgba(33, 31, 28, 0.16);
}

.level-card:not(:disabled):active {
  transform: translateY(3px);
  box-shadow: none;
}

.level-card:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55);
  opacity: 0.62;
}

.level-card[data-current="true"] {
  background: color-mix(in srgb, var(--accent-3) 42%, var(--card));
}

.level-num {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 32px;
  border: 2.5px solid var(--line);
  border-radius: 10px;
  background: var(--accent-2);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.level-name {
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
}

.level-goal {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.level-stars {
  display: flex;
  gap: 3px;
  font-size: 17px;
  color: color-mix(in srgb, var(--muted) 34%, transparent);
}

.level-stars .on {
  color: #f2a900;
  text-shadow: 0 1px 0 var(--line);
}

.level-lock {
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 18px;
}

.levels-foot {
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ---------- play ---------- */
.play-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.play-kicker {
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: var(--accent-2);
}

.play-title {
  font-size: clamp(22px, 3.6vw, 32px);
  font-weight: 900;
  line-height: 1.25;
}

.play-objective {
  color: var(--muted);
  font-size: 14px;
}

.hud {
  display: flex;
  gap: 10px;
  flex: none;
}

.hud-item {
  min-width: 78px;
  padding: 6px 12px;
  border: 2.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  text-align: center;
  box-shadow: 0 3px 0 var(--line-soft);
}

.hud-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.hud-item strong {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.hud-item.bump {
  animation: bump 260ms ease;
}

@keyframes bump {
  40% {
    transform: scale(1.13) rotate(-2deg);
  }
}

.timer {
  position: relative;
  height: 20px;
  margin: 16px 0 10px;
  overflow: hidden;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: var(--card);
}

.timer-fill {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--good), var(--accent-3) 62%, var(--accent));
  transform-origin: left center;
  transition: transform 80ms linear, background 200ms ease;
}

.timer.is-low .timer-fill {
  animation: pulse-low 520ms ease-in-out infinite;
}

@keyframes pulse-low {
  50% {
    opacity: 0.55;
  }
}

.timer-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

.q-progress {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}

.q-dot {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--line) 14%, transparent);
}

.q-dot.done {
  background: var(--accent-2);
}

.q-dot.now {
  background: var(--accent);
}

.question-host {
  min-height: 330px;
  padding: clamp(16px, 2.6vw, 26px);
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.play-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
}

.play-bottom .btn {
  box-shadow: 0 4px 0 var(--line-soft);
  font-size: 14px;
}

/* ---------- question pieces ---------- */
.q-prompt {
  margin-bottom: 8px;
  font-size: clamp(19px, 2.8vw, 26px);
  font-weight: 900;
  line-height: 1.45;
  text-wrap: balance;
}

.q-sub {
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 15px;
}

.q-passage {
  margin: 12px 0 18px;
  padding: 14px 18px;
  border: 2.5px dashed color-mix(in srgb, var(--line) 30%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent-3) 16%, var(--card));
  font-size: clamp(16px, 2.2vw, 20px);
  line-height: 1.9;
  white-space: pre-wrap;
}

.q-prompt-big {
  font-family: var(--font-zhuyin);
  font-size: clamp(56px, 13vw, 104px);
  font-weight: 400;
  line-height: 1.25;
  text-align: center;
  letter-spacing: 0.06em;
}

.q-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(9px, 1.6vw, 14px);
  margin-top: 16px;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 74px;
  padding: 12px 18px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 5px 0 var(--line-soft);
  font-size: clamp(17px, 2.4vw, 22px);
  font-weight: 900;
  line-height: 1.35;
  transition: transform 110ms ease, box-shadow 110ms ease, background 150ms ease;
}

.choice:hover:not(:disabled) {
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--accent-3) 22%, var(--card));
  box-shadow: 0 7px 0 var(--line-soft);
}

.choice:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: none;
}

.choice:disabled {
  cursor: default;
}

.choice .key {
  position: absolute;
  top: 8px;
  left: 10px;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

.choice.zhuyin-choice {
  font-family: var(--font-zhuyin);
  font-size: clamp(26px, 5vw, 38px);
  letter-spacing: 0.08em;
}

.choice.correct {
  background: color-mix(in srgb, var(--good) 24%, white);
  border-color: var(--good);
  box-shadow: 0 5px 0 var(--good);
  animation: pop 320ms ease;
}

.choice.wrong {
  background: color-mix(in srgb, var(--bad) 18%, white);
  border-color: var(--bad);
  box-shadow: 0 5px 0 var(--bad);
  animation: shake 340ms ease;
}

@keyframes pop {
  45% {
    transform: scale(1.06) rotate(1deg);
  }
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-7px);
  }
  40%,
  80% {
    transform: translateX(7px);
  }
}

/* ---------- feedback ---------- */
.feedback {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.feedback-burst {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 22px 34px;
  border: 4px solid var(--line);
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
  animation: feedback-in 260ms cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}

.feedback-burst.bad {
  background: color-mix(in srgb, var(--bad) 12%, var(--card));
}

.feedback-emoji {
  font-size: clamp(52px, 9vw, 76px);
  line-height: 1;
}

.feedback-text {
  font-size: clamp(22px, 3.6vw, 30px);
  font-weight: 900;
}

.feedback-explain {
  max-width: 22em;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

@keyframes feedback-in {
  from {
    opacity: 0;
    transform: scale(0.72) rotate(-4deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

body.flash-good::after,
body.flash-bad::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  animation: flash 420ms ease-out both;
}

body.flash-good::after {
  box-shadow: inset 0 0 0 14px color-mix(in srgb, var(--good) 70%, transparent);
}

body.flash-bad::after {
  box-shadow: inset 0 0 0 14px color-mix(in srgb, var(--bad) 70%, transparent);
}

@keyframes flash {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* ---------- results ---------- */
.screen-result {
  display: grid;
  place-items: center;
  min-height: 62vh;
}

.result-card {
  width: min(100%, 620px);
  padding: clamp(22px, 4vw, 40px);
  text-align: center;
}

.result-title {
  font-size: clamp(26px, 4.6vw, 38px);
  font-weight: 900;
}

.result-sub {
  margin-top: 4px;
  color: var(--muted);
}

.stars {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0;
  font-size: clamp(44px, 9vw, 66px);
  line-height: 1;
  color: color-mix(in srgb, var(--muted) 26%, transparent);
}

.star {
  display: inline-block;
}

.star.on {
  color: #f7b500;
  text-shadow: 0 4px 0 var(--line);
  animation: star-pop 420ms cubic-bezier(0.2, 0.9, 0.3, 1.4) both;
}

@keyframes star-pop {
  from {
    transform: scale(0.2) rotate(-30deg);
  }
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.result-stats div {
  padding: 10px 6px;
  border: 2.5px solid var(--line-soft);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-2) 36%, var(--card));
}

.result-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.result-stats strong {
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* ---------- dialogs ---------- */
.dialog {
  width: min(92vw, 460px);
  padding: 0;
  border: 0;
  background: transparent;
}

.dialog::backdrop {
  background: rgba(25, 22, 18, 0.48);
  backdrop-filter: blur(4px);
}

.dialog-panel {
  display: grid;
  gap: 10px;
  padding: 20px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-head h2 {
  font-size: 22px;
  font-weight: 900;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.dialog-note {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.install-list {
  display: grid;
  gap: 6px;
  font-size: 14px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 2px;
  border-bottom: 1px dashed var(--line-soft);
}

.setting-label {
  font-weight: 700;
}

.switch {
  appearance: none;
  position: relative;
  width: 54px;
  height: 30px;
  flex: none;
  margin: 0;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 24%, var(--card));
  cursor: pointer;
  transition: background 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 19px;
  height: 19px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.switch:checked {
  background: var(--accent-2);
}

.switch:checked::after {
  transform: translateX(23px);
}

/* ---------- toast & effects ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(64px + env(safe-area-inset-bottom));
  z-index: 70;
  max-width: min(90vw, 520px);
  padding: 10px 18px;
  border: 2.5px solid var(--line);
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}

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

.fx-layer {
  position: fixed;
  inset: 0;
  z-index: 65;
  pointer-events: none;
  overflow: hidden;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 18px;
  border: 2px solid var(--line);
  border-radius: 3px;
  animation: confetti-fall var(--dur, 1800ms) cubic-bezier(0.2, 0.6, 0.4, 1) forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate3d(var(--dx, 0), 110vh, 0) rotate(var(--rot, 540deg));
    opacity: 0.9;
  }
}

/* ---------- footer ---------- */
.site-footer {
  position: sticky;
  bottom: 0;
  z-index: 35;
  flex: none;
  padding: 9px 14px;
  padding-bottom: max(9px, env(safe-area-inset-bottom));
  border-top: 2px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 92%, white);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.site-footer a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- zhuyin ---------- */
body.zhuyin-on [data-zy] {
  font-family: var(--font-zhuyin);
  font-weight: 400;
  letter-spacing: 0.01em;
}

body.zhuyin-on .hero-title[data-zy] {
  line-height: 1.5;
  padding-top: 0.12em;
}

body.zhuyin-on .level-name[data-zy],
body.zhuyin-on .level-goal[data-zy] {
  line-height: 1.75;
}

body.zhuyin-on .q-prompt[data-zy],
body.zhuyin-on .q-passage[data-zy] {
  line-height: 2.05;
}

body.zhuyin-on .choice [data-zy] {
  line-height: 1.85;
}

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    text-align: center;
  }

  .hero-copy {
    order: 2;
  }

  .hero-art {
    order: 1;
    min-height: 0;
  }

  .hero-art img {
    width: min(74vw, 340px);
  }

  .hero-desc {
    margin-inline: auto;
  }

  .hero-actions {
    justify-content: center;
  }

  .level-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .result-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 620px) {
  body {
    font-size: 16px;
  }

  .brand-name {
    display: none;
  }

  .topbar {
    gap: 6px;
    padding-inline: 8px;
  }

  .topbar-actions {
    gap: 5px;
  }

  .icon-btn {
    width: 40px;
    height: 40px;
    border-width: 2px;
    border-radius: 12px;
  }

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

  .topbar-left {
    gap: 5px;
  }

  .level-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .play-top {
    flex-direction: column;
    gap: 8px;
  }

  .hud {
    width: 100%;
  }

  .hud-item {
    flex: 1;
  }

  .choices {
    grid-template-columns: 1fr;
  }

  .choice {
    min-height: 62px;
  }

  .question-host {
    min-height: 260px;
  }

  .screen-head {
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .hero-art img {
    animation: none;
  }
}

body[data-motion="off"] *,
body[data-motion="off"] *::before,
body[data-motion="off"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

body[data-motion="off"] .confetti {
  display: none;
}
