:root {
  --ink: #17120d;
  --soft-ink: #47372b;
  --muted: #7a6a5c;
  --cream: #fff7d8;
  --paper: #fffaf0;
  --line: rgba(23, 18, 13, 0.16);
  --yellow: #f0c66a;
  --orange: #b96f2c;
  --coral: #b85f4f;
  --teal: #2f8f86;
  --blue: #4f7f9a;
  --green: #5d9666;
  --red: #df4b37;
  --shadow: 0 18px 42px rgba(27, 17, 9, 0.2);
  --hard-shadow: 5px 5px 0 rgba(23, 18, 13, 0.82);
  --radius: 8px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --browser-bottom: 0px;
  --viewport-height: 100vh;
  --stage-height: clamp(342px, 45vh, 390px);
  --challenge-stage-height: clamp(322px, 43vh, 366px);
}

@supports (height: 100dvh) {
  :root {
    --viewport-height: 100dvh;
    --stage-height: clamp(342px, 45dvh, 390px);
    --challenge-stage-height: clamp(322px, 43dvh, 366px);
  }
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  height: var(--viewport-height);
  min-height: var(--viewport-height);
  overflow: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 8%, rgba(236, 189, 96, 0.46), transparent 24rem),
    radial-gradient(circle at 88% 82%, rgba(65, 150, 142, 0.3), transparent 24rem),
    linear-gradient(140deg, #7a3824 0%, #d29a4d 38%, #4aa99d 76%, #2e7d95 100%);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.app-shell {
  width: min(100vw, 480px);
  height: var(--viewport-height);
  min-height: var(--viewport-height);
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #d8b46d;
  box-shadow: var(--shadow);
}

.screen {
  min-height: 0;
  overflow: visible;
  background:
    linear-gradient(150deg, rgba(238, 201, 122, 0.95), rgba(188, 102, 70, 0.82) 48%, rgba(58, 145, 137, 0.9)),
    radial-gradient(circle at 18% 72%, rgba(255, 248, 226, 0.3), transparent 8rem);
}

.theme-2,
.theme-7 {
  background: linear-gradient(150deg, #fbf35f 0%, #5ad7cd 58%, #2f8fed 100%);
}

.theme-4,
.theme-6 {
  background: linear-gradient(150deg, #ff9b38 0%, #ff73a5 52%, #32b6d4 100%);
}

.theme-5 {
  background: linear-gradient(150deg, #ffd342 0%, #69d1a4 52%, #3c93e8 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: max(9px, env(safe-area-inset-top, 0px)) 12px 9px;
  color: #070604;
  background: rgba(232, 194, 120, 0.96);
  border-bottom: 2px solid rgba(58, 36, 22, 0.88);
}

.topbar::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 28px;
  height: 14px;
  background: inherit;
  border: solid rgba(23, 18, 13, 0.9);
  border-width: 0 3px 3px 3px;
  transform: translateX(-50%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 21px;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(23, 18, 13, 0.88);
  border-radius: 999px;
  box-shadow: 2px 3px 0 rgba(23, 18, 13, 0.82);
}

.icon-button:active {
  transform: translate(2px, 2px);
  box-shadow: 0 1px 0 rgba(23, 18, 13, 0.82);
}

.icon-button:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
}

.topbar-title {
  min-width: 0;
  text-align: center;
}

.topbar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.timer-badge {
  min-height: 34px;
  display: inline-grid;
  grid-auto-flow: column;
  gap: 5px;
  align-items: center;
  padding: 4px 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(23, 18, 13, 0.88);
  border-radius: 999px;
  box-shadow: 2px 3px 0 rgba(23, 18, 13, 0.82);
  font-weight: 950;
}

.timer-badge span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--red);
  border: 2px solid rgba(23, 18, 13, 0.82);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}

.timer-badge strong {
  min-width: 41px;
  font-size: 12px;
  line-height: 1;
}

.chapter-label {
  display: block;
  color: rgba(23, 18, 13, 0.66);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.page-title {
  display: block;
  margin-top: 2px;
  font-size: 19px;
  font-weight: 950;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.content {
  min-height: 0;
  display: grid;
  grid-template-rows: var(--stage-height) auto;
}

.content-challenge {
  grid-template-rows: var(--challenge-stage-height) auto;
}

.content-challenge .chapter-trail {
  display: none;
}

.stage {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px;
  padding: 14px 14px 0;
}

.mission-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 8px;
  align-items: stretch;
}

.mission-card,
.route-card {
  border: 2px solid rgba(23, 18, 13, 0.86);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.8);
}

.mission-card {
  min-width: 0;
  padding: 9px 11px;
  background: rgba(255, 250, 240, 0.92);
}

.mission-kicker,
.route-card span,
.scene-badge span {
  display: block;
  color: rgba(23, 18, 13, 0.58);
  font-size: 10px;
  font-weight: 900;
}

.mission-card strong,
.route-card strong {
  display: block;
  margin-top: 1px;
  font-size: 15px;
  line-height: 1.2;
}

.mission-card p {
  margin: 4px 0 0;
  color: var(--soft-ink);
  font-size: 12px;
  line-height: 1.38;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.route-card {
  padding: 9px 8px;
  color: #fff;
  background: linear-gradient(145deg, #1597d4, #1dc6c7);
}

.route-card span {
  color: rgba(255, 255, 255, 0.78);
}

.route-card strong {
  font-size: 14px;
}

.route-card em {
  display: inline-grid;
  place-items: center;
  min-width: 40px;
  height: 23px;
  margin-top: 5px;
  color: var(--ink);
  font-size: 12px;
  font-style: normal;
  font-weight: 950;
  background: var(--yellow);
  border: 2px solid rgba(23, 18, 13, 0.82);
  border-radius: 999px;
}

.chapter-trail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(42px, 1fr);
  gap: 5px;
  align-items: center;
}

.trail-node {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 2px;
  color: rgba(23, 18, 13, 0.48);
}

.trail-node i {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 12px;
  font-weight: 950;
  background: rgba(255, 255, 255, 0.72);
  border: 2px solid rgba(23, 18, 13, 0.26);
  border-radius: 999px;
}

.trail-node em {
  width: 100%;
  overflow: hidden;
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trail-node.done i {
  color: #fff;
  background: var(--green);
  border-color: rgba(23, 18, 13, 0.82);
}

.trail-node.active {
  color: var(--ink);
}

.trail-node.active i {
  color: #fff;
  background: var(--red);
  border-color: rgba(23, 18, 13, 0.9);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.54);
}

.visual-stack {
  width: 100%;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.visual-stack-lower {
  align-self: end;
  margin-bottom: 8px;
}

.hero-image {
  width: min(100%, 360px);
  margin: 0 auto;
  max-height: calc(100% - 28px);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: #221713;
  border: 6px solid #fff8d6;
  border-radius: var(--radius);
  box-shadow: 0 9px 0 rgba(23, 18, 13, 0.88), 0 18px 32px rgba(23, 18, 13, 0.2);
}

.visual-stack-lower .hero-image {
  max-height: none;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-image-contain {
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(249, 233, 76, 0.32), rgba(29, 185, 195, 0.24)),
    #fff7d8;
}

.hero-image-contain img {
  object-fit: contain;
}

.hero-image-natural {
  aspect-ratio: 4 / 3;
  height: auto;
}

.hero-image-natural img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.hero-image-empty {
  display: grid;
  align-content: center;
  justify-content: start;
  gap: 8px;
  padding: 28px 40px;
  color: #fffaf0;
  background:
    linear-gradient(145deg, rgba(23, 18, 13, 0.9), rgba(71, 55, 43, 0.82)),
    radial-gradient(circle at 16% 18%, rgba(249, 233, 76, 0.28), transparent 11rem);
}

.hero-image-empty span {
  width: max-content;
  max-width: 100%;
  padding: 5px 9px;
  color: var(--ink);
  background: var(--yellow);
  border: 2px solid rgba(255, 250, 240, 0.82);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
}

.hero-image-empty strong {
  font-size: 46px;
  font-weight: 950;
  line-height: 1.08;
}

.hero-image-empty p {
  margin: 0;
  color: rgba(255, 250, 240, 0.86);
  font-size: 15px;
  font-weight: 760;
  line-height: 1.5;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.scene-badge {
  position: relative;
  z-index: 2;
  min-width: 124px;
  margin-top: -27px;
  padding: 7px 16px;
  text-align: center;
  background: linear-gradient(145deg, #ffad2e, #ff6c29);
  border: 2px solid rgba(23, 18, 13, 0.88);
  border-radius: 999px;
  box-shadow: 3px 4px 0 rgba(23, 18, 13, 0.82);
}

.scene-badge span {
  color: rgba(255, 255, 255, 0.86);
}

.scene-badge strong {
  display: block;
  color: #fff;
  font-size: 13px;
  line-height: 1.15;
}

.panel {
  min-height: 0;
  display: block;
  padding: 22px 14px calc(10px + var(--safe-bottom) + var(--browser-bottom));
  background:
    linear-gradient(180deg, #fff8df 0%, #fffaf0 55%, #e7fbff 100%);
  border-top: 3px solid rgba(23, 18, 13, 0.88);
}

.story-scroll {
  min-height: 0;
  overflow-y: visible;
  padding: 2px 2px 12px;
}

.story-title {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 950;
  line-height: 1.16;
}

.story-text {
  color: var(--soft-ink);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.64;
}

.story-text p {
  margin: 0 0 9px;
}

.quote {
  position: relative;
  margin: 12px 0;
  padding: 13px 14px 13px 42px;
  color: #3f281b;
  font-weight: 750;
  background: #fff0b8;
  border: 2px solid rgba(23, 18, 13, 0.82);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.78);
}

.quote::before {
  content: "“";
  position: absolute;
  left: 12px;
  top: 4px;
  color: var(--orange);
  font-size: 44px;
  line-height: 1;
  font-family: Georgia, serif;
}

.route-hint,
.tip {
  margin: 12px 0 0;
  padding: 11px 12px;
  color: #073f45;
  background: #d9fbff;
  border: 2px solid rgba(23, 18, 13, 0.72);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.72);
  font-size: 14px;
  font-weight: 760;
  line-height: 1.55;
}

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

.question {
  position: relative;
  margin: 0;
  padding: 14px 14px;
  color: var(--ink);
  background: #ffe8f0;
  border: 2px solid rgba(23, 18, 13, 0.88);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 rgba(23, 18, 13, 0.82);
  font-size: 18px;
  font-weight: 950;
  line-height: 1.52;
}

.question::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: -10px;
  width: 18px;
  height: 18px;
  background: inherit;
  border: solid rgba(23, 18, 13, 0.88);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.option-list,
.match-board,
.music-list {
  display: grid;
  gap: 10px;
}

.option-button,
.match-target,
.answer-chip,
.primary-button,
.ghost-button,
.text-submit,
.music-option {
  min-height: 46px;
  border-radius: var(--radius);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.option-button,
.music-option {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 18px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  background: #fffef8;
  border: 2px solid rgba(23, 18, 13, 0.88);
  box-shadow: 4px 4px 0 #ffab30;
}

.option-button:active,
.music-option:active,
.match-target:active,
.answer-chip:active,
.primary-button:active,
.ghost-button:active,
.text-submit:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 rgba(23, 18, 13, 0.82);
}

.option-button span,
.music-option span {
  min-width: 0;
  font-weight: 880;
  line-height: 1.35;
}

.option-key {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--coral);
  border: 2px solid rgba(23, 18, 13, 0.84);
  border-radius: 999px;
  font-size: 17px;
  font-weight: 950;
}

.option-button.correct,
.music-option.correct,
.match-target.correct,
.text-input.correct {
  border-color: rgba(23, 18, 13, 0.9);
  background: #d9ffe6;
  box-shadow: 4px 4px 0 #41bd6b;
}

.option-button.wrong,
.music-option.wrong,
.match-target.wrong,
.text-input.wrong {
  border-color: rgba(23, 18, 13, 0.9);
  background: #ffe0dc;
  box-shadow: 4px 4px 0 #df4b37;
  animation: shake 260ms ease;
}

.option-button:disabled,
.music-option:disabled {
  cursor: not-allowed;
}

.option-button.locked,
.music-option.locked {
  opacity: 0.58;
  filter: grayscale(0.18);
}

.option-button.locked:active,
.music-option.locked:active {
  transform: none;
  box-shadow: 4px 4px 0 #ffab30;
}

.cooldown-card {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  color: #3b2419;
  background: #fff0b8;
  border: 2px solid rgba(23, 18, 13, 0.86);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.78);
}

.cooldown-card strong {
  font-size: 15px;
  font-weight: 950;
}

.cooldown-card span {
  font-size: 14px;
  font-weight: 780;
  line-height: 1.45;
}

.actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}

.primary-button,
.ghost-button,
.text-submit {
  display: inline-grid;
  place-items: center;
  padding: 0 16px;
  color: var(--ink);
  font-weight: 950;
  border: 2px solid rgba(62, 38, 22, 0.88);
  box-shadow: 0 8px 18px rgba(21, 13, 7, 0.26), inset 0 1px 0 rgba(255, 249, 226, 0.54);
}

.primary-button,
.text-submit {
  background: linear-gradient(145deg, #f8dc8d, #c78339);
}

.next-button {
  min-width: 84px;
}

.primary-button:disabled,
.text-submit:disabled {
  opacity: 0.46;
  cursor: not-allowed;
  filter: grayscale(0.35);
}

.primary-button:disabled:active,
.text-submit:disabled:active {
  transform: none;
  box-shadow: 4px 4px 0 rgba(23, 18, 13, 0.86);
}

.ghost-button {
  background: rgba(255, 246, 218, 0.78);
}

.progress-wrap {
  min-width: 0;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.58);
  border: 2px solid rgba(23, 18, 13, 0.22);
  border-radius: var(--radius);
}

.progress-text {
  display: block;
  margin-bottom: 6px;
  color: rgba(23, 18, 13, 0.68);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  background: rgba(23, 18, 13, 0.12);
  border: 1px solid rgba(23, 18, 13, 0.28);
  border-radius: 999px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--coral), var(--orange), var(--teal));
  border-radius: inherit;
}

.match-row {
  display: grid;
  grid-template-columns: minmax(78px, 0.75fr) minmax(144px, 1.25fr);
  gap: 9px;
  align-items: stretch;
}

.match-term {
  min-height: 48px;
  display: grid;
  place-items: center;
  padding: 9px;
  color: var(--ink);
  font-weight: 950;
  text-align: center;
  background: #fff0b8;
  border: 2px solid rgba(23, 18, 13, 0.82);
  border-radius: var(--radius);
}

.match-target {
  width: 100%;
  display: grid;
  align-items: center;
  padding: 10px 12px;
  color: var(--soft-ink);
  text-align: left;
  background: #fffef8;
  border: 2px dashed rgba(23, 18, 13, 0.52);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.24);
}

.answer-pool {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 -2px 2px;
  padding: 8px 2px;
  background: linear-gradient(180deg, #fff8df 0%, rgba(255, 248, 223, 0.92) 70%, rgba(255, 248, 223, 0));
  backdrop-filter: blur(4px);
}

.answer-chip {
  min-height: 40px;
  padding: 0 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  background: var(--teal);
  border: 2px solid rgba(23, 18, 13, 0.84);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.78);
}

.answer-chip.used {
  opacity: 0.36;
}

.answer-chip.selected {
  color: var(--ink);
  background: var(--yellow);
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.text-input {
  min-width: 0;
  min-height: 50px;
  padding: 0 13px;
  color: var(--ink);
  background: #fffef8;
  border: 2px solid rgba(23, 18, 13, 0.88);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.28);
  font-weight: 850;
}

.music-option {
  grid-template-columns: 40px minmax(0, 1fr) 38px;
}

.note-play {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border: 2px solid rgba(23, 18, 13, 0.82);
  border-radius: 999px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  z-index: 100;
  width: min(88vw, 360px);
  padding: 12px 14px;
  color: #fff;
  text-align: center;
  font-weight: 900;
  background: rgba(23, 18, 13, 0.94);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.cover {
  position: relative;
  height: var(--viewport-height);
  min-height: var(--viewport-height);
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow-y: auto;
  padding: max(12px, env(safe-area-inset-top, 0px)) 16px calc(18px + var(--safe-bottom));
  color: #fff;
  isolation: isolate;
}

.cover::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: var(--cover-image) center / cover no-repeat;
}

.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(9, 8, 6, 0.06) 0%, rgba(13, 9, 6, 0.14) 40%, rgba(10, 8, 7, 0.42) 100%),
    radial-gradient(circle at 18% 75%, rgba(158, 91, 52, 0.34), transparent 14rem),
    radial-gradient(circle at 84% 16%, rgba(229, 188, 104, 0.34), transparent 13rem);
}

.cover-content {
  align-self: end;
  display: grid;
  gap: 14px;
  padding-bottom: clamp(86px, 14vh, 132px);
}

.cover-tools {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px));
  right: 16px;
  z-index: 2;
}

.bgm-toggle {
  min-height: 30px;
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  align-items: center;
  padding: 4px 8px;
  color: var(--ink);
  background: rgba(255, 248, 226, 0.78);
  border: 1px solid rgba(62, 38, 22, 0.5);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(21, 13, 7, 0.16), inset 0 1px 0 rgba(255, 249, 226, 0.66);
  font-weight: 950;
}

.bgm-toggle span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #2f6f4f;
  border: 1px solid rgba(23, 18, 13, 0.64);
  border-radius: 999px;
  font-size: 13px;
  line-height: 1;
}

.bgm-toggle em {
  font-size: 11px;
  line-height: 1;
}

.bgm-toggle em {
  min-width: 12px;
  color: rgba(23, 18, 13, 0.62);
  font-style: normal;
}

.bgm-toggle.is-on {
  background: rgba(234, 184, 88, 0.88);
  border-color: rgba(62, 38, 22, 0.58);
}

.bgm-toggle.is-on span {
  background: var(--green);
}

.bgm-toggle.is-on em {
  color: var(--ink);
}

.bgm-toggle:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 rgba(23, 18, 13, 0.82);
}

.bgm-toggle-compact {
  min-height: 30px;
  padding: 4px 7px;
}

.cover-brand {
  width: max-content;
  max-width: 100%;
  display: inline-grid;
  grid-auto-flow: column;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  color: var(--ink);
  font-weight: 950;
  background: rgba(255, 255, 255, 0.86);
  border: 2px solid rgba(23, 18, 13, 0.88);
  border-radius: 999px;
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.82);
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #ff6e25, #e84269);
  border-radius: 999px;
}

.cover h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(54px, 17vw, 76px);
  font-weight: 950;
  line-height: 0.96;
  text-shadow: 0 5px 0 rgba(23, 18, 13, 0.72);
}

.cover-subtitle {
  max-width: 22em;
  margin: 0;
  color: rgba(255, 255, 255, 0.94);
  font-size: 17px;
  font-weight: 760;
  line-height: 1.62;
  text-shadow: 0 2px 9px rgba(0, 0, 0, 0.28);
}

.cover-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.cover-stats span {
  min-width: 0;
  padding: 10px 8px;
  color: var(--ink);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
  background: rgba(255, 250, 240, 0.9);
  border: 2px solid rgba(23, 18, 13, 0.86);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.8);
}

.cover-stats strong {
  display: block;
  color: #e94b2f;
  font-size: 24px;
  line-height: 1;
}

.completion-summary {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  color: var(--ink);
  background: rgba(255, 250, 240, 0.92);
  border: 2px solid rgba(23, 18, 13, 0.88);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 rgba(23, 18, 13, 0.82);
}

.completion-summary span {
  font-size: 13px;
  font-weight: 900;
}

.completion-summary strong {
  color: #e94b2f;
  font-size: 22px;
  font-weight: 950;
}

.cover-route {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.cover-route::-webkit-scrollbar {
  display: none;
}

.cover-route span {
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  background: rgba(249, 233, 76, 0.92);
  border: 2px solid rgba(23, 18, 13, 0.82);
  border-radius: 999px;
}

.cover-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  width: min(82vw, 360px);
  margin: 0 auto;
}

.cover-actions .primary-button,
.cover-actions .ghost-button {
  width: 100%;
  min-height: 48px;
  color: #24170d;
  border-color: rgba(61, 36, 18, 0.88);
  border-radius: 999px;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(255, 246, 211, 0.34), rgba(255, 246, 211, 0) 46%),
    linear-gradient(145deg, rgba(247, 205, 117, 0.95), rgba(166, 99, 45, 0.96));
  box-shadow:
    0 14px 24px rgba(15, 10, 6, 0.34),
    0 0 0 5px rgba(30, 20, 12, 0.22),
    inset 0 1px 0 rgba(255, 249, 228, 0.72);
}

.ending-light {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(255, 245, 190, 0.78), transparent 42%);
  animation: lightPulse 1200ms ease forwards;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-6px); }
  65% { transform: translateX(5px); }
}

@keyframes lightPulse {
  from {
    opacity: 0;
    transform: scale(0.3);
  }
  45% {
    opacity: 1;
  }
  to {
    opacity: 0;
    transform: scale(1.45);
  }
}

@media (min-width: 720px) {
  body {
    padding: 20px 0;
  }

  .app-shell,
  .cover {
    height: calc(100vh - 40px);
    min-height: calc(100vh - 40px);
    border-radius: 18px;
  }

  .screen {
    border-radius: 18px;
  }
}

@media (max-width: 720px) {
  :root {
    --browser-bottom: 0px;
    --stage-height: clamp(330px, 44vh, 372px);
    --challenge-stage-height: clamp(306px, 41vh, 348px);
  }

  @supports (height: 100dvh) {
    :root {
      --stage-height: clamp(330px, 44dvh, 372px);
      --challenge-stage-height: clamp(306px, 41dvh, 348px);
    }
  }

  .topbar {
    padding-top: calc(max(9px, env(safe-area-inset-top, 0px)) + 2px);
  }

  .content-challenge .stage {
    padding-top: 10px;
  }

  .content-challenge .mission-card p {
    -webkit-line-clamp: 1;
  }

  .content-challenge .hero-image,
  .content-challenge .hero-image-natural {
    width: min(100%, 340px);
  }

  .content-challenge .hero-image-natural {
    height: auto;
  }

  .panel-challenge {
    padding-top: 18px;
  }

}

@media (max-height: 740px) {
  :root {
    --stage-height: clamp(316px, 42vh, 352px);
    --challenge-stage-height: clamp(292px, 39vh, 326px);
  }

  @supports (height: 100dvh) {
    :root {
      --stage-height: clamp(316px, 42dvh, 352px);
      --challenge-stage-height: clamp(292px, 39dvh, 326px);
    }
  }

  .topbar {
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
  }

  .stage {
    padding-top: 12px;
  }

  .hero-image,
  .hero-image-natural {
    width: min(100%, 330px);
  }

  .hero-image-natural {
    height: auto;
  }

  .mission-card p {
    -webkit-line-clamp: 1;
  }

  .chapter-trail em {
    display: none;
  }

  .panel {
    padding-top: 18px;
  }

  .story-title {
    font-size: 23px;
  }

  .story-text {
    font-size: 15.5px;
    line-height: 1.58;
  }
}

@media (max-height: 680px) {
  :root {
    --stage-height: clamp(296px, 40vh, 326px);
    --challenge-stage-height: clamp(274px, 37vh, 304px);
  }

  @supports (height: 100dvh) {
    :root {
      --stage-height: clamp(296px, 40dvh, 326px);
      --challenge-stage-height: clamp(274px, 37dvh, 304px);
    }
  }

  .mission-card,
  .route-card {
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .hero-image,
  .hero-image-natural {
    width: min(100%, 300px);
  }

  .hero-image-natural {
    height: auto;
  }

  .scene-badge {
    min-width: 116px;
    margin-top: -24px;
    padding: 6px 14px;
  }

  .panel {
    padding-top: 16px;
  }

  .story-title {
    font-size: 22px;
  }

  .story-text {
    font-size: 15px;
    line-height: 1.52;
  }
}

@media (max-width: 380px) {
  .mission-hud {
    grid-template-columns: minmax(0, 1fr) 88px;
    gap: 6px;
  }

  .route-card {
    display: block;
  }

  .route-card strong,
  .route-card em {
    margin-top: 4px;
  }

  .story-title {
    font-size: 23px;
  }

  .story-text {
    font-size: 15px;
  }

  .question {
    font-size: 17px;
  }

  .match-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .topbar {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 6px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .timer-badge span {
    display: none;
  }

  .timer-badge strong {
    min-width: 39px;
  }

  .mission-hud {
    grid-template-columns: minmax(0, 1fr) 84px;
  }

  .route-card strong {
    font-size: 13px;
  }

  .actions {
    gap: 6px;
  }

  .next-button {
    min-width: 78px;
  }
}

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