:root {
  color-scheme: light;
  --ink: #171717;
  --ink-soft: #262626;
  --paper: #ffffff;
  --soft: #fafafa;
  --muted: #4d4d4d;
  --subtle: #666666;
  --gray-100: #ebebeb;
  --danger: #ff5b4f;
  --focus: #0a72ef;
  --dialogue-bg: rgba(255, 255, 255, 0.94);
  --glass: rgba(255, 255, 255, 0.78);
  --shadow-card: 0 0 0 1px rgba(0, 0, 0, 0.08), 0 2px 2px rgba(0, 0, 0, 0.04),
    0 8px 8px -8px rgba(0, 0, 0, 0.04), inset 0 0 0 1px #fafafa;
  --font-ja: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
    "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo,
    sans-serif;
  --font-mono: SFMono-Regular, Consolas, Menlo, Monaco,
    "Noto Sans Mono CJK JP", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ja);
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

h1,
p {
  margin: 0;
  overflow-wrap: break-word;
  line-break: strict;
}

.novel-shell {
  width: min(100%, 1180px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
}

.novel-stage {
  position: relative;
  min-height: calc(100svh - 62px);
  overflow: hidden;
  border-radius: 8px;
  background: var(--soft);
  box-shadow: var(--shadow-card);
  isolation: isolate;
}

.scene-backdrop {
  position: absolute;
  inset: 0;
  z-index: -3;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(250, 250, 250, 0.72) 46%, rgba(23, 23, 23, 0.12) 100%),
    linear-gradient(110deg, rgba(255, 91, 79, 0.16), transparent 38%),
    #ffffff;
}

.school-building {
  position: absolute;
  right: -34px;
  bottom: 18%;
  width: min(72vw, 760px);
  height: 42%;
  background: rgba(23, 23, 23, 0.1);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
  transform: skewX(-7deg);
}

.school-windows {
  position: absolute;
  right: 6%;
  bottom: 28%;
  width: min(54vw, 570px);
  height: 18%;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.76) 0 44px, transparent 44px 72px),
    repeating-linear-gradient(0deg, transparent 0 34px, rgba(23, 23, 23, 0.12) 34px 36px);
  opacity: 0.78;
}

.sun-slash {
  position: absolute;
  left: -10%;
  top: 16%;
  width: 78%;
  height: 18%;
  background: rgba(255, 91, 79, 0.18);
  transform: rotate(-10deg);
}

.top-hud {
  position: relative;
  z-index: 5;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px;
}

.title-lockup {
  min-width: 0;
}

.eyebrow,
.scene-tag {
  color: var(--subtle);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
}

h1 {
  margin-top: 4px;
  color: var(--ink);
  font-size: 48px;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.15;
}

.brand-lead {
  max-width: 420px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
}

.system-controls {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.hud-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 12;
  display: flex;
  width: min(340px, calc(100vw - 36px));
  max-height: min(440px, calc(100vh - 120px));
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  overflow-y: auto;
  border-radius: 8px;
  padding: 10px;
  background: var(--dialogue-bg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.menu-note {
  flex-basis: 100%;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.6;
}

.hud-button,
.advance-button,
.choice-button {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
  font-size: 14px;
  font-weight: 600;
}

.hud-button {
  padding: 10px 14px;
}

.hud-button--primary {
  background: var(--ink);
  color: #fff;
}

.hud-button--compact {
  min-height: 36px;
  padding: 8px 10px;
  font-size: 12px;
}

.volume-control {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 8px;
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--glass);
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  backdrop-filter: blur(10px);
}

.volume-control input {
  width: 82px;
  accent-color: var(--ink);
}

.stats-hud {
  position: absolute;
  left: 18px;
  top: 116px;
  z-index: 2;
  width: min(310px, calc(100% - 36px));
  border-radius: 8px;
  padding: 14px;
  background: var(--glass);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
}

.ending-book {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 112px;
  bottom: 18px;
  z-index: 6;
  width: auto;
  max-height: none;
  overflow: auto;
  border-radius: 8px;
  padding: 18px;
  background: var(--dialogue-bg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.event-gallery {
  width: auto;
}

.ending-book__header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.collection-page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ending-book__count {
  margin-top: 3px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.ending-book__list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.ending-record {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 100%;
  border-radius: 8px;
  padding: 10px;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
  text-align: left;
}

button.ending-record:hover {
  background: var(--soft);
}

.ending-record--locked,
.cg-record--locked {
  opacity: 0.72;
}

.ending-record__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
}

.cg-gallery-list {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.cg-record {
  display: grid;
  gap: 8px;
}

.cg-record__image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
}

.cg-record--locked {
  grid-template-columns: 1fr;
}

.study-review-list {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.study-review-record {
  gap: 10px;
}

.quiz-review-meta {
  width: fit-content;
  border-radius: 9999px;
  padding: 3px 9px;
  background: #ebf5ff;
  color: #0068d6;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.quiz-review-prompt {
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
}

.quiz-review-answer {
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--soft);
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
}

.artwork-viewer {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 100%;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  background: rgba(23, 23, 23, 0.96);
  color: #fff;
}

.artwork-viewer__bar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.artwork-viewer__bar .scene-tag {
  color: rgba(255, 255, 255, 0.68);
}

.artwork-viewer__title {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.35;
}

.artwork-viewer__image {
  align-self: center;
  justify-self: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  border-radius: 8px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.artwork-viewer__body {
  color: rgba(255, 255, 255, 0.78);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.7;
}

.novel-stage--collection .scene-backdrop {
  opacity: 0.28;
}

.novel-stage--collection .character-sprite {
  opacity: 0;
  pointer-events: none;
}

.ending-record__title {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
}

.ending-record__body {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.turn-text {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.stats-grid {
  display: grid;
  gap: 7px;
}

.forecast-panel {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  padding-top: 12px;
  box-shadow: 0 -1px 0 0 rgb(235, 235, 235);
}

.forecast-badge {
  width: fit-content;
  border-radius: 9999px;
  padding: 3px 9px;
  background: #ebf5ff;
  color: #0068d6;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.forecast-badge--warning {
  background: #fff7e8;
  color: #8a4b00;
}

.forecast-badge--danger {
  background: #fff0ef;
  color: #c7352c;
}

.forecast-body,
.forecast-detail {
  color: var(--ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.65;
}

.forecast-detail {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.stat-row {
  display: grid;
  grid-template-columns: 68px 1fr 34px;
  gap: 8px;
  align-items: center;
}

.stat-name,
.stat-value {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.stat-value {
  color: var(--muted);
  font-family: var(--font-mono);
  text-align: right;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 9999px;
  background: var(--gray-100);
}

.meter__fill {
  display: block;
  width: var(--value);
  height: 100%;
  border-radius: inherit;
  background: var(--ink);
}

.meter__fill--danger {
  background: var(--danger);
}

.character-sprite {
  position: absolute;
  right: clamp(-8px, 7vw, 120px);
  bottom: 210px;
  z-index: -1;
  width: min(42vw, 380px);
  height: auto;
  max-height: calc(100svh - 270px);
  object-fit: contain;
  object-position: bottom center;
  opacity: 0.98;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.18));
}

.novel-stage--profile .character-sprite--profile-bancho,
.novel-stage--profile .character-sprite--profile-gyaru {
  transition:
    left 1.65s cubic-bezier(0.16, 1, 0.3, 1),
    right 1.65s cubic-bezier(0.16, 1, 0.3, 1),
    transform 1.65s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 1.45s ease,
    width 1.65s cubic-bezier(0.16, 1, 0.3, 1),
    filter 1.65s ease;
  will-change: transform, opacity;
}

.character-sprite--gyaru {
  right: clamp(-18px, 6vw, 110px);
  width: min(38vw, 340px);
}

.character-sprite--profile-bancho {
  right: auto;
  left: clamp(4px, 10vw, 176px);
  width: min(32vw, 330px);
}

.character-sprite--profile-gyaru {
  right: clamp(0px, 9vw, 164px);
  width: min(31vw, 310px);
}

.novel-stage--profile-selecting .choice-button {
  opacity: 0.38;
  pointer-events: none;
  transition: opacity 0.45s ease;
}

.novel-stage--profile-selecting .dialogue-box {
  background: rgba(255, 255, 255, 0.86);
}

.novel-stage--selected-bancho .character-sprite--profile-bancho {
  left: 50%;
  right: auto;
  z-index: 4;
  width: min(36vw, 360px);
  opacity: 1;
  transform: translateX(-50%);
  filter: drop-shadow(0 20px 24px rgba(0, 0, 0, 0.2));
}

.novel-stage--selected-bancho .character-sprite--profile-gyaru {
  opacity: 0;
  transform: translateX(28px);
}

.novel-stage--selected-gyaru .character-sprite--profile-gyaru {
  right: 50%;
  z-index: 4;
  width: min(34vw, 340px);
  opacity: 1;
  transform: translateX(50%);
  filter: drop-shadow(0 20px 24px rgba(0, 0, 0, 0.2));
}

.novel-stage--selected-gyaru .character-sprite--profile-bancho {
  opacity: 0;
  transform: translateX(-28px);
}

.novel-stage--route-centered .character-sprite {
  left: 50%;
  right: auto;
  width: min(36vw, 360px);
  opacity: 1;
  transform: translateX(-50%);
  filter: drop-shadow(0 20px 24px rgba(0, 0, 0, 0.2));
}

.novel-stage--route-centered .character-sprite--gyaru {
  width: min(34vw, 340px);
}

.ending-artwork {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}

.novel-stage:has(.ending-artwork:not([hidden])) .ending-artwork {
  top: 0;
  bottom: auto;
  height: calc(100% - 300px);
  object-fit: contain;
  background: #111;
}

.ending-artwork:not([hidden]) + .dialogue-box {
  min-height: 0;
  max-height: 280px;
  overflow: auto;
  background: rgba(255, 255, 255, 0.92);
}

.novel-stage:has(.ending-artwork:not([hidden])) .scene-backdrop {
  opacity: 0;
}

.novel-stage:has(.ending-artwork:not([hidden])) .character-sprite {
  opacity: 0;
}

.novel-stage:has(.ending-artwork:not([hidden])) .stats-hud {
  opacity: 0;
  pointer-events: none;
}

.dialogue-box {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  display: grid;
  gap: 12px;
  min-height: 210px;
  border-radius: 8px;
  padding: 18px;
  background: var(--dialogue-bg);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.speaker-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.speaker-name {
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--ink);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.dialogue-text {
  min-height: 78px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 500;
  line-height: 1.75;
  white-space: pre-line;
}

.choice-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.choice-button {
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 12px 14px;
  background: var(--paper);
  text-align: left;
}

.choice-button:hover {
  background: var(--soft);
}

.choice-button--selected {
  background: var(--ink);
  color: #fff;
}

.choice-button--selected .choice-title,
.choice-button--selected .choice-subtitle {
  color: #fff;
}

.choice-button--selected .school-requirements {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
  color: #fff;
}

.choice-button--quiz {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 68px;
}

.quiz-choice-marker {
  display: inline-grid;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
}

.choice-button--school {
  align-content: start;
  min-height: 118px;
}

.choice-button--profile {
  grid-template-columns: minmax(92px, 0.42fr) minmax(0, 1fr);
  min-height: 174px;
  align-items: center;
  gap: 6px 12px;
}

.profile-preview {
  grid-row: 1 / 4;
  align-self: stretch;
  display: grid;
  min-height: 132px;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
}

.profile-preview__image {
  align-self: end;
  justify-self: center;
  width: min(118px, 100%);
  max-height: 146px;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.16));
}

.profile-preview__image--gyaru {
  width: min(106px, 94%);
}

.choice-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.choice-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.school-requirements {
  display: block;
  margin-top: 4px;
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--soft);
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
}

.target-school-detail {
  display: grid;
  grid-column: 1 / -1;
  gap: 6px;
  border-radius: 8px;
  padding: 12px 14px;
  background: var(--soft);
  box-shadow: 0 0 0 1px rgb(235, 235, 235);
}

.target-school-detail__label {
  width: fit-content;
  border-radius: 9999px;
  padding: 3px 9px;
  background: #ebf5ff;
  color: #0068d6;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
}

.target-school-detail__title {
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.35;
}

.target-school-detail__body {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
}

.choice-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.effect-pill {
  border-radius: 9999px;
  padding: 2px 8px;
  background: #ebf5ff;
  color: #0068d6;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.effect-pill--risk {
  background: #fff0ef;
  color: #c7352c;
}

.advance-button {
  justify-self: end;
  min-width: 132px;
  padding: 11px 16px;
  background: var(--ink);
  color: #fff;
}

.dialogue-box .advance-button {
  position: sticky;
  bottom: 0;
  z-index: 1;
}

.credit {
  margin: 12px 0 0;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.7;
}

[hidden] {
  display: none !important;
}

@media (max-width: 860px) {
  .novel-shell {
    width: 100%;
  }

  .novel-stage {
    min-height: calc(100svh - 54px);
  }

  .top-hud {
    flex-direction: column;
    gap: 12px;
  }

  .system-controls {
    justify-content: flex-start;
  }

  .stats-hud {
    top: 154px;
  }

  .ending-book {
    top: 154px;
  }

  .character-sprite {
    right: 4vw;
    bottom: 292px;
    width: 48vw;
    opacity: 0.9;
  }

  .character-sprite--gyaru {
    width: 42vw;
  }

  .character-sprite--profile-bancho {
    left: 6vw;
    right: auto;
    width: min(36vw, 260px);
  }

  .character-sprite--profile-gyaru {
    right: 6vw;
    width: min(34vw, 244px);
  }

  .choice-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  html,
  body {
    overflow-x: hidden;
  }

  .novel-shell {
    padding: 0;
  }

  .novel-stage {
    min-height: 100svh;
    border-radius: 0;
  }

  .top-hud {
    gap: 7px;
    padding: max(8px, env(safe-area-inset-top)) 8px 7px;
  }

  .eyebrow {
    display: none;
  }

  h1 {
    margin-top: 0;
    font-size: 26px;
    line-height: 1.08;
  }

  .brand-lead {
    max-width: none;
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.45;
  }

  .title-lockup {
    width: 100%;
  }

  .system-controls {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
    gap: 6px;
  }

  #restartTopButton {
    order: 3;
  }

  .hud-button {
    width: 100%;
    min-height: 38px;
    min-width: 0;
    padding: 8px 6px;
    font-size: 12px;
    line-height: 1.25;
  }

  .volume-control {
    display: none;
  }

  .stats-hud {
    left: 8px;
    top: 96px;
    width: calc(100% - 16px);
    padding: 9px 10px;
  }

  .turn-text {
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.45;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 8px;
  }

  .forecast-panel {
    margin-top: 8px;
    padding-top: 8px;
  }

  .forecast-body,
  .forecast-detail {
    font-size: 11px;
    line-height: 1.45;
  }

  .stat-row {
    grid-template-columns: 50px minmax(44px, 1fr) 24px;
    gap: 5px;
  }

  .stat-name,
  .stat-value {
    font-size: 11px;
  }

  .meter {
    height: 7px;
  }

  .ending-book {
    left: 8px;
    right: 8px;
    top: 132px;
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    max-height: none;
    padding: 10px;
  }

  .ending-book__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .collection-page__actions {
    width: 100%;
    justify-content: stretch;
  }

  .collection-page__actions .hud-button {
    flex: 1 1 0;
  }

  .ending-book__list,
  .study-review-list,
  .cg-gallery-list {
    grid-template-columns: 1fr;
  }

  .ending-record {
    padding: 9px;
  }

  .artwork-viewer {
    gap: 10px;
    padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
  }

  .artwork-viewer__bar {
    align-items: stretch;
    flex-direction: column;
  }

  .artwork-viewer__title {
    font-size: 18px;
  }

  .character-sprite {
    right: 50%;
    bottom: 42svh;
    width: min(190px, 54vw);
    max-height: 250px;
    transform: translateX(50%);
    opacity: 0.12;
  }

  .character-sprite--gyaru {
    width: min(180px, 52vw);
  }

  .character-sprite--profile-bancho {
    left: 7vw;
    right: auto;
    bottom: 50svh;
    width: min(134px, 36vw);
    transform: none;
    opacity: 0.44;
  }

  .character-sprite--profile-gyaru {
    right: 7vw;
    bottom: 50svh;
    width: min(126px, 34vw);
    transform: none;
    opacity: 0.48;
  }

  .novel-stage--selected-bancho .character-sprite--profile-bancho {
    left: 50%;
    bottom: 36svh;
    width: min(270px, 72vw);
    opacity: 1;
    transform: translateX(-50%);
  }

  .novel-stage--selected-bancho .character-sprite--profile-gyaru {
    opacity: 0;
    transform: translateX(34px);
  }

  .novel-stage--selected-gyaru .character-sprite--profile-gyaru {
    right: 50%;
    bottom: 36svh;
    width: min(252px, 68vw);
    opacity: 1;
    transform: translateX(50%);
  }

  .novel-stage--selected-gyaru .character-sprite--profile-bancho {
    opacity: 0;
    transform: translateX(-34px);
  }

  .novel-stage--route-centered .character-sprite {
    left: 50%;
    right: auto;
    bottom: 36svh;
    width: min(270px, 72vw);
    max-height: 380px;
    opacity: 0.96;
    transform: translateX(-50%);
  }

  .novel-stage--route-centered .character-sprite--gyaru {
    width: min(252px, 68vw);
  }

  .novel-stage:has(.ending-artwork:not([hidden])) .ending-artwork {
    height: calc(100% - min(53svh, 410px) - 24px);
  }

  .dialogue-box {
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    gap: 9px;
    min-height: 0;
    max-height: min(68svh, 560px);
    overflow: auto;
    padding: 12px;
    scroll-padding-bottom: 58px;
  }

  .novel-stage--profile .dialogue-box {
    max-height: min(62svh, 520px);
  }

  .novel-stage--profile .choice-list {
    grid-template-columns: 1fr;
  }

  .speaker-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .dialogue-text {
    min-height: 0;
    font-size: 17px;
    line-height: 1.62;
  }

  .novel-stage[data-screen="opening"] .dialogue-text,
  .novel-stage[data-screen="target"] .dialogue-text,
  .novel-stage[data-screen="result"] .dialogue-text,
  .novel-stage[data-screen="choices"] .dialogue-text,
  .novel-stage[data-screen="studyQuiz"] .dialogue-text {
    font-size: 15px;
    line-height: 1.56;
  }

  .novel-stage[data-screen="targetConfirm"] .dialogue-box {
    max-height: min(38svh, 300px);
  }

  .novel-stage[data-screen="targetConfirm"].novel-stage--route-centered .character-sprite {
    bottom: 34svh;
    width: min(300px, 78vw);
    max-height: 430px;
    opacity: 1;
  }

  .novel-stage[data-screen="targetConfirm"].novel-stage--route-centered .character-sprite--gyaru {
    width: min(280px, 74vw);
  }

  .choice-list {
    gap: 8px;
  }

  .novel-stage[data-screen="target"] .choice-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-button {
    min-height: 72px;
    padding: 10px 11px;
  }

  .novel-stage[data-screen="opening"] .choice-button,
  .novel-stage[data-screen="choices"] .choice-button,
  .novel-stage[data-screen="target"] .choice-button {
    min-height: 64px;
  }

  .choice-button--quiz {
    min-height: 58px;
  }

  .choice-button--school {
    min-height: 92px;
  }

  .novel-stage[data-screen="target"] .choice-button--school {
    min-height: 58px;
    padding: 8px 10px;
  }

  .novel-stage[data-screen="target"] .choice-button--target-option .choice-subtitle {
    display: none;
  }

  .choice-button--profile {
    grid-template-columns: 1fr;
    min-height: 84px;
    align-content: center;
  }

  .profile-preview {
    display: none;
  }

  .novel-stage--profile .choice-button--profile {
    padding: 9px;
  }

  .novel-stage--profile .school-requirements {
    display: none;
  }

  .choice-title {
    font-size: 14px;
    line-height: 1.32;
  }

  .choice-subtitle {
    font-size: 11px;
    line-height: 1.42;
  }

  .school-requirements {
    font-size: 10px;
  }

  .novel-stage[data-screen="target"] .school-requirements {
    margin-top: 2px;
    padding: 5px 7px;
    font-size: 9px;
    line-height: 1.35;
  }

  .target-school-detail {
    gap: 4px;
    padding: 9px 10px;
  }

  .target-school-detail__label {
    padding: 2px 8px;
    font-size: 10px;
  }

  .target-school-detail__title {
    font-size: 13px;
  }

  .target-school-detail__body {
    font-size: 11px;
    line-height: 1.45;
  }

  .effect-pill {
    padding: 2px 7px;
    font-size: 10px;
  }

  .advance-button {
    width: 100%;
    justify-self: stretch;
    min-width: 0;
    min-height: 46px;
  }

  .credit {
    display: none;
  }
}

@media (max-width: 380px) {
  .stats-hud {
    top: 94px;
  }

  .stat-row {
    grid-template-columns: 46px minmax(38px, 1fr) 22px;
  }

  .stat-name,
  .stat-value {
    font-size: 10px;
  }

  .dialogue-text {
    font-size: 16px;
  }
}

@media (max-height: 620px) and (max-width: 560px) {
  .stats-hud {
    top: 92px;
  }

  .ending-book {
    top: 124px;
    max-height: none;
  }

  .dialogue-box {
    max-height: 50svh;
  }

  .novel-stage--profile .dialogue-box {
    max-height: 62svh;
  }

  .novel-stage[data-screen="opening"] .dialogue-box,
  .novel-stage[data-screen="openingResult"] .dialogue-box,
  .novel-stage[data-screen="target"] .dialogue-box,
  .novel-stage[data-screen="result"] .dialogue-box,
  .novel-stage[data-screen="choices"] .dialogue-box,
  .novel-stage[data-screen="studyQuiz"] .dialogue-box {
    max-height: 66svh;
  }

  .character-sprite {
    opacity: 0.08;
  }

  .novel-stage--route-centered .character-sprite {
    bottom: 35svh;
    max-height: 310px;
    opacity: 0.92;
  }

  .novel-stage:has(.ending-artwork:not([hidden])) .ending-artwork {
    height: calc(100% - 50svh - 20px);
  }
}

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

  .credit {
    display: none;
  }

  .novel-stage {
    min-height: 100svh;
    border-radius: 0;
  }

  .top-hud {
    padding: max(8px, env(safe-area-inset-top)) 10px 6px;
  }

  h1 {
    font-size: 26px;
  }

  .system-controls {
    gap: 6px;
  }

  .hud-menu {
    left: 0;
    right: auto;
  }

  .hud-button,
  .volume-control {
    min-height: 38px;
  }

  .stats-hud {
    left: 10px;
    top: 86px;
    width: min(300px, 38vw);
    padding: 10px;
  }

  .stats-grid {
    gap: 5px;
  }

  .ending-book {
    left: 10px;
    right: 10px;
    top: 72px;
    bottom: 8px;
    width: auto;
    max-height: none;
  }

  .character-sprite {
    display: none;
  }

  .novel-stage--route-centered .character-sprite {
    display: block;
    left: 50%;
    right: auto;
    bottom: 8px;
    width: min(26vw, 190px);
    max-height: calc(100svh - 18px);
    opacity: 0.34;
    transform: translateX(-50%);
  }

  .character-sprite--profile-bancho,
  .character-sprite--profile-gyaru {
    display: block;
    bottom: 12px;
    width: min(18vw, 120px);
    opacity: 0.24;
  }

  .character-sprite--profile-bancho {
    left: 12px;
  }

  .character-sprite--profile-gyaru {
    right: 12px;
  }

  .novel-stage:has(.ending-artwork:not([hidden])) .ending-artwork {
    left: 10px;
    top: 72px;
    right: auto;
    bottom: auto;
    width: min(300px, 38vw);
    height: calc(100svh - 88px);
  }

  .dialogue-box {
    left: calc(min(300px, 38vw) + 22px);
    right: 10px;
    bottom: max(8px, env(safe-area-inset-bottom));
    min-height: 0;
    max-height: calc(100svh - 96px);
    overflow: auto;
    padding: 12px;
  }

  .novel-stage--profile .dialogue-box {
    left: 10px;
    max-height: calc(100svh - 76px);
  }

  .novel-stage--profile .choice-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .novel-stage--profile .choice-button--profile {
    grid-template-columns: 1fr;
    min-height: 84px;
    padding: 9px;
  }

  .novel-stage--profile .profile-preview,
  .novel-stage--profile .school-requirements {
    display: none;
  }

  .dialogue-text {
    min-height: 0;
    font-size: 16px;
    line-height: 1.65;
  }

  .choice-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .choice-button {
    min-height: 68px;
    padding: 9px;
  }
}

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

/* ほぼ週刊MOTHER語り部屋の写し（2026-11-25）：スマホでも素材と声の案内を出す */
@media (max-width: 560px) {
  .credit {
    display: block;
    margin: 12px 12px 0;
    font-size: 0.75rem;
  }
}
