*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  color-scheme: light;
  --pink: #ff8eb8;
  --pink-deep: #e56b96;
  --pink-ink: #8a2758;
  --mint: #8ee8d4;
  --mint-deep: #1f9d86;
  --mint-ink: #0d5c4e;
  --lilac: #d9ccfb;
  --lilac-deep: #7d66c4;
  --lilac-ink: #4d3b86;
  --paper: #fff4fb;
  --card: #ffffff;
  --ink: #3d2a36;
  --ink-soft: #7a6170;
  --line: #f0d7e6;
  --gold: #e7a322;
  --bar: rgba(255, 248, 252, 0.94);
  --shadow: 0 12px 28px rgba(160, 80, 120, 0.12);
  --radius: 24px;
  --ok: #0f7a52;
  --ok-bg: #e5f8ef;
  --warn: #9a3d45;
  --warn-bg: #ffe8ea;
  --focus: #7d66c4;
  --header: #c45b86;
  --lv1: #8a4b12;
  --lv1-bg: #fff1dc;
  --lv2: #9d3058;
  --lv2-bg: #ffe4ef;
  --lv3: #6d3d8d;
  --lv3-bg: #f3e6fb;
  --lv4: #3d6b86;
  --lv4-bg: #e5f4fb;
  --lv5: #2f6a52;
  --lv5-bg: #e5f6ee;
}

html {
  font-family: "PingFang TC", "Noto Sans TC", "PingFang SC", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  background: var(--paper);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(800px 360px at 10% -10%, rgba(217, 204, 251, 0.9), transparent 60%),
    radial-gradient(700px 320px at 110% 0%, rgba(142, 232, 212, 0.55), transparent 55%),
    var(--paper);
}

button, select, input { font-family: inherit; color: inherit; }
button {
  cursor: pointer;
  border: none;
  background: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:disabled { cursor: default; opacity: 0.45; }
img { max-width: 100%; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

header {
  background: var(--header);
  color: #fff;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 10px 8px;
  z-index: 10;
}
.header-inner, .header-actions { display: flex; align-items: center; }
.header-inner { justify-content: space-between; gap: 6px; }
.header-actions { gap: 2px; }
.logo {
  color: #fff;
  text-align: left;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.15;
  min-height: 44px;
  padding: 0 4px;
}
.logo span {
  display: block;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.85;
}
.icon-btn {
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.icon-btn.dark { color: var(--ink-soft); }
.icon-btn:active { background: rgba(255, 255, 255, 0.16); }
.badge {
  position: absolute;
  top: 2px;
  right: 0;
  background: #fff;
  color: var(--pink-ink);
  font-size: 10px;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

.combo-pill, .wallet {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 8px 0 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.combo-pill img, .wallet img { width: 28px; height: 28px; object-fit: contain; }

.screen {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 12px 16px;
  -webkit-overflow-scrolling: touch;
}
.screen:not([hidden]) { animation: screen-in 0.28s ease; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.screen-title { font-size: 1.25rem; letter-spacing: 0.04em; }
.screen-subtitle { margin: 14px 0 8px; font-size: 1.02rem; }
.fine { color: var(--ink-soft); font-size: 0.78rem; line-height: 1.45; }
.map-lead { margin: 4px 0 10px; }

.tab-bar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--bar);
  border-top: 1px solid var(--line);
}
.tab {
  min-height: 48px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-soft);
}
.tab[aria-current="page"] {
  background: var(--lilac);
  color: var(--lilac-ink);
}

.hero-card, .streak-card, .quest-card, .card, .result-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(217, 204, 251, 0.65);
}
.hero-card, .streak-card, .quest-card { padding: 10px 12px; margin-bottom: 8px; position: relative; }
.hero-card { text-align: center; }
.hero-art { position: relative; display: inline-block; }
.home-mascot { height: 132px; width: auto; }
.speech {
  margin: 8px auto 0;
  max-width: 18em;
  background: #fff;
  border: 3px solid #d9ccfb;
  border-radius: 16px;
  padding: 8px 12px;
  font-weight: 800;
  line-height: 1.45;
  position: relative;
}
.speech::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  margin-left: -7px;
  border: 7px solid transparent;
  border-bottom-color: #d9ccfb;
}
.xp-row { margin-top: 8px; }
#xp-label { display: block; font-size: 0.78rem; font-weight: 800; color: var(--lilac-ink); margin-bottom: 4px; }
.xp-track, .chest-cta { }
.xp-track {
  height: 10px;
  border-radius: 99px;
  background: #f3eaff;
  overflow: hidden;
}
#xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #c9b6f7, #7d66c4); }
.cta.chest-cta { margin-bottom: 8px; background: linear-gradient(180deg, #ffe7a8, #f0b429); color: #6a4a08; box-shadow: 0 6px 0 #ffe7b8; }
.hearts-row { font-weight: 850; letter-spacing: 0.06em; margin: 0 0 6px; }
.hearts-refill { width: 100%; margin-bottom: 8px; }
.streak-flame.is-lit { animation: flame-flicker 1.15s ease-in-out infinite; transform-origin: 50% 80%; }
@keyframes flame-flicker {
  0%, 100% { transform: scale(1) rotate(-2deg); }
  50% { transform: scale(1.08) rotate(2deg); }
}
.achieve-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.achieve {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  min-height: 118px;
  text-align: center;
}
.achieve.is-off { opacity: 0.62; }
.achieve.is-off img { filter: grayscale(1); }
.ring-wrap { position: relative; width: 64px; height: 64px; margin: 0 auto 4px; }
.ring { width: 64px; height: 64px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #f0e4f6; stroke-width: 6; }
.ring-fg { fill: none; stroke: #7d66c4; stroke-width: 6; stroke-linecap: round; }
.ring-wrap img { position: absolute; inset: 14px; width: 36px; height: 36px; object-fit: contain; margin: auto; }
.achieve strong { display: block; font-size: 0.78rem; }
.achieve small { color: var(--ink-soft); font-size: 0.68rem; }
.chest-reel { display: flex; gap: 8px; justify-content: center; min-height: 52px; margin-bottom: 6px; }
.chest-reel img { width: 48px; height: 48px; object-fit: contain; }
.chest-reel.is-spin img { animation: reel 0.45s linear infinite; }
@keyframes reel {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}
#chest-prize { width: 96px; height: 96px; object-fit: contain; }

.streak-card {
  display: grid;
  grid-template-columns: 1fr 72px;
  column-gap: 6px;
  align-items: center;
}
.streak-hero { display: flex; gap: 8px; align-items: center; grid-column: 1; }
.streak-flame { width: 68px; height: 68px; object-fit: contain; }
.streak-count { font-size: 1.05rem; }
.streak-pig {
  position: static;
  grid-column: 2;
  grid-row: 1 / span 2;
  width: auto;
  height: 96px;
  object-fit: contain;
  object-position: bottom right;
  justify-self: end;
  align-self: end;
}
.week-row {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  margin-top: 6px;
  grid-column: 1;
}
.day-pip { flex: 1; text-align: center; min-width: 0; }
.pip {
  width: 32px;
  height: 32px;
  margin: 0 auto 3px;
  border-radius: 50%;
  border: 3px solid #ffd0e2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: var(--pink-ink);
  background: #fff;
  font-size: 0.85rem;
}
.day-pip.is-done .pip { background: #fff0f5; border-color: var(--pink); }
.day-pip.is-today .pip { border-color: var(--mint-deep); }
.dow { display: block; font-size: 0.68rem; color: var(--ink-soft); font-weight: 700; }
.day-pip.is-today .dow { color: var(--mint-ink); }

.quest-list { list-style: none; }
.quest { padding: 6px 0; border-top: 1px solid var(--line); }
.quest:first-child { border-top: none; }
.quest-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; font-weight: 750; }
.quest-top small { color: var(--ink-soft); font-weight: 700; }
.quest-track { margin-top: 6px; height: 10px; border-radius: 99px; background: #f3eaff; overflow: hidden; }
.quest-fill { height: 100%; background: linear-gradient(90deg, var(--mint), #5dcec0); border-radius: inherit; width: 0; }
.quest.is-done .quest-fill { background: linear-gradient(90deg, #ffd0e4, var(--pink)); }

.cta {
  width: 100%;
  min-height: 56px;
  border-radius: 999px;
  background: linear-gradient(180deg, #b9f6e8, #3ecfb4);
  color: var(--mint-ink);
  font-size: 1.12rem;
  font-weight: 850;
  box-shadow: 0 6px 0 #c9f3ea;
}
.cta:active { transform: translateY(2px); box-shadow: 0 3px 0 #c9f3ea; }
.ghost {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-weight: 800;
  color: var(--ink);
}
.home-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.soft-btn {
  min-height: 56px;
  border-radius: 18px;
  font-weight: 850;
  font-size: 0.92rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}
.soft-mint { background: #dff8f2; color: var(--mint-ink); }
.soft-pink { background: #ffe3ef; color: var(--pink-ink); }
.soft-lilac { background: #f1e9ff; color: var(--lilac-ink); }
.btn-sub { display: block; font-size: 0.75rem; font-weight: 800; }

.map-stage { position: relative; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow); }
.map-art { width: 100%; height: auto; display: block; }
.map-node {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 78px;
  min-height: 44px;
  padding: 4px 8px 5px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 6px 16px rgba(70, 40, 90, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.15;
}
.map-node .node-index {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--lilac-ink);
}
.map-node .node-name { font-size: 0.68rem; font-weight: 850; white-space: nowrap; }
.node-badge { width: 46px; height: 40px; object-fit: contain; }
.map-node .node-meta { font-size: 0.64rem; color: var(--ink-soft); font-weight: 700; }
.map-node[aria-current="true"] { outline: 3px solid var(--mint-deep); }
.map-node.is-locked { background: rgba(255, 255, 255, 0.82); }
.map-node.is-locked .node-name { color: var(--ink-soft); }

.stage-head { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.stage-head .screen-subtitle { margin: 0; }
#stage-badge { width: 72px; height: 64px; object-fit: contain; }
.listen-badge { width: 42px; height: 36px; object-fit: contain; flex-shrink: 0; }
.stage-list { display: flex; flex-direction: column; gap: 8px; }
.stage-btn {
  width: 100%;
  min-height: 52px;
  text-align: left;
  padding: 8px 12px;
  border-radius: 16px;
  background: var(--card);
  border: 1.5px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.stage-btn small { display: block; color: var(--ink-soft); font-weight: 650; font-size: 0.72rem; }
.stage-name { font-weight: 800; }
.stage-status { font-size: 0.75rem; font-weight: 800; color: var(--ink-soft); text-align: right; }
.stage-btn.is-open .stage-status { color: var(--mint-ink); }
.stage-btn.is-locked { background: #fbf7fb; }

.listen-top, .speed-row, .progress-row, .tag-row, .pig-progress, .transport, .quiz-actions, .volume-row {
  display: flex;
  align-items: center;
}
.tag-row { flex-wrap: wrap; justify-content: center; gap: 6px; max-width: 100%; }
.category-tag { max-width: 100%; }
.listen-top { justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.path-caption { font-size: 0.82rem; font-weight: 800; line-height: 1.35; }
.mode-switch { display: flex; background: #fff; border-radius: 999px; padding: 3px; border: 1.5px solid var(--line); flex-shrink: 0; }
.mode-switch button { min-height: 36px; min-width: 52px; padding: 0 10px; border-radius: 999px; font-weight: 800; font-size: 0.85rem; }
.mode-switch button[aria-pressed="true"] { background: var(--lilac); color: var(--lilac-ink); }

.filter-bar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.filter-bar select, #default-category-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 36px 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background-color: #fff;
  font-size: 0.95rem;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%237d66c4' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.level-bar { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.level-bar::-webkit-scrollbar { display: none; }
.level-chip {
  flex: 1 0 auto;
  min-width: 52px;
  min-height: 44px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.level-chip .chip-name { font-size: 0.72rem; font-weight: 800; }
.level-chip .chip-count { font-size: 0.66rem; color: var(--ink-soft); }
.level-chip[data-level="1"] { color: var(--lv1); background: var(--lv1-bg); }
.level-chip[data-level="2"] { color: var(--lv2); background: var(--lv2-bg); }
.level-chip[data-level="3"] { color: var(--lv3); background: var(--lv3-bg); }
.level-chip[data-level="4"] { color: var(--lv4); background: var(--lv4-bg); }
.level-chip[data-level="5"] { color: var(--lv5); background: var(--lv5-bg); }
.level-chip[aria-checked="true"] { box-shadow: inset 0 0 0 2px currentColor; }

.boss-arena {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 8px;
  align-items: end;
  background: linear-gradient(180deg, #f4ecff, #fff);
  border: 1.5px solid var(--line);
  border-radius: 20px;
  padding: 8px 10px 10px;
  margin-bottom: 8px;
}
.boss-cloud { width: 100%; height: auto; transform-origin: center; }
.boss-hero { width: 92px; height: auto; justify-self: center; }
.boss-side { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.hp-block { width: 100%; }
.hp-track {
  height: 16px;
  border-radius: 99px;
  background: #efe4ff;
  border: 2px solid #c9b6f2;
  overflow: hidden;
}
.hp-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8b74d6, #c4b0ff); }
#hp-label { font-size: 0.75rem; font-weight: 800; text-align: center; margin-top: 4px; }
.boss-side button { min-height: 36px; font-weight: 800; color: var(--lilac-ink); }
.boss-cloud.is-down { filter: grayscale(0.85); opacity: 0.55; }

.card { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.progress-row { justify-content: space-between; }
.progress-label { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-weight: 700; }
.react-pig { width: 48px; height: 48px; object-fit: contain; flex-shrink: 0; }
.quiz-pig { width: 72px; height: 72px; object-fit: contain; display: block; margin: 0 auto 2px; position: relative; z-index: 1; }
.star-row { display: flex; gap: 2px; margin-left: auto; }
.equip-hat {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  width: 46%;
  height: auto;
}
.equip-hat[data-item="lantern"] { top: -8%; width: 42%; }
.equip-hat[data-item="grad"] { top: 0; width: 52%; }
.equip-hat[data-item="sunglasses"] { top: 28%; width: 50%; }
.equip-hat[data-item="chef"] { top: -10%; width: 46%; }
.equip-hat[data-item="crown"] { top: -12%; width: 42%; }
.equip-hat[data-item="panda"] { top: -2%; width: 62%; }
.star-row img { width: 26px; height: 26px; object-fit: contain; }
.star-row img.off { filter: grayscale(1); opacity: 0.35; }
.star-row img.is-pop { animation: pop 0.45s ease; }

.sentence-stage {
  min-height: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  position: relative;
}
.sentence-text {
  font-size: clamp(1.35rem, 5.6vw, 1.8rem);
  line-height: 1.65;
  font-weight: 700;
  letter-spacing: 0.03em;
  user-select: text;
}
.sentence-text.is-concealed {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.pinyin-text { color: var(--ink-soft); font-size: 0.92rem; line-height: 1.5; }
.level-tag, .category-tag, .heard-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
}
.category-tag { background: #ffe3ef; color: var(--pink-ink); }
.heard-tag { background: var(--ok-bg); color: var(--ok); }
.heard-tag::before { content: "✓ "; }
.level-tag[data-level="1"] { background: var(--lv1-bg); color: var(--lv1); }
.level-tag[data-level="2"] { background: var(--lv2-bg); color: var(--lv2); }
.level-tag[data-level="3"] { background: var(--lv3-bg); color: var(--lv3); }
.level-tag[data-level="4"] { background: var(--lv4-bg); color: var(--lv4); }
.level-tag[data-level="5"] { background: var(--lv5-bg); color: var(--lv5); }

.listen-veil, .empty-state {
  width: 100%;
  min-height: 168px;
  border-radius: 20px;
  background: linear-gradient(180deg, #f4ecff, #e7fff8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
}
.empty-state img { width: 120px; }
.bars { display: flex; align-items: flex-end; gap: 5px; height: 28px; }
.bars span {
  width: 5px;
  border-radius: 99px;
  background: var(--pink-deep);
  animation: bar 1.1s ease-in-out infinite;
}
.bars span:nth-child(1) { height: 10px; }
.bars span:nth-child(2) { height: 18px; animation-delay: 0.12s; }
.bars span:nth-child(3) { height: 26px; animation-delay: 0.24s; }
.bars span:nth-child(4) { height: 16px; animation-delay: 0.08s; }
.bars span:nth-child(5) { height: 12px; animation-delay: 0.2s; }
@keyframes bar {
  0%, 100% { transform: scaleY(0.55); }
  50% { transform: scaleY(1); }
}
.veil-label { font-weight: 800; color: var(--lilac-ink); }
.reveal-btn, .kicker {
  font-weight: 800;
}
.reveal-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--lilac-deep);
  color: #fff;
}

.audio-note {
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--warn);
  background: var(--warn-bg);
  border-radius: 10px;
  padding: 6px 10px;
}
.pig-progress { gap: 6px; }
.wing-pig, .coin-end { width: 42px; height: 42px; object-fit: contain; flex-shrink: 0; }
.track-col { flex: 1; min-width: 0; }
.progress-bar-wrap {
  height: 28px;
  border-radius: 999px;
  background: #f4ecff;
  border: 3px solid #e6d8fb;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: pointer;
}
.audio-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd0e4, #ff7eae);
  border-radius: inherit;
}
.progress-bar-wrap.is-speaking .audio-progress { animation: speak 1.2s ease-in-out infinite; }
@keyframes speak {
  0% { width: 18%; }
  50% { width: 82%; }
  100% { width: 18%; }
}
.time-display {
  display: block;
  margin-top: 2px;
  text-align: right;
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2.5px solid var(--lilac);
  border-top-color: var(--pink-deep);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.transport { justify-content: center; gap: 6px; }
.kit-btn {
  width: 48px;
  height: 48px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 rgba(255, 255, 255, 0.65);
}
.kit-play {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  background: linear-gradient(180deg, #c9fbee, #67d8c4);
  color: var(--mint-ink);
  box-shadow: 0 6px 0 #d7f7f1;
}
.kit-pink { background: linear-gradient(180deg, #ffe0ee, #ffb3d0); color: var(--pink-ink); box-shadow: 0 5px 0 #ffd6e7; }
.kit-lilac { background: linear-gradient(180deg, #f4edff, #d9ccfb); color: var(--lilac-ink); box-shadow: 0 5px 0 #efe6ff; }
.kit-btn:active { transform: translateY(2px); }
.kit-btn[aria-pressed="true"] { outline: 3px solid var(--gold); }
#btn-bookmark[aria-pressed="true"] #star-icon { fill: var(--pink-deep); }

.tool-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool-btn, .shuffle-btn {
  min-height: 44px;
  border-radius: 14px;
  background: #fff7fb;
  border: 1.5px solid var(--line);
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--ink);
  padding: 4px;
}
.tool-btn[aria-pressed="true"], .shuffle-btn[aria-pressed="true"] {
  background: var(--lilac);
  border-color: var(--lilac-deep);
  color: var(--lilac-ink);
}
.tool-strong { background: #e7fff8; border-color: #9ee6d6; color: var(--mint-ink); }
.speed-row { gap: 8px; }
.speed-label { font-size: 0.8rem; color: var(--ink-soft); }
.speed-readout {
  min-width: 64px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: 12px;
  font-weight: 850;
  background: #ffe3ef;
  color: var(--pink-ink);
}
.shuffle-btn { margin-left: auto; padding: 0 12px; }
.volume-row { gap: 8px; }
.volume-note { font-size: 0.72rem; color: var(--ink-soft); white-space: nowrap; }
#volume-slider, #speed-slider {
  flex: 1;
  width: 100%;
  height: 28px;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
#volume-slider:disabled { opacity: 0.45; }
#volume-slider::-webkit-slider-runnable-track, #speed-slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px; background: var(--lilac);
}
#volume-slider::-webkit-slider-thumb, #speed-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px; border-radius: 50%; background: var(--pink-deep); margin-top: -8px;
}
#volume-slider::-moz-range-track, #speed-slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--lilac); }
#volume-slider::-moz-range-thumb, #speed-slider::-moz-range-thumb {
  width: 20px; height: 20px; border: none; border-radius: 50%; background: var(--pink-deep);
}

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.stat-cell {
  background: var(--card);
  border-radius: 18px;
  padding: 12px;
  border: 1.5px solid var(--line);
  min-height: 78px;
}
.stat-cell strong { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat-cell span { color: var(--ink-soft); font-size: 0.78rem; font-weight: 700; }
.badge-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.badge-item {
  display: flex;
  gap: 10px;
  align-items: center;
  background: var(--card);
  border-radius: 16px;
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  min-height: 64px;
}
.badge-item img { width: 48px; height: 48px; object-fit: contain; }
.badge-item.is-off { filter: grayscale(1); opacity: 0.55; }
.badge-item strong { display: block; }
.badge-item small { color: var(--ink-soft); }

.sprint-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sprint-time { font-size: 2rem; font-weight: 850; font-variant-numeric: tabular-nums; color: var(--pink-ink); }
#sprint-score { font-weight: 800; }
#sprint-stop, #sprint-replay, #sprint-home { margin-left: auto; }
.sprint-track { height: 8px; border-radius: 99px; background: #f3eaff; margin: 8px 0 12px; overflow: hidden; }
#sprint-bar { height: 100%; width: 0; background: var(--pink); }
#sprint-play .quiz-options { margin-bottom: 10px; }
.result-card { padding: 16px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.result-card img { width: min(240px, 70%); }

.layer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(48, 24, 40, 0.48);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
}
.victory-layer { align-items: center; z-index: 60; }
.quiz-bubble, .victory-card {
  width: min(460px, 100%);
  max-height: min(92dvh, 760px);
  overflow: auto;
  background: var(--card);
  position: relative;
}
.quiz-bubble {
  border-radius: 32px 32px 28px 18px;
  border: 6px solid #d9ccfb;
  padding: 22px 16px 14px;
  box-shadow: 0 18px 40px rgba(70, 40, 100, 0.2);
}
.stitch {
  position: absolute;
  inset: 8px;
  border: 2px dashed #f3b4d0;
  border-radius: 24px 24px 20px 14px;
  pointer-events: none;
}
.corner { position: absolute; font-weight: 900; pointer-events: none; z-index: 1; }
.corner.mint { left: 16px; top: 10px; color: #3cbfa6; }
.corner.pink { right: 16px; top: 10px; color: var(--pink-deep); }
.corner.heart { right: 18px; bottom: 12px; color: #7ddec4; }
.tail {
  position: absolute;
  left: 32px;
  bottom: -16px;
  width: 22px;
  height: 18px;
  background: #d9ccfb;
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
.kicker { color: var(--lilac-ink); font-size: 0.78rem; letter-spacing: 0.08em; }
#quiz-prompt { font-size: 1.15rem; margin: 2px 0 8px; position: relative; }
.quiz-clue {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.55;
  margin-bottom: 8px;
  position: relative;
}
.quiz-options { display: flex; flex-direction: column; gap: 8px; position: relative; }
.quiz-option {
  width: 100%;
  min-height: 48px;
  text-align: left;
  padding: 10px 12px;
  border-radius: 16px;
  background: #fff7fb;
  border: 1.5px solid var(--line);
  font-size: 0.98rem;
  line-height: 1.45;
  font-weight: 700;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.quiz-option .mark {
  flex: 0 0 auto;
  min-width: 2.6em;
  font-size: 0.75rem;
  font-weight: 850;
  color: var(--ink-soft);
}
.quiz-option.is-correct { background: var(--ok-bg); border-color: var(--ok); }
.quiz-option.is-correct .mark { color: var(--ok); }
.quiz-option.is-wrong { background: var(--warn-bg); border-color: var(--warn); animation: shake 0.35s ease; }
.quiz-option.is-wrong .mark { color: var(--warn); }
.quiz-feedback { min-height: 1.2em; margin: 8px 0; font-weight: 750; line-height: 1.45; position: relative; }
.quiz-actions { flex-wrap: wrap; gap: 8px; position: relative; }
.quiz-actions button { min-height: 44px; padding: 0 12px; border-radius: 999px; background: #f6f0ff; font-weight: 800; }
.quiz-actions .cta { flex: 1 1 100%; }

.victory-card {
  border-radius: 28px;
  padding: 16px 16px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 6px solid #ffd0e4;
}
.victory-card img { width: min(230px, 68%); }
.victory-card .ghost { width: 100%; }
.victory-stars { display: flex; gap: 4px; justify-content: center; }
.victory-stars img { width: 42px; height: 42px; }
.victory-stars img.is-pop { animation: pop 0.5s ease; }
.victory-coins { font-weight: 850; color: var(--pink-ink); }

#fx-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 65;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(420px, calc(100% - 24px));
  background: #3d2a36;
  color: #fff;
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 750;
  text-align: center;
}
.coin-fly {
  position: fixed;
  z-index: 80;
  width: 36px;
  height: 36px;
  pointer-events: none;
}
.combo-pill.is-bounce, .wallet.is-bounce { animation: bounce 0.4s ease; }
@keyframes pop {
  0% { transform: scale(0.3); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
@keyframes bounce {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-6px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}
@keyframes mascot-bounce {
  0% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-12px) scale(1.08); }
  100% { transform: translateY(0) scale(1); }
}
@keyframes mascot-cheer {
  0%, 100% { transform: rotate(0) scale(1); }
  30% { transform: rotate(-8deg) scale(1.08); }
  65% { transform: rotate(8deg) scale(1.06); }
}
@keyframes boss-hit {
  0%, 100% { transform: translate(0, 0) rotate(0); }
  25% { transform: translate(-10px, 2px) rotate(-4deg); }
  50% { transform: translate(8px, -2px) rotate(4deg); }
  75% { transform: translate(-4px, 0) rotate(-2deg); }
}
.home-mascot.is-bounce, .react-pig.is-bounce, .quiz-pig.is-bounce { animation: mascot-bounce 0.48s ease; }
.home-mascot.is-cheer, .react-pig.is-cheer, .quiz-pig.is-cheer { animation: mascot-cheer 0.6s ease; }
.home-mascot.is-shake, .react-pig.is-shake, .quiz-pig.is-shake, .boss-hero.is-shake { animation: boss-hit 0.4s ease; }
.boss-cloud.is-hit { animation: boss-hit 0.45s ease; filter: brightness(1.35); }

.overlay { position: fixed; inset: 0; background: rgba(28, 12, 18, 0.45); z-index: 45; }
.panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  max-height: 78dvh;
  background: var(--card);
  color: var(--ink);
  border-radius: 22px 22px 0 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.18);
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
}
.bookmark-list, .settings-list { overflow: auto; flex: 1; padding-bottom: env(safe-area-inset-bottom, 12px); }
.settings-list { padding: 8px 16px calc(16px + env(safe-area-inset-bottom, 0px)); }
.empty-msg { text-align: center; color: var(--ink-soft); padding: 20px; line-height: 1.6; }
.empty-mascot { width: 140px; display: block; margin: 8px auto; }
.bookmark-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid #fff0f6; }
.bookmark-item-text { flex: 1; text-align: left; font-size: 0.95rem; line-height: 1.4; min-height: 44px; }
.bookmark-item-cat { display: block; font-size: 0.72rem; color: var(--ink-soft); margin-top: 2px; }
.bookmark-item-remove { width: 44px; height: 44px; border-radius: 50%; color: var(--ink-soft); font-size: 1.2rem; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #fff0f6;
}
.setting-row-stack { flex-direction: column; align-items: stretch; }
.setting-row span, .shop-copy { display: flex; flex-direction: column; gap: 4px; }
.setting-row small, .shop-copy small { color: var(--ink-soft); font-size: 0.78rem; line-height: 1.45; }
#speed-value { color: var(--pink-ink); font-weight: 850; }
#startup-random, #sound-on { width: 22px; height: 22px; accent-color: var(--lilac-deep); }
.shop-row { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.shop-row img, .shop-bow { width: 54px; height: 54px; object-fit: contain; flex-shrink: 0; }
.shop-row button { margin-left: auto; min-height: 44px; padding: 0 12px; border-radius: 999px; background: var(--mint); color: var(--mint-ink); font-weight: 850; white-space: nowrap; }

button:focus-visible, select:focus-visible, input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #160f16;
    --card: #2a1c28;
    --ink: #fff5f8;
    --ink-soft: #d8c2ce;
    --line: #4c3648;
    --bar: rgba(28, 16, 26, 0.94);
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    --header: #6e2044;
    --ok: #9be7c2;
    --ok-bg: #163328;
    --warn: #ffb4bc;
    --warn-bg: #4a2430;
    --focus: #e4d4ff;
    --lv1: #ffc48a; --lv1-bg: #3a2a1c;
    --lv2: #ffb3cc; --lv2-bg: #3d2432;
    --lv3: #e4c6ff; --lv3-bg: #34243f;
    --lv4: #b7e4ff; --lv4-bg: #1d3140;
    --lv5: #b6f0d4; --lv5-bg: #173328;
  }
  body { background: radial-gradient(700px 280px at 0% 0%, rgba(125, 102, 196, 0.28), transparent 60%), var(--paper); }
  .quiz-bubble, .victory-card, .hero-card, .streak-card, .quest-card, .card { background: var(--card); }
  .quiz-bubble { border-color: #b9a6e8; }
  .stitch { border-color: #ffb3d0; }
  .quiz-option, .tool-btn, .ghost, .stage-btn, .stat-cell, .badge-item { background: #231620; }
  .mode-switch, .filter-bar select, #default-category-select { background-color: #231620; color: var(--ink); }
  .listen-veil, .empty-state { background: linear-gradient(180deg, #34243f, #1d3330); }
  .boss-arena { background: linear-gradient(180deg, #34243f, #231620); }
  .speech { background: #2a1c28; }
  .kit-play, .kit-pink, .kit-lilac, .cta, .soft-mint, .soft-pink, .soft-lilac { color: #1a1220; }
  .map-node { background: rgba(255, 248, 252, 0.94); color: #3d2a36; }
  .map-node .node-meta, .map-node .node-index { color: #6d5470; }
  .toast { background: #ffe3ef; color: #3d2a36; }
  .pip { background: #2a1c28; }
}

html.large-font { font-size: 19px; }
html.contrast {
  --paper: #fff;
  --card: #fff;
  --ink: #14080e;
  --ink-soft: #3a2430;
  --line: #241018;
}
html.contrast .card,
html.contrast .quest-card,
html.contrast .speech { border-width: 2px; border-color: #241018; }
html.mascot-alive .home-mascot { animation: mascot-idle 2.8s ease-in-out infinite; }
@keyframes mascot-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.more-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.event-banner { font-weight: 800; margin-bottom: 8px; }
.wave { width: 100%; background: #fff; border-radius: 12px; border: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .kit-btn:active, .cta:active { transform: none; }
}
