:root {
  --ink: #172126;
  --deep: #233239;
  --paper: #f6f1e8;
  --cream: #fffaf0;
  --mint: #a9d7bd;
  --mint-dark: #39745e;
  --red: #d9574f;
  --red-dark: #8f3435;
  --yellow: #f0c64c;
  --blue: #6ba8c7;
  --line: #26363d;
  --shadow: 0 5px 0 rgba(23, 33, 38, .28);
  --pixel-font: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
body {
  overflow-x: hidden;
  color: var(--ink);
  background: #10191d;
  font-family: var(--pixel-font);
  letter-spacing: 0;
}
button { font: inherit; }
button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

.game-shell { min-height: 100vh; background: #10191d; }
.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(260px, 500px) minmax(210px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  color: #fff;
  background: var(--deep);
  border-bottom: 4px solid #111b20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-cross {
  width: 40px; height: 40px; display: grid; place-items: center;
  background: var(--red); border: 3px solid #fff; box-shadow: 3px 3px 0 #111b20;
  font-size: 29px; font-weight: 900; line-height: 1;
}
.brand b, .brand small { display: block; }
.brand b { font-size: 16px; }
.brand small { margin-top: 2px; color: #b9c7cb; font-size: 11px; }
.chapter-progress { text-align: center; }
.chapter-progress > span { display: block; margin-bottom: 7px; color: #d9e4e5; font-size: 12px; font-weight: 700; }
.progress-track { height: 9px; overflow: hidden; background: #111b20; border: 2px solid #475b64; }
.progress-track i { display: block; width: 2%; height: 100%; background: var(--yellow); transition: width .45s steps(8); }
.status-strip { display: flex; justify-content: flex-end; align-items: center; gap: 11px; }
.status-strip > span { min-width: 68px; color: #dce9e9; font-size: 13px; }
.status-strip > span:first-child { color: #8ed6e8; }
.status-strip > span:nth-child(2) { color: var(--yellow); }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; padding: 0;
  color: #fff; background: #344952; border: 2px solid #75909a; border-radius: 3px;
  box-shadow: 2px 2px 0 #111b20; cursor: pointer; font-weight: 900; font-size: 20px;
}
.icon-btn:hover { background: #42606b; transform: translateY(-1px); }

.game-main { min-height: calc(100vh - 72px); display: grid; grid-template-columns: minmax(0, 1fr) 320px; }
.world { position: relative; min-height: 690px; overflow: hidden; isolation: isolate; background: #c8d9d1; }
.ambient-light { position: absolute; inset: 0; z-index: -4; background: #dce8df; }
.wall-top {
  position: absolute; inset: 0 0 auto; height: 22%; z-index: -2;
  background: repeating-linear-gradient(90deg, #e8dfd3 0 90px, #ddd3c8 90px 92px);
  border-bottom: 9px solid #6d8f89;
  box-shadow: inset 0 -4px 0 #b7c9c0;
}
.wall-top::after {
  content: ""; position: absolute; inset: auto 0 -19px; height: 10px;
  background: #f4eee6; border-block: 2px solid #596a6b;
}
.floor-grid {
  position: absolute; inset: 22% 0 0; z-index: -3;
  background-color: #bcd2c7;
  background-image: linear-gradient(rgba(61,100,89,.12) 2px, transparent 2px), linear-gradient(90deg, rgba(61,100,89,.12) 2px, transparent 2px);
  background-size: 64px 64px;
  transform: perspective(500px) rotateX(5deg); transform-origin: top center;
}
.floor-grid::after {
  content: ""; position: absolute; inset: 28% 10% 17%;
  border: 4px dashed rgba(255,255,255,.55); background: rgba(255,255,255,.12);
}
.location { position: absolute; z-index: 2; text-align: center; transition: filter .2s, transform .2s; }
.location img { display: block; width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(5px 7px 0 rgba(32,54,57,.18)); }
.location span {
  display: inline-block; margin-top: -3px; padding: 4px 8px; color: #fff; background: #263b42;
  border: 2px solid #fff; box-shadow: 2px 2px 0 #142026; font-size: 10px; font-weight: 800;
}
.location.active { filter: brightness(1.1) saturate(1.2); animation: targetPulse 1.2s steps(2) infinite; }
.reception { left: 5%; top: 26%; width: 17%; height: 26%; }
.waiting { left: 27%; top: 25%; width: 17%; height: 22%; }
.doctor { left: 50%; top: 25%; width: 17%; height: 25%; }
.pharmacy { right: 7%; top: 27%; width: 11%; height: 24%; }
.injection { right: 9%; bottom: 12%; width: 12%; height: 17%; }
.exit { left: 7%; bottom: 7%; width: 15%; height: 23%; }
.world-decor { position: absolute; z-index: 1; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(4px 6px 0 rgba(32,54,57,.14)); }
.decor-plant { right: 24%; top: 7%; width: 8%; height: 14%; }
.decor-water { left: 33%; bottom: 6%; width: 8%; height: 16%; }
.decor-sign { left: 43%; bottom: 9%; width: 8%; height: 16%; }

.sprite {
  position: absolute; z-index: 8; width: 44px; height: 58px; transform: translate(-50%, -70%);
  transition: left .55s steps(8), top .55s steps(8); filter: drop-shadow(4px 5px 0 rgba(20,32,38,.25));
}
.sprite::before {
  content: ""; position: absolute; left: 8px; top: 22px; width: 28px; height: 28px;
  background: var(--red); border: 3px solid var(--line); border-radius: 3px 3px 8px 8px;
}
.sprite::after {
  content: ""; position: absolute; left: 4px; bottom: 0; width: 14px; height: 12px;
  background: var(--deep); border: 3px solid var(--line); box-shadow: 22px 0 0 -3px var(--deep), 22px 0 0 0 var(--line);
}
.sprite-face {
  position: absolute; left: 7px; top: 0; z-index: 2; width: 30px; height: 27px; display: grid; place-items: center;
  color: var(--ink); background: #f2c7a5; border: 3px solid var(--line); border-radius: 5px; font-size: 11px; font-weight: 900;
}
.sprite i { position: absolute; left: 10px; top: -4px; z-index: 3; width: 25px; height: 8px; background: #5a3f31; border: 3px solid var(--line); }
.player::before { background: #d5b047; }
.friend { left: 25%; top: 75%; transform: translate(-50%, -70%) scale(.92); }
.friend::before { background: var(--red); }
.doctor-npc { left: 60%; top: 43%; transform: translate(-50%, -70%) scale(.92); }
.doctor-npc::before { background: #ecf0e8; }
.doctor-npc i { background: #d9e4e2; }
.nurse-sprite {
  position: absolute; left: 82%; top: 72%; z-index: 7; width: 52px; height: 52px;
  background-image: url("nurse.png"); background-size: 156px 156px; background-position: 0 0;
  image-rendering: pixelated; filter: drop-shadow(4px 5px 0 rgba(20,32,38,.22));
  transform: translate(-50%, -50%) scale(1.2); animation: nurseIdle 1.8s steps(3) infinite;
}
.player { left: 18%; top: 74%; }
.player.walking, .friend.walking { animation: playerBob .28s steps(2) infinite; }
.quest-marker {
  position: absolute; left: 82%; top: 61%; z-index: 10; width: 27px; height: 33px; display: grid; place-items: center;
  color: #fff; background: var(--red); border: 3px solid #fff; box-shadow: 3px 3px 0 var(--deep);
  font-weight: 1000; animation: markerBounce .75s steps(4) infinite;
}
.clock-panel {
  position: absolute; top: 6%; left: 50%; z-index: 1; min-width: 100px; padding: 8px 12px;
  color: #c7f1df; background: #152327; border: 4px solid #718582; box-shadow: 4px 4px 0 rgba(26,39,43,.28); text-align: center;
}
.clock-panel span, .clock-panel small { display: block; color: #8aa19d; font-size: 9px; }
.clock-panel b { display: block; margin: 2px 0; font-family: monospace; font-size: 19px; letter-spacing: 0; }
.controls-hint { position: absolute; left: 20px; bottom: 16px; z-index: 12; display: flex; align-items: center; gap: 6px; color: #294449; font-size: 10px; font-weight: 700; }
kbd { min-width: 27px; padding: 4px 5px; background: #f7f3e8; border: 2px solid #526a6e; box-shadow: 2px 2px 0 #526a6e; text-align: center; font: 700 9px monospace; }
.toast {
  position: absolute; left: 50%; bottom: 22px; z-index: 40; max-width: min(520px, 82%); padding: 10px 15px;
  color: #fff; background: #20363d; border: 3px solid #fff; box-shadow: 4px 4px 0 rgba(20,32,38,.45);
  font-size: 12px; font-weight: 700; transform: translate(-50%, 24px); opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.mobile-pad { display: none; }

.mission-panel { position: relative; z-index: 20; padding: 28px 22px; background: var(--paper); border-left: 5px solid var(--deep); box-shadow: -7px 0 0 rgba(35,50,57,.18); }
.mission-panel::before { content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .16; background-image: radial-gradient(#315a58 1px, transparent 1px); background-size: 7px 7px; }
.mission-panel > * { position: relative; }
.mission-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding-bottom: 18px; border-bottom: 3px solid #d5cdbc; }
.eyebrow { display: block; color: var(--red-dark); font-size: 10px; font-weight: 900; letter-spacing: .12em; }
.mission-head h1 { margin: 5px 0 0; font-size: 23px; letter-spacing: 0; }
.phase-tag { padding: 6px 8px; color: #fff; background: var(--red); border: 2px solid var(--red-dark); box-shadow: 2px 2px 0 var(--red-dark); font-size: 10px; font-weight: 900; white-space: nowrap; }
.mission-text { min-height: 54px; margin: 18px 0; color: #4d5e62; font-size: 13px; line-height: 1.7; }
.objective-list { display: grid; gap: 8px; }
.objective {
  display: grid; grid-template-columns: 25px 1fr; gap: 9px; align-items: center; padding: 10px;
  background: rgba(255,255,255,.58); border: 2px solid #d2c9b7; font-size: 12px; font-weight: 700;
}
.objective i { width: 21px; height: 21px; display: grid; place-items: center; font-style: normal; color: #fff; background: #74888a; border: 2px solid var(--deep); font-size: 9px; }
.objective.done { color: #4c7765; text-decoration: line-through; opacity: .68; }
.objective.done i { background: var(--mint-dark); }
.objective.active { border-color: var(--red); box-shadow: 3px 3px 0 rgba(143,52,53,.18); }
.objective.active i { background: var(--red); }
.lexicon-mini { margin-top: 26px; padding-top: 18px; border-top: 3px solid #d5cdbc; }
.lexicon-title { display: flex; justify-content: space-between; font-size: 11px; font-weight: 900; }
.lexicon-title small { display: block; margin-top: 3px; color: #7b8584; font-size: 9px; font-weight: 600; }
.lexicon-title b { color: var(--mint-dark); }
.word-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.word-chip { padding: 6px 7px; color: #536368; background: #e3ddd0; border: 2px solid #c8bfaf; border-radius: 2px; cursor: pointer; font-size: 10px; font-weight: 800; }
.word-chip:hover { color: #fff; background: #526d68; border-color: #304944; transform: translateY(-1px); }
.word-chip.mastered { color: #fff; background: var(--mint-dark); border-color: #285344; }

.modal { position: fixed; inset: 0; z-index: 100; display: none; place-items: center; padding: 20px; }
.modal.open { display: grid; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(13,23,27,.72); backdrop-filter: blur(2px); }
.dialog-card {
  position: relative; width: min(720px, 100%); max-height: min(82vh, 760px); overflow: auto;
  color: var(--ink); background: var(--cream); border: 5px solid var(--deep); box-shadow: 10px 10px 0 rgba(0,0,0,.32);
}
.dialog-card::after { content: ""; position: absolute; inset: 7px; pointer-events: none; border: 2px solid #d8cfbd; }
.dialog-top { position: relative; z-index: 2; display: grid; grid-template-columns: 62px 1fr auto; gap: 13px; align-items: center; padding: 18px 20px 13px; border-bottom: 4px solid #ded4c2; }
.speaker-portrait { width: 58px; height: 58px; display: grid; place-items: center; color: #fff; background: var(--mint-dark); border: 4px solid var(--deep); box-shadow: 3px 3px 0 #c9beab; font-size: 22px; font-weight: 900; }
.dialog-heading span { color: var(--red-dark); font-size: 11px; font-weight: 900; }
.dialog-heading h2 { margin: 4px 0 0; font-size: 20px; letter-spacing: 0; }
.close-btn { width: 34px; height: 34px; color: var(--ink); background: #ddd5c5; border-color: #8e877b; box-shadow: none; }
.dialog-tools { display: flex; gap: 6px; }
.dialog-body { position: relative; z-index: 2; padding: 22px; }
.dialog-actions { position: relative; z-index: 2; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; padding: 0 22px 22px; }
.dialog-copy { margin: 0; color: #3b4b4f; font-size: 14px; line-height: 1.8; }
.speech-line { margin: 0 0 15px; padding: 13px 15px; background: #edf4ed; border-left: 5px solid var(--mint-dark); font-size: 16px; line-height: 1.7; }
.speech-line small { display: block; margin-top: 5px; color: #667578; font-size: 11px; }
.scene-dialogue { display: grid; gap: 10px; }
.scene-context { margin: 0 0 14px; padding: 9px 11px; color: #657174; background: #e8e0d2; border: 2px solid #cbbfac; font-size: 11px; line-height: 1.6; }
.character-stage { position: relative; min-height: 190px; margin: 0 0 14px; padding: 20px 34px 14px; overflow: hidden; background-color: #c6d9cf; background-image: linear-gradient(rgba(55,92,82,.13) 2px, transparent 2px), linear-gradient(90deg, rgba(55,92,82,.13) 2px, transparent 2px); background-size: 32px 32px; border: 4px solid var(--deep); box-shadow: inset 0 -30px 0 rgba(82,116,106,.18); }
.character-stage::before { content: ""; position: absolute; inset: 0 0 auto; height: 35px; background: #e9e1d6; border-bottom: 5px solid #6d8f89; }
.stage-character { position: absolute; bottom: 13px; z-index: 2; width: 120px; display: grid; justify-items: center; gap: 7px; transition: transform .2s steps(3), filter .2s; }
.stage-character.left { left: 68px; }
.stage-character.right { right: 68px; }
.stage-character.listening { transform: scale(.88); filter: saturate(.65) brightness(.92); }
.stage-character.speaking { transform: translateY(-4px) scale(1.06); animation: stageTalk .75s steps(2) infinite; }
.stage-character strong { min-width: 68px; padding: 4px 7px; color: #fff; background: var(--deep); border: 2px solid #fff; box-shadow: 2px 2px 0 #152126; text-align: center; font-size: 10px; }
.pixel-person { position: relative; width: 86px; height: 124px; image-rendering: pixelated; filter: drop-shadow(5px 6px 0 rgba(24,40,44,.22)); }
.pixel-head { position: absolute; left: 21px; top: 14px; z-index: 3; width: 46px; height: 43px; background: #f1c39e; border: 5px solid var(--line); border-radius: 6px 6px 12px 12px; }
.pixel-head i, .pixel-head b { position: absolute; top: 17px; width: 5px; height: 5px; background: var(--ink); }
.pixel-head i { left: 9px; }
.pixel-head b { right: 9px; }
.pixel-hair { position: absolute; left: 17px; top: 7px; z-index: 4; width: 53px; height: 25px; background: #4c392e; border: 5px solid var(--line); border-radius: 5px 8px 3px 3px; }
.pixel-body { position: absolute; left: 15px; top: 54px; z-index: 2; width: 58px; height: 60px; background: #d5b047; border: 5px solid var(--line); border-radius: 4px 4px 9px 9px; }
.pixel-body::after { content: ""; position: absolute; left: 5px; bottom: -14px; width: 16px; height: 18px; background: #26363d; border: 4px solid var(--line); box-shadow: 25px 0 0 -4px #26363d, 25px 0 0 0 var(--line); }
.pixel-arm { position: absolute; top: 62px; z-index: 1; width: 19px; height: 48px; background: #d5b047; border: 5px solid var(--line); transform-origin: top center; }
.arm-left { left: 3px; transform: rotate(7deg); }
.arm-right { right: 2px; transform: rotate(-16deg); }
.speaking .arm-right { transform: rotate(-50deg); }
.pier .pixel-body, .pier .pixel-arm { background: var(--red); }
.pier .pixel-hair { background: #6a4a32; }
.doctor .pixel-body, .doctor .pixel-arm, .nurse .pixel-body, .nurse .pixel-arm, .pharmacist .pixel-body, .pharmacist .pixel-arm { background: #f1f3eb; }
.doctor .pixel-body i, .nurse .pixel-body i, .pharmacist .pixel-body i { position: absolute; left: 19px; top: 13px; width: 12px; height: 12px; background: var(--red); }
.doctor .pixel-body i::before, .nurse .pixel-body i::before, .pharmacist .pixel-body i::before { content: ""; position: absolute; left: 4px; top: -4px; width: 4px; height: 20px; background: var(--red); }
.doctor .pixel-body i::after, .nurse .pixel-body i::after, .pharmacist .pixel-body i::after { content: ""; position: absolute; left: -4px; top: 4px; width: 20px; height: 4px; background: var(--red); }
.nurse .pixel-hair { top: 3px; height: 21px; background: #eef1e9; }
.pharmacist .pixel-body, .pharmacist .pixel-arm { background: #86b8ad; }
.guide .pixel-body, .guide .pixel-arm { background: #6ba8c7; }
.speech-signal { position: absolute; left: 50%; top: 75px; z-index: 1; display: flex; gap: 7px; transform: translateX(-50%); }
.speech-signal i { width: 8px; height: 8px; background: var(--red); border: 2px solid var(--red-dark); animation: speechDot .9s steps(2) infinite; }
.speech-signal i:nth-child(2) { animation-delay: .15s; }
.speech-signal i:nth-child(3) { animation-delay: .3s; }
.scene-bubble { display: grid; grid-template-columns: 38px minmax(0, 1fr) 32px; gap: 10px; align-items: start; padding: 11px; background: #fff; border: 3px solid #c9c1b3; box-shadow: 3px 3px 0 #ddd3c1; }
.scene-bubble.current { border-color: var(--mint-dark); background: #edf5ef; }
.scene-avatar { width: 36px; height: 36px; display: grid; place-items: center; color: #fff; background: var(--deep); border: 2px solid #142026; font-size: 13px; font-weight: 900; }
.scene-words b { display: block; margin-bottom: 4px; color: var(--red-dark); font-size: 10px; }
.scene-words p { margin: 0; color: #26383c; font-size: 14px; line-height: 1.7; }
.line-audio { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: #fff; background: var(--mint-dark); border: 2px solid #285344; cursor: pointer; font-size: 11px; }
.dialogue-progress { display: flex; gap: 5px; margin-top: 14px; }
.dialogue-progress i { flex: 1; height: 5px; background: #d2c9b8; }
.dialogue-progress i.done { background: var(--mint-dark); }
.vocab-detail { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: stretch; }
.vocab-focus { display: grid; place-items: center; align-content: center; min-height: 150px; padding: 14px; color: #fff; background: var(--mint-dark); border: 4px solid #254d41; box-shadow: 4px 4px 0 #d2c8b5; text-align: center; }
.vocab-focus b { font-size: 30px; }
.vocab-focus span { margin-top: 7px; font-size: 12px; }
.vocab-notes { padding: 4px 0; }
.vocab-notes h3 { margin: 0 0 8px; color: var(--red-dark); font-size: 15px; }
.vocab-notes p { margin: 0 0 12px; color: #3e5054; font-size: 13px; line-height: 1.7; }
.example-box { padding: 10px 12px; background: #edf4ed; border-left: 5px solid var(--mint-dark); }
.example-box b { display: block; margin-bottom: 4px; color: var(--mint-dark); font-size: 10px; }
.audio-line { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; color: var(--mint-dark); background: transparent; border: 0; cursor: pointer; font-weight: 900; font-size: 12px; }
.audio-line::before { content: "▶"; width: 24px; height: 24px; display: grid; place-items: center; color: #fff; background: var(--mint-dark); }
.primary-btn, .secondary-btn, .choice-btn, .word-card, .tile, .skip-btn {
  min-height: 42px; padding: 10px 15px; cursor: pointer; border-radius: 3px; font-weight: 800; letter-spacing: 0;
}
.primary-btn { color: #fff; background: var(--red); border: 3px solid var(--red-dark); box-shadow: 3px 3px 0 var(--red-dark); }
.primary-btn:hover { background: #e4675e; transform: translateY(-1px); }
.secondary-btn { color: var(--ink); background: #dfe8e0; border: 3px solid #789084; box-shadow: 3px 3px 0 #789084; }
.skip-btn { margin-right: auto; color: #657375; background: transparent; border: 2px solid #aaa294; }
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 16px; }
.choice-btn { min-height: 54px; color: #26363d; background: #fff; border: 3px solid #adaba2; box-shadow: 3px 3px 0 #adaba2; text-align: left; }
.choice-btn:hover { border-color: var(--mint-dark); transform: translateY(-1px); }
.choice-btn.correct { color: #fff; background: var(--mint-dark); border-color: #285344; }
.choice-btn.wrong { color: #fff; background: var(--red); border-color: var(--red-dark); animation: shake .3s steps(3); }
.feedback { margin-top: 14px; padding: 11px 13px; color: #fff; background: var(--deep); border-left: 6px solid var(--yellow); font-size: 12px; line-height: 1.6; }
.word-study { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.word-card { position: relative; min-height: 102px; padding: 15px; color: var(--ink); background: #fff; border: 3px solid #bcb5a8; box-shadow: 4px 4px 0 #d2c8b5; text-align: left; }
.word-card b { display: block; color: var(--red-dark); font-size: 22px; }
.word-card span { display: block; margin-top: 4px; color: #677577; font-size: 11px; }
.word-card small { display: block; margin-top: 8px; color: #394b4e; font-size: 12px; }
.word-card.learned { background: #e0efe5; border-color: var(--mint-dark); }
.word-card.learned::after { content: "✓"; position: absolute; top: 8px; right: 10px; color: var(--mint-dark); font-size: 20px; font-weight: 900; }
.scratch-zone { min-height: 68px; display: flex; flex-wrap: wrap; gap: 9px; align-content: flex-start; padding: 12px; background: #e5ded0; border: 3px dashed #968f82; }
.scratch-zone.target { margin-bottom: 14px; background: #edf4ed; border-color: var(--mint-dark); }
.scratch-zone.target:empty::after { content: "依次点击下方句块，排成完整句子"; color: #768583; font-size: 12px; margin: auto; }
.tile { min-height: 39px; padding: 8px 10px; color: #fff; background: #315a58; border: 3px solid #203b3a; box-shadow: 3px 3px 0 #203b3a; }
.tile:hover { background: #477c75; }
.sentence-tip { margin: 10px 0 14px; color: #6c7778; font-size: 11px; }
.meter { height: 14px; margin: 15px 0; padding: 2px; background: #26363d; border: 2px solid #26363d; }
.meter i { display: block; width: 0; height: 100%; background: var(--red); transition: width .6s steps(8); }
.quiz-count { color: var(--red-dark); font-size: 11px; font-weight: 900; }
.ending { position: fixed; inset: 0; z-index: 120; display: none; place-items: center; padding: 20px; background: rgba(16,25,29,.94); }
.ending.open { display: grid; }
.ending-scene { width: min(620px, 100%); padding: 34px; color: var(--ink); background: var(--paper); border: 6px solid var(--mint); box-shadow: 12px 12px 0 #05090b; text-align: center; }
.ending-cross { width: 60px; height: 60px; display: grid; place-items: center; margin: 0 auto 17px; color: #fff; background: var(--red); border: 5px solid var(--deep); font-size: 41px; font-weight: 900; }
.ending h2 { margin: 5px 0 8px; font-size: 30px; }
.ending p { color: #536368; font-size: 14px; }
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 22px 0; }
.report-grid div { padding: 14px 8px; background: #fff; border: 3px solid #d3cabb; }
.report-grid span, .report-grid b { display: block; }
.report-grid span { color: #687678; font-size: 10px; }
.report-grid b { margin-top: 6px; color: var(--red-dark); font-size: 22px; }
.final-badges { min-height: 32px; display: flex; justify-content: center; flex-wrap: wrap; gap: 7px; margin-bottom: 22px; }
.badge { padding: 7px 9px; color: #fff; background: var(--mint-dark); border: 2px solid #285344; font-size: 10px; font-weight: 900; }

.reader { position: fixed; inset: 0; z-index: 150; display: none; place-items: center; padding: 18px; }
.reader.open { display: grid; }
.reader-backdrop { position: absolute; inset: 0; background: rgba(10,18,21,.82); backdrop-filter: blur(3px); }
.reader-panel { position: relative; width: min(900px, 100%); height: min(88vh, 820px); display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; overflow: hidden; color: var(--ink); background: #f8f2e7; border: 6px solid var(--deep); box-shadow: 12px 12px 0 rgba(0,0,0,.38); }
.reader-panel::before { content: ""; position: absolute; inset: 8px; pointer-events: none; border: 2px solid #d3c7b4; }
.reader-head { position: relative; z-index: 2; display: grid; grid-template-columns: 54px 1fr 36px; gap: 13px; align-items: center; padding: 16px 20px 12px; background: #efe7d9; border-bottom: 4px solid #d4c7b4; }
.reader-book { width: 50px; height: 54px; display: grid; place-items: center; color: #fff; background: var(--red); border: 4px solid var(--red-dark); box-shadow: 4px 4px 0 #c9bcaa; font-size: 20px; font-weight: 900; }
.reader-head span { color: var(--red-dark); font-size: 10px; font-weight: 900; }
.reader-head h2 { margin: 3px 0 0; font-size: 24px; }
.reader-nav { position: relative; z-index: 2; display: flex; gap: 7px; overflow-x: auto; padding: 11px 18px; background: #fffaf0; border-bottom: 3px solid #d8cdbc; scrollbar-width: thin; }
.reader-tab { flex: 0 0 auto; padding: 7px 10px; color: #516064; background: #e3dccf; border: 2px solid #bfb5a5; cursor: pointer; font-size: 10px; font-weight: 800; }
.reader-tab.active { color: #fff; background: var(--mint-dark); border-color: #285344; }
.reader-tab.current::before { content: "●"; margin-right: 5px; color: var(--yellow); }
.reader-content { position: relative; z-index: 2; overflow-y: auto; padding: 22px 28px 34px; scroll-behavior: smooth; }
.textbook-section { margin: 0 auto; max-width: 700px; padding: 19px 21px; background: rgba(255,255,255,.62); border: 3px solid #d7cdbb; box-shadow: 5px 5px 0 rgba(96,78,54,.08); }
.textbook-section.current { border-color: var(--red); box-shadow: 5px 5px 0 rgba(143,52,53,.14); }
.textbook-section h3 { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 14px; color: var(--red-dark); font-size: 18px; }
.current-story { padding: 4px 7px; color: #fff; background: var(--red); border: 2px solid var(--red-dark); font-size: 9px; white-space: nowrap; }
.textbook-section p { margin: 0 0 13px; color: #2f4044; font-size: 15px; line-height: 2; text-indent: 2em; }
.textbook-section p:last-child { margin-bottom: 0; }
.section-audio { float: right; margin: 0 0 10px 13px; width: 35px; height: 35px; display: grid; place-items: center; color: #fff; background: var(--mint-dark); border: 3px solid #285344; cursor: pointer; }
.reader-footer { position: relative; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; background: #efe7d9; border-top: 4px solid #d4c7b4; }
.reader-footer span { color: #687576; font-size: 10px; }

@keyframes targetPulse { 50% { transform: translateY(-4px); } }
@keyframes markerBounce { 50% { transform: translateY(-8px); } }
@keyframes playerBob { 50% { margin-top: -3px; } }
@keyframes stageTalk { 50% { margin-top: -3px; } }
@keyframes speechDot { 50% { transform: translateY(-6px); } }
@keyframes nurseIdle { 0% { background-position: 0 0; } 33% { background-position: -52px 0; } 66%, 100% { background-position: -104px 0; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 33% { transform: translateX(-6px); } 66% { transform: translateX(6px); } }

@media (max-width: 900px) {
  .topbar { height: 64px; grid-template-columns: 1fr auto; padding: 0 12px; gap: 10px; }
  .chapter-progress { position: absolute; top: 64px; left: 0; right: 0; z-index: 50; }
  .chapter-progress > span { display: none; }
  .progress-track { height: 6px; border: 0; }
  .brand small { display: none; }
  .status-strip > span { min-width: auto; }
  .game-main { min-height: calc(100vh - 64px); grid-template-columns: 1fr; grid-template-rows: minmax(520px, 66vh) auto; }
  .world { min-height: 520px; }
  .mission-panel { border-left: 0; border-top: 5px solid var(--deep); padding: 20px 18px 28px; }
  .lexicon-mini { margin-top: 18px; }
  .controls-hint { display: none; }
  .mobile-pad { position: absolute; left: 14px; bottom: 13px; z-index: 30; width: 138px; height: 102px; display: grid; grid-template-columns: repeat(3, 42px); grid-template-rows: repeat(2, 42px); gap: 5px; }
  .mobile-pad button { color: #fff; background: rgba(35,50,57,.86); border: 2px solid #afc8c5; box-shadow: 2px 2px 0 rgba(14,25,28,.8); }
  .mobile-pad button[data-move="up"] { grid-column: 2; }
  .mobile-pad button[data-move="left"] { grid-column: 1; grid-row: 2; }
  .mobile-pad button[data-move="down"] { grid-column: 2; grid-row: 2; }
  .mobile-pad button[data-move="right"] { grid-column: 3; grid-row: 2; }
  .mobile-pad .interact { position: absolute; left: 150px; bottom: 0; width: 48px; height: 48px; color: var(--deep); background: var(--yellow); border-radius: 50%; font-weight: 1000; }
}

@media (max-width: 560px) {
  .topbar { grid-template-columns: 1fr auto; }
  .brand-cross { width: 34px; height: 34px; font-size: 25px; }
  .status-strip { gap: 7px; }
  .status-strip > span:first-child { display: none; }
  .icon-btn { width: 34px; height: 34px; }
  .game-main { grid-template-rows: 510px auto; }
  .world { min-height: 510px; }
  .wall-top { height: 20%; }
  .floor-grid { inset: 20% 0 0; }
  .clock-panel { top: 4%; transform: translateX(-50%); }
  .reception { left: 2%; width: 22%; }
  .waiting { left: 26%; width: 21%; }
  .doctor { left: 49%; width: 22%; }
  .pharmacy { right: 2%; width: 18%; }
  .injection { right: 3%; width: 18%; }
  .exit { left: 3%; width: 20%; }
  .decor-sign { display: none; }
  .mission-head h1 { font-size: 20px; }
  .dialog-card { max-height: 88vh; }
  .dialog-top { grid-template-columns: 48px 1fr auto; padding: 14px 13px 10px; }
  .speaker-portrait { width: 46px; height: 46px; }
  .dialog-heading h2 { font-size: 16px; }
  .dialog-body { padding: 16px 14px; }
  .dialog-actions { padding: 0 14px 16px; }
  .choice-grid, .word-study { grid-template-columns: 1fr; }
  .word-study { max-height: 45vh; overflow-y: auto; }
  .vocab-detail { grid-template-columns: 1fr; }
  .vocab-focus { min-height: 105px; }
  .character-stage { min-height: 160px; padding: 18px 8px 10px; }
  .stage-character { bottom: 8px; width: 82px; }
  .stage-character.left { left: 16px; }
  .stage-character.right { right: 16px; }
  .stage-character.speaking { transform: translateY(-2px) scale(1); }
  .stage-character.listening { transform: scale(.82); }
  .pixel-person { transform: scale(.76); transform-origin: bottom center; margin-bottom: -16px; }
  .scene-bubble { grid-template-columns: 34px minmax(0, 1fr) 30px; gap: 8px; padding: 9px; }
  .scene-words p { font-size: 13px; }
  .report-grid { grid-template-columns: 1fr; }
  .ending-scene { padding: 23px 16px; }
  .reader { padding: 8px; }
  .reader-panel { height: 94vh; border-width: 4px; }
  .reader-head { grid-template-columns: 46px 1fr 34px; padding: 12px 12px 9px; }
  .reader-book { width: 42px; height: 46px; }
  .reader-head h2 { font-size: 19px; }
  .reader-nav { padding: 9px 10px; }
  .reader-content { padding: 14px 12px 24px; }
  .textbook-section { padding: 15px 14px; }
  .textbook-section p { font-size: 14px; line-height: 1.9; }
  .reader-footer { padding: 9px 11px; }
  .reader-footer span { display: none; }
  .reader-footer button { width: 100%; }
}

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