:root {
  --ink: #2c1748;
  --muted: #745f88;
  --panel: rgba(255, 250, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --border: rgba(91, 58, 140, 0.18);
  --violet: #7c4fd8;
  --violet-strong: #5f33ba;
  --pink: #ff8fc9;
  --gold: #ffd968;
  --teal: #75d7ee;
  --good: #2ca86f;
  --bad: #d84d6f;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  color: var(--ink);
  background: #130b24;
}

body {
  position: fixed;
  inset: 0;
}

button {
  border: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  display: grid;
  place-items: center;
  padding: 18px;
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 217, 104, 0.28), transparent 28%),
    radial-gradient(circle at 84% 72%, rgba(117, 215, 238, 0.25), transparent 26%),
    linear-gradient(135deg, #1e1236, #381d5e 48%, #111a3a);
}

.game-shell {
  position: relative;
  width: min(100vw - 36px, 1180px);
  aspect-ratio: 16 / 10;
  min-height: 520px;
  overflow: hidden;
  border-radius: 24px;
  background: #fff6fb;
  box-shadow: 0 28px 90px rgba(5, 2, 21, 0.42);
  isolation: isolate;
}

.full-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
}

.dimmed {
  filter: saturate(1.06);
}

.room-art {
  filter: saturate(1.04) contrast(1.02);
}

.launch-overlay,
.floating-card,
.hud,
.panel-header,
.question-card,
.result-card,
.info-panel,
.metric-card {
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 45px rgba(54, 26, 96, 0.2);
}

.launch-overlay {
  position: absolute;
  left: 6%;
  bottom: 8%;
  width: min(460px, 48%);
  padding: 26px;
  border-radius: 22px;
}

.brand-note,
.eyebrow {
  margin: 0 0 8px;
  color: var(--violet);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 4.4vw, 54px);
  line-height: 1.05;
}

h2 {
  margin-bottom: 10px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.08;
}

p {
  color: var(--muted);
  line-height: 1.7;
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
}

.action-row.centered {
  justify-content: center;
}

.install-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid rgba(124, 79, 216, 0.18);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.install-card strong,
.install-card span,
.install-card em {
  display: block;
}

.install-card strong {
  margin-bottom: 3px;
  color: var(--ink);
  font-weight: 900;
}

.install-card span,
.install-card em {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.install-card em {
  margin-top: 4px;
  font-style: normal;
  font-weight: 800;
}

.install-card.is-installed {
  display: block;
  background: rgba(44, 168, 111, 0.12);
}

.install-actions {
  flex: 0 0 auto;
}

.install-help {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 9, 36, 0.48);
}

.install-help-panel {
  position: relative;
  width: min(540px, 92%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--panel-strong);
  box-shadow: 0 24px 70px rgba(5, 2, 21, 0.34);
}

.install-help-panel ol {
  margin: 0 0 18px;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.7;
}

.install-help-panel li {
  margin: 6px 0;
}

.install-close {
  position: absolute;
  right: 18px;
  top: 18px;
}

.primary,
.secondary,
.small-link,
.icon-button,
.listen-chip,
.danger-link,
.music-toggle,
.download-link {
  min-height: 44px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 800;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease;
}

.primary {
  color: white;
  background: linear-gradient(135deg, var(--violet), var(--pink));
  box-shadow: 0 12px 24px rgba(124, 79, 216, 0.34);
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  text-decoration: none;
}

.secondary,
.small-link,
.icon-button,
.listen-chip,
.music-toggle {
  color: var(--violet-strong);
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(124, 79, 216, 0.18);
}

.primary:hover,
.secondary:hover,
.small-link:hover,
.icon-button:hover,
.listen-chip:hover,
.map-pin:hover,
.hotspot:hover,
.answer:hover,
.swatch:hover,
.music-toggle:hover,
.download-link:hover {
  transform: translateY(-2px);
}

.music-toggle {
  position: absolute;
  right: 34px;
  top: 27px;
  z-index: 8;
  display: grid;
  place-items: center;
  width: 48px;
  min-height: 48px;
  padding: 0;
  color: #55318f;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 26px rgba(44, 23, 72, 0.18);
}

.music-toggle span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fff7c5, #ffd1eb);
  font-size: 22px;
  line-height: 1;
}

.music-toggle.is-off {
  color: var(--muted);
  opacity: 0.74;
}

.full {
  width: 100%;
}

.hud,
.panel-header {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 20px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 70px 8px 12px;
  border-radius: 18px;
}

.hud strong,
.panel-header strong {
  font-size: 18px;
}

.hud span,
.panel-header span {
  margin-left: auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  min-height: 42px;
  padding: 0;
  font-size: 28px;
  line-height: 1;
}

.small-link {
  min-height: 38px;
  padding-inline: 14px;
  font-size: 13px;
}

.map-pin {
  position: absolute;
  z-index: 3;
  min-width: 150px;
  padding: 14px 18px;
  border-radius: 18px;
  color: white;
  background: linear-gradient(135deg, #7c4fd8, #ff8fc9);
  box-shadow: 0 16px 34px rgba(44, 23, 72, 0.28);
  font-weight: 900;
}

.map-pin span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.9;
}

.pin-home {
  left: 16%;
  top: 50%;
}

.pin-review {
  right: 16%;
  top: 20%;
}

.pin-parent {
  right: 9%;
  bottom: 13%;
}

.locked-area {
  position: absolute;
  z-index: 2;
  padding: 10px 14px;
  border-radius: 999px;
  color: #4d3b66;
  background: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  font-weight: 800;
}

.area-castle {
  left: 40%;
  top: 26%;
}

.area-garden {
  left: 48%;
  bottom: 22%;
}

.home-node {
  position: absolute;
  z-index: 3;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 900;
}

.home-node.active {
  color: #3d2370;
  background: var(--gold);
}

.node-hall {
  left: 46%;
  top: 56%;
}

.node-bedroomDoor {
  left: 68%;
  top: 32%;
}

.node-livingDoor {
  left: 28%;
  top: 68%;
}

.node-kitchenDoor {
  left: 68%;
  top: 68%;
}

.node-bathDoor {
  left: 24%;
  top: 39%;
}

.mini-princess {
  position: absolute;
  left: var(--x);
  top: var(--y);
  z-index: 4;
  width: 58px;
  height: 78px;
  transform: translate(-50%, -85%);
  filter: drop-shadow(0 14px 12px rgba(44, 23, 72, 0.3));
  transition:
    left 0.32s ease,
    top 0.32s ease;
}

.princess-head {
  position: absolute;
  left: 15px;
  top: 5px;
  width: 28px;
  height: 30px;
  border-radius: 50%;
  background: #ffd6bc;
  border: 7px solid #6c3f8e;
}

.princess-body {
  position: absolute;
  left: 8px;
  top: 34px;
  width: 42px;
  height: 42px;
  border-radius: 50% 50% 12px 12px;
  background: linear-gradient(135deg, var(--pink), #f9d6ff);
}

.home-card {
  position: absolute;
  right: 28px;
  bottom: 84px;
  z-index: 5;
  width: min(360px, 36%);
  padding: 22px;
  border-radius: 22px;
}

.listen-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.listen-chip span {
  color: var(--muted);
  font-size: 13px;
}

.tiny {
  margin: 12px 0 0;
  font-size: 13px;
}

.dpad {
  position: absolute;
  left: 28px;
  bottom: 28px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(3, 50px);
  grid-template-rows: repeat(2, 50px);
  gap: 8px;
}

.dpad button {
  border-radius: 16px;
  color: var(--violet-strong);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(124, 79, 216, 0.18);
  font-weight: 900;
}

.dpad [data-move="up"] {
  grid-column: 2;
}

.dpad [data-move="left"] {
  grid-column: 1;
}

.dpad [data-move="down"] {
  grid-column: 2;
}

.dpad [data-move="right"] {
  grid-column: 3;
}

.room-hud {
  right: 22px;
}

.room-hotspots {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.hotspot {
  position: absolute;
  min-width: 74px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  border: 2px solid rgba(255, 217, 104, 0.82);
  box-shadow: 0 8px 20px rgba(44, 23, 72, 0.16);
  font-size: 13px;
  font-weight: 900;
}

.hotspot.selected {
  color: #412370;
  background: var(--gold);
  border-color: white;
}

.hot-bed { left: 20%; top: 58%; }
.hot-chair { left: 52%; top: 64%; }
.hot-dresser { left: 64%; top: 48%; }
.hot-lamp { left: 72%; top: 35%; }
.hot-wardrobe { left: 77%; top: 53%; }
.hot-rug { left: 43%; top: 76%; }
.hot-crown { left: 57%; top: 42%; }
.hot-dress { left: 83%; top: 69%; }
.hot-shoes { left: 64%; top: 79%; }
.hot-table { left: 46%; top: 53%; }
.hot-window { left: 36%; top: 31%; }
.hot-book { left: 58%; top: 56%; }

.reading-card {
  position: absolute;
  right: 28px;
  top: 98px;
  z-index: 4;
  width: min(320px, 32%);
  padding: 22px;
  border-radius: 22px;
}

.speaker-large,
.speaker-xl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--violet), var(--pink));
  box-shadow: 0 14px 28px rgba(124, 79, 216, 0.26);
  font-weight: 900;
}

.speaker-large {
  width: 52px;
  padding: 0;
}

.speaker-xl {
  padding: 0 24px;
  font-size: 20px;
}

.speaking {
  animation: pulse 0.56s ease;
}

.phonetic {
  color: var(--violet);
  font-weight: 800;
}

.meaning {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.sentence {
  margin-bottom: 0;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(124, 79, 216, 0.08);
}

.word-rail {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 82px;
  z-index: 4;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--border);
}

.word-rail button {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--violet-strong);
  background: white;
  border: 1px solid rgba(124, 79, 216, 0.14);
  font-size: 13px;
  font-weight: 900;
}

.word-rail button.active {
  color: white;
  background: var(--violet);
}

.story-bar {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 18px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  font-weight: 800;
}

.story-bar .primary {
  margin-left: auto;
}

.wardrobe-card {
  position: absolute;
  left: 40px;
  top: 100px;
  z-index: 3;
  width: min(360px, 36%);
  padding: 24px;
  border-radius: 22px;
}

.option-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}

.option-group > span {
  font-weight: 900;
}

.swatch {
  min-width: 42px;
  min-height: 42px;
  border-radius: 14px;
  color: var(--violet-strong);
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid transparent;
  font-weight: 900;
}

.swatch.active {
  border-color: var(--gold);
  background: linear-gradient(135deg, #fff7c5, #ffd1eb);
}

.challenge-stage,
.result-layout,
.review-layout,
.parent-layout {
  min-height: 100%;
  padding: 96px 28px 28px;
  background:
    radial-gradient(circle at 20% 22%, rgba(255, 217, 104, 0.4), transparent 24%),
    radial-gradient(circle at 78% 70%, rgba(117, 215, 238, 0.36), transparent 24%),
    linear-gradient(135deg, #fff6fb, #ecf7ff);
}

.question-card,
.result-card {
  width: min(760px, 92%);
  margin: 0 auto;
  padding: 34px;
  border-radius: 24px;
  text-align: center;
}

.answer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 12px;
}

.answer {
  min-height: 92px;
  border-radius: 20px;
  background: white;
  border: 2px solid rgba(124, 79, 216, 0.13);
}

.answer strong,
.answer span {
  display: block;
}

.answer strong {
  font-size: 24px;
}

.answer span {
  margin-top: 4px;
  color: var(--muted);
}

.answer.correct {
  border-color: rgba(44, 168, 111, 0.65);
  background: rgba(44, 168, 111, 0.12);
}

.answer.wrong {
  border-color: rgba(216, 77, 111, 0.58);
  background: rgba(216, 77, 111, 0.11);
}

.feedback {
  min-height: 28px;
  margin-bottom: 0;
  font-weight: 800;
}

.stars {
  margin: 18px 0;
  color: var(--gold);
  font-size: clamp(40px, 7vw, 74px);
  letter-spacing: 0;
  text-shadow: 0 8px 22px rgba(255, 178, 41, 0.24);
}

.stars .empty {
  color: rgba(44, 23, 72, 0.16);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 16px 0;
}

.tag-row span {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--violet-strong);
  background: rgba(124, 79, 216, 0.1);
  font-size: 13px;
  font-weight: 900;
}

.review-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 1.1fr);
  gap: 24px;
  align-items: start;
}

.review-list {
  display: grid;
  gap: 10px;
}

.review-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  text-align: left;
}

.review-list span {
  color: var(--muted);
  font-size: 13px;
}

.parent-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-card {
  padding: 18px;
  border-radius: 20px;
}

.metric-card span,
.metric-card em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
}

.metric-card strong {
  display: block;
  margin: 8px 0 2px;
  font-size: 42px;
  line-height: 1;
}

.parent-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.info-panel {
  min-height: 250px;
  padding: 22px;
  border-radius: 22px;
}

.info-panel li {
  margin: 8px 0;
  color: var(--muted);
}

.danger-link {
  margin-top: 14px;
  color: var(--bad);
  background: rgba(216, 77, 111, 0.1);
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@media (max-width: 860px) {
  .app {
    padding: 0;
  }

  .game-shell {
    width: 100vw;
    height: 100vh;
    min-height: 100vh;
    aspect-ratio: auto;
    border-radius: 0;
  }

  .launch-overlay {
    width: 52%;
    left: 4%;
    bottom: 5%;
    padding: 18px;
  }

  h1 {
    font-size: clamp(24px, 5vw, 38px);
  }

  h2 {
    font-size: 24px;
  }

  p {
    font-size: 14px;
    line-height: 1.55;
  }

  .hud,
  .panel-header {
    left: 12px;
    right: 12px;
    top: 10px;
    min-height: 50px;
  }

  .music-toggle {
    right: 22px;
    top: 16px;
    width: 42px;
    min-height: 42px;
  }

  .map-pin {
    min-width: 118px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .home-card,
  .reading-card,
  .wardrobe-card {
    width: 34%;
    padding: 14px;
  }

  .reading-card {
    top: 74px;
    right: 12px;
  }

  .wardrobe-card {
    left: 14px;
    top: 76px;
  }

  .home-card {
    right: 12px;
    bottom: 66px;
  }

  .word-rail {
    left: 12px;
    right: 12px;
    bottom: 70px;
  }

  .story-bar {
    left: 12px;
    right: 12px;
    bottom: 10px;
    font-size: 13px;
  }

  .story-bar span:nth-of-type(2),
  .story-bar span:nth-of-type(3) {
    display: none;
  }

  .install-card {
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
  }

  .install-card .primary,
  .install-card .secondary,
  .install-card .download-link {
    min-height: 40px;
    padding-inline: 12px;
    font-size: 13px;
  }

  .dpad {
    left: 14px;
    bottom: 16px;
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(2, 42px);
  }

  .answer-grid,
  .review-grid,
  .parent-columns {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 720px) and (orientation: portrait) {
  .game-shell {
    aspect-ratio: auto;
  }

  .launch-overlay {
    width: calc(100% - 28px);
    left: 14px;
    right: 14px;
  }

  .home-card,
  .reading-card,
  .wardrobe-card {
    width: calc(100% - 28px);
    left: 14px;
    right: 14px;
    top: auto;
    bottom: 96px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .app {
    padding: 0;
  }

  .game-shell {
    width: 100vw;
    height: 100vh;
    min-height: 0;
    aspect-ratio: auto;
    border-radius: 0;
  }

  .hud,
  .panel-header {
    left: 14px;
    right: 14px;
    top: 10px;
    min-height: 50px;
    padding: 6px 64px 6px 10px;
  }

  .music-toggle {
    right: 24px;
    top: 16px;
    width: 42px;
    min-height: 42px;
  }

  .reading-card {
    top: 78px;
    right: 16px;
    width: 31%;
    padding: 14px;
  }

  .reading-card h2 {
    margin-bottom: 6px;
    font-size: 28px;
  }

  .meaning {
    margin-bottom: 8px;
    font-size: 20px;
  }

  .sentence {
    padding: 10px 12px;
    font-size: 14px;
  }

  .word-rail {
    left: 12px;
    right: 12px;
    bottom: 62px;
    padding: 8px;
  }

  .word-rail button {
    min-height: 34px;
    padding: 0 12px;
  }

  .story-bar {
    left: 12px;
    right: 12px;
    bottom: 8px;
    min-height: 44px;
    padding: 8px 10px;
  }

  .story-bar span:nth-of-type(2),
  .story-bar span:nth-of-type(3) {
    display: none;
  }

  .install-card {
    margin-top: 10px;
  }

  .install-card span,
  .install-card em {
    font-size: 12px;
  }

  .home-card,
  .wardrobe-card {
    width: 34%;
    padding: 14px;
  }

  .home-card {
    right: 14px;
    bottom: 64px;
  }

  .wardrobe-card {
    left: 14px;
    top: 74px;
  }

  .dpad {
    left: 14px;
    bottom: 12px;
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(2, 42px);
  }

  .challenge-stage,
  .result-layout,
  .review-layout,
  .parent-layout {
    padding: 76px 18px 18px;
  }

  .question-card,
  .result-card {
    padding: 20px;
  }

  .answer-grid {
    margin: 14px 0 8px;
  }

  .answer {
    min-height: 70px;
  }

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