/*
 * Sentence practice responsive layout
 *
 * Layout contract:
 * - Width and orientation choose the main layout mode.
 * - Available height limits the vertical content in each mode.
 * - The scene owns the game content; page-level navigation owns the viewport edges.
 */

/* 01. Shared layout tokens and the default desktop-like baseline. */
:root {
  --blue-ink: #10326a;
  --display-cn-font: "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --serif-cn-font: "Source Han Serif SC", "Noto Serif CJK SC", "Noto Serif SC", "Songti SC", "SimSun", serif;
  --sentence-bg-image: url("assets/images/backgrounds/sentence/sentence-bg-portrait.jpg?v=20260819-bg-compress-v1");
  --sentence-bg-landscape-image: url("assets/images/backgrounds/sentence/sentence-bg-landscape.jpg?v=20260819-bg-compress-v1");
  --page-bg-image: var(--sentence-bg-image);
  --scene-width: min(100vw, 56.25svh);
  --scene-height: min(177.778vw, 100svh);
  --header-width: 100vw;
  --header-height: 100svh;
  --top-back-width: 16.5%;
  --top-control-height: clamp(28px, 7.16vw, 58px);
  --top-title-width: 94px;
  --top-deck-width: min(50vw, calc(var(--challenge-width) * 0.70), 300px);
  --top-deck-height: calc(var(--top-deck-width) * 0.13447);
  --top-deck-border-offset: calc(var(--challenge-height) * 0.025);
  --top-tool-size: 8.7%;
  --challenge-width: 85vw;
  --challenge-top: calc(2.2svh + var(--top-control-height) * 1.5 - (100svh - var(--scene-height)) / 2 + 10px);
  --challenge-bottom: calc(var(--scene-height) - var(--companion-ground-y) + var(--scene-width) * 0.31 + 10px);
  --challenge-height: calc(var(--scene-height) - var(--challenge-top) - var(--challenge-bottom));
  --sentence-copy-font: 16px;
  --sentence-hint-size: clamp(12px, calc(var(--challenge-height) * 0.032), 17px);
  --token-height: clamp(24px, calc(var(--challenge-height) * 0.065), 40px);
  --token-pad-inline: 0;
  --word-token-font: clamp(12px, calc(var(--challenge-height) * 0.03), 17px);
  --word-button-height: var(--token-height);
  --word-button-font: var(--word-token-font);
  --action-buttons-max-width: 400px;
  --submit-button-max-width: 160px;
  --bottom-nav-width: min(94.4vw, 53.1svh);
  --bottom-nav-height: clamp(62px, 9.8svh, 86px);
  --companion-action-height: 32px;
  --companion-action-width: calc(var(--companion-action-height) * 2.7397);
  --companion-action-side: 14%;
  --companion-gap: calc(var(--scene-height) * 0.025);
  --companion-top: max(calc(var(--scene-height) * 0.639), calc(var(--challenge-top) + var(--challenge-height) + var(--companion-gap)));
  --companion-zone-height: calc(var(--scene-height) * 0.146);
  --companion-ground-y: calc(var(--scene-height) * 0.78);
  --companion-nameplate-gap: 10px;
  --companion-nameplate-top: calc(var(--companion-ground-y) - var(--companion-top) + var(--companion-nameplate-gap));
  --companion-nameplate-height: 38px;
  --companion-nameplate-width: 36%;
  --companion-nameplate-half-width: 18%;
  --companion-action-gap: 10px;
  --companion-action-edge: calc(50% - var(--companion-nameplate-half-width) - var(--companion-action-gap) - var(--companion-action-width));
  --reward-name-gap: 10px;
  --speech-bubble-pet-top-gap: 8px;
  --speech-bubble-pet-side-gap: 5px;
  --speech-bubble-font-size: 15px;
  --evolution-stone-left: 10.8%;
  --evolution-stone-width: clamp(112px, 18%, 148px);
  --evolution-stone-min-height: clamp(106px, 17%, 132px);
  --evolution-stone-padding: 14px 13px 18px;
}

@media (orientation: landscape) {
  :root {
    --page-bg-image: var(--sentence-bg-landscape-image);
  }
}

/* 02. Phone portrait: current accepted layout. */
@media (max-width: 540px) and (max-height: 700px) and (orientation: portrait) {
  :root {
    --scene-width: min(100vw, 56.25svh);
    --scene-height: min(177.778vw, 100svh);
    --header-width: 100vw;
    --header-height: 100svh;
    --top-control-height: clamp(28px, 7.16vw, 58px);
    --top-title-width: 94px;
    --top-deck-width: min(50vw, calc(var(--challenge-width) * 0.70), 300px);
    --top-deck-height: calc(var(--top-deck-width) * 0.13447);
    --top-deck-border-offset: calc(var(--challenge-height) * 0.025);
    --bottom-nav-width: min(94.4vw, 53.1svh);
    --bottom-nav-height: clamp(58px, 9.8svh, 78px);
    --companion-action-height: 26px;
    --companion-action-width: calc(var(--companion-action-height) * 2.7397);
    --companion-nameplate-height: 32px;
    --companion-nameplate-gap: 5px;
    --companion-action-side: 10%;
    --reward-name-gap: 5px;
    --speech-bubble-font-size: 10px;
    --evolution-stone-left: clamp(16px, 5.8%, 28px);
    --evolution-stone-width: clamp(80px, calc(var(--scene-width) * 0.19), 96px);
    --evolution-stone-min-height: clamp(78px, calc(var(--scene-width) * 0.18), 92px);
    --evolution-stone-padding: 11px 10px 14px;
  }

  .deck-selector-card {
    width: min(100%, 600px);
    max-height: 82svh;
    padding: 18px;
    gap: 12px;
  }

  .companion-pet {
    bottom: -6px;
  }

  .companion-nameplate strong {
    font-size: 14px;
  }

  .speech-bubble {
    font-size: var(--speech-bubble-font-size);
  }

  .companion-action {
    top: var(--companion-nameplate-top);
    bottom: auto;
  }

  .picker-head {
    gap: 10px;
  }

  .picker-head h2 {
    font-size: 19px;
  }

  .picker-head button {
    min-height: 34px;
    padding: 0 14px;
    font-size: 12px;
  }

  .sentence-stage-item,
  .sentence-series-item {
    flex-basis: clamp(126px, 22vw, 176px);
    min-height: 62px;
    padding: 10px 12px;
  }

  .sentence-stage-item span:first-child,
  .sentence-series-item span:first-child {
    font-size: 16px;
    line-height: 1.12;
    white-space: normal;
    word-break: break-word;
  }

  .sentence-stage-sub,
  .sentence-series-sub {
    font-size: 10px;
  }

  .sentence-grade-list {
    gap: 7px;
  }

  .sentence-deck-item {
    padding: 10px 10px;
  }
}

/* 03. Tablet portrait. */
@media (min-width: 541px) and (orientation: portrait) {
  :root {
    --scene-width: min(100vw, 56.25svh);
    --scene-height: min(177.778vw, 100svh);
    --header-width: 100vw;
    --header-height: 100svh;
    --top-control-height: clamp(44px, 7.16vw, 58px);
    --top-title-width: 94px;
    --top-deck-width: min(50vw, calc(var(--challenge-width) * 0.70), 300px);
    --top-deck-height: calc(var(--top-deck-width) * 0.13447);
    --top-deck-border-offset: calc(var(--challenge-height) * 0.025);
    --word-button-height: clamp(26px, calc(var(--challenge-height) * 0.0715), 44px);
    --word-token-font: clamp(16px, calc(var(--challenge-height) * 0.05), 24px);
    --sentence-copy-font: 20px;
    --bottom-nav-width: min(94.4vw, 53.1svh);
    --bottom-nav-height: clamp(62px, 9.8svh, 86px);
  }
}

/* 04. Tablet landscape: the main width-sensitive landscape mode. */
@media (min-width: 541px) and (max-width: 1180px) and (orientation: landscape) {
  :root {
    --scene-width: min(58vw, 56.25svh);
    --scene-height: calc(var(--scene-width) * 1.77778);
    --header-width: 100vw;
    --header-height: 100svh;
    --top-control-height: 45px;
    --top-back-width: 104px;
    --top-title-width: 94px;
    --top-deck-width: min(50vw, calc(var(--challenge-width) * 0.70), 300px);
    --top-deck-height: calc(var(--top-deck-width) * 0.13447);
    --top-deck-border-offset: calc(var(--challenge-height) * 0.025);
    --word-button-height: clamp(26px, calc(var(--challenge-height) * 0.0715), 44px);
    --word-token-font: clamp(16px, calc(var(--challenge-height) * 0.05), 24px);
    --sentence-copy-font: 20px;
    --top-tool-size: 56px;
    --bottom-nav-width: min(94.4vw, 53.1svh);
    --bottom-nav-height: clamp(62px, 9.8svh, 86px);
  }
}

/* 05. Wide landscape: capped desktop/tablet landscape presentation. */
@media (min-width: 1181px) and (orientation: landscape) {
  :root {
    --scene-width: min(46vw, 56.25svh);
    --scene-height: calc(var(--scene-width) * 1.77778);
    --header-width: 100vw;
    --header-height: 100svh;
    --top-control-height: 47px;
    --top-back-width: 108px;
    --top-title-width: 94px;
    --top-deck-width: min(50vw, calc(var(--challenge-width) * 0.70), 300px);
    --top-deck-height: calc(var(--top-deck-width) * 0.13447);
    --top-deck-border-offset: calc(var(--challenge-height) * 0.025);
    --word-button-height: clamp(26px, calc(var(--challenge-height) * 0.0715), 44px);
    --word-token-font: clamp(16px, calc(var(--challenge-height) * 0.05), 24px);
    --sentence-copy-font: 20px;
    --top-tool-size: 58px;
    --bottom-nav-width: min(94.4vw, 53.1svh);
    --bottom-nav-height: clamp(62px, 9.8svh, 86px);
  }
}

* {
  box-sizing: border-box;
}

/* 06. Document reset and page-level background. */
html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #0f356f var(--page-bg-image) center / cover no-repeat;
  font-family: var(--serif-cn-font);
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

/* 07. Scene shell: the shared coordinate system for all game layers. */
.sentence-redesign-page {
  position: relative;
  width: 100vw;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0f356f var(--page-bg-image) center / cover no-repeat;
}

.sentence-scene {
  position: relative;
  width: var(--scene-width);
  height: var(--scene-height);
  min-width: 320px;
  z-index: 0;
  overflow: visible;
  isolation: isolate;
  background: var(--sentence-bg-image) center / cover no-repeat;
  box-shadow: 0 0 36px rgba(3, 13, 35, 0.36);
}

/* 08. Header controls: back, title, deck selector, tutorial, and sound. */
.scene-header {
  /* Viewport layer: never inherit the scene's size or transform. */
  position: fixed;
  left: 50%;
  top: 0;
  width: var(--header-width);
  height: var(--header-height);
  z-index: 21;
  pointer-events: none;
  transform: translateX(-50%);
}


.back-link {
  position: absolute;
  left: 2.8%;
  top: 2.2%;
  width: var(--top-back-width);
  height: var(--top-control-height);
  aspect-ratio: 415 / 180;
  display: block;
  background: url("assets/images/ui/sentence/back-button.png") center / contain no-repeat;
  pointer-events: auto;
}

.title-banner {
  position: absolute;
  left: 50%;
  top: 2.2%;
  width: auto;
  height: calc(var(--top-control-height) * 1.5);
  display: block;
  transform: translateX(-50%);
}

.deck-select-button {
  position: absolute;
  left: 50%;
  top: calc((100svh - var(--scene-height)) / 2 + var(--challenge-top) - var(--top-deck-height) / 2 + var(--top-deck-border-offset));
  width: var(--top-deck-width);
  aspect-ratio: 1584 / 213;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 0 7%;
  color: #ffffff;
  cursor: pointer;
  font: bold 12px/1 "SimSun", "宋体", serif;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 2px 2px rgba(0, 20, 70, 0.72);
  -webkit-text-stroke: 0.25px currentColor;
  background: url("assets/images/ui/sentence/bottom-nav-bar.png") center / 100% 100% no-repeat;
  pointer-events: auto;
  transform: translateX(-50%);
}

.deck-select-button span {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 50%;
  font-size: clamp(10px, calc(var(--top-deck-width) * 0.05556), 18px);
  width: auto;
  max-width: none;
  overflow: visible;
  white-space: nowrap;
  text-align: center;
  transform: translateY(-50%);
}

.round-tool {
  position: absolute;
  top: 2.1%;
  width: var(--top-tool-size);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  cursor: pointer;
  background-color: transparent;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: auto;
}

.tutorial-tool {
  right: 13.6%;
  background-image: url("assets/images/ui/sentence/tutorial-round-button.png");
}

.sound-tool {
  right: 3.7%;
  background-image: url("assets/images/ui/sentence/sound-round-button.png");
}

.sound-tool.is-muted {
  filter: grayscale(0.85) brightness(0.82);
}

/* 09. Sentence challenge: panel geometry, Chinese prompt, answer slots, word bank, and actions. */
.challenge-card {
  position: absolute;
  left: 50%;
  top: var(--challenge-top);
  bottom: var(--challenge-bottom);
  width: var(--challenge-width);
  height: auto;
  padding: 0 8%;
  border: 6px solid #c78f2a;
  border-radius: 24px;
  display: grid;
  grid-template-rows: 5fr 10fr 30fr 30fr 10fr 10fr 5fr;
  align-items: stretch;
  align-content: stretch;
  row-gap: 0;
  z-index: 10;
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.8), transparent 38%),
    linear-gradient(180deg, rgba(255, 246, 207, 0.8), rgba(255, 251, 239, 0.8));
  box-shadow:
    0 16px 30px rgba(30, 72, 119, 0.18),
    inset 0 0 0 2px rgba(255, 255, 255, 0.84),
    inset 0 0 0 6px rgba(250, 215, 124, 0.42);
  transform: translateX(-50%);
}

.sentence-copy {
  grid-row: 2;
  width: calc(85% / 0.84);
  height: 100%;
  display: grid;
  place-items: center;
  container-type: size;
  text-align: center;
  color: var(--blue-ink);
}

.sentence-copy h1 {
  margin: 0;
  font-family: "SimSun", "宋体", serif;
  font-size: var(--sentence-copy-font);
  line-height: 1.18;
  font-weight: bold;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.85);
  -webkit-text-stroke: 0.3px currentColor;
}

.answer-slots {
  grid-row: 3;
  position: relative;
  width: 95%;
  height: 97%;
  min-height: 0;
  margin: auto;
  padding: 8px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: clamp(5px, calc(var(--challenge-height) * 0.012), 10px)
    clamp(7px, calc(var(--challenge-width) * 0.016), 14px);
  align-content: flex-start;
  align-items: flex-start;
  justify-content: flex-start;
  border: 2px solid rgba(203, 154, 70, 0.54);
  border-radius: 14px;
  touch-action: none;
  background:
    linear-gradient(180deg, rgba(255, 254, 245, 0.68), rgba(255, 245, 222, 0.5)),
    rgba(255, 250, 235, 0.42);
  box-shadow:
    inset 0 2px 7px rgba(92, 55, 12, 0.12),
    0 2px 0 rgba(255, 255, 255, 0.38);
}

.answer-slots.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  color: #8b673c;
  font-family: "SimSun", "宋体", serif;
  font-size: var(--sentence-hint-size);
  font-weight: bold;
  line-height: 1.25;
  text-align: center;
  -webkit-text-stroke: 0.25px currentColor;
  pointer-events: none;
}

.answer-slot {
  position: relative;
  flex: 0 0 auto;
  width: max-content;
  height: var(--token-height);
  min-width: calc(3ch + 14px);
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #c98d25;
  border-radius: 8px;
  min-width: 0;
  padding: 0 5px;
  cursor: pointer;
  color: #fff8dc;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--word-token-font);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 20, 70, 0.8);
  overflow: visible;
  white-space: nowrap;
  background: #0a4fae;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -2px 0 rgba(3, 29, 86, 0.42),
    0 2px 0 rgba(67, 38, 8, 0.28);
  touch-action: none;
}

.answer-slot:hover {
  background: #1767c8;
  border-color: #f0bd4c;
}

.answer-slot:focus-visible {
  outline: 2px solid #fff2a8;
  outline-offset: 2px;
}

.answer-slot:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 3px rgba(3, 29, 86, 0.42),
    0 1px 0 rgba(67, 38, 8, 0.28);
}

.answer-slot span,
.word-token span {
  display: block;
  max-width: none;
  overflow: visible;
  white-space: nowrap;
  transform: translateY(0.08em);
}

.word-bank {
  grid-row: 4;
  width: 95%;
  height: 97%;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: center;
  gap: clamp(5px, calc(var(--challenge-height) * 0.014), 11px)
    clamp(10px, calc(var(--challenge-width) * 0.02), 18px);
}

.word-token {
  flex: 0 0 auto;
  width: max-content;
  height: var(--word-button-height);
  min-width: calc(3ch + 14px);
  display: flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid #c98d25;
  border-radius: 8px;
  padding: 0 5px;
  cursor: pointer;
  color: #fff8dc;
  font-family: Georgia, "Times New Roman", serif;
  font-size: var(--word-button-font);
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 20, 70, 0.8);
  overflow: visible;
  background: #0a4fae;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.42),
    inset 0 -2px 0 rgba(3, 29, 86, 0.42),
    0 2px 0 rgba(67, 38, 8, 0.28);
  touch-action: none;
}

.word-token:hover:not(:disabled) {
  background: #1767c8;
  border-color: #f0bd4c;
}

.word-token:focus-visible {
  outline: 2px solid #fff2a8;
  outline-offset: 2px;
}

.word-token:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 2px 3px rgba(3, 29, 86, 0.42),
    0 1px 0 rgba(67, 38, 8, 0.28);
}

.answer-slot.is-drag-source,
.word-token.is-drag-source {
  opacity: 0.42;
}

.is-drag-preview {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2147482000;
  margin: 0;
  pointer-events: none;
  opacity: 0.92;
  filter: drop-shadow(0 10px 14px rgba(4, 15, 39, 0.28));
}

.word-token.used {
  color: rgba(255, 255, 255, 0.58);
  pointer-events: none;
  opacity: 0.72;
  filter: grayscale(0.55) brightness(0.94);
}

.word-token.wrong,
.answer-slot.wrong {
  filter: saturate(0.82) sepia(0.24) hue-rotate(305deg);
}

.answer-slot.correct {
  filter: drop-shadow(0 0 10px rgba(59, 201, 109, 0.52));
}

.action-buttons {
  grid-row: 5;
  width: 95%;
  max-width: var(--action-buttons-max-width);
  height: 95%;
  min-height: 0;
  margin: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 1.2fr;
  align-items: center;
  gap: clamp(6px, calc(var(--challenge-width) * 0.014), 14px);
}

.asset-button {
  aspect-ratio: 456 / 180;
  border: 0;
  padding: 0;
  cursor: pointer;
  background-color: transparent;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  transition: filter 110ms ease, transform 110ms ease;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.asset-button:active,
.asset-button.is-pressed {
  filter: brightness(1.14) saturate(1.08);
  transform: translateY(2px) scale(0.96);
}

.read-action {
  background-image: url("assets/images/ui/sentence/read-button.png");
}

.hint-action {
  background-image: url("assets/images/ui/sentence/hint-button.png");
}

.reset-action {
  background-image: url("assets/images/ui/sentence/reset-button.png");
}

.next-action {
  aspect-ratio: 2169 / 689;
  background-image: url("assets/images/ui/sentence/next-question-button.png");
}

.submit-action {
  grid-row: 6;
  width: 42%;
  max-width: var(--submit-button-max-width);
  max-height: 80%;
  aspect-ratio: 1152 / 342;
  margin: auto;
  border: 0;
  padding: 0;
  cursor: pointer;
  background: url("assets/images/ui/sentence/submit-button-gold.png") center / contain no-repeat;
}

.feedback-line {
  display: none;
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 2%;
  min-height: 0;
  margin: 0;
  color: #1b4c93;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
}

/* 10. Companion zone: pet, nameplate, speech bubble, rewards, and pet actions. */
.companion-zone {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--companion-top);
  height: var(--companion-zone-height);
  z-index: 2;
}

.companion-nameplate {
  position: absolute;
  left: 50%;
  top: var(--companion-nameplate-top);
  bottom: auto;
  z-index: 5;
  width: var(--companion-nameplate-width);
  height: var(--companion-nameplate-height);
  padding: 6px 13px 7px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-content: center;
  align-items: center;
  color: var(--blue-ink);
  font-family: var(--display-cn-font);
  text-align: center;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.86), 0 2px 2px rgba(21, 61, 119, 0.22);
  background: url("assets/images/ui/sentence/pet-name-frame-young.png") center / 100% 100% no-repeat;
  transform: translateX(-50%);
}

.companion-nameplate.stage-mature {
  background-image: url("assets/images/ui/sentence/pet-name-frame-mature.png");
}

.companion-nameplate.stage-complete {
  background-image: url("assets/images/ui/sentence/pet-name-frame-complete.png");
}

.companion-nameplate strong {
  min-width: 0;
  font-family: "SimSun", "宋体", serif;
  font-size: 17px;
  font-weight: bold;
  line-height: 1;
  white-space: nowrap;
  -webkit-text-stroke: 0.35px currentColor;
}

.companion-action {
  position: absolute;
  top: calc(var(--companion-nameplate-top) + 3px);
  bottom: auto;
  width: var(--companion-action-width);
  height: var(--companion-action-height);
  aspect-ratio: 1063 / 388;
  z-index: 4;
  display: block;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  pointer-events: auto;
}

.companion-switch-action {
  left: var(--companion-action-edge);
  background-image: url("assets/images/ui/sentence/switch-companion-button.png");
}

.companion-detail-action {
  right: var(--companion-action-edge);
  background-image: url("assets/images/ui/sentence/pet-detail-button.png");
}

.evolution-stone-button {
  position: absolute;
  left: var(--evolution-stone-left);
  bottom: 8px;
  z-index: 6;
  width: var(--evolution-stone-width);
  min-height: var(--evolution-stone-min-height);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  gap: 1px;
  border: 0;
  padding: var(--evolution-stone-padding);
  color: var(--blue-ink);
  background: url("assets/images/ui/sentence/answer-slot-selected.png") center / 100% 100% no-repeat;
  cursor: pointer;
  filter: drop-shadow(0 7px 6px rgba(13, 28, 62, 0.28));
  font-family: "SimSun", "宋体", serif;
  text-align: center;
  touch-action: manipulation;
}

.evolution-stone-button[hidden] {
  display: none;
}

.evolution-stone-button:active {
  transform: translateY(2px) scale(0.96);
}

.evolution-stone-button.is-empty {
  filter: grayscale(0.72) brightness(0.82) drop-shadow(0 7px 6px rgba(13, 28, 62, 0.22));
}

.evolution-stone-button em {
  max-width: 100%;
  min-width: 0;
  color: #063675;
  font-style: normal;
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.95), 0 2px 2px rgba(7, 38, 91, 0.32);
  transform: translateY(-6px);
  -webkit-text-stroke: 0.34px currentColor;
}

.evolution-stone-button strong {
  display: none;
}

.evolution-stone-button em {
  font-size: clamp(13px, calc(var(--scene-width) * 0.0155), 16px);
}

.evolution-stone-art {
  width: min(70px, 66%);
  aspect-ratio: 1;
  display: block;
  background: var(--evolution-stone-image) center / contain no-repeat;
}

.evolution-stone-count {
  position: absolute;
  right: 8px;
  top: 8px;
  min-width: 24px;
  height: 24px;
  padding: 2px 6px;
  display: grid;
  place-items: center;
  color: #fff7d7;
  background: linear-gradient(180deg, #66717e, #313b48);
  border: 2px solid rgba(255, 255, 255, 0.74);
  border-radius: 999px;
  box-shadow: 0 2px 4px rgba(3, 12, 31, 0.42);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 13px;
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 1px 1px rgba(0, 17, 64, 0.8);
}

.companion-pet {
  position: absolute;
  left: 50%;
  bottom: calc(var(--companion-top) + var(--companion-zone-height) - var(--companion-ground-y));
  width: 31%;
  height: auto;
  filter: drop-shadow(0 10px 8px rgba(13, 28, 62, 0.32));
  transform: translateX(-50%);
}

.companion-pet[data-pet-stage="2"] {
  width: 36%;
}

.companion-pet[data-pet-stage="3"] {
  width: 42%;
}

.companion-pet.happy {
  animation: pet-bounce 0.52s ease;
}

.companion-pet.sad {
  filter: drop-shadow(0 10px 8px rgba(13, 28, 62, 0.32)) saturate(0.82);
  transform: translateX(-50%) translateY(3px);
}

.companion-pet.cry {
  animation: pet-shake 0.58s ease;
  filter: drop-shadow(0 10px 8px rgba(13, 28, 62, 0.32)) saturate(0.75) brightness(0.92);
}

.companion-pet.eat {
  animation: pet-nibble 0.62s ease;
}

.speech-bubble {
  position: absolute;
  left: calc(50% + var(--scene-width) * 0.155 + var(--speech-bubble-pet-side-gap));
  top: calc(var(--companion-ground-y) - var(--companion-top) - var(--scene-width) * 0.31 + var(--speech-bubble-pet-top-gap));
  width: 29.5%;
  min-height: 102px;
  padding: 13px 16px 12px;
  color: var(--blue-ink);
  background: rgba(255, 248, 230, 0.95);
  border: 2px solid rgba(192, 144, 76, 0.75);
  border-radius: 16px;
  box-shadow: 0 4px 0 rgba(90, 54, 19, 0.16);
  font-family: var(--display-cn-font);
  font-size: var(--speech-bubble-font-size);
  font-weight: 950;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.speech-bubble small {
  display: block;
  margin-top: 5px;
  color: #8a5f27;
  font-size: 11px;
  line-height: 1.1;
  text-shadow: none;
}

.speech-bubble::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 38%;
  width: 18px;
  height: 18px;
  background: inherit;
  border-left: 2px solid rgba(192, 144, 76, 0.75);
  border-bottom: 2px solid rgba(192, 144, 76, 0.75);
  transform: rotate(45deg);
}

@keyframes pet-bounce {
  0%,
  100% {
    transform: translateX(-50%) translateY(0);
  }
  45% {
    transform: translateX(-50%) translateY(-8px);
  }
}

@keyframes pet-shake {
  0%,
  100% {
    transform: translateX(-50%);
  }
  25% {
    transform: translateX(calc(-50% - 4px));
  }
  55% {
    transform: translateX(calc(-50% + 4px));
  }
}

@keyframes pet-nibble {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }
  35% {
    transform: translateX(-50%) scale(1.04, 0.96);
  }
  65% {
    transform: translateX(-50%) scale(0.98, 1.03);
  }
}

.reward-panel {
  position: absolute;
  left: var(--companion-action-edge);
  right: var(--companion-action-edge);
  top: calc(var(--companion-nameplate-top) + var(--companion-nameplate-height) + var(--reward-name-gap));
  bottom: auto;
  height: 30px;
  min-height: 30px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 70px;
  align-items: center;
  gap: 8px;
  padding: 2px 13px;
  color: #fff8dc;
  background: linear-gradient(180deg, rgba(12, 63, 128, 0.96), rgba(10, 38, 88, 0.96));
  border: 2px solid rgba(215, 170, 86, 0.82);
  border-radius: 13px;
  box-shadow: 0 4px 0 rgba(7, 23, 57, 0.48), inset 0 0 0 2px rgba(55, 149, 250, 0.3);
  font-family: var(--display-cn-font);
  font-size: 12px;
  font-weight: 950;
}

.reward-panel i {
  height: 7px;
  min-width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #40cfff 0 42%, rgba(8, 35, 83, 0.8) 42% 100%);
  border: 2px solid rgba(89, 169, 255, 0.9);
  box-shadow: inset 0 1px 4px rgba(255, 255, 255, 0.4);
}

.companion-level-badge {
  min-width: 70px;
  min-height: 22px;
  padding: 3px 10px 4px;
  display: grid;
  place-items: center;
  color: #9a5a00;
  font-family: "Times New Roman", Times, serif;
  font-size: 12px;
  font-style: normal;
  font-weight: 950;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255, 245, 184, 0.86), 0 1px 1px rgba(74, 32, 0, 0.46);
  background: url("assets/images/ui/sentence/pet-name-frame-young.png") center / 100% 100% no-repeat;
}

/* 11. Persistent bottom navigation. */
.bottom-nav {
  /* Viewport layer: keep the five links at the page bottom. */
  position: fixed;
  z-index: 20;
  left: 50%;
  right: auto;
  bottom: max(6px, env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: center;
  width: var(--bottom-nav-width);
  max-width: var(--bottom-nav-width);
  min-width: 0;
  height: var(--bottom-nav-height);
  min-height: 0;
  gap: 0;
  padding: 1% 4.8% 1.4%;
  border: 0;
  border-radius: 0;
  background: url("assets/images/ui/sentence/bottom-nav-bar.png") center / 100% 100% no-repeat;
  box-shadow: none;
  transform: translateX(-50%);
}

/* 12. Deck and tutorial overlays. */
.deck-selector-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  place-items: center;
  padding: 7%;
  background: rgba(5, 18, 46, 0.62);
}

.deck-selector-modal.open {
  display: grid;
}

/* 13. Food reward overlay. */
.food-reward-modal {
  position: fixed;
  inset: 0;
  z-index: 34;
  display: none;
  place-items: center;
  padding: 8%;
  background: rgba(5, 18, 46, 0.5);
}

.food-reward-modal.open {
  display: grid;
}

/* Keep every popup control inside its own card stacking context. */
.deck-selector-card,
.food-reward-card,
.hatch-card,
.pet-picker-card {
  position: relative;
  z-index: 0;
}

.deck-selector-card button,
.food-reward-card button,
.hatch-card button,
.pet-picker-card button {
  position: relative;
  z-index: 0;
}

.food-reward-card {
  width: min(94%, 430px);
  min-height: 282px;
  padding: 44px 54px 50px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 10px;
  color: var(--blue-ink);
  text-align: center;
  background: url("assets/images/ui/sentence/answer-slot-selected.png") center / 100% 100% no-repeat;
  border: 0;
  box-shadow: 0 18px 48px rgba(4, 15, 39, 0.36);
}

.food-reward-art {
  width: 56px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: 48px;
  background: var(--food-image) center / contain no-repeat;
  filter: drop-shadow(0 5px 5px rgba(25, 43, 85, 0.24));
}

.food-reward-title {
  font-family: "SimSun", "宋体", serif;
  font-size: 20px;
  font-weight: bold;
  line-height: 1.1;
  -webkit-text-stroke: 0.25px currentColor;
}

.food-reward-exp {
  color: #8a5f27;
  font-family: "SimSun", "宋体", serif;
  font-size: 13px;
  font-weight: bold;
}

.food-reward-actions {
  width: 100%;
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.food-reward-actions button {
  flex: 0 0 clamp(108px, calc(var(--scene-width) * 0.30), 124px);
  width: clamp(108px, calc(var(--scene-width) * 0.30), 124px);
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 7px 16px 0;
  color: #ffffff;
  background: url("assets/images/ui/sentence/blue-empty-label.png") center / 100% 100% no-repeat;
  font-family: "SimSun", "宋体", serif;
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
  transform: translateY(2px);
  text-shadow: 0 2px 2px rgba(0, 20, 70, 0.72);
  -webkit-text-stroke: 0.22px currentColor;
  cursor: pointer;
}
.sentence-limit-actions .primary-button {
  min-width: 124px;
}

.food-reward-actions .feed-now {
  flex-basis: clamp(116px, calc(var(--scene-width) * 0.32), 132px);
  width: clamp(116px, calc(var(--scene-width) * 0.32), 132px);
}

/* 14. Hatching and evolution overlays. */
.hatch-modal {
  position: fixed;
  inset: 0;
  z-index: 36;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(5, 18, 46, 0.5);
}

.hatch-modal.open {
  display: grid;
}

.hatch-card {
  width: min(calc(var(--scene-width) - 32px), 720px);
  min-height: min(calc(var(--scene-height) - 32px), 620px);
  max-height: calc(var(--scene-height) - 32px);
  padding: 90px 68px 62px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 14px;
  color: var(--blue-ink);
  text-align: center;
  background: url("assets/images/ui/sentence/answer-slot-selected.png") center / 100% 100% no-repeat;
  box-shadow: 0 18px 48px rgba(4, 15, 39, 0.36);
  overflow: hidden;
}

.hatch-card.is-hatch-preview {
  width: min(calc(var(--scene-width) - 20px), 760px);
  min-height: min(calc(var(--scene-height) - 20px), 700px);
  padding: 138px 58px 56px;
  gap: 10px;
  transform: translateY(calc(var(--scene-height) * -0.05));
}

.hatch-card.is-evolution-missing {
  width: min(calc(var(--scene-width) * 0.96), 660px);
  min-height: min(calc(var(--scene-height) * 0.84), 560px);
  padding-top: 104px;
  padding-bottom: 58px;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hatch-card.is-hatch-success {
  padding-top: 118px;
  padding-bottom: 58px;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hatch-card.is-evolution-success {
  padding-top: 118px;
  padding-bottom: 58px;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hatch-card.is-hatching-blocked {
  padding-top: 132px;
  padding-bottom: 58px;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hatch-card.is-evolution-preview {
  padding-top: 138px;
  padding-bottom: 52px;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.hatch-head {
  display: grid;
  gap: 8px;
  justify-items: center;
  max-width: 86%;
}

.hatch-card.is-hatch-preview .hatch-head {
  max-width: 92%;
  gap: 7px;
}

.hatch-head h2 {
  margin: 0;
  font: bold 22px/1.1 "SimSun", "宋体", serif;
  overflow-wrap: anywhere;
  -webkit-text-stroke: 0.25px currentColor;
}

.hatch-head small,
.hatch-preview-item small,
.hatch-result-item small {
  color: #8a5f27;
  font: bold 13px/1.25 "SimSun", "宋体", serif;
  overflow-wrap: anywhere;
}

.hatch-grid {
  width: 100%;
  max-height: min(calc(var(--scene-height) * 0.56), 440px);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 18px 22px;
  overflow: auto;
  padding: 2px;
}

.hatch-card.is-hatch-preview .hatch-grid {
  width: min(74%, 430px);
  max-height: min(calc(var(--scene-height) * 0.58), 500px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 8px;
  align-content: center;
  justify-self: center;
}

.hatch-card.is-evolution-preview .hatch-grid {
  align-content: center;
}

.hatch-card.is-evolution-success .hatch-grid {
  align-content: center;
}

.hatch-card.is-hatching-blocked .hatch-grid {
  align-content: center;
}

.hatch-preview-item,
.hatch-result-item {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 5px;
}

.hatch-card.is-hatch-preview .hatch-preview-item {
  gap: 3px;
}

.hatch-card.is-evolution-preview .hatch-result-item {
  gap: 4px;
  transform: translateY(-4px);
}

.hatch-preview-art {
  width: min(86px, calc(var(--scene-width) * 0.20));
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(25, 43, 85, 0.24));
}

.hatch-card.is-hatch-preview .hatch-preview-art {
  width: min(78px, calc(var(--scene-width) * 0.18));
}

.hatch-preview-item.is-hidden-hatch .hatch-preview-art {
  filter: brightness(0) opacity(0.72) drop-shadow(0 5px 5px rgba(25, 43, 85, 0.24));
}

.hatch-preview-item strong,
.hatch-result-item strong {
  color: var(--blue-ink);
  font: bold 15px/1.1 "SimSun", "宋体", serif;
  -webkit-text-stroke: 0.2px currentColor;
}

.hatch-result-art {
  width: min(128px, calc(var(--scene-width) * 0.34));
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 8px 8px rgba(25, 43, 85, 0.24));
}

.hatch-card.is-evolution-preview .hatch-result-art {
  transform: translateY(-26px);
  margin-bottom: -16px;
}

.hatch-card.is-hatch-success .hatch-result-item {
  align-self: center;
  gap: 8px;
}

.hatch-card.is-evolution-success .hatch-result-item {
  align-self: center;
  gap: 8px;
}

.hatch-card.is-hatching-blocked .hatch-result-item {
  align-self: center;
  gap: 3px;
  transform: translateY(18px);
}

.hatch-card.is-hatch-success .hatch-result-item small {
  max-width: min(86%, 360px);
  line-height: 1.42;
}

.hatch-card.is-hatching-blocked .hatch-result-art {
  transform: translateY(-18px);
  margin-bottom: -10px;
}

.hatch-card.is-hatching-blocked .hatch-result-item small {
  line-height: 1.04;
}

.hatch-card.is-evolution-success .hatch-result-item small {
  max-width: min(86%, 360px);
  line-height: 1.42;
}

.hatch-card.is-evolution-preview .hatch-result-item small {
  max-width: min(72%, 320px);
  line-height: 1.06;
}

.evolution-missing-item {
  align-self: center;
  gap: 10px;
}

.evolution-stone-missing-art {
  width: min(150px, calc(var(--scene-width) * 0.34));
}

.hatch-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hatch-close,
.hatch-challenge {
  min-width: 118px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  padding: 7px 18px 0;
  color: #ffffff;
  background: url("assets/images/ui/sentence/blue-empty-label.png") center / 100% 100% no-repeat;
  font: bold 13px/1 "SimSun", "宋体", serif;
  text-shadow: 0 2px 2px rgba(0, 20, 70, 0.72);
  -webkit-text-stroke: 0.22px currentColor;
  cursor: pointer;
}
.sentence-limit-actions .primary-button {
  min-width: 124px;
}

.hatch-challenge[hidden] {
  display: none;
}

.hatch-challenge {
  min-width: 126px;
}

/* 15. Companion picker overlay. */
.pet-picker-modal {
  position: fixed;
  inset: 0;
  z-index: 35;
  display: none;
  place-items: center;
  padding: 7%;
  background: rgba(5, 18, 46, 0.56);
}

.pet-picker-modal.open {
  display: grid;
}

.pet-picker-card {
  width: min(100%, 540px);
  max-height: 78%;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  color: var(--blue-ink);
  background: rgba(255, 250, 235, 0.97);
  border: 3px solid rgba(218, 166, 78, 0.9);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(4, 15, 39, 0.42), inset 0 0 0 2px rgba(75, 155, 255, 0.18);
}

.pet-picker-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

.pet-picker-head h2 {
  margin: 0;
  font-family: "SimSun", "宋体", serif;
  font-size: 22px;
  font-weight: bold;
}

.pet-picker-close {
  border: 2px solid rgba(91, 150, 219, 0.72);
  border-radius: 12px;
  padding: 8px 14px;
  color: var(--blue-ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(215, 236, 255, 0.94));
  font-family: "SimSun", "宋体", serif;
  font-weight: bold;
  cursor: pointer;
}
.sentence-limit-actions .primary-button {
  min-width: 124px;
}

.pet-picker-grid {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  padding-right: 3px;
}

.pet-picker-option {
  min-width: 0;
  min-height: 96px;
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border: 2px solid rgba(91, 150, 219, 0.72);
  border-radius: 14px;
  padding: 9px 11px;
  color: var(--blue-ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(215, 236, 255, 0.94));
  box-shadow: 0 3px 0 rgba(82, 134, 210, 0.18);
  font-family: "SimSun", "宋体", serif;
  text-align: left;
  cursor: pointer;
}
.sentence-limit-actions .primary-button {
  min-width: 124px;
}

.pet-picker-option.active {
  border-color: #d99b2f;
  background: linear-gradient(180deg, #fff0a3, #ffd45a);
}

.pet-picker-thumb {
  width: 74px;
  aspect-ratio: 1;
  background: var(--pet-image) center / contain no-repeat;
  filter: drop-shadow(0 5px 5px rgba(25, 43, 85, 0.22));
}

.pet-picker-info {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 7px 12px;
}

.pet-picker-option strong,
.pet-picker-option small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pet-picker-option strong {
  font-size: 19px;
  font-weight: bold;
}

.pet-picker-option small {
  color: rgba(16, 50, 106, 0.72);
  font-size: 14px;
  font-weight: bold;
}

.pet-picker-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.pet-picker-stats span {
  min-width: 0;
  padding: 4px 5px;
  border: 1px solid rgba(91, 150, 219, 0.34);
  border-radius: 8px;
  color: #24476f;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  white-space: nowrap;
}

.pet-picker-stats b {
  margin-right: 3px;
  color: var(--blue-ink);
}

.deck-selector-card {
  width: min(100%, 600px);
  max-height: 82svh;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  color: var(--blue-ink);
  background: rgba(255, 250, 235, 0.96);
  border: 3px solid rgba(218, 166, 78, 0.9);
  border-radius: 22px;
  box-shadow: 0 18px 50px rgba(4, 15, 39, 0.42), inset 0 0 0 2px rgba(75, 155, 255, 0.2);
}

.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.picker-head h2 {
  margin: 0;
  font-family: var(--display-cn-font);
  font-size: 22px;
  line-height: 1.1;
}

.sentence-deck-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sentence-deck-manage {
  min-height: 34px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  border: 2px solid #8fc1f4;
  border-radius: 999px;
  color: var(--blue-ink);
  background: linear-gradient(180deg, #ffffff 0%, #eaf7ff 100%);
  box-shadow: 0 3px 0 rgba(82, 134, 210, 0.16);
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}
.picker-head button,
.sentence-stage-item,
.sentence-series-item,
.sentence-deck-item {
  border: 2px solid rgba(91, 150, 219, 0.72);
  color: var(--blue-ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(215, 236, 255, 0.94));
  box-shadow: 0 3px 0 rgba(82, 134, 210, 0.18);
  font-family: var(--display-cn-font);
  font-weight: 950;
  cursor: pointer;
}
.sentence-limit-actions .primary-button {
  min-width: 124px;
}

.picker-head button {
  min-height: 34px;
  padding: 0 14px;
  border-color: #8fc1f4;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #eaf7ff 100%);
  font-size: 12px;
  font-weight: 900;
}

.sentence-stage-list,
.sentence-series-list {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.sentence-series-list {
  min-width: 0;
}

.sentence-stage-item,
.sentence-series-item,
.sentence-deck-item {
  min-width: 0;
  padding: 10px 8px;
  display: grid;
  gap: 3px;
  text-align: left;
}

.sentence-stage-item,
.sentence-series-item {
  flex: 0 0 clamp(126px, 22vw, 176px);
}

.sentence-stage-item {
  align-items: center;
  justify-content: center;
  min-height: 62px;
  border-radius: 18px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(228, 241, 255, 0.94));
  box-shadow: 0 3px 0 rgba(82, 134, 210, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.sentence-series-item {
  min-height: 86px;
  border-radius: 16px;
  padding: 12px 10px 10px;
  background: linear-gradient(180deg, rgba(244, 248, 255, 0.98), rgba(223, 236, 255, 0.95));
}

.sentence-deck-item {
  border-radius: 13px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(228, 239, 251, 0.94));
}

.sentence-stage-item span:first-child,
.sentence-series-item span:first-child {
  white-space: normal;
  word-break: break-word;
}

.sentence-stage-item.active,
.sentence-series-item.active,
.sentence-deck-item.active {
  color: #4b3107;
  border-color: #d99b2f;
  background: linear-gradient(180deg, #fff0a3, #ffd45a);
}

.sentence-stage-sub,
.sentence-series-sub,
.sentence-deck-total {
  color: rgba(16, 50, 106, 0.68);
  font-size: 11px;
  font-weight: 800;
}

.sentence-grade-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding-right: 3px;
}

.sentence-deck-item {
  grid-template-columns: 1fr auto;
  align-items: center;
}

/* 17. Bottom navigation icon assets. */
.nav-item {
  display: block;
  align-self: center;
  justify-self: center;
  width: 70%;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 5px 8px;
  border: 0;
  border-radius: 0;
  background-color: transparent;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: none;
}

.nav-item.active {
  width: 78%;
}

.nav-hall {
  background-image: url("assets/images/ui/sentence/nav-hall.png");
}

.nav-hall.active {
  background-image: url("assets/images/ui/sentence/nav-hall-active.png");
}

.nav-training {
  background-image: url("assets/images/ui/sentence/nav-training.png");
}

.nav-training.active {
  background-image: url("assets/images/ui/sentence/nav-training-active.png");
}

.nav-adventure {
  background-image: url("assets/images/ui/sentence/nav-adventure.png");
}

.nav-adventure.active {
  background-image: url("assets/images/ui/sentence/nav-adventure-active.png");
}

.nav-home {
  background-image: url("assets/images/ui/sentence/nav-home.png");
}

.nav-home.active {
  background-image: url("assets/images/ui/sentence/nav-home-active.png");
}

.nav-bag {
  background-image: url("assets/images/ui/sentence/nav-bag.png");
}

.nav-bag.active {
  background-image: url("assets/images/ui/sentence/nav-bag-active.png");
}

/* 18. Very narrow phone adjustments. */
@media (max-width: 540px) and (min-height: 701px) and (orientation: portrait) {
  .companion-nameplate {
    padding: 8px 10px;
  }

  .speech-bubble {
    width: 29%;
    min-height: 96px;
    padding: 10px 12px;
    font-size: 13px;
  }

  .reward-panel {
    left: var(--companion-action-edge);
    right: var(--companion-action-edge);
    font-size: 12px;
  }

}

/* Step-by-step tutorial. The highlighted target remains usable while the
   surrounding four panels block accidental clicks elsewhere. */
.sentence-guide.hidden {
  display: none;
}

.sentence-guide {
  position: fixed;
  inset: 0;
  z-index: 5000;
  pointer-events: none;
  font-family: "Noto Sans SC", "Inter", system-ui, sans-serif;
}

.sentence-guide-dim {
  position: fixed;
  z-index: 5000;
  pointer-events: auto;
  background: rgba(16, 44, 78, 0.48);
}

.sentence-guide-spotlight {
  position: fixed;
  z-index: 5001;
  pointer-events: none;
  border: 2px solid rgba(255, 222, 99, 0.98);
  border-radius: 12px;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9),
    0 0 24px rgba(117, 179, 241, 0.78),
    inset 0 0 18px rgba(255, 255, 255, 0.34);
  animation: sentenceGuideSpotlightPulse 0.95s ease-in-out infinite alternate;
}

.sentence-guide-arrow {
  position: fixed;
  z-index: 5003;
  width: 28px;
  height: 28px;
  pointer-events: none;
  filter: drop-shadow(0 4px 8px rgba(35, 92, 155, 0.28));
}

.sentence-guide-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
}

.sentence-guide-arrow.up::before {
  border-bottom: 27px solid #6bb6ff;
}

.sentence-guide-arrow.down::before {
  border-top: 27px solid #6bb6ff;
}

.sentence-guide-card {
  position: fixed;
  z-index: 5004;
  max-width: calc(100vw - 28px);
  padding: 16px;
  pointer-events: auto;
  border: 2px solid rgba(126, 177, 235, 0.95);
  border-radius: 16px;
  color: #17345f;
  background: #f5fbff;
  box-shadow: 0 18px 34px rgba(37, 92, 150, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.92);
}

.sentence-guide-step {
  margin: 0 0 4px;
  color: #3b82d6;
  font-size: 12px;
  font-weight: 900;
}

.sentence-guide-title {
  margin: 0 0 7px;
  color: #1f5ea9;
  font-size: 20px;
  line-height: 1.2;
}

.sentence-guide-text {
  margin: 0;
  color: #21476f;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.5;
}

.sentence-guide-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.sentence-guide-actions button {
  min-height: 36px;
  padding: 7px 14px;
  border: 2px solid rgba(96, 151, 216, 0.9);
  border-radius: 10px;
  color: #1f5ea9;
  background: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
}

.sentence-guide-next {
  color: #ffffff !important;
  background: #3b82d6 !important;
}

@keyframes sentenceGuideSpotlightPulse {
  from {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.9),
      0 0 18px rgba(117, 179, 241, 0.62),
      inset 0 0 14px rgba(255, 255, 255, 0.28);
  }
  to {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.96),
      0 0 28px rgba(117, 179, 241, 0.9),
      inset 0 0 20px rgba(255, 255, 255, 0.4);
  }
}

@media (max-width: 540px) {
  .sentence-guide-card {
    padding: 14px;
  }

  .sentence-guide-title {
    font-size: 18px;
  }

  .sentence-guide-text {
    font-size: 13px;
  }
}


/* Sentence playback speed menu opened from the top-right speaker button. */
.sentence-rate-menu{position:absolute;right:calc(3.7% + var(--top-tool-size) + 8px);top:2.1%;z-index:40;display:flex;align-items:center;gap:7px;padding:9px 10px;color:#17345f;font:900 13px/1 "Noto Sans SC","Microsoft YaHei",sans-serif;border:2px solid #d5a13b;border-radius:12px;background:rgba(255,250,235,.98);box-shadow:0 8px 20px rgba(10,29,68,.3);pointer-events:auto;white-space:nowrap}.sentence-rate-menu label{font-weight:900}.sentence-rate-menu select{min-width:72px;padding:5px 4px;color:#17345f;font:inherit;border:1px solid #8fb8df;border-radius:7px;background:#fff;cursor:pointer}.sentence-rate-menu[hidden]{display:none}@media(max-width:600px){.sentence-rate-menu{right:calc(3.7% + var(--top-tool-size) + 8px);top:2.1%;padding:8px;font-size:12px}.sentence-rate-menu select{min-width:66px;font-size:12px}}

/* Access-limit dialog follows the adventure end-card visual system. */
.sentence-limit-modal {
  position: fixed;
  inset: 0;
  z-index: 5030;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(55, 118, 178, 0.34);
  overflow: hidden;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}
.sentence-limit-card {
  position: relative;
  box-sizing: border-box;
  width: min(410px, calc(100vw - 32px));
  padding: 20px 18px 18px;
  border: 2px solid rgba(111, 184, 231, 0.88);
  border-radius: 20px;
  color: #24446c;
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(236, 249, 255, 0.97));
  box-shadow: 0 20px 46px rgba(48, 116, 178, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.92);
}
.sentence-limit-card h2 {
  margin: 0 0 8px;
  color: #1f5f9c;
  font-size: clamp(22px, 4.6vw, 32px);
  line-height: 1.14;
  text-shadow: none;
}
.sentence-limit-card p {
  max-width: 340px;
  margin: 0 auto 16px;
  color: #4b6f91;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.55;
  text-align: center;
}
.sentence-limit-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sentence-limit-actions button {
  min-width: 86px;
  min-height: 42px;
  padding: 0 18px;
  border: 2px solid rgba(111, 184, 231, 0.88);
  border-radius: 14px;
  color: #1f5f9c;
  font: inherit;
  font-weight: 900;
  background: linear-gradient(180deg, #ffffff, #e7f5ff);
  box-shadow: 0 8px 18px rgba(74, 142, 205, 0.14);
  cursor: pointer;
}
.sentence-limit-actions .primary-button {
  min-width: 124px;
}