:root {
  --room: #140e0b;
  --room-glow: #3a2414;
  --wood: #5a3b28;
  --wood-deep: #2c1c14;
  --lantern: #e2a04a;
  --paper: #f3e6d0;
  --paper-deep: #e7d3b4;
  --ink: #24170f;
  --ink-soft: #5c4636;
  --cloak: #5e6a46;
  --cloak-deep: #3f4930;
  --carpet: #6d4c68;
  --clay: #e0b48d;
  --danger: #8a3d32;
  --line: rgba(243, 230, 208, 0.16);
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --serif: "Noto Serif TC", "Songti TC", serif;
  --display: "ZCOOL XiaoWei", "Noto Serif TC", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  color: var(--paper);
  font-family: var(--sans);
  font-size: 1.05rem;
  line-height: 1.65;
  background:
    radial-gradient(circle at 50% -10%, rgba(226, 160, 74, 0.18), transparent 36%),
    radial-gradient(circle at 50% 120%, rgba(109, 76, 104, 0.2), transparent 32%),
    var(--room);
}

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

button { cursor: pointer; }

.room {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.top[hidden] { display: none; }

.top {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "brand progress" "pips pips";
  gap: 8px 16px;
  align-items: end;
  margin-bottom: 14px;
}

.brand-block { grid-area: brand; }

.brand {
  margin: 0;
  font-family: var(--display);
  font-size: 2rem;
  letter-spacing: 0.12em;
  line-height: 1;
}

.place, .progress {
  margin: 4px 0 0;
  color: rgba(243, 230, 208, 0.72);
  font-size: 0.92rem;
}

.progress { grid-area: progress; text-align: right; }

.pips {
  grid-area: pips;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pips li {
  width: 28px;
  height: 8px;
  border-radius: 999px;
  background: rgba(243, 230, 208, 0.16);
}

.pips li.is-done { background: var(--cloak); }
.pips li.is-now { background: var(--lantern); }

.frame {
  position: relative;
  overflow: hidden;
  padding: 12px 12px 18px;
  border-radius: 18px 18px 10px 10px;
  background:
    linear-gradient(var(--carpet), var(--carpet)) bottom / 100% 16px no-repeat,
    linear-gradient(180deg, #6a4632, var(--wood-deep));
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(243, 230, 208, 0.18);
}

.frame img,
.board {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: min(48vh, 480px);
  object-fit: cover;
  border-radius: 8px;
  background: #3a2618;
}

.frame img.is-fresh { animation: rise 0.45s ease; }

.spot {
  position: absolute;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 16px;
}

.spot span {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(20, 14, 11, 0.72);
  color: var(--paper);
  font-size: 0.78rem;
  white-space: nowrap;
  opacity: 1;
}

.spot:hover,
.spot:focus-visible {
  background: rgba(243, 230, 208, 0.14);
  outline: 2px solid rgba(243, 230, 208, 0.9);
  outline-offset: -6px;
}

.spot:hover span,
.spot:focus-visible span,
.spot.is-speaking span { opacity: 1; }

.bubble {
  position: absolute;
  z-index: 4;
  top: 8px;
  left: 8px;
  width: min(240px, 52%);
  max-height: calc(100% - 28px);
  overflow: auto;
  padding: 10px 12px 12px;
  border-radius: 18px;
  background: #f7efe2;
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.bubble.is-right { left: auto; right: 8px; }

.bubble-name {
  margin: 0 0 4px;
  color: var(--carpet);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

.bubble p { margin: 0; }

.bubble form {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.bubble input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(36, 23, 15, 0.16);
  border-radius: 999px;
  background: #fffaf3;
  color: var(--ink);
  font: inherit;
}

.bubble button {
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--cloak);
  color: #f6f1e6;
  font: inherit;
}

.bubble .say.bad { color: var(--danger); }
.bubble .say.ok { color: var(--cloak-deep); }

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.token,
.choice,
.primary,
.ghost,
.texty {
  min-height: 48px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.token {
  padding: 0 16px;
  background: var(--paper);
  color: var(--ink);
}

.token.is-on,
.primary {
  background: var(--cloak);
  color: #f6f1e6;
}

.primary { padding: 0 22px; border: 0; }
.primary:hover { background: var(--cloak-deep); }
.primary:disabled {
  background: rgba(243, 230, 208, 0.16);
  color: rgba(243, 230, 208, 0.45);
  cursor: default;
}

.paper {
  margin-top: 14px;
  padding: 16px 18px 18px;
  border-radius: 16px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.who {
  margin: 0 0 4px;
  color: var(--carpet);
  font-size: 0.86rem;
  letter-spacing: 0.08em;
}

.say { margin: 0; font-size: 1.08rem; }

.say.bad { color: var(--danger); }
.say.ok { color: var(--cloak-deep); }

.paper .quote:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.quote {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(36, 23, 15, 0.1);
}

.quote small {
  display: block;
  margin-bottom: 4px;
  color: var(--ink-soft);
  letter-spacing: 0.12em;
}

.classic {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.45rem;
  line-height: 1.5;
  font-weight: 700;
}

label.listen {
  display: block;
  margin: 14px 0 8px;
  color: var(--ink-soft);
}

textarea {
  width: 100%;
  min-height: 96px;
  padding: 12px 14px;
  border: 1px solid rgba(36, 23, 15, 0.16);
  border-radius: 12px;
  background: #fffaf3;
  color: var(--ink);
  resize: vertical;
}

textarea:focus-visible,
.token:focus-visible,
.primary:focus-visible,
.ghost:focus-visible,
.choice:focus-visible,
.texty:focus-visible,
.pin:focus-visible {
  outline: 3px solid var(--lantern);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  position: sticky;
  bottom: 0;
  padding: 12px 0 4px;
  background: linear-gradient(rgba(20, 14, 11, 0), var(--room) 28%);
}

.ghost, .choice, .texty {
  padding: 0 16px;
  background: transparent;
  border-color: rgba(36, 23, 15, 0.2);
}

.actions .ghost,
.actions .choice {
  color: var(--paper);
  border-color: rgba(243, 230, 208, 0.4);
}

.actions .ghost:hover,
.actions .choice:hover { background: rgba(243, 230, 208, 0.08); }

.paper .texty { color: var(--ink); }

.sheet .who { color: var(--lantern); }

.help {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--paper-deep);
  border-left: 4px solid var(--carpet);
}

.help p { margin: 6px 0 0; }

.choices { display: flex; flex-wrap: wrap; gap: 10px; }

.board {
  position: relative;
  background:
    radial-gradient(circle at 18% 70%, rgba(90, 58, 36, 0.25), transparent 28%),
    linear-gradient(180deg, #d7b48a, #8d6244);
}

.road {
  position: absolute;
  z-index: 2;
  left: 8%;
  right: 8%;
  top: 62%;
  height: 14px;
  border-radius: 999px;
  background: #4a3022;
}

.pin {
  position: absolute;
  top: -34px;
  left: 0;
  min-width: 72px;
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 14px 14px 14px 4px;
  background: var(--clay);
  color: var(--ink);
  font-weight: 700;
  transition: left 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.pin.is-moved { left: calc(100% - 76px); }

.dest {
  position: absolute;
  right: 0;
  top: 24px;
  color: rgba(36, 23, 15, 0.62);
  font-size: 0.92rem;
}

.map-copy {
  position: absolute;
  left: 8%;
  right: 8%;
  top: 12%;
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.15rem;
}

.gloss {
  margin: 12px 0 0;
  color: var(--ink-soft, #5c4636);
}

.sheet {
  margin-top: 8px;
  padding: 8px 4px 0;
}

.sheet h1 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 2.4rem;
  letter-spacing: 0.08em;
  font-weight: 400;
}

.entry {
  padding: 16px 0;
  border-top: 1px solid rgba(243, 230, 208, 0.14);
}

.entry p { margin: 4px 0; }
.entry .original { font-family: var(--serif); font-size: 1.2rem; }
.muted { color: rgba(243, 230, 208, 0.7); }

.title-block { padding-top: 12px; }
.title-block h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(3.2rem, 8vw, 5.4rem);
  letter-spacing: 0.14em;
  font-weight: 400;
  line-height: 0.95;
}
.title-block .volume {
  margin: 8px 0 0;
  letter-spacing: 0.22em;
  color: var(--lantern);
}
.lede {
  max-width: 38rem;
  margin: 14px 0 0;
  color: rgba(243, 230, 208, 0.86);
}

.back {
  display: inline-block;
  margin-top: 18px;
  color: rgba(243, 230, 208, 0.55);
  font-size: 0.88rem;
}

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

@keyframes rise {
  from { opacity: 0.35; transform: scale(1.015); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 720px) {
  .room { width: min(100% - 20px, 980px); padding-top: 16px; }
  .classic { font-size: 1.28rem; }
  .frame img, .board { max-height: 34vh; }
  .top { grid-template-columns: 1fr; grid-template-areas: "brand" "progress" "pips"; }
  .progress { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .frame img.is-fresh,
  .pin { animation: none; transition: none; }
}
