:root {
  --ink: #fff6df;
  --soft: #ecd8b0;
  --gold: #e6b54a;
  --font: "Noto Sans SC", "PingFang SC", sans-serif;
  --display: "Fredoka", "Noto Sans SC", sans-serif;
  --ipa: "Andika", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #140c0c;
}

button { font-family: inherit; cursor: pointer; border: 0; }

.hidden { display: none !important; }

.app {
  min-height: 100dvh;
  position: relative;
  overflow-x: hidden;
  background: #1a1010;
}

.sky {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(60% 40% at 70% 0%, rgba(80, 180, 170, 0.22), transparent 55%),
    linear-gradient(180deg, #2a1814, #120c0c 72%);
}

.screen {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 230, 170, 0.1), transparent 42%),
    rgba(28, 16, 14, 0.88);
  border: 3px solid #3d2412;
  box-shadow: 0 10px 0 #0c0806, inset 0 1px 0 rgba(255, 230, 180, 0.14);
}

.kicker,
.title-en {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 700;
  color: var(--gold);
}

.title-stack {
  position: absolute;
  left: 28px;
  top: 28px;
  width: min(460px, calc(100% - 180px));
  padding: 22px 24px 20px;
  border-radius: 24px;
}

.home-art {
  position: absolute;
  right: 4vw;
  top: 12vh;
  width: min(46vw, 640px);
  border-radius: 28px;
  overflow: hidden;
  border: 4px solid #3d2412;
  box-shadow: 0 14px 0 #0c0806;
}

.home-art img {
  display: block;
  width: 100%;
  height: auto;
}

.title-stack h1,
.panel h2,
.board h2 {
  margin: 8px 0 0;
  font-family: var(--display);
  line-height: 1.1;
}

.title-stack h1 {
  font-size: clamp(32px, 5vw, 52px);
  text-shadow: 0 4px 0 #2a1a0c;
}

.title-en { margin-top: 10px; font-size: 16px; }

.home-progress {
  position: absolute;
  top: 26px;
  right: 28px;
  z-index: 3;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  color: #3d220c;
  background: linear-gradient(180deg, #ffe08a, #d7a03c);
  border: 3px solid #7a4814;
}

.home-panel {
  position: absolute;
  left: 50%;
  bottom: 5vh;
  transform: translateX(-50%);
  z-index: 5;
  width: min(720px, calc(100% - 36px));
  padding: 22px 24px 24px;
  text-align: center;
  border-radius: 24px;
}

.lede,
.tip {
  margin: 8px 0 0;
  color: var(--soft);
  line-height: 1.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.primary,
.ghost,
.back,
.listen,
.link-btn {
  padding: 12px 22px;
  font-size: 18px;
  font-weight: 800;
  border-radius: 999px;
}

.primary {
  color: #fff8e8;
  background: linear-gradient(180deg, #2f8a7a, #145248);
  border: 3px solid #083830;
  box-shadow: 0 6px 0 #042420;
}

.primary.big { padding: 15px 36px; font-size: 24px; }
.primary:hover { transform: translateY(1px); }

.ghost,
.back,
.link-btn {
  color: #3d220c;
  text-decoration: none;
  background: linear-gradient(180deg, #ffe7a8, #e2b24a);
  border: 3px solid #7a4814;
  box-shadow: 0 6px 0 #4a2a08;
}

.link-btn { display: inline-block; }

.listen {
  margin-top: 8px;
  padding: 8px 16px;
  font-size: 15px;
  color: #fff8e8;
  background: linear-gradient(180deg, #2a7a6e, #145248);
  border: 3px solid #083830;
  box-shadow: 0 4px 0 #042420;
}

.panel-wrap {
  min-height: 100dvh;
  padding: 28px 22px;
}

.panel.wide {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding: 22px;
  border-radius: 28px;
}

.panel header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.help-grid,
.world-grid,
.stage-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

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

.help-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(20, 10, 6, 0.28);
  border: 2px solid rgba(232, 195, 106, 0.28);
}

.help-card strong { display: block; margin-bottom: 6px; }

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

.world-card,
.stage-node {
  text-align: left;
  padding: 16px;
  border-radius: 20px;
  color: #3d220c;
  border: 3px solid #5a3010;
  box-shadow: 0 8px 0 #2a1406;
}

.world-card {
  background: linear-gradient(180deg, #fff1c4, #e2b24a);
  min-height: 210px;
}

.world-card.day1,
.world-card.day2 { background: linear-gradient(180deg, #d8f3ec, #4aa89a); }
.world-card.day3,
.world-card.day4,
.world-card.day5,
.world-card.day6 { background: linear-gradient(180deg, #ffe1b0, #e08a3a); }
.world-card.day7,
.world-card.day8,
.world-card.day9,
.world-card.day10 { background: linear-gradient(180deg, #ffd0c4, #d45454); }
.world-card.day11,
.world-card.day12,
.world-card.day13 { background: linear-gradient(180deg, #e4d4ff, #7a5ab4); color: #241434; }

.world-card h3 {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: 24px;
}

.world-card p { margin: 6px 0 0; color: #4a3014; }
.world-card.day11 p,
.world-card.day12 p,
.world-card.day13 p { color: #2a1840; }

.world-card.open:hover,
.stage-node.open:hover { transform: translateY(-3px); }

.world-card .done {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(20, 12, 8, 0.16);
  font-weight: 800;
}

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

.stage-node {
  background: linear-gradient(180deg, #fff4d2, #e8c36a);
  min-height: 132px;
}

.stage-node .stage-num {
  font-family: var(--display);
  font-size: 28px;
}

.stage-node strong { display: block; margin-top: 4px; font-size: 16px; }

.stage-patient {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: #5a3410;
}

.stage-patient img {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #7a4814;
  pointer-events: none;
}

.stage-node .meta {
  margin-top: 8px;
  font-size: 13px;
  color: #6a4018;
}

.stage-node.done {
  background: linear-gradient(180deg, #dff6c8, #8fce6e);
}

.play {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  padding: 12px 16px 16px;
}

.play-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.board {
  border-radius: 16px;
  padding: 8px 12px 10px;
  max-width: min(360px, 48vw);
  background:
    linear-gradient(180deg, rgba(255, 230, 170, 0.1), transparent 40%),
    rgba(28, 16, 14, 0.86);
  border: 1px solid rgba(232, 196, 120, 0.28);
}

.board.compact h2 {
  margin: 4px 0 0;
  font-size: 18px;
}

.patient-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  background: rgba(28, 16, 14, 0.86);
  border: 1px solid rgba(232, 196, 120, 0.28);
}

.patient-chip img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid #e6b54a;
  pointer-events: none;
}

.patient-chip .kicker { font-size: 10px; }

.patient-chip strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.patient-chip p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--soft);
}

.status {
  min-width: 148px;
  text-align: right;
  color: #3d220c;
  background: linear-gradient(180deg, #ffe08a, #d7a03c);
  border-color: #7a4814;
}

.status p { margin: 0 0 4px; font-weight: 800; font-size: 14px; }

.play-layout {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.word-board {
  padding: 18px 18px 20px;
  border-radius: 22px;
  text-align: center;
}

.cue-kicker {
  margin: 0;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
}

.cue-word {
  margin: 10px 0 0;
  font-family: var(--ipa);
  font-size: clamp(36px, 5vw, 58px);
  line-height: 1.15;
  color: #fff4d0;
  text-shadow: 0 3px 0 #2a1608;
}

.cue-word .grapheme {
  text-decoration: underline;
  text-decoration-color: #ffe08a;
  text-decoration-thickness: 0.14em;
  text-underline-offset: 0.16em;
  text-decoration-skip-ink: none;
  font-style: normal;
}

.cue-zh {
  margin: 6px 0 0;
  font-size: 20px;
  color: var(--soft);
}

.cue-ipa {
  margin: 10px 0 0;
  min-height: 1.3em;
  font-family: var(--ipa);
  font-size: 22px;
  color: #ffe08a;
}

.or-wrap {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.or-frame {
  position: relative;
  width: min(100%, calc(100cqh * 16 / 9));
  max-height: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  overflow: hidden;
  border: 4px solid #3d2412;
  box-shadow: 0 12px 0 #0c0806;
  background: #1a1010;
}

.or-bg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.patient-face {
  position: absolute;
  left: 43%;
  top: 2%;
  width: 12%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid rgba(255, 230, 180, 0.55);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 2;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.patient-plate {
  position: absolute;
  left: 42%;
  top: 15%;
  width: 14%;
  margin: 0;
  padding: 2px 0;
  text-align: center;
  font-size: clamp(10px, 1.2vw, 13px);
  font-weight: 800;
  color: #3d220c;
  background: linear-gradient(180deg, #ffe08a, #d7a03c);
  border-radius: 999px;
  border: 2px solid #7a4814;
  pointer-events: none;
  z-index: 2;
}

.cavity {
  position: absolute;
  left: 28%;
  top: 34%;
  width: 44%;
  height: 42%;
  z-index: 6;
  display: grid;
  grid-template-columns: 1fr 1fr;
  place-items: center;
  gap: 4%;
  pointer-events: auto;
}

.tumor {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(92%, 168px);
  aspect-ratio: 1;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  background-color: transparent;
  filter: drop-shadow(0 8px 10px rgba(40, 8, 8, 0.45));
  transition: transform 0.16s ease, filter 0.16s ease;
}

.tumor::before {
  content: "";
  position: absolute;
  inset: -10%;
}

.tumor span {
  display: inline-grid;
  place-items: center;
  min-width: 72%;
  padding: 5px 8px;
  border-radius: 999px;
  font-family: var(--ipa);
  font-size: clamp(16px, 2.1vw, 24px);
  font-weight: 800;
  color: #fff8e4;
  background: rgba(18, 8, 6, 0.62);
  text-shadow: 0 1px 0 #2a1008;
  pointer-events: none;
}

.tumor-red { background-image: url("../assets/tumor-red.png"); }
.tumor-gold { background-image: url("../assets/tumor-gold.png"); }
.tumor-teal { background-image: url("../assets/tumor-teal.png"); }
.tumor-purple { background-image: url("../assets/tumor-purple.png"); }

.tumor:hover { transform: scale(1.08); }
.tumor.wrong { animation: tumorWrong 0.42s ease; }
.tumor.removed {
  transform: scale(0.2);
  opacity: 0.15;
  filter: grayscale(0.4) brightness(1.4);
}
.tumor.dim { opacity: 0.45; filter: grayscale(0.35); }

.or-frame.is-scream { animation: tableShake 0.45s ease; }
.or-frame.is-scream .patient-face {
  transform: scale(1.14);
  border-color: #ff6a4a;
  box-shadow: 0 0 28px rgba(255, 70, 50, 0.6);
}
.or-frame.is-scream::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 40%, rgba(255, 60, 50, 0.22), transparent 55%);
  pointer-events: none;
}

.or-frame.is-success::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(120, 255, 180, 0.16), transparent 52%);
  pointer-events: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 8;
  margin: 0;
  padding: 10px 20px;
  border-radius: 999px;
  pointer-events: none;
  background: #2a150a;
  border: 2px solid #c9a056;
  font-weight: 800;
}

.result-card {
  position: absolute;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%);
  width: min(560px, calc(100% - 36px));
  text-align: center;
  padding: 24px;
  border-radius: 28px;
  z-index: 8;
}

.result-words {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.word-chip {
  min-width: 108px;
  padding: 10px 14px;
  border-radius: 16px;
  font-family: var(--ipa);
  font-size: 18px;
  font-weight: 800;
  color: #fff8d2;
  background: linear-gradient(180deg, #3d8a7a, #145248);
  border: 1px solid #ffe08a;
}

.result-score {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: 42px;
  color: var(--gold);
}

@keyframes tumorWrong {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px) rotate(-6deg); }
  75% { transform: translateX(8px) rotate(6deg); }
}

@keyframes tableShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px) rotate(-0.4deg); }
  40% { transform: translateX(7px) rotate(0.4deg); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@media (max-width: 1100px) {
  .world-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .play { height: auto; max-height: none; overflow: auto; }
  .play-layout { grid-template-columns: 1fr; }
  .word-board { order: -1; }
  .or-wrap { min-height: 52vw; }
  .or-frame { width: 100%; }
  .cavity {
    left: 27%;
    top: 34%;
    width: 46%;
    height: 42%;
  }
  .patient-face { left: 43%; width: 13%; }
}

@media (max-width: 720px) {
  .help-grid { grid-template-columns: 1fr; }
  .world-grid,
  .stage-grid { grid-template-columns: 1fr 1fr; }
  .title-stack { left: 16px; top: 18px; width: calc(100% - 32px); }
  .home-art { display: none; }
  .home-progress { top: auto; bottom: 28vh; right: 18px; }
  .play-hud { flex-wrap: wrap; }
  .board { max-width: none; }
}
