:root {
  color-scheme: light;
  --ink: #2f2630;
  --muted: #6c5b5e;
  --paper: #fff8ea;
  --paper-strong: #fffdf6;
  --vellum: rgba(255, 250, 238, 0.86);
  --vellum-strong: rgba(255, 253, 246, 0.94);
  --line-soft: rgba(80, 54, 43, 0.14);
  --plum: #3f3150;
  --plum-soft: #665178;
  --plum-deep: #281d37;
  --teal: #2e7773;
  --teal-deep: #1f5f5b;
  --mint: #d8eee6;
  --rose: #a34b53;
  --rose-deep: #7d3549;
  --gold: #d8a447;
  --gold-light: #f4d790;
  --wood: #8f5d35;
  --wood-dark: #4d2e22;
  --shadow: 0 22px 58px rgba(47, 38, 48, 0.24);
  --soft-shadow: 0 12px 28px rgba(47, 38, 48, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(50, 33, 54, 0.52), rgba(35, 83, 79, 0.44)),
    url("./assets/ui-library-backdrop.png") center / cover fixed,
    linear-gradient(135deg, #f3efe7 0%, #d7ece8 52%, #efe2ed 100%);
  color: var(--ink);
  font-family:
    "Hiragino Sans", "Yu Gothic", "YuGothic", "Noto Sans JP", system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

.app-shell {
  position: relative;
  width: min(100%, 430px);
  height: 100dvh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(239, 248, 245, 0.97)),
    #fff8ea;
  box-shadow: var(--shadow);
}

.screen {
  display: none;
  min-height: 100dvh;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

.title-screen {
  position: relative;
  --lily-height: clamp(800px, 144dvh, 1080px);
  --lily-right: clamp(-170px, -34vw, -92px);
  --lily-top: clamp(154px, 28dvh, 228px);
  overflow: hidden;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, rgba(255, 246, 230, 0.74), rgba(49, 34, 39, 0.24)),
    #fff6e6;
}

.title-hero {
  position: absolute;
  inset: 0;
  min-height: inherit;
  overflow: hidden;
  background: #2f2630;
}

.hero-art {
  width: 100%;
  height: 100%;
  min-height: inherit;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: saturate(1.06) contrast(1.05);
}

.title-hero::after {
  position: absolute;
  inset: 0;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 250, 230, 0.02), rgba(40, 29, 55, 0.22) 40%, rgba(27, 20, 30, 0.72)),
    radial-gradient(circle at 50% 20%, rgba(255, 248, 220, 0.26), transparent 12rem),
    radial-gradient(circle at 50% 92%, rgba(244, 178, 76, 0.28), transparent 14rem);
}

.title-hero::before {
  position: absolute;
  inset: auto 0 0;
  z-index: 1;
  height: 18px;
  content: "";
  background: linear-gradient(180deg, rgba(245, 198, 111, 0), rgba(91, 55, 34, 0.48));
}

.hero-copy {
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(30px + env(safe-area-inset-top));
  bottom: auto;
  z-index: 4;
  color: #fffdf6;
  text-shadow: 0 3px 16px rgba(40, 22, 24, 0.6);
}

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

.title-logo {
  display: block;
  width: min(100%, 320px);
  height: auto;
  margin: 0 auto;
  filter:
    drop-shadow(0 15px 20px rgba(34, 18, 15, 0.5))
    drop-shadow(0 2px 0 rgba(255, 222, 126, 0.55));
}

.title-lily-mask {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}

.title-lily {
  position: absolute;
  top: var(--lily-top);
  right: var(--lily-right);
  width: auto;
  height: var(--lily-height);
  max-width: none;
  object-fit: contain;
  object-position: top center;
  filter:
    drop-shadow(0 18px 20px rgba(34, 18, 15, 0.36))
    drop-shadow(0 2px 0 rgba(255, 240, 180, 0.3));
  transform: none;
}

.lily-secret-button {
  position: absolute;
  top: calc(var(--lily-top) + var(--lily-height) * 0.08);
  right: calc(var(--lily-right) + var(--lily-height) * 0.172);
  z-index: 6;
  width: clamp(96px, calc(var(--lily-height) * 0.16), 176px);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}

.lily-secret-button:focus-visible {
  outline: 3px solid rgba(255, 241, 168, 0.86);
  outline-offset: 3px;
}

.series-name,
.screen-kicker {
  margin: 0;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
}

.hero-copy .series-name {
  color: #f6d88c;
}

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

h1 {
  margin-bottom: 0;
  font-size: 2.15rem;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  color: var(--plum);
  font-size: 1.05rem;
  line-height: 1.25;
  letter-spacing: 0;
}

.title-actions {
  position: relative;
  z-index: 5;
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 12px;
  justify-content: flex-end;
  min-height: inherit;
  padding: 0 18px calc(10px + env(safe-area-inset-bottom));
  background: transparent;
}

.title-credits {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 3px 10px;
  margin: 0;
  color: rgba(255, 248, 216, 0.78);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
  text-shadow:
    0 1px 0 rgba(52, 25, 13, 0.82),
    0 4px 9px rgba(28, 16, 12, 0.56);
}

.title-credits span {
  white-space: nowrap;
}

.mascot-strip,
.helper-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 9px 12px 9px 9px;
  border: 1px solid rgba(124, 77, 46, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.94), rgba(247, 236, 214, 0.88));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.88),
    0 10px 24px rgba(47, 38, 48, 0.13);
}

.mascot-strip img,
.helper-row img {
  width: 70px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
  box-shadow:
    0 0 0 2px rgba(255, 253, 246, 0.8),
    0 8px 16px rgba(47, 38, 48, 0.18);
}

.mascot-strip p,
.helper-row p {
  margin: 0;
  color: var(--plum);
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.45;
}

.helper-row p {
  color: #4a2a1b;
}

.mode-grid {
  display: grid;
  gap: 10px;
}

.utility-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  overflow: hidden;
  padding: 14px 18px 15px;
  border-radius: 8px;
  border: 2px solid rgba(255, 214, 119, 0.78);
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.34), transparent 48%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.02) 28%, rgba(53, 24, 12, 0.24)),
    linear-gradient(135deg, #9f5727, #6f3419 52%, #3f2118);
  box-shadow:
    inset 0 1px rgba(255, 248, 206, 0.66),
    inset 0 -3px rgba(45, 21, 13, 0.3),
    0 12px 24px rgba(31, 18, 18, 0.26);
  text-align: center;
  text-shadow:
    0 2px 0 rgba(52, 25, 13, 0.82),
    0 5px 10px rgba(28, 16, 12, 0.46);
}

.mode-card::before,
.mode-card::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.mode-card::before {
  inset: 5px;
  border: 1px solid rgba(255, 233, 153, 0.34);
  border-radius: 6px;
}

.mode-card::after {
  inset: 0 18px auto;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 247, 200, 0.92), transparent);
  opacity: 0.9;
}

.mode-card:active,
.primary-action:active,
.secondary-action:active,
.icon-button:active {
  transform: translateY(1px) scale(0.995);
}

.mode-card strong {
  display: block;
  margin-bottom: 0;
  color: #fff8d8;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.25;
}

.utility-card {
  min-height: 46px;
  padding: 10px 12px 11px;
  border-color: rgba(255, 214, 119, 0.62);
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.28), transparent 48%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.02) 28%, rgba(53, 24, 12, 0.2)),
    linear-gradient(135deg, #7b4425, #55301f 56%, #2f211f);
}

.utility-card strong {
  font-size: 0.92rem;
}

.mode-card small {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
}

.mode-icon {
  position: relative;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 8px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.64), rgba(216, 238, 230, 0.68)),
    var(--mint);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.8),
    0 8px 16px rgba(46, 119, 115, 0.16);
}

.search-icon::before {
  width: 17px;
  height: 17px;
  border: 3px solid var(--teal);
  border-radius: 50%;
  content: "";
}

.search-icon::after {
  position: absolute;
  width: 13px;
  height: 3px;
  border-radius: 999px;
  content: "";
  background: var(--teal);
  transform: translate(11px, 12px) rotate(45deg);
}

.sort-icon::before {
  display: block;
  width: 23px;
  height: 26px;
  border-radius: 3px;
  content: "";
  background:
    linear-gradient(var(--teal), var(--teal)) 0 2px / 16px 3px no-repeat,
    linear-gradient(var(--gold), var(--gold)) 0 11px / 23px 3px no-repeat,
    linear-gradient(var(--rose), var(--rose)) 0 20px / 12px 3px no-repeat;
}

.game-screen {
  overflow-x: hidden;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 247, 221, 0.3), rgba(48, 30, 28, 0.2)),
    url("./assets/ui-library-backdrop.png") center / cover no-repeat;
}

.game-screen::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 247, 226, 0.76), rgba(255, 247, 226, 0.42) 34%, rgba(46, 24, 18, 0.18)),
    radial-gradient(circle at 50% 7%, rgba(255, 222, 126, 0.24), transparent 14rem);
}

.game-screen > * {
  position: relative;
}

.game-header {
  position: sticky;
  top: calc(8px + env(safe-area-inset-top));
  z-index: 10;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px;
  border: 2px solid rgba(255, 214, 119, 0.52);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.2), transparent 48%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(63, 30, 14, 0.18)),
    linear-gradient(135deg, rgba(151, 83, 39, 0.92), rgba(92, 42, 24, 0.94) 58%, rgba(55, 29, 23, 0.96));
  box-shadow:
    inset 0 1px rgba(255, 248, 206, 0.5),
    inset 0 -3px rgba(45, 21, 13, 0.26),
    0 12px 26px rgba(31, 18, 18, 0.24);
  backdrop-filter: blur(12px);
}

.game-header .screen-kicker {
  color: #f8dc91;
  text-shadow: 0 2px 0 rgba(43, 22, 12, 0.5);
}

.game-header h2 {
  color: #fff8d8;
  text-shadow:
    0 2px 0 rgba(52, 25, 13, 0.82),
    0 5px 10px rgba(28, 16, 12, 0.42);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 244, 190, 0.36), transparent),
    linear-gradient(135deg, #fff9e8, #e2c28a);
  color: #54301d;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.88),
    0 8px 18px rgba(31, 18, 18, 0.18);
}

.icon-button span {
  font-size: 2rem;
  line-height: 1;
  transform: translateY(-1px);
}

.timer-pill {
  min-width: 72px;
  padding: 9px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 214, 119, 0.52);
  background:
    linear-gradient(180deg, #5d3f6f, #2a1c37 58%, #1f5f5b);
  color: #fffdf6;
  font-size: 0.86rem;
  font-weight: 900;
  text-align: center;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.2),
    0 8px 16px rgba(63, 49, 80, 0.22);
}

.header-label {
  min-width: 62px;
}

.countdown-overlay[hidden] {
  display: none;
}

.countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 226, 143, 0.26), transparent 10rem),
    rgba(38, 22, 30, 0.22);
  backdrop-filter: blur(2px);
}

.countdown-card {
  display: grid;
  width: min(88vw, 300px);
  min-height: 174px;
  place-items: center;
  padding: 20px 18px;
  border: 3px solid rgba(255, 222, 126, 0.82);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 240, 170, 0.28), transparent 45%),
    linear-gradient(135deg, #a45d2e, #6b351e 58%, #392018);
  box-shadow:
    inset 0 1px rgba(255, 250, 213, 0.72),
    inset 0 -5px rgba(42, 20, 13, 0.32),
    0 22px 42px rgba(31, 18, 18, 0.36);
}

#countdownText {
  display: block;
  color: #fff8d8;
  font-size: 5.15rem;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  word-break: keep-all;
  text-shadow:
    0 3px 0 rgba(66, 31, 15, 0.86),
    0 10px 22px rgba(28, 16, 12, 0.48);
  transform-origin: center;
}

#countdownText.is-word {
  font-size: 2.75rem;
}

@media (max-width: 360px) {
  #countdownText {
    font-size: 4.7rem;
  }

  #countdownText.is-word {
    font-size: 2.35rem;
  }
}

#countdownText.is-pop {
  animation: countdownPop 840ms cubic-bezier(0.17, 1.22, 0.32, 1) both;
}

@keyframes countdownPop {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.72);
  }

  42% {
    opacity: 1;
    transform: translateY(0) scale(1.08);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.round-meter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin: 4px 0 9px;
}

.round-dot {
  height: 9px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 246, 201, 0.72), rgba(74, 37, 22, 0.22));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.72),
    0 4px 9px rgba(31, 18, 18, 0.12);
}

.round-dot.is-current,
.round-dot.is-done {
  background: var(--teal);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.38),
    0 5px 12px rgba(46, 119, 115, 0.24);
}

.mission-text {
  min-height: 34px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 214, 119, 0.5);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(247, 231, 190, 0.91));
  color: #4a2a1b;
  font-size: 0.85rem;
  font-weight: 800;
  line-height: 1.35;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.8),
    0 10px 22px rgba(31, 18, 18, 0.15);
}

.helper-row {
  grid-template-columns: 62px 1fr;
  min-height: 70px;
  margin-bottom: 12px;
  border-color: rgba(255, 214, 119, 0.44);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(247, 231, 190, 0.9));
}

.helper-row img {
  width: 62px;
  height: 52px;
}

.bookshelf {
  position: relative;
  display: grid;
  gap: 10px;
  overflow: hidden;
  padding: 16px 12px 17px;
  border-radius: 8px;
  border: 2px solid rgba(255, 214, 119, 0.38);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), transparent 16%, rgba(0, 0, 0, 0.1)),
    linear-gradient(180deg, #9a6438, #553429 58%, #40261f);
  box-shadow:
    inset 0 0 0 2px rgba(69, 38, 28, 0.34),
    inset 0 12px 22px rgba(255, 219, 139, 0.13),
    0 18px 34px rgba(47, 38, 48, 0.25);
}

.bookshelf::before {
  position: absolute;
  inset: 5px;
  pointer-events: none;
  border: 1px solid rgba(255, 225, 159, 0.18);
  border-radius: 6px;
  content: "";
}

.shelf-row {
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 4px;
  min-height: 160px;
  align-items: end;
  padding: 0 5px 12px;
}

.shelf-row::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 10px;
  border-radius: 3px;
  content: "";
  background:
    linear-gradient(180deg, rgba(255, 220, 149, 0.38), transparent 42%),
    linear-gradient(180deg, #be8152, #55372a);
  box-shadow:
    0 -1px 0 rgba(47, 27, 21, 0.42),
    0 2px 0 rgba(255, 248, 234, 0.18) inset,
    0 5px 10px rgba(35, 21, 17, 0.24);
}

.book {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: end;
  justify-content: center;
  width: 100%;
  height: var(--book-height, 146px);
  min-width: 0;
  padding: 5px 0 6px;
  border: 1px solid rgba(255, 248, 234, 0.28);
  border-radius: 5px 5px 3px 3px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.03) 24%, rgba(0, 0, 0, 0.16) 72%, rgba(0, 0, 0, 0.28)),
    linear-gradient(180deg, rgba(255, 231, 166, 0.2), transparent 34%, rgba(0, 0, 0, 0.16)),
    var(--book-color);
  box-shadow:
    inset 2px 0 rgba(255, 255, 255, 0.18),
    inset -2px 0 rgba(0, 0, 0, 0.18),
    0 5px 9px rgba(31, 24, 25, 0.26);
  touch-action: none;
}

#findShelf .book {
  touch-action: pan-y;
}

.book::before,
.book::after {
  position: absolute;
  right: 5px;
  left: 5px;
  height: 2px;
  border-radius: 999px;
  content: "";
  background:
    linear-gradient(90deg, transparent, rgba(255, 234, 171, 0.94), transparent);
}

.book::before {
  top: 10px;
}

.book::after {
  top: 17px;
}

.book:focus-visible {
  outline: 3px solid #fff1a8;
  outline-offset: 2px;
}

.book.is-selected {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
  box-shadow:
    0 0 0 4px rgba(216, 164, 71, 0.16),
    0 12px 22px rgba(216, 164, 71, 0.24),
    inset 2px 0 rgba(255, 255, 255, 0.18),
    inset -2px 0 rgba(0, 0, 0, 0.18);
}

.book.is-dragging {
  opacity: 0;
}

.book.is-answer {
  animation: correctPulse 0.55s ease;
  outline: 3px solid #79c987;
  outline-offset: 2px;
}

.book.is-wrong {
  animation: wrongShake 0.42s ease;
  outline: 3px solid #c55260;
  outline-offset: 2px;
}

.call-label {
  display: grid;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(63, 49, 80, 0.24);
  border-radius: 3px;
  background:
    linear-gradient(180deg, #fffdf6, #f2e9d2);
  color: #3b3032;
  font-size: 0.52rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  box-shadow: 0 1px 3px rgba(42, 27, 25, 0.24);
}

.call-label span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 16px;
  padding: 3px 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
}

.call-label span + span {
  border-top: 1px solid rgba(63, 49, 80, 0.2);
}

.feedback {
  min-height: 42px;
  margin: 12px 0 0;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid rgba(255, 214, 119, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.95), rgba(247, 231, 190, 0.9));
  color: #4a2a1b;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.35;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.76),
    0 9px 20px rgba(31, 18, 18, 0.14);
}

.feedback.is-good {
  color: #24694f;
}

.feedback.is-warn {
  color: #9a3946;
}

.info-screen {
  gap: 12px;
}

#storyScreen {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

#storyScreen .game-header {
  position: relative;
  top: auto;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.story-choice,
.record-board {
  display: grid;
  gap: 12px;
}

#storyScreen .story-choice {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.story-choice-card,
.record-panel {
  overflow: hidden;
  border: 2px solid rgba(255, 214, 119, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(247, 231, 190, 0.92));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.76),
    0 14px 28px rgba(31, 18, 18, 0.18);
}

.story-choice-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0;
  text-align: left;
}

.story-choice-image {
  display: block;
  flex: 1 1 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: rgba(255, 248, 226, 0.3);
}

.story-choice-card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 34%;
}

.story-choice-card strong {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 52px;
  width: 100%;
  padding: 13px 14px 14px;
  border-top: 1px solid rgba(124, 77, 46, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.98), rgba(247, 231, 190, 0.95));
  color: #4a2a1b;
  font-size: 1.05rem;
  font-weight: 900;
  line-height: 1.25;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.76);
}

.record-panel h3 {
  margin: 2px 0 8px;
  color: #4a2a1b;
  font-size: 1rem;
  line-height: 1.25;
}

.kamishibai[hidden],
.story-choice[hidden] {
  display: none;
}

.kamishibai {
  display: grid;
  gap: 10px;
}

#storyScreen .kamishibai {
  flex: 1 1 auto;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr) auto;
}

.kamishibai-frame {
  min-height: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 214, 119, 0.5);
  border-radius: 8px;
  background: rgba(255, 248, 226, 0.2);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.4),
    0 15px 30px rgba(31, 18, 18, 0.24);
}

.kamishibai-art {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  max-height: 48dvh;
  object-fit: contain;
  object-position: center;
}

#storyScreen .kamishibai-art {
  max-height: none;
}

.kamishibai-panel {
  padding: 12px 13px 13px;
  border: 2px solid rgba(255, 214, 119, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(247, 231, 190, 0.92));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.76),
    0 14px 28px rgba(31, 18, 18, 0.18);
}

.story-progress {
  display: flex;
  gap: 6px;
  margin: 7px 0 10px;
}

.story-progress span {
  width: 28px;
  height: 7px;
  border-radius: 999px;
  background: rgba(91, 55, 34, 0.22);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.62);
}

.story-progress .is-current {
  background: var(--teal);
}

.kamishibai-text {
  min-height: 0;
  margin: 0;
  color: #5f3a27;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.58;
}

.kamishibai-actions {
  display: grid;
  grid-template-columns: 0.82fr 0.82fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.kamishibai-actions .primary-action,
.kamishibai-actions .secondary-action {
  min-height: 44px;
  padding: 9px 8px;
}

.kamishibai-actions button:disabled {
  cursor: default;
  opacity: 0.45;
  transform: none;
}

.record-panel {
  padding: 13px;
}

.record-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.record-list li {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  min-height: 38px;
  gap: 9px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 214, 119, 0.34);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.2), transparent),
    rgba(255, 253, 246, 0.56);
  color: #4a2a1b;
}

.record-list span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background:
    linear-gradient(135deg, #9f5727, #6f3419 52%, #3f2118);
  color: #fff8d8;
  font-size: 0.78rem;
  font-weight: 900;
}

.record-list strong {
  font-size: 0.98rem;
  font-weight: 900;
}

.record-list small {
  color: #7a5841;
  font-size: 0.72rem;
  font-weight: 800;
}

.record-list .record-empty {
  display: block;
  color: #6f4a34;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
}

.gallery-screen {
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: visible;
}

.gallery-screen .game-header {
  position: relative;
  top: auto;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.gallery-layout {
  display: grid;
  flex: 0 0 auto;
  gap: 10px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-content: start;
  gap: 10px;
  overflow: visible;
  padding: 2px 2px calc(18px + env(safe-area-inset-bottom));
}

.gallery-thumb {
  position: relative;
  display: grid;
  aspect-ratio: 3 / 4;
  min-height: 132px;
  overflow: hidden;
  min-width: 0;
  border: 2px solid rgba(255, 214, 119, 0.44);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.92), rgba(247, 231, 190, 0.78));
  color: #4a2a1b;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.74),
    0 8px 16px rgba(31, 18, 18, 0.16);
}

.gallery-thumb:focus-visible {
  outline: 3px solid rgba(255, 241, 168, 0.9);
  outline-offset: 2px;
}

.gallery-thumb:not(:disabled):active {
  transform: translateY(1px) scale(0.992);
}

.gallery-thumb:disabled {
  cursor: default;
}

.gallery-thumb.is-unlocked {
  border-color: rgba(255, 241, 168, 0.9);
  box-shadow:
    0 0 0 2px rgba(216, 164, 71, 0.18),
    0 10px 18px rgba(31, 18, 18, 0.2);
}

.gallery-thumb img,
.gallery-thumb-lock {
  display: block;
  width: 100%;
  height: 100%;
}

.gallery-thumb img {
  object-fit: cover;
  object-position: center;
}

.gallery-thumb-lock {
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.18), transparent),
    linear-gradient(135deg, var(--plum), var(--plum-deep));
  color: #fff8d8;
  font-size: clamp(2.4rem, 14vw, 4.4rem);
  font-weight: 900;
}

.gallery-thumb-badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  min-width: 24px;
  padding: 3px 5px 4px;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.28), transparent 46%),
    linear-gradient(135deg, rgba(63, 49, 80, 0.94), rgba(40, 29, 55, 0.96));
  color: #fff8d8;
  font-size: 0.64rem;
  font-weight: 900;
  text-align: center;
  box-shadow: 0 5px 10px rgba(31, 18, 18, 0.28);
}

.gallery-modal[hidden] {
  display: none;
}

.gallery-modal {
  position: absolute;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: calc(14px + env(safe-area-inset-top)) 14px calc(14px + env(safe-area-inset-bottom));
}

.gallery-modal-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 24%, rgba(255, 230, 154, 0.18), transparent 15rem),
    rgba(35, 20, 25, 0.74);
  backdrop-filter: blur(4px);
}

.gallery-modal-panel {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(100%, 390px);
  max-height: 100%;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 2px solid rgba(255, 214, 119, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.96), rgba(247, 231, 190, 0.9));
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.76),
    0 28px 54px rgba(16, 10, 14, 0.46);
}

.gallery-modal-panel img {
  display: block;
  justify-self: center;
  width: 100%;
  min-height: 0;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  background: rgba(45, 28, 23, 0.12);
}

.gallery-modal-close {
  position: absolute;
  top: 9px;
  right: 9px;
  z-index: 2;
  width: 38px;
  height: 38px;
}

.gallery-modal-close span {
  font-size: 1.65rem;
  transform: translateY(-1px);
}

.gallery-modal-caption {
  display: grid;
  gap: 3px;
  padding: 10px 12px 11px;
  border-top: 1px solid rgba(91, 55, 34, 0.14);
}

.gallery-modal-caption strong {
  color: #4a2a1b;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.25;
}

.drag-ghost {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  filter: drop-shadow(0 18px 18px rgba(30, 19, 22, 0.36));
  transform: translate(-50%, -78%) scale(1.04);
}

.sort-shelf .book {
  cursor: grab;
  transition:
    transform 340ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 160ms ease;
  will-change: transform;
}

.sort-shelf .book:active {
  cursor: grabbing;
}

.sort-shelf .book.is-reordering {
  z-index: 2;
}

.sort-shelf .book.is-previewing {
  z-index: 2;
}

.result-screen {
  gap: 12px;
  height: 100dvh;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: hidden;
  padding: calc(12px + env(safe-area-inset-top)) 14px calc(16px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(255, 247, 221, 0.28), rgba(48, 30, 28, 0.26)),
    url("./assets/ui-library-backdrop.png") center / cover no-repeat;
}

.result-screen.is-active {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.result-art {
  display: block;
  align-self: stretch;
  justify-self: center;
  width: auto;
  max-width: min(100%, 390px);
  height: 100%;
  min-height: 0;
  max-height: none;
  border-radius: 8px;
  background: rgba(255, 248, 226, 0.18);
  object-fit: contain;
  object-position: center;
  box-shadow:
    0 0 0 2px rgba(255, 214, 119, 0.34),
    0 18px 34px rgba(31, 18, 18, 0.28);
  filter: saturate(1.04) contrast(1.04);
}

.result-copy {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  gap: 10px;
  padding: 13px;
  border: 2px solid rgba(255, 214, 119, 0.5);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.18), transparent 40%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(63, 30, 14, 0.14)),
    linear-gradient(135deg, rgba(151, 83, 39, 0.95), rgba(92, 42, 24, 0.96) 58%, rgba(55, 29, 23, 0.98));
  box-shadow: inset 0 1px rgba(255, 248, 206, 0.5);
}

.result-copy .screen-kicker {
  color: #f8dc91;
  text-shadow: 0 2px 0 rgba(43, 22, 12, 0.5);
}

.score-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 214, 119, 0.48);
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.18), transparent 46%),
    linear-gradient(135deg, var(--plum), var(--plum-deep) 54%, #1f5f5b);
  color: #fffdf6;
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.16),
    0 12px 24px rgba(63, 49, 80, 0.22);
}

.score-panel span {
  color: #f6d88c;
  font-size: 0.78rem;
  font-weight: 900;
}

.score-panel strong {
  font-size: 1.35rem;
  letter-spacing: 0;
}

.result-message {
  min-height: 44px;
  margin: 0;
  color: #fff4cb;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.55;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 0;
}

.result-actions .primary-action,
.result-actions .secondary-action {
  min-width: 0;
  white-space: nowrap;
}

.primary-action,
.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 48px;
  padding: 11px 12px;
  border-radius: 8px;
  border: 2px solid rgba(255, 214, 119, 0.66);
  font-weight: 900;
  box-shadow:
    inset 0 1px rgba(255, 248, 206, 0.54),
    inset 0 -3px rgba(45, 21, 13, 0.24),
    0 10px 20px rgba(31, 18, 18, 0.22);
}

.primary-action {
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.24), transparent 48%),
    linear-gradient(135deg, var(--teal), var(--teal-deep));
  color: #fffdf6;
}

.secondary-action {
  background:
    linear-gradient(180deg, rgba(255, 238, 159, 0.34), transparent 48%),
    linear-gradient(135deg, #9f5727, #6f3419 52%, #3f2118);
  color: #fff8d8;
  text-shadow:
    0 2px 0 rgba(52, 25, 13, 0.82),
    0 5px 10px rgba(28, 16, 12, 0.42);
}

.x-post-action {
  text-decoration: none;
}

.x-post-action span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 248, 216, 0.95);
  color: #2c1816;
  font-size: 0.82rem;
  line-height: 1;
  text-shadow: none;
  box-shadow: inset 0 -2px rgba(45, 21, 13, 0.16);
}

@keyframes correctPulse {
  50% {
    transform: translateY(-5px) scale(1.04);
  }
}

@keyframes wrongShake {
  25% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
}

@media (max-height: 600px) {
  .title-screen {
    --lily-height: clamp(760px, 144dvh, 850px);
    --lily-right: clamp(-152px, -36vw, -96px);
    --lily-top: clamp(148px, 28dvh, 178px);
  }

  .title-hero {
    min-height: inherit;
  }

  .hero-art {
    min-height: inherit;
  }

  .title-logo {
    width: min(100%, 272px);
  }

  .title-actions {
    gap: 9px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .title-credits {
    font-size: 0.56rem;
  }

  h1 {
    font-size: 1.85rem;
  }

  .mascot-strip {
    min-height: 66px;
  }

  .mode-card {
    min-height: 54px;
    padding: 10px;
  }

  .utility-card {
    min-height: 42px;
    padding: 8px 10px;
  }

  .shelf-row {
    min-height: 152px;
  }

  .book {
    --book-height: 138px;
  }

  .feedback {
    min-height: 36px;
    padding-block: 8px;
  }

  #storyScreen,
  .result-screen {
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .gallery-screen {
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 0;
  }

  #storyScreen .game-header,
  .gallery-screen .game-header {
    grid-template-columns: 38px 1fr 54px;
    gap: 8px;
    padding: 6px;
  }

  #storyScreen .icon-button,
  .gallery-screen .icon-button {
    width: 38px;
    height: 38px;
  }

  #storyScreen .timer-pill,
  .gallery-screen .timer-pill {
    min-width: 54px;
    padding: 7px 8px;
    font-size: 0.78rem;
  }

  #storyScreen .story-choice,
  #storyScreen .kamishibai {
    gap: 8px;
  }

  #storyScreen .story-choice-card strong {
    min-height: 46px;
    padding: 9px 11px 10px;
    font-size: 0.94rem;
  }

  #storyScreen .kamishibai-panel {
    padding: 9px 10px 10px;
  }

  #storyScreen .story-progress {
    margin: 5px 0 7px;
  }

  #storyScreen .kamishibai-text {
    font-size: 0.82rem;
    line-height: 1.44;
  }

  #storyScreen .kamishibai-actions {
    gap: 6px;
    margin-top: 8px;
  }

  #storyScreen .kamishibai-actions .primary-action,
  #storyScreen .kamishibai-actions .secondary-action {
    min-height: 39px;
    padding: 7px 6px;
    font-size: 0.86rem;
  }

  .gallery-layout {
    gap: 8px;
  }

  .gallery-grid {
    gap: 8px;
  }

  .gallery-thumb {
    min-height: 116px;
  }

  .gallery-thumb-badge {
    right: 4px;
    bottom: 4px;
    min-width: 21px;
    padding: 2px 4px 3px;
    font-size: 0.58rem;
  }

  .gallery-modal {
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .gallery-modal-caption {
    padding: 8px 10px 9px;
  }

  .gallery-modal-caption strong {
    font-size: 0.92rem;
  }

  .result-copy {
    gap: 8px;
    padding: 10px;
  }

  .score-panel {
    padding: 9px 11px;
  }

  .score-panel strong {
    font-size: 1.18rem;
  }

  .result-message {
    min-height: 0;
    font-size: 0.82rem;
    line-height: 1.42;
  }

  .result-actions .primary-action,
  .result-actions .secondary-action {
    min-height: 42px;
    padding: 8px 7px;
    font-size: 0.82rem;
  }

  .x-post-action span {
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
  }
}

@media (max-width: 360px) {
  .result-actions {
    gap: 5px;
  }

  .result-actions .primary-action,
  .result-actions .secondary-action {
    gap: 4px;
    min-height: 40px;
    padding: 7px 4px;
    font-size: 0.72rem;
  }

  .result-actions .x-post-action span {
    flex: 0 0 auto;
    width: 17px;
    height: 17px;
    font-size: 0.64rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sort-shelf .book {
    transition: none;
  }

  .book.is-answer,
  .book.is-wrong {
    animation: none;
  }
}

@media (min-width: 700px) {
  body {
    padding: 24px 0;
  }

  .app-shell {
    height: min(860px, calc(100dvh - 48px));
    min-height: min(860px, calc(100dvh - 48px));
    border-radius: 22px;
  }

  .screen {
    min-height: min(860px, calc(100dvh - 48px));
  }

  #storyScreen,
  .result-screen {
    height: min(860px, calc(100dvh - 48px));
    max-height: min(860px, calc(100dvh - 48px));
  }
}
