/* ============================================================
   丸ゴシック（Zen Maru Gothic / SIL Open Font License 1.1）
   ------------------------------------------------------------
   このゲームで使う文字だけに絞って同梱しています（2ウェイトで約226KB）。
   ライセンス全文は assets/fonts/LICENSE-Zen-Maru-Gothic.txt。
   台詞に新しい漢字を足す場合は、フォントに無い字が出ないか確認してください。
   ============================================================ */
@font-face {
  font-family: "Zen Maru Gothic";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("./assets/fonts/zenmaru-500.woff2") format("woff2");
}

@font-face {
  font-family: "Zen Maru Gothic";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./assets/fonts/zenmaru-700.woff2") format("woff2");
}

/* 見出し用。本文より丸くて太い、ポップな書体。
   本文に使うと可読性が落ちるので、大きい字だけに当てる。 */

@font-face {
  font-family: "Mochiy Pop One";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/mochiypop-400.woff2") format("woff2");
}

:root {
  --ink: #08070b;
  --ink-soft: #121019;
  --panel: rgba(10, 8, 15, 0.9);
  --panel-soft: rgba(13, 10, 20, 0.78);
  --white: #fffaff;
  --muted: #bcb5c7;
  --purple: #a84fff;
  --purple-bright: #c77dff;
  --purple-dark: #5d178a;
  --cyan: #87e7f1;
  --danger: #ff6f9d;
  --line: rgba(255, 255, 255, 0.16);
  --shadow: 0 30px 100px rgba(0, 0, 0, 0.55);
  --radius: 18px;
  --background-image: url("./assets/images/kitchen_simple04.webp");
  --character-image: url("./assets/images/expressions/maine-neutral.webp");
  color-scheme: dark;
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro",
    "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: #efe6fa;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--white);
  background:
    radial-gradient(circle at 78% 12%, rgba(194, 118, 255, 0.34), transparent 32%),
    linear-gradient(145deg, #fffaff 0%, #ebd9fa 58%, #f8f2ff 100%);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.page-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  position: relative;
}

.game {
  position: relative;
  width: min(100vw, calc(100dvh * 16 / 9));
  max-width: 1920px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  background: #15101a;
  box-shadow: var(--shadow);
}

.scene-background {
  position: absolute;
  inset: 0;
  z-index: -5;
  overflow: hidden;
  background-image:
    linear-gradient(90deg, rgba(8, 6, 12, 0.58) 0%, rgba(18, 13, 25, 0.28) 50%, rgba(10, 7, 14, 0.12) 100%),
    var(--background-image),
    linear-gradient(130deg, #110d18 0%, #2e2138 47%, #17111f 100%);
  background-position: center;
  background-size: cover;
  transition: filter 600ms ease, background-color 600ms ease;
}

.game.has-background-image .scene-background {
  background-image:
    linear-gradient(90deg, rgba(13, 8, 19, 0.58) 0%, rgba(28, 15, 37, 0.36) 48%, rgba(21, 12, 29, 0.3) 100%),
    linear-gradient(180deg, rgba(16, 10, 23, 0.12), rgba(16, 9, 23, 0.46)),
    var(--background-image);
  background-position: center;
  background-size: cover;
  filter: saturate(0.78) brightness(0.72) contrast(1.05);
}

.game.has-background-image .scene-background::before,
.game.has-background-image .scene-background > * {
  display: none;
}

.scene-background::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.36;
  background:
    linear-gradient(90deg, transparent 0 7%, rgba(218, 179, 255, 0.14) 7.2% 7.5%, transparent 7.7% 100%),
    linear-gradient(0deg, transparent 0 74%, rgba(255, 255, 255, 0.055) 74.2% 74.7%, transparent 74.9% 100%);
}

.window-glow {
  position: absolute;
  top: 8%;
  left: 7%;
  width: 27%;
  height: 46%;
  overflow: hidden;
  border: 1px solid rgba(225, 211, 244, 0.16);
  border-radius: 4px 4px 14px 14px;
  background:
    linear-gradient(90deg, transparent 49.4%, rgba(226, 207, 255, 0.16) 49.5% 50.4%, transparent 50.5%),
    linear-gradient(0deg, transparent 55%, rgba(226, 207, 255, 0.14) 55.2% 55.7%, transparent 55.9%),
    radial-gradient(circle at 64% 30%, rgba(220, 188, 255, 0.2), transparent 19%),
    linear-gradient(145deg, #19132c, #090713 70%);
  box-shadow: 0 0 70px rgba(137, 61, 195, 0.14), inset 0 0 40px rgba(0, 0, 0, 0.55);
}

.window-glow::before,
.window-glow::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(235, 219, 255, 0.7);
  box-shadow:
    56px 17px rgba(235, 219, 255, 0.35),
    112px 54px rgba(235, 219, 255, 0.42),
    168px 3px rgba(235, 219, 255, 0.3),
    215px 86px rgba(235, 219, 255, 0.36),
    38px 120px rgba(235, 219, 255, 0.25);
  width: 2px;
  height: 2px;
  top: 23%;
  left: 12%;
}

.window-glow::after {
  filter: blur(3px);
  transform: translate(22px, 16px) scale(2.2);
  opacity: 0.6;
}

.kitchen-shape {
  position: absolute;
  background: rgba(11, 8, 14, 0.54);
  border: 1px solid rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035), 0 20px 70px rgba(0, 0, 0, 0.28);
}

.kitchen-shape--cabinet {
  top: 10%;
  right: 3%;
  width: 33%;
  height: 34%;
  border-radius: 3px 3px 12px 12px;
  background:
    linear-gradient(90deg, transparent 49.7%, rgba(255, 255, 255, 0.07) 50%, transparent 50.3%),
    rgba(17, 13, 21, 0.62);
}

.kitchen-shape--counter {
  left: 0;
  right: 0;
  bottom: 27%;
  height: 21%;
  border-radius: 0;
  background:
    linear-gradient(0deg, rgba(8, 6, 11, 0.9) 0 72%, rgba(255, 255, 255, 0.08) 72.5% 74%, rgba(12, 9, 16, 0.84) 74.5%),
    rgba(13, 10, 17, 0.8);
  transform: perspective(600px) rotateX(2deg);
}

.kitchen-shape--table {
  left: 24%;
  bottom: 17%;
  width: 43%;
  height: 10%;
  border-radius: 50%;
  filter: blur(1px);
  background: rgba(10, 7, 13, 0.78);
  transform: perspective(600px) rotateX(65deg);
}

.kitchen-shape--lamp {
  top: -7%;
  left: 50%;
  width: 11%;
  height: 29%;
  border: 0;
  border-radius: 0 0 50% 50%;
  background:
    radial-gradient(ellipse at center bottom, rgba(239, 211, 255, 0.34), transparent 42%),
    linear-gradient(90deg, transparent 48%, rgba(222, 198, 239, 0.32) 49% 51%, transparent 52%);
  box-shadow: none;
}

.night-specks {
  position: absolute;
  inset: 0;
  opacity: 0.48;
  background:
    radial-gradient(circle at 11% 69%, rgba(187, 103, 255, 0.7) 0 1px, transparent 2px),
    radial-gradient(circle at 38% 19%, rgba(255, 255, 255, 0.4) 0 1px, transparent 2px),
    radial-gradient(circle at 69% 12%, rgba(187, 103, 255, 0.5) 0 1px, transparent 2px),
    radial-gradient(circle at 83% 64%, rgba(255, 255, 255, 0.35) 0 1px, transparent 2px);
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(3, 2, 5, 0.58), transparent 23%, transparent 65%, rgba(3, 2, 5, 0.54)),
    radial-gradient(ellipse at 55% 46%, transparent 42%, rgba(2, 1, 4, 0.48) 100%);
}

.grain {
  position: absolute;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  opacity: 0.08;
  background-image: radial-gradient(rgba(255, 255, 255, 0.5) 0.45px, transparent 0.65px);
  background-size: 3px 3px;
  mix-blend-mode: soft-light;
}

.top-bar {
  position: absolute;
  z-index: 35;
  top: 1.5%;
  left: 2%;
  right: 2%;
  display: flex;
  min-height: clamp(48px, 4.5vw, 72px);
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 1.8vw, 32px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: clamp(12px, 1.2vw, 20px);
  background: linear-gradient(180deg, rgba(6, 4, 9, 0.88), rgba(6, 4, 9, 0.56));
  backdrop-filter: blur(12px);
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.7em;
  letter-spacing: 0.22em;
  font-family: Arial, sans-serif;
  font-size: clamp(0.62rem, 0.72vw, 0.84rem);
  font-weight: 800;
}

.brand-mark small {
  padding-left: 0.9em;
  border-left: 1px solid rgba(255, 255, 255, 0.22);
  color: #8e8798;
  font-size: 0.66em;
  letter-spacing: 0.18em;
}

.brand-mark__diamond {
  width: 11px;
  height: 11px;
  border: 2px solid var(--purple-bright);
  transform: rotate(45deg);
  box-shadow: 0 0 14px rgba(186, 92, 255, 0.6);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: clamp(2px, 0.35vw, 7px);
}

.utility-button {
  display: grid;
  min-width: clamp(54px, 4.6vw, 82px);
  min-height: clamp(32px, 2.55vw, 42px);
  place-content: center;
  gap: 0.22em;
  padding: 0 0.85em;
  border: 1px solid transparent;
  border-radius: 11px;
  color: rgba(255, 255, 255, 0.82);
  background: transparent;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: clamp(0.54rem, 0.58vw, 0.7rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  transition: color 180ms ease, background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.utility-button > span {
  color: #77717f;
  font-size: 0.65em;
  font-weight: 500;
}

.utility-button:hover,
.utility-button.is-active {
  color: var(--white);
  background: linear-gradient(180deg, rgba(171, 75, 240, 0.18), rgba(171, 75, 240, 0.04));
  transform: translateY(-1px);
}

.utility-button.is-active {
  box-shadow: inset 0 -2px var(--purple-bright);
}

.utility-button--menu {
  grid-template-columns: 14px auto;
  grid-template-rows: repeat(3, 2px);
  column-gap: 0.7em;
  min-width: clamp(68px, 5.6vw, 96px);
}

.utility-button--menu > span {
  display: block;
  width: 14px;
  height: 1px;
  background: currentColor;
}

.utility-button--menu b {
  grid-column: 2;
  grid-row: 1 / 4;
  align-self: center;
  font-size: inherit;
}

.stage {
  position: absolute;
  inset: 0;
}

.scene-meta {
  position: absolute;
  z-index: 8;
  top: 10.5%;
  left: 4.2%;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: rgba(255, 255, 255, 0.72);
  font-family: Arial, sans-serif;
  text-transform: uppercase;
}

.scene-meta__chapter {
  color: rgba(255, 255, 255, 0.28);
  font-size: clamp(1.7rem, 2.8vw, 3.3rem);
  font-weight: 200;
  letter-spacing: -0.06em;
}

.scene-meta__line {
  width: clamp(26px, 3.6vw, 64px);
  height: 1px;
  background: linear-gradient(90deg, var(--purple-bright), transparent);
}

.scene-meta div {
  display: grid;
  gap: 0.2em;
}

.scene-meta strong {
  font-family: inherit;
  font-size: clamp(0.64rem, 0.7vw, 0.85rem);
  letter-spacing: 0.14em;
}

.scene-meta small {
  color: rgba(255, 255, 255, 0.32);
  font-size: clamp(0.46rem, 0.5vw, 0.6rem);
  letter-spacing: 0.18em;
}

.character-wrap {
  position: absolute;
  z-index: 7;
  right: 0;
  bottom: 20.5%;
  width: 58%;
  height: 74%;
  pointer-events: none;
  transition: transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 450ms ease;
}

.character-art {
  position: absolute;
  inset: 0;
  z-index: 3;
  background-image: var(--character-image);
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: auto 100%;
  filter: drop-shadow(0 18px 26px rgba(70, 35, 91, 0.28));
  transition: background-image 120ms ease, filter 260ms ease;
}

.game.has-character-image .character-fallback {
  display: none;
}

.game[data-expression="neutral"] .character-art {
  background-image: url("./assets/images/expressions/maine-neutral.webp");
}

.game[data-expression="shy"] .character-art {
  background-image: url("./assets/images/expressions/maine-shy.webp");
}

.game[data-expression="surprised"] .character-art {
  background-image: url("./assets/images/expressions/maine-surprised.webp");
}

.game[data-expression="sad"] .character-art {
  background-image: url("./assets/images/expressions/maine-sad.webp");
}

.game[data-expression="happy"] .character-art {
  background-image: url("./assets/images/expressions/maine-happy.webp");
}

.game[data-expression="joy"] .character-art {
  background-image: url("./assets/images/expressions/maine-joy.webp");
}

.game[data-expression="angry"] .character-art {
  background-image: url("./assets/images/expressions/maine-angry.webp");
}

.game[data-expression="crying"] .character-art {
  background-image: url("./assets/images/expressions/maine-crying.webp");
}

.character-aura {
  position: absolute;
  z-index: 1;
  top: 9%;
  right: 7%;
  width: 64%;
  aspect-ratio: 1;
  border: 1px solid rgba(194, 114, 255, 0.17);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(181, 88, 255, 0.18) 0, rgba(135, 58, 199, 0.05) 41%, transparent 70%);
  box-shadow: 0 0 90px rgba(169, 72, 239, 0.12), inset 0 0 50px rgba(169, 72, 239, 0.08);
}

.character-aura::before,
.character-aura::after {
  content: "";
  position: absolute;
  inset: 7%;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
}

.character-aura::after {
  inset: 17%;
  border-color: rgba(195, 109, 255, 0.12);
}

.character-shadow {
  position: absolute;
  z-index: 0;
  right: 13%;
  bottom: -2%;
  width: 64%;
  height: 9%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.58);
  filter: blur(14px);
}

.character-fallback {
  position: absolute;
  z-index: 2;
  top: 11%;
  right: 13%;
  width: 52%;
  height: 82%;
  opacity: 0.42;
  filter: drop-shadow(0 0 24px rgba(173, 84, 245, 0.55));
}

.fallback-head,
.fallback-body,
.fallback-hair {
  position: absolute;
  display: block;
  background: linear-gradient(145deg, #30223d, #110d18);
}

.fallback-head {
  top: 3%;
  left: 27%;
  width: 47%;
  aspect-ratio: 0.9;
  border-radius: 48% 52% 44% 46%;
}

.fallback-body {
  top: 27%;
  left: 18%;
  width: 66%;
  height: 70%;
  border-radius: 44% 44% 18% 18%;
  clip-path: polygon(25% 0, 74% 0, 100% 100%, 0 100%);
}

.fallback-hair {
  top: 6%;
  width: 35%;
  height: 63%;
  border-radius: 50%;
  background: linear-gradient(180deg, #5b3370, #21142a);
}

.fallback-hair--left {
  left: 3%;
  transform: rotate(12deg);
}

.fallback-hair--right {
  right: 2%;
  transform: rotate(-10deg);
}

.game[data-mood="shy"] .character-wrap {
  transform: translateY(0.7%) rotate(0.35deg);
  filter: saturate(1.08) brightness(1.03);
}

.game[data-mood="happy"] .character-wrap,
.game[data-mood="warm"] .character-wrap {
  transform: translateY(-0.8%);
  filter: saturate(1.1) brightness(1.05);
}

.game[data-mood="annoyed"] .character-wrap {
  transform: translateX(-1.5%);
  filter: saturate(0.8) contrast(1.1);
}

.game[data-scene="ending"] .scene-background {
  filter: saturate(1.1) brightness(1.14);
}

.choice-layer {
  position: absolute;
  z-index: 30;
  top: 20.5%;
  left: 4.5%;
  display: grid;
  width: min(49%, 780px);
  gap: clamp(9px, 0.9vw, 15px);
  pointer-events: none;
}

.choice-layer.is-visible {
  pointer-events: auto;
}

.choice-button {
  position: relative;
  display: grid;
  grid-template-columns: clamp(42px, 4vw, 66px) 1fr auto;
  min-height: clamp(52px, 4.7vw, 76px);
  align-items: center;
  gap: clamp(10px, 1.3vw, 22px);
  overflow: hidden;
  padding: 0 clamp(15px, 2vw, 32px) 0 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: clamp(12px, 1.1vw, 18px);
  opacity: 0;
  color: rgba(255, 255, 255, 0.9);
  background: linear-gradient(90deg, rgba(13, 10, 19, 0.94), rgba(17, 13, 23, 0.82));
  box-shadow: 0 13px 35px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  text-align: left;
  transform: translateX(-16px);
  animation: choice-in 360ms forwards;
  backdrop-filter: blur(12px);
}

.choice-button::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  background: linear-gradient(90deg, rgba(174, 76, 243, 0.25), transparent 70%);
  transition: opacity 180ms ease;
}

.choice-button:nth-child(2) { animation-delay: 70ms; }
.choice-button:nth-child(3) { animation-delay: 140ms; }

.choice-key {
  display: grid;
  align-self: stretch;
  place-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--purple-bright);
  background: rgba(145, 54, 208, 0.13);
  font-family: Georgia, serif;
  font-size: clamp(1rem, 1.45vw, 1.6rem);
  font-style: italic;
}

.choice-text {
  position: relative;
  z-index: 1;
  font-size: clamp(0.72rem, 1.08vw, 1.15rem);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.choice-arrow {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.35);
  transition: transform 180ms ease, color 180ms ease;
}

.choice-button:hover,
.choice-button:focus-visible {
  border-color: rgba(206, 141, 255, 0.65);
  color: #fff;
  transform: translateX(5px);
}

.choice-button:hover::after,
.choice-button:focus-visible::after {
  opacity: 1;
}

.choice-button:hover .choice-arrow,
.choice-button:focus-visible .choice-arrow {
  color: var(--purple-bright);
  transform: translateX(4px);
}

@keyframes choice-in {
  to { opacity: 1; transform: translateX(0); }
}

.dialogue-panel {
  position: absolute;
  z-index: 25;
  right: 4.5%;
  bottom: 3.2%;
  left: 4.5%;
  min-height: 23.5%;
  padding: clamp(20px, 1.8vw, 32px) clamp(28px, 3.2vw, 58px) clamp(18px, 1.7vw, 30px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: clamp(16px, 1.5vw, 24px);
  background:
    linear-gradient(90deg, rgba(12, 9, 17, 0.97), rgba(13, 10, 19, 0.88) 74%, rgba(10, 8, 14, 0.95)),
    rgba(6, 5, 9, 0.9);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5), inset 0 1px rgba(255, 255, 255, 0.05);
  cursor: pointer;
  backdrop-filter: blur(16px);
  transition: opacity 220ms ease, transform 220ms ease;
}

.dialogue-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(170, 75, 240, 0.07), transparent 24%);
}

.dialogue-accent {
  position: absolute;
  top: -1px;
  left: -1px;
  width: 28%;
  height: 2px;
  background: linear-gradient(90deg, var(--purple), rgba(173, 83, 238, 0));
  box-shadow: 0 0 18px rgba(171, 75, 240, 0.55);
}

.speaker-row {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  margin-bottom: clamp(7px, 0.65vw, 12px);
}

.speaker-row h2 {
  margin: 0;
  font-size: clamp(0.95rem, 1.08vw, 1.3rem);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.speaker-kana {
  color: var(--purple-bright);
  font-family: Arial, sans-serif;
  font-size: clamp(0.52rem, 0.53vw, 0.66rem);
  font-weight: 800;
  letter-spacing: 0.18em;
}

.speaker-rule {
  width: 55px;
  height: 1px;
  margin-left: 0.1em;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.26), transparent);
}

.dialogue-text {
  position: relative;
  z-index: 1;
  max-width: 94%;
  min-height: 2.9em;
  margin: 0;
  color: rgba(255, 255, 255, 0.94);
  font-size: clamp(0.86rem, 1.16vw, 1.34rem);
  font-weight: 700;
  line-height: 1.78;
  letter-spacing: 0.055em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.48);
}

.advance-button {
  position: absolute;
  right: clamp(26px, 3vw, 52px);
  bottom: 11%;
  display: flex;
  align-items: center;
  gap: 0.55em;
  padding: 7px 11px;
  border: 0;
  color: rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: rgba(169, 81, 223, 0.08);
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: clamp(0.42rem, 0.45vw, 0.56rem);
  letter-spacing: 0.16em;
}

.advance-button i {
  display: block;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--purple-bright);
  border-bottom: 1px solid var(--purple-bright);
  transform: rotate(45deg);
  animation: next-pulse 1.4s ease infinite;
}

@keyframes next-pulse {
  50% { transform: translateY(3px) rotate(45deg); opacity: 0.45; }
}

.keyboard-hint {
  display: none;
}

.keyboard-hint span {
  margin: 0 0.5em;
  color: var(--purple-bright);
}

.game.is-text-hidden .dialogue-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(25px);
}

.show-dialogue {
  position: absolute;
  z-index: 26;
  right: 4%;
  bottom: 4%;
  display: none;
  padding: 10px 16px;
  border: 1px solid rgba(205, 137, 255, 0.48);
  border-radius: 999px;
  color: rgba(255, 255, 255, 0.8);
  background: rgba(9, 7, 13, 0.7);
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  backdrop-filter: blur(8px);
}

.game.is-text-hidden .show-dialogue {
  display: block;
}

.overlay-screen {
  position: absolute;
  z-index: 60;
  inset: 0;
  display: grid;
  visibility: hidden;
  opacity: 0;
  transition: opacity 450ms ease, visibility 450ms;
  pointer-events: none;
}

.overlay-screen.is-visible {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.title-screen {
  place-items: center start;
  padding: 6% 8%;
  background:
    linear-gradient(90deg, rgba(5, 4, 8, 0.97) 0%, rgba(8, 6, 12, 0.89) 40%, rgba(8, 6, 12, 0.36) 67%, rgba(7, 5, 11, 0.38) 100%),
    linear-gradient(180deg, rgba(5, 4, 8, 0.44), transparent 40%, rgba(5, 4, 8, 0.55));
}

.title-screen::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2.8%;
  width: 1px;
  background: linear-gradient(transparent 8%, rgba(200, 124, 255, 0.5) 50%, transparent 92%);
}

.title-screen__glow {
  position: absolute;
  top: 10%;
  left: 28%;
  width: 46%;
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.3;
  background: radial-gradient(circle, rgba(180, 83, 244, 0.18), transparent 68%);
  filter: blur(20px);
}

.title-card {
  position: relative;
  z-index: 3;
  width: min(47%, 760px);
  padding-top: 4%;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin: 0 0 1.2em;
  color: var(--purple-bright);
  font-family: Arial, sans-serif;
  font-size: clamp(0.5rem, 0.64vw, 0.8rem);
  font-weight: 700;
  letter-spacing: 0.26em;
}

.eyebrow span {
  width: 24px;
  height: 1px;
  background: currentColor;
}

.title-card h1 {
  display: grid;
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(2.3rem, 5.4vw, 6.4rem);
  font-weight: 650;
  line-height: 0.96;
  letter-spacing: 0.07em;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.55);
}

.title-card h1 span {
  margin-bottom: 0.1em;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.48em;
  font-weight: 400;
  letter-spacing: 0.18em;
}

.title-subtitle {
  margin: 1.5em 0 2.3em;
  color: rgba(255, 255, 255, 0.62);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(0.7rem, 0.86vw, 1.05rem);
  letter-spacing: 0.08em;
}

.title-actions {
  display: flex;
  width: min(100%, 530px);
  gap: 10px;
}

.primary-button,
.secondary-button {
  position: relative;
  display: grid;
  min-height: clamp(52px, 5vw, 74px);
  align-content: center;
  flex: 1;
  padding: 0 22px;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
}

.primary-button {
  border: 1px solid rgba(216, 158, 255, 0.54);
  color: #fff;
  background: linear-gradient(110deg, #7423aa, #a141d9 60%, #67228f);
  box-shadow: 0 10px 32px rgba(121, 37, 176, 0.28), inset 0 1px rgba(255, 255, 255, 0.14);
}

.secondary-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.035);
}

.primary-button span,
.secondary-button span {
  font-size: clamp(0.7rem, 0.88vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.primary-button small,
.secondary-button small {
  margin-top: 0.35em;
  color: rgba(255, 255, 255, 0.44);
  font-family: Arial, sans-serif;
  font-size: clamp(0.4rem, 0.42vw, 0.53rem);
  font-weight: 700;
  letter-spacing: 0.16em;
}

.primary-button i {
  position: absolute;
  top: 50%;
  right: 20px;
  font-style: normal;
  transform: translateY(-50%);
}

.primary-button:hover,
.secondary-button:hover:not(:disabled) {
  filter: brightness(1.13);
}

.secondary-button:disabled {
  opacity: 0.36;
  cursor: not-allowed;
}

.title-note {
  margin: 1.5em 0 0;
  color: rgba(255, 255, 255, 0.35);
  font-size: clamp(0.54rem, 0.63vw, 0.76rem);
  letter-spacing: 0.06em;
}

.title-note span {
  margin-right: 0.6em;
  color: var(--purple-bright);
  font-size: 0.7em;
}

.title-index {
  position: absolute;
  right: 3.5%;
  bottom: 7%;
  display: flex;
  align-items: center;
  gap: 0.8em;
  color: rgba(255, 255, 255, 0.18);
  font-family: Arial, sans-serif;
  writing-mode: vertical-rl;
}

.title-index span {
  color: rgba(197, 122, 255, 0.55);
  font-size: clamp(1.4rem, 2.4vw, 2.8rem);
  font-weight: 200;
}

.title-index b {
  font-size: clamp(0.38rem, 0.42vw, 0.5rem);
  letter-spacing: 0.22em;
}

.end-screen {
  place-items: center;
  padding: 6%;
  background:
    radial-gradient(circle at center, rgba(118, 43, 165, 0.22), transparent 42%),
    rgba(5, 4, 8, 0.91);
  backdrop-filter: blur(12px);
}

.end-card {
  width: min(700px, 78%);
  text-align: center;
}

.end-label {
  margin: 0 0 1.3em;
  color: var(--purple-bright);
  font-family: Arial, sans-serif;
  font-size: clamp(0.58rem, 0.7vw, 0.86rem);
  font-weight: 700;
  letter-spacing: 0.32em;
}

.end-screen.is-bad .end-label {
  color: var(--danger);
}

.end-ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8em;
  margin: 0 auto 1.2em;
}

.end-ornament span {
  width: clamp(35px, 5vw, 80px);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28));
}

.end-ornament span:last-child {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.28), transparent);
}

.end-ornament i {
  color: var(--purple-bright);
  font-size: 0.6rem;
  font-style: normal;
}

.end-card h2 {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1.6rem, 3.2vw, 3.6rem);
  font-weight: 500;
  letter-spacing: 0.08em;
}

.end-card > p:not(.end-label) {
  margin: 1.3em auto 2.4em;
  color: rgba(255, 255, 255, 0.58);
  font-size: clamp(0.66rem, 0.8vw, 1rem);
  line-height: 1.8;
  letter-spacing: 0.08em;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.end-actions .primary-button,
.end-actions .secondary-button {
  max-width: 220px;
  flex-basis: 200px;
}

.text-button {
  flex-basis: 100%;
  margin-top: 0.5em;
  padding: 8px;
  border: 0;
  color: rgba(255, 255, 255, 0.42);
  background: transparent;
  cursor: pointer;
  font-size: 0.72rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.modal-layer {
  position: absolute;
  z-index: 80;
  inset: 0;
  display: grid;
  visibility: hidden;
  place-items: center;
  padding: 5%;
  opacity: 0;
  background: rgba(4, 3, 6, 0.7);
  transition: opacity 180ms ease, visibility 180ms;
  backdrop-filter: blur(8px);
}

.modal-layer.is-open {
  visibility: visible;
  opacity: 1;
}

.modal-card {
  width: min(580px, 82%);
  max-height: 78%;
  padding: clamp(22px, 3vw, 44px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(22, 16, 29, 0.98), rgba(8, 7, 11, 0.98));
  box-shadow: var(--shadow);
}

.modal-card--log {
  width: min(840px, 84%);
}

.modal-card--menu {
  width: min(500px, 80%);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.8rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-heading small {
  color: var(--purple-bright);
  font-family: Arial, sans-serif;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.24em;
}

.modal-heading h2 {
  margin: 0.25em 0 0;
  font-size: clamp(1.1rem, 1.6vw, 1.8rem);
  letter-spacing: 0.08em;
}

.close-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.58);
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
}

.log-list {
  display: grid;
  gap: 0;
}

.log-entry {
  display: grid;
  grid-template-columns: minmax(64px, 100px) 1fr;
  gap: 1.2rem;
  padding: 1rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.log-entry strong {
  color: var(--purple-bright);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
}

.log-entry p {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.78rem;
  line-height: 1.8;
}

.log-empty {
  padding: 2.5rem 0;
  color: rgba(255, 255, 255, 0.4);
  text-align: center;
}

.range-setting {
  display: grid;
  gap: 1rem;
  margin: 0 0 1.8rem;
}

.range-setting > span {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
}

.range-setting small {
  color: var(--purple-bright);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--purple);
}

.shortcut-list {
  margin: 2rem 0 0;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.66rem;
  line-height: 2;
}

kbd {
  padding: 2px 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  font-family: Arial, sans-serif;
}

.menu-row {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0.5rem;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.menu-row:hover {
  color: var(--purple-bright);
}

.menu-row small {
  color: rgba(255, 255, 255, 0.26);
  font-family: Arial, sans-serif;
  font-size: 0.52rem;
  letter-spacing: 0.16em;
}

.toast {
  position: absolute;
  z-index: 100;
  top: 10%;
  left: 50%;
  visibility: hidden;
  min-width: 220px;
  padding: 12px 20px;
  border: 1px solid rgba(208, 145, 255, 0.38);
  border-radius: 999px;
  opacity: 0;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(11, 8, 16, 0.88);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  font-size: clamp(0.64rem, 0.7vw, 0.82rem);
  text-align: center;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 180ms ease, visibility 180ms;
  backdrop-filter: blur(10px);
}

.toast.is-visible {
  visibility: visible;
  opacity: 1;
  transform: translate(-50%, 0);
}

.screen-transition {
  position: absolute;
  z-index: 110;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  background: #060409;
  transition: opacity 240ms ease, visibility 240ms;
}

.screen-transition.is-active {
  visibility: visible;
  opacity: 1;
}

.outside-note {
  position: fixed;
  right: 12px;
  bottom: 8px;
  z-index: -1;
  margin: 0;
  color: rgba(255, 255, 255, 0.2);
  font-size: 9px;
  letter-spacing: 0.05em;
}

@media (max-width: 900px) and (orientation: landscape) {
  .brand-mark small,
  .utility-button > span,
  .keyboard-hint {
    display: none;
  }

  .top-bar {
    min-height: 48px;
  }

  .dialogue-panel {
    min-height: 27%;
  }
}

@media (max-aspect-ratio: 3 / 4) {
  body {
    overflow: auto;
  }

  .page-shell {
    display: block;
  }

  .game {
    width: 100%;
    min-height: 100dvh;
    aspect-ratio: auto;
  }

  .top-bar {
    top: 8px;
    right: 8px;
    left: 8px;
    min-height: 52px;
    padding: 0 10px;
  }

  .brand-mark {
    font-size: 0.58rem;
  }

  .brand-mark small,
  .utility-button:nth-child(1),
  .utility-button:nth-child(2) {
    display: none;
  }

  .utility-button {
    min-width: 40px;
    min-height: 34px;
    padding: 0 6px;
    font-size: 0.46rem;
  }

  .utility-button--menu {
    min-width: 44px;
    grid-template-columns: 14px;
  }

  .utility-button--menu b {
    display: none;
  }

  .scene-meta {
    top: 9.5%;
    left: 18px;
  }

  .character-wrap {
    right: -2%;
    bottom: 27%;
    width: 68%;
    height: 66%;
  }

  .character-aura {
    right: 8%;
  }

  .window-glow {
    top: 10%;
    left: 4%;
    width: 53%;
    height: 42%;
  }

  .choice-layer {
    top: 17%;
    left: 4%;
    width: 92%;
    gap: 9px;
  }

  .choice-button {
    grid-template-columns: 48px 1fr 18px;
    min-height: 62px;
    background: rgba(11, 8, 16, 0.93);
  }

  .choice-text {
    font-size: 0.78rem;
  }

  .dialogue-panel {
    right: 3%;
    bottom: 2.5%;
    left: 3%;
    min-height: 27%;
    padding: 18px 18px 20px;
  }

  .dialogue-text {
    max-width: 100%;
    min-height: 3.8em;
    font-size: 0.92rem;
    line-height: 1.75;
  }

  .advance-button {
    right: 18px;
    bottom: 12px;
  }

  .keyboard-hint {
    display: none;
  }

  .title-screen {
    align-items: end;
    padding: 16% 8% 9%;
    background: linear-gradient(0deg, rgba(5, 4, 8, 0.99) 0%, rgba(5, 4, 8, 0.92) 46%, rgba(5, 4, 8, 0.25) 77%, rgba(5, 4, 8, 0.45));
  }

  
  .title-card {
    width: 100%;
    padding: 0;
  }

  .title-card h1 {
    font-size: clamp(3rem, 15vw, 5rem);
  }

  .title-subtitle {
    margin: 1.1em 0 1.6em;
  }

  .title-actions {
    width: 100%;
  }

  .title-index {
    top: 12%;
    right: 5%;
    bottom: auto;
  }

  .end-card {
    width: 92%;
  }

  .end-actions {
    display: grid;
  }

  .end-actions .primary-button,
  .end-actions .secondary-button {
    width: 100%;
    max-width: none;
  }

  .modal-card,
  .modal-card--log,
  .modal-card--menu {
    width: 96%;
    max-height: 86%;
  }

  .log-entry {
    grid-template-columns: 70px 1fr;
    gap: 0.8rem;
  }

  .outside-note {
    display: none;
  }
}

@media (max-width: 520px) {
  .title-actions {
    display: grid;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .speaker-rule {
    display: none;
  }

  .scene-meta__line {
    width: 20px;
  }
}

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

/* ============================================================
   v4 adjustments — レイアウト / 可読性 / 立ち絵の見せ方
   ここより下が今回の調整分。元の指定を上書きしています。
   ============================================================ */

/* --- 会話ボックス：高さを内容に追従させ、空白を詰める --------- */
.dialogue-panel {
  min-height: 0;
  padding: clamp(16px, 1.35vw, 26px) clamp(24px, 3vw, 54px) clamp(14px, 1.2vw, 22px);
}

.dialogue-text {
  min-height: 3.4em;      /* 2行分を確保して行数変化のガタつきを防ぐ */
  line-height: 1.7;
}

.advance-button {
  bottom: clamp(9px, 0.9vw, 15px);
}

/* --- 立ち絵：下端の切れを見せない / 存在感を出す --------------- */
.character-wrap {
  bottom: 17%;
  width: 54%;
  height: 78%;
}

.character-art {
  -webkit-mask-image: linear-gradient(180deg, #000 84%, rgba(0, 0, 0, 0.35) 95%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 84%, rgba(0, 0, 0, 0.35) 95%, transparent 100%);
  filter: drop-shadow(0 10px 30px rgba(80, 34, 122, 0.34)) drop-shadow(0 2px 4px rgba(80, 34, 122, 0.18));
}

/* 立ち絵の後ろにやわらかい抜きを置いて、背景から分離させる */
.character-wrap::before {
  content: "";
  position: absolute;
  z-index: 0;
  right: -6%;
  bottom: -6%;
  left: 4%;
  top: 4%;
  border-radius: 50% 50% 44% 44%;
  background: radial-gradient(ellipse at 52% 46%, rgba(255, 253, 255, 0.42), rgba(250, 240, 255, 0.2) 50%, transparent 72%);
  filter: blur(12px);
}

.character-shadow {
  bottom: 1%;
  height: 6%;
  background: rgba(96, 46, 132, 0.3);
}

/* --- 背景：白飛びを抑えて奥行きを戻す ------------------------- */
/* --- タイトル/エンド表示中は本編UIを隠す ---------------------- */
.game.is-overlay .top-bar,
.game.is-overlay .dialogue-panel,
.game.is-overlay .scene-meta,
.game.is-overlay .show-dialogue {
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

/* --- 選択肢：本文の上に重ねず、読み順どおりに置く ------------- */
.choice-layer {
  top: auto;
  bottom: 34%;
  left: 4.5%;
  width: min(52%, 720px);
}

/* ============================================================
   スマホ縦持ち
   ============================================================ */
@media (max-aspect-ratio: 3 / 4) {
  .dialogue-panel {
    right: 3%;
    bottom: 2.5%;
    left: 3%;
    min-height: 0;
    padding: 16px 18px 16px;
  }

  .dialogue-text {
    min-height: 5.1em;    /* 3行分 */
    font-size: 0.95rem;
    line-height: 1.7;
  }

  .character-wrap {
    right: -4%;
    bottom: 24%;
    width: 78%;
    height: 60%;
  }

  .choice-layer {
    top: auto;
    bottom: 31%;
    left: 4%;
    width: 92%;
    gap: 8px;
  }

  .choice-button {
    min-height: 56px;
  }

  .advance-button {
    right: 16px;
    bottom: 10px;
  }
}

/* 横持ちスマホ：会話ボックスが画面の半分を占めないように */
@media (max-width: 900px) and (orientation: landscape) {
  .dialogue-panel {
    min-height: 0;
    padding: 12px 20px 14px;
  }

  .dialogue-text {
    min-height: 3.4em;
    font-size: 0.82rem;
  }

  .choice-layer {
    bottom: 32%;
  }
}

/* --- 音量コントロール ----------------------------------------- */
.utility-button--sound i {
  font-style: normal;
  font-size: 1.05em;
  line-height: 1;
}

.utility-button--sound.is-active {
  opacity: 0.55;
}

.utility-button--sound.is-active i {
  text-decoration: line-through;
}

.volume-section {
  margin-top: clamp(12px, 1.4vw, 20px);
  padding-top: clamp(12px, 1.4vw, 18px);
  border-top: 1px solid rgba(86, 35, 108, 0.14);
}

.volume-heading {
  display: flex;
  align-items: baseline;
  gap: 0.7em;
  margin: 0 0 0.9em;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.volume-heading small {
  color: rgba(69, 35, 82, 0.5);
  font-family: Arial, sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.2em;
}

.volume-row {
  display: grid;
  grid-template-columns: 4.4em 1fr;
  align-items: center;
  gap: 0.9em;
  padding: 0.42em 0;
  font-size: 0.78rem;
  cursor: pointer;
}

.volume-row input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--purple);
  background: transparent;
  cursor: pointer;
}


/* メニューは音量欄を足したぶん高さに余裕を持たせる */
.modal-card--menu {
  max-height: 90%;
}

.modal-card--menu .modal-heading {
  margin-bottom: 1.1rem;
}

@media (max-aspect-ratio: 3 / 4) {
  .utility-button--sound span {
    display: none;
  }

  .utility-button--sound {
    min-width: 36px;
  }
}

/* サウンドボタンはアイコンのみ表示（ラベルは読み上げ用に残す） */
.utility-button--sound span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.utility-button--sound i {
  font-size: 1.15em;
}


/* ============================================================
   v6 — 配色トークン
   ------------------------------------------------------------
   色は下の変数だけを見ています。明るさや色味を変えたいときは
   このブロックの値を触れば、画面全体に一度に反映されます。
   `.game` に is-night を付けると暗色版に切り替わります。
   ============================================================ */

:root {
  /* 面：奥から手前へ、明るさに段差をつける */
  --surface-back: #efe7f6;      /* 画面の外側 */
  --surface-panel: rgba(255, 253, 255, 0.95);   /* 会話ボックス／モーダル */
  --surface-card: rgba(255, 252, 255, 0.93);    /* 選択肢 */
  --surface-chip: rgba(255, 252, 255, 0.82);    /* 上部の操作 */

  /* 文字 */
  --ink-hi: #24122e;            /* 本文 */
  --ink-mid: rgba(41, 21, 52, 0.72);
  --ink-low: rgba(41, 21, 52, 0.5);
  --ink-on-accent: #ffffff;

  /* 差し色 */
  --accent: #8b2fc4;
  --accent-soft: rgba(139, 47, 196, 0.12);
  --accent-line: rgba(139, 47, 196, 0.24);

  /* 縁と影 */
  --edge: rgba(88, 38, 118, 0.22);
  --edge-strong: rgba(139, 47, 196, 0.42);
  --shadow-panel: 0 22px 58px rgba(66, 26, 96, 0.3);
  --shadow-card: 0 14px 34px rgba(66, 26, 96, 0.22);
  --shadow-chip: 0 8px 26px rgba(66, 26, 96, 0.18);

  /* 背景写真の調整
     白い立ち絵が背景に溶けないよう、背景だけ薄紫に寄せて一段沈める */
  --bg-filter: saturate(0.8) brightness(0.94) contrast(0.96) hue-rotate(4deg);
  --bg-warm: rgba(255, 224, 172, 0.26);      /* 天井照明 */
  --bg-cool: rgba(84, 116, 190, 0.26);       /* 窓の外＝夕暮れ以降 */
  --bg-veil: rgba(233, 220, 248, 0.42);      /* 背景を一段奥へ引く薄紫のヴェール */
  --bg-floor: rgba(126, 92, 168, 0.3);       /* 下端の締め */
  --vignette: rgba(104, 66, 146, 0.24);

  /* 立ち絵まわり
     背景より少し濃い紫の抜きを敷いて、白い衣装の輪郭を立たせる */
  --char-halo: rgba(158, 116, 200, 0.26);
  --char-shadow: 0 16px 38px rgba(72, 32, 108, 0.42);
  --char-rim: 0 0 22px rgba(110, 62, 158, 0.28);
  --char-floor: rgba(96, 52, 134, 0.3);

  /* オーバーレイ（タイトル／エンド／モーダルの下地） */
  --overlay-strong: rgba(252, 248, 255, 0.97);
  --overlay-soft: rgba(250, 244, 255, 0.1);
  --scrim: rgba(70, 36, 100, 0.28);
}

.game.is-night {
  --surface-back: #08050d;
  --surface-panel: rgba(24, 15, 38, 0.92);
  --surface-card: rgba(27, 16, 42, 0.92);
  --surface-chip: rgba(15, 9, 23, 0.66);
  --ink-hi: #f6eefc;
  --ink-mid: rgba(238, 228, 248, 0.72);
  --ink-low: rgba(230, 220, 244, 0.46);
  --ink-on-accent: #1a0b28;
  --accent: #c98cff;
  --accent-soft: rgba(201, 140, 255, 0.16);
  --accent-line: rgba(201, 140, 255, 0.24);
  --edge: rgba(201, 140, 255, 0.2);
  --edge-strong: rgba(201, 140, 255, 0.7);
  --shadow-panel: 0 22px 60px rgba(0, 0, 0, 0.62);
  --shadow-card: 0 14px 34px rgba(0, 0, 0, 0.46);
  --shadow-chip: 0 8px 26px rgba(0, 0, 0, 0.42);
  --bg-filter: saturate(0.88) brightness(0.86) contrast(1.05) hue-rotate(-6deg);
  --bg-warm: rgba(255, 206, 146, 0.36);
  --bg-cool: rgba(120, 170, 236, 0.12);
  --bg-veil: rgba(28, 18, 40, 0.08);
  --bg-floor: rgba(11, 8, 18, 0.7);
  --vignette: rgba(6, 4, 10, 0.6);
  --char-halo: rgba(122, 66, 178, 0.3);
  --char-shadow: 0 14px 34px rgba(0, 0, 0, 0.6);
  --char-rim: 0 0 26px rgba(150, 82, 214, 0.22);
  --char-floor: rgba(0, 0, 0, 0.6);
  --overlay-strong: rgba(9, 5, 15, 0.96);
  --overlay-soft: rgba(11, 7, 18, 0.14);
  --scrim: rgba(6, 4, 10, 0.66);
}

/* ============================================================
   v6 — 画面まわり
   ============================================================ */

html,
body {
  background: var(--surface-back);
}

body {
  color: var(--ink-hi);
  background:
    radial-gradient(circle at 50% 0%, rgba(186, 132, 240, 0.28), transparent 58%),
    linear-gradient(180deg, #fbf6ff 0%, #efe4fa 58%, #f7f1ff 100%);
}

.game.is-night body,
body:has(.game.is-night) {
  background: linear-gradient(180deg, #0d0814 0%, #08050d 60%, #0b0712 100%);
}

.game {
  background: var(--surface-back);
  box-shadow: 0 26px 90px rgba(76, 34, 108, 0.26);
}

.game.is-night {
  box-shadow: 0 30px 110px rgba(0, 0, 0, 0.7);
}

/* --- 背景：明るい室内。窓の外だけ夜を残す ------------------- */
.game.has-background-image .scene-background {
  background-image:
    /* 天井照明の暖かい光 */
    radial-gradient(ellipse at 24% 14%, var(--bg-warm), transparent 56%),
    /* 窓の外は夜 */
    radial-gradient(ellipse at 88% 24%, var(--bg-cool), transparent 40%),
    /* 全体を一段奥へ引く */
    linear-gradient(180deg, var(--bg-veil) 0%, var(--bg-veil) 62%, var(--bg-floor) 100%),
    var(--background-image);
  background-position: center;
  background-size: cover;
  filter: var(--bg-filter);
}

.vignette {
  background:
    linear-gradient(180deg, var(--vignette), transparent 24%, transparent 62%, var(--vignette)),
    radial-gradient(ellipse at 58% 42%, transparent 46%, var(--vignette) 100%);
  opacity: 0.7;
}

.grain {
  opacity: 0.04;
  mix-blend-mode: multiply;
}

.game.is-night .grain {
  opacity: 0.05;
  mix-blend-mode: soft-light;
}

.screen-transition {
  background: var(--overlay-strong);
}

/* ============================================================
   v6 — 操作まわり
   ============================================================ */

.top-bar {
  top: 2.4%;
  right: 2.6%;
  left: auto;
  display: block;
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--surface-chip);
  box-shadow: var(--shadow-chip);
  backdrop-filter: blur(14px) saturate(1.1);
}

.utility-button {
  min-width: 0;
  min-height: 0;
  padding: 7px clamp(9px, 0.85vw, 14px);
  border: 0;
  border-radius: 999px;
  color: var(--ink-mid);
  background: none;
  font-family: inherit;
  font-size: clamp(0.66rem, 0.78vw, 0.86rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: color 160ms ease, background 160ms ease;
}

.utility-button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.utility-button.is-active {
  color: var(--ink-on-accent);
  background: var(--accent);
}

.top-actions .utility-button--menu {
  display: grid;
  width: 38px;
  min-width: 38px;
  height: 34px;
  padding: 0;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(3, 2px);
  row-gap: 4.5px;
  column-gap: 0;
  place-content: center;
  justify-items: center;
}

/* 横持ち時の「.utility-button > span を隠す」指定が
   ハンバーガーの3本線まで消していたので、明示的に戻す */
.top-actions .utility-button--menu > span {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.utility-button--sound i {
  font-style: normal;
  font-size: 1.15em;
  line-height: 1;
}

.utility-button--sound.is-active {
  opacity: 0.5;
}

.utility-button--sound.is-active i {
  text-decoration: line-through;
}

.utility-button--sound span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- 章表示 ------------------------------------------------- */
.scene-meta {
  top: 3.6%;
  bottom: auto;
  left: 3.4%;
  gap: 0.7rem;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
}

.scene-meta__chapter {
  color: var(--accent);
  opacity: 0.62;
  font-size: clamp(1rem, 1.5vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.scene-meta__line {
  width: clamp(18px, 2vw, 34px);
  background: linear-gradient(90deg, var(--edge-strong), transparent);
}

.scene-meta strong {
  color: var(--ink-mid);
  font-size: clamp(0.78rem, 0.95vw, 1.05rem);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-shadow: 0 1px 10px var(--overlay-strong);
}

/* ============================================================
   v6 — 会話ボックス
   ============================================================ */

.dialogue-panel {
  right: 4%;
  bottom: 3.4%;
  left: 4%;
  min-height: 0;
  padding: clamp(20px, 1.9vw, 34px) clamp(26px, 3.2vw, 60px) clamp(22px, 2vw, 34px);
  border: 1px solid var(--edge);
  border-radius: clamp(14px, 1.2vw, 20px);
  background: var(--surface-panel);
  box-shadow: var(--shadow-panel), inset 0 1px rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px) saturate(1.1);
}

.game.is-night .dialogue-panel {
  box-shadow: var(--shadow-panel), inset 0 1px rgba(255, 255, 255, 0.07);
}

.dialogue-panel::before {
  background: linear-gradient(100deg, var(--accent-soft), transparent 32%);
}

.dialogue-accent {
  width: 34%;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  box-shadow: 0 0 16px var(--accent-line);
}

.speaker-row {
  margin-bottom: clamp(6px, 0.6vw, 11px);
}

.speaker-row h2 {
  color: var(--accent);
  font-size: clamp(1rem, 1.22vw, 1.4rem);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.dialogue-panel.is-narration .speaker-row {
  display: none;
}

.dialogue-text {
  max-width: 96%;
  min-height: 3.5em;
  color: var(--ink-hi);
  font-size: clamp(1.05rem, 1.52vw, 1.72rem);
  font-weight: 500;
  line-height: 1.88;
  letter-spacing: 0.045em;
  text-shadow: none;
}

.game.is-night .dialogue-text {
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.7);
}

.dialogue-panel.is-narration .dialogue-text {
  color: var(--ink-mid);
}

.advance-button {
  right: clamp(20px, 2.4vw, 40px);
  bottom: clamp(12px, 1.1vw, 20px);
  padding: 6px;
  background: none;
}

.advance-button i {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  opacity: 0.8;
}

.show-dialogue {
  border: 1px solid var(--edge-strong);
  color: var(--ink-hi);
  background: var(--surface-panel);
  font-size: clamp(0.78rem, 0.9vw, 0.95rem);
}

/* ============================================================
   v6 — 選択肢
   ============================================================ */

.choice-layer {
  top: auto;
  bottom: 33%;
  left: 3.4%;
  width: min(50%, 700px);
}

.choice-button {
  min-height: clamp(54px, 4.6vw, 74px);
  grid-template-columns: clamp(40px, 3.6vw, 58px) 1fr auto;
  border: 1px solid var(--edge);
  border-radius: clamp(10px, 0.9vw, 14px);
  color: var(--ink-hi);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px) saturate(1.1);
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.choice-button:hover,
.choice-button:focus-visible {
  border-color: var(--edge-strong);
  box-shadow: var(--shadow-panel);
  transform: translateX(4px);
}

.choice-key {
  border-right: 1px solid var(--accent-line);
  color: var(--accent);
  background: var(--accent-soft);
  font-family: inherit;
  font-size: clamp(0.86rem, 1vw, 1.15rem);
  font-weight: 700;
  font-style: normal;
}

.choice-text {
  font-size: clamp(1rem, 1.3vw, 1.44rem);
  font-weight: 500;
  letter-spacing: 0.035em;
}

.choice-arrow {
  color: var(--accent);
  opacity: 0.55;
}

/* ============================================================
   v6 — 立ち絵
   ============================================================ */

.character-wrap {
  bottom: 17%;
  width: 54%;
  height: 78%;
}

.character-wrap::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: 4%;
  right: -6%;
  bottom: -6%;
  left: 4%;
  border-radius: 50% 50% 44% 44%;
  background: radial-gradient(ellipse at 52% 46%, var(--char-halo), transparent 72%);
  filter: blur(16px);
}

.character-art {
  -webkit-mask-image: linear-gradient(180deg, #000 84%, rgba(0, 0, 0, 0.35) 95%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 84%, rgba(0, 0, 0, 0.35) 95%, transparent 100%);
  filter: drop-shadow(var(--char-shadow)) drop-shadow(var(--char-rim));
}

.character-shadow {
  bottom: 1%;
  height: 6%;
  background: var(--char-floor);
}

/* ============================================================
   v6 — タイトル / エンディング / モーダル
   ============================================================ */

.title-screen {
  background:
    linear-gradient(90deg, var(--overlay-strong) 0%, var(--overlay-strong) 30%, var(--overlay-soft) 56%, var(--overlay-soft) 100%),
    linear-gradient(180deg, var(--overlay-soft), transparent 36%, var(--overlay-soft));
}

.title-screen::before {
  background: linear-gradient(transparent 8%, var(--edge-strong) 50%, transparent 92%);
}

.title-screen__glow {
  opacity: 0.5;
  background: radial-gradient(circle, rgba(176, 96, 240, 0.26), transparent 68%);
}

.title-card h1,
.title-card h1 span {
  color: var(--ink-hi);
  text-shadow: 0 6px 30px rgba(255, 255, 255, 0.8);
}

.game.is-night .title-card h1,
.game.is-night .title-card h1 span {
  text-shadow: 0 6px 34px rgba(150, 70, 230, 0.5);
}

.title-subtitle {
  color: var(--ink-mid);
  font-size: clamp(0.85rem, 1.05vw, 1.15rem);
}

.title-note {
  color: var(--ink-low);
  font-size: clamp(0.72rem, 0.85vw, 0.92rem);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: clamp(50px, 4vw, 64px);
  align-items: center;
  justify-content: center;
  padding: 0 clamp(24px, 2.6vw, 44px);
  border-radius: clamp(10px, 0.9vw, 14px);
  font-size: clamp(0.92rem, 1.08vw, 1.2rem);
  font-weight: 700;
  letter-spacing: 0.1em;
}

.primary-button {
  border: 0;
  color: #ffffff;
  background: linear-gradient(100deg, #a94fdd, #8b2fc4 60%, #6f1ba6);
  box-shadow: 0 14px 32px rgba(110, 32, 166, 0.34);
}

.game.is-night .primary-button {
  color: #1a0b28;
  background: linear-gradient(100deg, #d9a2ff, #c98cff 55%, #a558ec);
  box-shadow: 0 14px 34px rgba(138, 63, 214, 0.42);
}

.secondary-button {
  border: 1px solid var(--edge-strong);
  color: var(--ink-hi);
  background: var(--surface-panel);
}

.secondary-button:disabled {
  opacity: 0.36;
}

.text-button {
  flex-basis: 100%;
  margin-top: 0.4em;
  color: var(--ink-low);
  font-size: clamp(0.78rem, 0.9vw, 0.95rem);
}

.end-screen {
  background:
    radial-gradient(circle at center, rgba(186, 120, 244, 0.24), transparent 48%),
    var(--overlay-strong);
}

.end-card {
  width: min(760px, 86%);
}

.end-label {
  color: var(--accent);
  letter-spacing: 0.24em;
}

.end-card h2 {
  color: var(--ink-hi);
}

.end-card > p:not(.end-label) {
  max-width: 40em;
  margin-inline: auto;
  color: var(--ink-mid);
  font-size: clamp(0.88rem, 1.02vw, 1.12rem);
  line-height: 1.95;
  white-space: pre-line;
}

.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(10px, 1vw, 16px);
  align-items: center;
  justify-content: center;
}

.end-actions .primary-button,
.end-actions .secondary-button {
  white-space: nowrap;
}

.modal-layer {
  background: var(--scrim);
  backdrop-filter: blur(4px);
}

.modal-card {
  border: 1px solid var(--edge);
  background: var(--surface-panel);
  box-shadow: var(--shadow-panel);
  backdrop-filter: blur(20px) saturate(1.1);
}

.modal-card--menu {
  max-height: 90%;
}

.modal-heading {
  margin-bottom: 1.2rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px solid var(--edge);
}

.modal-heading h2 {
  color: var(--ink-hi);
  font-size: clamp(1rem, 1.2vw, 1.3rem);
}

.close-button {
  border: 1px solid var(--edge);
  color: var(--ink-mid);
}

.menu-row {
  display: block;
  padding: clamp(13px, 1.2vw, 18px) 2px;
  border-bottom: 1px solid var(--edge);
  color: var(--ink-hi);
  font-size: clamp(0.88rem, 1vw, 1.08rem);
  text-align: left;
}

.menu-row:hover {
  color: var(--accent);
}

.log-entry {
  border-bottom-color: var(--edge);
}

.log-entry strong {
  color: var(--accent);
}

.log-entry p {
  color: var(--ink-mid);
  font-size: clamp(0.85rem, 0.98vw, 1.05rem);
  line-height: 1.85;
}

.log-empty {
  color: var(--ink-low);
}

.toast {
  border: 1px solid var(--edge-strong);
  color: var(--ink-hi);
  background: var(--surface-panel);
  box-shadow: var(--shadow-card);
  font-size: clamp(0.8rem, 0.92vw, 0.98rem);
}

/* --- 音量 --------------------------------------------------- */
.volume-section {
  margin-top: clamp(12px, 1.4vw, 20px);
  padding-top: clamp(12px, 1.4vw, 18px);
  border-top: 1px solid var(--edge);
}

.volume-heading {
  margin: 0 0 0.9em;
  color: var(--ink-hi);
  font-size: clamp(0.86rem, 0.98vw, 1.02rem);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.volume-row {
  display: grid;
  grid-template-columns: 4.6em 1fr;
  align-items: center;
  gap: 0.9em;
  padding: 0.42em 0;
  color: var(--ink-mid);
  font-size: clamp(0.84rem, 0.95vw, 1rem);
  cursor: pointer;
}

.volume-row input[type="range"] {
  width: 100%;
  height: 26px;
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
}

.volume-row input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--accent-line);
}

.volume-row input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--accent-line);
}

.volume-row input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.volume-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 2px 8px rgba(60, 24, 90, 0.35);
  cursor: pointer;
}

.volume-row input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  cursor: pointer;
}

/* --- タイトル／エンド表示中は本編UIを隠す ------------------- */
.game.is-overlay .top-bar,
.game.is-overlay .dialogue-panel,
.game.is-overlay .scene-meta,
.game.is-overlay .show-dialogue {
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

/* ============================================================
   v6 — レスポンシブ（ここが最後。端末別に上書きする）
   ============================================================ */

/* スマホ縦持ち */
@media (max-aspect-ratio: 3 / 4) {
  .top-bar {
    top: 10px;
    right: 10px;
  }

  .top-actions {
    gap: 0;
    padding: 3px;
  }

  .utility-button {
    padding: 8px 9px;
    font-size: 0.76rem;
  }

  .scene-meta {
    top: 16px;
    left: 14px;
    gap: 0.5rem;
  }

  .scene-meta__chapter {
    font-size: 1.05rem;
  }

  .scene-meta strong {
    font-size: 0.82rem;
  }

  .character-wrap {
    right: -4%;
    bottom: 26%;
    width: 82%;
    height: 58%;
  }

  .choice-layer {
    bottom: 30%;
    left: 4%;
    width: 92%;
    gap: 9px;
  }

  .choice-button {
    min-height: 58px;
    grid-template-columns: 44px 1fr 20px;
    gap: 12px;
    padding-right: 14px;
  }

  .choice-key {
    font-size: 0.95rem;
  }

  .choice-text {
    font-size: 0.94rem;
    line-height: 1.5;
  }

  .dialogue-panel {
    right: 3%;
    bottom: 2.6%;
    left: 3%;
    padding: 16px 18px 18px;
  }

  .dialogue-text {
    max-width: 100%;
    min-height: 5.4em;
    font-size: 1.02rem;
    line-height: 1.8;
  }

  .speaker-row h2 {
    font-size: 0.95rem;
  }

  .advance-button {
    right: 14px;
    bottom: 10px;
  }

  .title-card h1 {
    font-size: clamp(2.9rem, 14vw, 4.6rem);
  }

  .title-actions {
    display: grid;
    width: 100%;
    gap: 10px;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
    min-height: 54px;
  }

  .end-card {
    width: 92%;
  }

  .end-actions {
    display: grid;
    width: 100%;
  }

  .modal-card,
  .modal-card--log,
  .modal-card--menu {
    width: 94%;
    max-height: 88%;
  }
}

/* スマホ横持ち */
@media (max-width: 900px) and (orientation: landscape) {
  .dialogue-panel {
    padding: 12px 22px 14px;
  }

  .dialogue-text {
    min-height: 3.5em;
    font-size: 0.94rem;
    line-height: 1.72;
  }

  .choice-layer {
    bottom: 34%;
    width: min(56%, 560px);
  }

  .choice-button {
    min-height: 46px;
  }

  .utility-button {
    padding: 6px 9px;
    font-size: 0.72rem;
  }
}

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


/* スマホ縦持ちのタイトルは、上下方向に敷いて立ち絵を残す */
@media (max-aspect-ratio: 3 / 4) {
  .title-screen {
    align-items: end;
    padding: 16% 7% 8%;
    background: linear-gradient(0deg,
      var(--overlay-strong) 0%,
      var(--overlay-strong) 42%,
      var(--overlay-soft) 74%,
      var(--overlay-soft) 100%);
  }

  .title-card {
    width: 100%;
    padding: 0;
  }

  .title-note {
    max-width: 22em;
  }
}

/* ============================================================
   v7 — 丸みと、立ち絵まわりの影の整理
   ============================================================ */

/* Arial 指定が残っていた箇所も丸ゴシックに寄せる */
.speaker-kana,
.utility-button,
.scene-meta__chapter,
.end-label,
.choice-key,
.advance-button,
.title-note,
.log-entry strong,
.volume-heading {
  font-family: inherit;
}

/* --- 角をまるく ---------------------------------------------- */
.dialogue-panel {
  border-radius: clamp(20px, 1.9vw, 30px);
}

.choice-button {
  border-radius: clamp(16px, 1.5vw, 24px);
}

.choice-key {
  border-right: 0;
  border-radius: clamp(12px, 1.1vw, 18px);
  margin: 6px 0 6px 6px;
}

.primary-button,
.secondary-button {
  border-radius: 999px;
}

.modal-card {
  border-radius: clamp(20px, 1.8vw, 28px);
}

.menu-row {
  padding-inline: clamp(10px, 1vw, 16px);
  border-radius: 14px;
  border-bottom: 1px solid var(--edge);
}

.menu-row:hover {
  background: var(--accent-soft);
}

.toast,
.show-dialogue {
  border-radius: 999px;
}

.close-button {
  border-radius: 999px;
}

/* --- 文字まわり：丸ゴシックに合わせて字間と行間を調整 -------- */
.dialogue-text {
  font-weight: 500;
  letter-spacing: 0.06em;
  line-height: 1.92;
}

.speaker-row h2 {
  letter-spacing: 0.14em;
}

.choice-text {
  font-weight: 500;
  letter-spacing: 0.05em;
}

.title-card h1,
.title-card h1 span {
  font-weight: 700;
  letter-spacing: 0.06em;
}

.end-card h2 {
  font-weight: 700;
  letter-spacing: 0.08em;
}

/* --- 立ち絵：黒い影をなくす --------------------------------- */
/* 足元の黒い楕円は削除 */
.character-shadow {
  display: none;
}

/* 落とし影もやめて、うっすら明るい縁だけ残す */
.character-art {
  filter: drop-shadow(var(--char-rim));
}

:root {
  /* 影の代わりに、背景よりわずかに濃い紫の抜きで輪郭を支える */
  --char-halo: rgba(170, 128, 210, 0.3);
  --char-rim: 0 0 18px rgba(255, 252, 255, 0.85);
}

.game.is-night {
  --char-halo: rgba(122, 66, 178, 0.34);
  --char-rim: 0 0 20px rgba(190, 140, 240, 0.34);
}

/* 角を丸くしたぶん、上辺の差し色は内側に収まるピル型にする */
.dialogue-accent {
  top: 0;
  left: 9%;
  width: 20%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), transparent);
  box-shadow: none;
  opacity: 0.75;
}

.dialogue-panel::before {
  border-radius: inherit;
}

/* ============================================================
   v8 — タイトル画面を白紙に戻す
   ------------------------------------------------------------
   .title-stage が空きスペースです。ロゴやキャッチを入れてください。
   ============================================================ */
.title-screen {
  display: grid;
  grid-template-rows: 1fr auto;
  place-items: center;
  padding: clamp(24px, 4vw, 60px);
  background: #fdfaff;   /* 完全に不透明。後ろのゲーム画面は見せない */
}

.title-screen::before,
.title-screen__glow {
  display: none;
}

.title-stage {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.title-screen .title-actions {
  display: flex;
  gap: clamp(10px, 1.2vw, 18px);
  align-items: center;
  justify-content: center;
  width: auto;
  padding-bottom: clamp(8px, 2vw, 28px);
}

@media (max-aspect-ratio: 3 / 4) {
  .title-screen {
    align-items: stretch;
    padding: clamp(20px, 6vw, 40px);
    background: #fdfaff;
  }

  .title-screen .title-actions {
    display: grid;
    width: 100%;
  }
}

/* ============================================================
   v8 — 立ち絵が白い背景に溶けないようにする
   ------------------------------------------------------------
   黒い影は使わず、
   ・立ち絵のふちに淡い紫の縁取り（ステッカー風）
   ・背景側は立ち絵の後ろだけを少し濃くする
   の2つで輪郭を立たせています。
   ============================================================ */

:root {
  --char-outline: rgba(139, 88, 192, 0.78);   /* 縁取りの色 */
  --char-halo: rgba(158, 112, 206, 0.34);      /* 後ろの抜き */
}

.game.is-night {
  --char-outline: rgba(214, 168, 255, 0.42);
  --char-halo: rgba(122, 66, 178, 0.4);
}

.character-art {
  filter:
    drop-shadow(2.5px 0 0 var(--char-outline))
    drop-shadow(-2.5px 0 0 var(--char-outline))
    drop-shadow(0 2.5px 0 var(--char-outline))
    drop-shadow(0 -2.5px 0 var(--char-outline))
    drop-shadow(0 0 14px rgba(139, 88, 192, 0.45))
    drop-shadow(0 6px 20px rgba(120, 78, 168, 0.26));
}

/* 後ろの抜きを少しはっきりさせて、白い衣装の外側に色を置く */
.character-wrap::before {
  top: 2%;
  right: -8%;
  bottom: -8%;
  left: 2%;
  background:
    radial-gradient(ellipse at 52% 44%, var(--char-halo), transparent 68%);
  filter: blur(22px);
}

/* 立ち絵が立つあたりだけ、背景をわずかに沈める */
.character-wrap::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -14% -18% -12% -10%;
  background: radial-gradient(ellipse at 54% 52%, rgba(108, 66, 152, 0.16), transparent 66%);
  filter: blur(28px);
  pointer-events: none;
}

/* ============================================================
   v9 — 画面全体の紫かぶりを取る
   ------------------------------------------------------------
   面・影・背景・ふちを、色味のない灰色〜白に置き換えます。
   紫は「差し色として意図して置いた場所」だけに残しています
   （話者名／ボタン／選択肢のA・B・C／章番号／立ち絵のふち）。
   ============================================================ */

:root {
  /* 面：無彩色の白〜薄灰で段差をつける */
  --surface-back: #ececed;
  --surface-panel: rgba(255, 255, 255, 0.96);
  --surface-card: rgba(255, 255, 255, 0.94);
  --surface-chip: rgba(255, 255, 255, 0.84);

  /* 文字：紫みのない濃灰 */
  --ink-hi: #23232a;
  --ink-mid: rgba(38, 38, 46, 0.72);
  --ink-low: rgba(38, 38, 46, 0.5);

  /* 縁と影：無彩色 */
  --edge: rgba(40, 40, 50, 0.14);
  --edge-strong: rgba(40, 40, 50, 0.3);
  --shadow-panel: 0 20px 52px rgba(30, 30, 40, 0.18);
  --shadow-card: 0 12px 30px rgba(30, 30, 40, 0.14);
  --shadow-chip: 0 8px 22px rgba(30, 30, 40, 0.12);

  /* 背景：色を足さず、明るさだけ整える
     （hue-rotate と薄紫のヴェールをやめたので紫かぶりが消えます） */
  --bg-filter: saturate(0.86) brightness(0.97) contrast(0.97);
  --bg-warm: rgba(255, 232, 196, 0.2);     /* 天井照明。ほんのり暖色 */
  --bg-cool: rgba(150, 178, 214, 0.14);    /* 窓の外 */
  --bg-veil: rgba(255, 255, 255, 0.2);     /* 白のヴェール */
  --bg-floor: rgba(96, 96, 108, 0.2);      /* 下端の締め */
  --vignette: rgba(48, 48, 58, 0.14);

  /* 立ち絵：後ろの抜きは無彩色に。ふちの色だけ残す */
  --char-halo: rgba(120, 120, 134, 0.14);
  --char-shadow: 0 16px 36px rgba(40, 40, 50, 0.22);
  --char-rim: 0 0 20px rgba(255, 255, 255, 0.6);

  /* オーバーレイ */
  --overlay-strong: rgba(253, 253, 254, 0.97);
  --overlay-soft: rgba(250, 250, 252, 0.1);
  --scrim: rgba(36, 36, 44, 0.3);
}

/* 画面の外側も無彩色に */
body {
  background:
    radial-gradient(circle at 50% 0%, rgba(198, 198, 206, 0.42), transparent 58%),
    linear-gradient(180deg, #fafafb 0%, #ececee 58%, #f6f6f7 100%);
}

.game {
  box-shadow: 0 24px 80px rgba(30, 30, 40, 0.2);
}

/* 立ち絵の後ろの沈み込みも無彩色へ */
.character-wrap::after {
  background: radial-gradient(ellipse at 54% 52%, rgba(70, 70, 84, 0.1), transparent 66%);
}

/* タイトル（白紙）は純白に */
.title-screen {
  background: #ffffff;
}

@media (max-aspect-ratio: 3 / 4) {
  .title-screen {
    background: #ffffff;
  }
}

/* 面に広く敷いていた紫のグラデーションを外す
   （差し色は、話者名・ボタン・A/B/Cのバッジなど「点」だけに残す） */
.dialogue-panel::before {
  background: none;
}

.choice-button::after {
  background: linear-gradient(90deg, rgba(40, 40, 50, 0.06), transparent 70%);
}

/* 上辺の差し色ラインも、無彩色の面に合わせて控えめに */
.dialogue-accent {
  opacity: 0.6;
}

/* ============================================================
   v10 — 立ち絵の後ろの紫を完全に消す
   ------------------------------------------------------------
   紫の円（オーラ）と、後ろに敷いていた抜き・沈み込みを全部やめます。
   背景からの分離は、立ち絵のふちの縁取りだけで行います。
   ============================================================ */

.character-aura,
.character-aura::before,
.character-aura::after {
  display: none;
}

.character-wrap::before,
.character-wrap::after {
  display: none;
}

/* 立ち絵まわりのぼんやりした紫の発光もやめる。
   残すのは、輪郭にぴたりと沿った細い縁取りだけ。 */
.character-art {
  filter:
    drop-shadow(2.5px 0 0 var(--char-outline))
    drop-shadow(-2.5px 0 0 var(--char-outline))
    drop-shadow(0 2.5px 0 var(--char-outline))
    drop-shadow(0 -2.5px 0 var(--char-outline));
}

/* ============================================================
   v11 — 立ち絵の縁取りもなくす
   ------------------------------------------------------------
   立ち絵は加工なしで、そのまま表示します。
   （下端のフェードだけは、切れ目を隠すために残しています）

   もし白い背景に溶けて見えるようなら、下の filter を有効にすると
   ふちに細い縁取りが戻ります。色は --char-outline で変えられます。

   .character-art {
     filter:
       drop-shadow(2.5px 0 0 var(--char-outline))
       drop-shadow(-2.5px 0 0 var(--char-outline))
       drop-shadow(0 2.5px 0 var(--char-outline))
       drop-shadow(0 -2.5px 0 var(--char-outline));
   }
   ============================================================ */

.character-art {
  filter: none;
}

/* ============================================================
   v12 — 会話ボックスを固定サイズにする / 立ち絵の透けを止める
   ============================================================ */

/* --- 会話ボックス：高さを固定。台詞の長さで伸び縮みしない ---- */
.dialogue-panel {
  height: 20%;
  min-height: 0;
  overflow: hidden;
}

.dialogue-text {
  min-height: 0;
}

/* --- 立ち絵：下端のフェードをやめて、透けないようにする ------
   画像は下端で断ち切られているので、切れ目は会話ボックスの裏に
   隠れる位置に置いています。 */
.character-art {
  -webkit-mask-image: none;
  mask-image: none;
}

@media (max-aspect-ratio: 3 / 4) {
  .dialogue-panel {
    height: 24%;
  }

  /* 会話ボックスが高くなったぶん、立ち絵の切れ目を確実に隠す */
  .character-wrap {
    bottom: 21%;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .dialogue-panel {
    height: 30%;
  }
}

/* 保存／再開を廃止したので、スマホで先頭2ボタンを隠していた指定を解除する
   （そのままだと「オート」「スキップ」が消えてしまう） */
@media (max-aspect-ratio: 3 / 4) {
  .utility-button:nth-child(1),
  .utility-button:nth-child(2) {
    display: inline-flex;
  }
}

/* ============================================================
   v13 — 終盤のイラスト表示
   ------------------------------------------------------------
   .is-cg のあいだは、会話ボックス・立ち絵・章表示を隠して
   イラストだけを画面いっぱいに出します。
   画像を入れるまでは白紙のままです。
   ============================================================ */

.cg-layer {
  position: absolute;
  z-index: 20;
  inset: 0;
  opacity: 0;
  visibility: hidden;
  background-color: #ffffff;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;     /* 16:9の絵を画面いっぱいに。全体を入れたいときは contain に */
  transition: opacity 320ms ease, visibility 320ms;
  pointer-events: none;
}

.game.is-cg .cg-layer {
  opacity: 1;
  visibility: visible;
}

.game.is-cg .dialogue-panel,
.game.is-cg .character-wrap,
.game.is-cg .scene-meta,
.game.is-cg .choice-layer,
.game.is-cg .show-dialogue {
  opacity: 0;
  pointer-events: none;
  transition: opacity 260ms ease;
}

/* 操作ボタンだけは、イラストの上に残す */
.game.is-cg .top-bar {
  z-index: 30;
}

/* ============================================================
   v17 — スマホ縦のイラストの見せ方
   ------------------------------------------------------------
   16:9の絵をスマホ縦に敷くと左右が大きく切れます。
   切り出し位置を右寄りにして、天板と手が入るようにしています。
   数字を大きくするほど右が写ります（50%＝中央）。
   ============================================================ */
@media (max-aspect-ratio: 3 / 4) {
  .cg-layer {
    background-position: 53% center;
  }
}

/* ============================================================
   v20 — 本文を太めに
   ------------------------------------------------------------
   Zen Maru Gothic は太いほうが丸みがはっきり出るので、
   読ませる面（本文・選択肢）は 700 にしています。
   細くしたいときはこの2つを 500 に戻してください。
   ============================================================ */
.dialogue-text {
  font-weight: 700;
}

.choice-text {
  font-weight: 700;
}

/* 三点リーダを中央の高さへ。Zen Maru Gothic は点が下に付くため */
.dot3 {
  display: inline-block;
  font-style: normal;
  transform: translateY(-0.28em);
}

/* ============================================================
   v22 — エンド画面の作り直し
   ------------------------------------------------------------
   ・背景に本編の絵を透かして「余韻」を出す
   ・通常ENDとBAD ENDで空気を変える
   ・題名の字間を詰め、説明文を本編と釣り合う大きさに
   ============================================================ */

/* --- 余韻：直前の画面をぼかして透かす ----------------------- */
.end-screen {
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 245, 235, 0.55), transparent 62%),
    rgba(252, 251, 253, 0.80);
  backdrop-filter: blur(26px) saturate(1.06) brightness(1.04);
  -webkit-backdrop-filter: blur(26px) saturate(1.06) brightness(1.04);
}

/* BAD ENDは色を抜いて、少し沈ませる */
.end-screen.is-bad {
  background:
    radial-gradient(ellipse at 50% 38%, rgba(226, 228, 238, 0.5), transparent 62%),
    rgba(244, 244, 247, 0.84);
  backdrop-filter: blur(26px) saturate(0.55) brightness(0.98);
  -webkit-backdrop-filter: blur(26px) saturate(0.55) brightness(0.98);
}

/* --- カードの出かた：わずかに浮き上がらせる ----------------- */
.end-card {
  width: min(820px, 88%);
  opacity: 0;
  transform: translateY(14px);
}

.end-screen.is-visible .end-card {
  animation: end-rise 620ms cubic-bezier(0.22, 0.9, 0.24, 1) 120ms forwards;
}

@keyframes end-rise {
  to { opacity: 1; transform: translateY(0); }
}

/* --- ラベル ------------------------------------------------- */
.end-label {
  margin: 0 0 0.9em;
  color: var(--accent);
  font-size: clamp(0.78rem, 0.92vw, 1rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  opacity: 0.85;
}

.end-screen.is-bad .end-label {
  color: #8d6a78;
}

/* --- 題名：字間を詰めて、ひとかたまりに見せる --------------- */
.end-card h2 {
  max-width: 15em;
  margin: 0 auto 0.5em;
  font-size: clamp(1.75rem, 3.1vw, 3.3rem);
  font-weight: 700;
  line-height: 1.42;
  letter-spacing: 0.02em;
  text-wrap: balance;    /* 1文字だけ次行に落ちるのを防ぐ */
}

/* --- 説明文：本編と釣り合う大きさに ------------------------- */
.end-card > p:not(.end-label) {
  max-width: 26em;
  margin: 0 auto;
  color: var(--ink-mid);
  font-size: clamp(1rem, 1.15vw, 1.2rem);
  font-weight: 500;
  line-height: 2.05;
  letter-spacing: 0.04em;
  text-wrap: balance;    /* 行末に「た。」だけ残るのを防ぐ */
}

/* --- ボタン ------------------------------------------------- */
.end-actions {
  margin-top: clamp(28px, 3vw, 46px);
}

.text-button {
  color: var(--ink-mid);
  text-decoration: none;
  opacity: 0.9;
  transition: opacity 160ms ease, color 160ms ease;
}

.text-button:hover {
  opacity: 1;
  color: var(--accent);
}

/* --- スマホ ------------------------------------------------- */
@media (max-aspect-ratio: 3 / 4) {
  .end-card {
    width: 100%;           /* 1行に収まる幅を確保する */
  }

  .end-card h2 {
    max-width: 11em;       /* 「〜勇気が出／た日」のような割れ方を防ぐ */
    font-size: clamp(1.6rem, 7.6vw, 2.2rem);
    line-height: 1.46;
  }

  .end-card > p:not(.end-label) {
    max-width: 100%;
    font-size: 0.95rem;
    line-height: 1.95;
    letter-spacing: 0.02em;  /* 1文を1行に収める */
  }

  .end-label {
    font-size: 0.8rem;
  }
}

/* ============================================================
   v24 — 中央寄せの構図
   ------------------------------------------------------------
   ・立ち絵を常に画面の中央に置く
   ・テキストが出ているあいだは背景をわずかにぼかして奥へ引っ込める
   ・選択肢も中央に置く
   ============================================================ */

/* --- 立ち絵：常に中央 --------------------------------------
   transform は data-mood の演出（傾き・上下の揺れ）で使っている。
   ぶつからないよう、中央寄せは margin で行う。
   margin の % は親の「幅」基準なので、幅の半分をマイナスに置けば
   ちょうど真ん中に来る。 */
.character-wrap {
  right: auto;
  left: 50%;
  margin-left: -27%;          /* width: 54% の半分 */
}

/* --- 背景：テキスト表示中だけ、少しぼかす -------------------
   blur は縁がにじむので、わずかに拡大して縁を画面の外へ逃がす。 */
.scene-background {
  transform: scale(1.06);
  transition: filter 420ms ease;
}

.game:not(.is-text-hidden):not(.is-cg) .scene-background {
  filter: saturate(0.86) brightness(0.99) contrast(0.95) blur(5px);
}

.game:not(.is-text-hidden):not(.is-cg)[data-scene="ending"] .scene-background {
  filter: saturate(1.1) brightness(1.14) blur(5px);
}

/* --- 選択肢：中央 ------------------------------------------
   .choice-layer に transform を使っているものは他にないので、
   こちらは translateX で中央に寄せる。 */
.choice-layer {
  left: 50%;
  width: min(580px, 74%);
  transform: translateX(-50%);
}

/* 立ち絵の上に重なるぶん、選択肢の地色を少しだけ強くする */
.choice-button {
  background: var(--surface-card-solid, var(--surface-card));
  backdrop-filter: blur(18px) saturate(1.12);
}

:root {
  --surface-card-solid: rgba(255, 255, 255, 0.965);
}

.game.is-night {
  --surface-card-solid: rgba(24, 14, 38, 0.955);
}

/* --- 横向きのスマホ ----------------------------------------- */
@media (max-width: 900px) and (orientation: landscape) {
  /* 立ち絵の幅はこの向きでも 54%（上の v6 指定が効いている）ので、
     margin-left は基本指定の -27% のままでよい。 */

  /* 横向きは縦の余裕がないので、立ち絵を少し小さくして顔を上に逃がす。
     .character-wrap の transform は data-mood の演出が使っているため、
     中の .character-art を縮める。
     起点を top にするのが肝で、bottom 起点だと縮めたぶん頭が下がって
     かえって選択肢とぶつかる。
     倍率は、縮めた下端が会話ボックス（高さ30%）の裏に隠れる範囲で
     いちばん小さい値を取っている。これ以上縮めると切れ目が見える。 */
  .character-art {
    transform: scale(0.86);
    transform-origin: top center;
  }

  /* 選択肢は、あご先と会話ボックスのあいだに収める */
  .choice-layer {
    width: min(520px, 88%);
    bottom: 34%;
    gap: 6px;
  }

  .choice-button {
    min-height: 40px;
  }
}

/* --- スマホ（縦） ------------------------------------------- */
@media (max-aspect-ratio: 3 / 4) {
  .character-wrap {
    margin-left: -41%;        /* width: 82% の半分 */
  }

  .choice-layer {
    width: 90%;
  }
}

/* ============================================================
   v27 — 冒頭の立ち絵フェードイン
   ------------------------------------------------------------
   1枚目（ドアの開く音）ではまいんを出さず、
   「……あ。おかえり、お兄ちゃん。」でふわっと現れるようにする。

   出し入れは script.js の story 側で chara: "off" / "on" を指定。
   指定のないノードは直前の状態を引き継ぐ。

   transform は data-mood の演出と横向きの縮小で使っているので、
   ここでは opacity だけを動かす。
   ============================================================ */

.character-wrap {
  /* 立ち上がりの速いカーブだとパッと出た感じになるので、
     ほぼ等速で、終わりだけ緩やかにする */
  transition: opacity 820ms cubic-bezier(0.4, 0, 0.35, 1);
}

.game[data-chara="off"] .character-wrap {
  opacity: 0;
}

/* ============================================================
   v28 — エンド画面の外向きボタン（ティザーPV / Xシェア）
   ------------------------------------------------------------
   ・上段にPVとシェア、下段に選び直す／最初から、と2段に割れる
     （既存の flex-basis: 200px が効いて自然に折り返す）
   ・Xボタンだけは明色・暗色とも黒のまま。ブランド色なので崩さない
   ============================================================ */

.cta-button {
  position: relative;
  display: inline-flex;
  min-height: clamp(50px, 4vw, 64px);
  align-items: center;
  justify-content: center;
  gap: 0.6em;
  padding: 0 clamp(20px, 2.2vw, 36px);
  border: 0;
  border-radius: clamp(10px, 0.9vw, 14px);
  cursor: pointer;
  font-size: clamp(0.92rem, 1.08vw, 1.2rem);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.end-actions .cta-button {
  max-width: 280px;
  flex-basis: 244px;
  white-space: nowrap;
}

/* 上段（PV・シェア）と下段（選び直す・最初から）を確実に分ける */
.end-actions-break {
  flex-basis: 100%;
  height: 0;
}

/* --- ティザーPV -------------------------------------------- */
.cta-button--teaser {
  color: #ffffff;
  background: linear-gradient(100deg, #a94fdd, #8b2fc4 60%, #6f1ba6);
  box-shadow: 0 14px 32px rgba(110, 32, 166, 0.34);
}

.game.is-night .cta-button--teaser {
  color: #1a0b28;
  background: linear-gradient(100deg, #d9a2ff, #c98cff 55%, #a558ec);
}

.cta-button:hover {
  transform: translateY(-2px);
}

.cta-button[hidden] {
  display: none;
}

.cta-icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}

.cta-icon--play {
  width: 0;
  height: 0;
  border-top: 0.42em solid transparent;
  border-bottom: 0.42em solid transparent;
  border-left: 0.66em solid currentColor;
  margin-left: 0.1em;
}

/* --- Xシェア ----------------------------------------------- */
.cta-button--x {
  color: #ffffff;
  background: #0f0f10;
  box-shadow: 0 12px 28px rgba(15, 15, 16, 0.22);
}

.cta-button--x:hover {
  background: #26262a;
  box-shadow: 0 16px 34px rgba(15, 15, 16, 0.28);
}

.game.is-night .cta-button--x {
  border: 1px solid rgba(255, 255, 255, 0.22);
}

/* 公開URLが未設定のあいだは押せないようにしておく */
.cta-button.is-disabled {
  opacity: 0.34;
  pointer-events: none;
}

/* --- スマホ（縦） ------------------------------------------ */
@media (max-aspect-ratio: 3 / 4) {
  .end-actions .cta-button {
    width: 100%;
    max-width: none;
  }

  .cta-button {
    letter-spacing: 0.06em;
  }
}

/* ============================================================
   v29 — タイトル画面
   ------------------------------------------------------------
   いただいた1枚絵（1280×720）を使う。
   枠の座標は元画像から実測した値：
       左 63.12%  上 50.69%  幅 35.16%  高さ 23.33%
       中心 (80.66%, 62.29%)  枠線 #DC4FFF
   絵の中の枠に「はじめる」を重ね、その下にSNSボタンを置く。

   縦向きは16:9が入らないので、キャラ・ロゴ・枠を組み直す。
   ============================================================ */

.title-screen {
  display: block;
  padding: 0;
  background: #ffffff;
}

.title-frame {
  position: absolute;
  inset: 0;
  margin: auto;
  container-type: size;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  background: url("./assets/images/title.webp") center / 100% 100% no-repeat;
}

/* 縦向き専用の部品は、横向きでは出さない */
.title-chara,
.title-logo {
  display: none;
}

/* --- 絵の中の枠に重ねる ------------------------------------- */
.title-box {
  position: absolute;
  top: 50.69%;
  left: 63.12%;
  display: grid;
  width: 35.16%;
  height: 23.33%;
  place-items: center;
}

.title-start {
  min-width: 62%;
  padding: 2.2cqh 3cqh;
  border: 0;
  border-radius: 999px;
  color: #ffffff;
  background: linear-gradient(100deg, #c45ff0, #9b34d8 58%, #7a1fb4);
  box-shadow: 0 1.4cqh 3cqh rgba(122, 31, 180, 0.34);
  cursor: pointer;
  font-family: inherit;
  font-size: 4.6cqh;
  font-weight: 700;
  letter-spacing: 0.14em;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.title-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 2cqh 3.6cqh rgba(122, 31, 180, 0.42);
}

/* --- 枠の下：X / YouTube ------------------------------------ */
.title-socials {
  position: absolute;
  top: 79.5%;
  left: 80.66%;
  display: flex;
  gap: 2.4cqh;
  transform: translateX(-50%);
}

.social-button {
  display: inline-flex;
  align-items: center;
  gap: 1.1cqh;
  padding: 1.6cqh 3.2cqh;
  border: 0.42cqh solid #dc4fff;
  border-radius: 999px;
  color: #241c2c;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 1cqh 2.4cqh rgba(122, 31, 180, 0.16);
  text-decoration: none;
  white-space: nowrap;
  font-size: 3.1cqh;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: transform 170ms ease, box-shadow 170ms ease;
}

.social-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 1.8cqh 3.2cqh rgba(122, 31, 180, 0.24);
}

.social-icon {
  width: 3.4cqh;
  height: 3.4cqh;
  flex: none;
}

.social-button--x .social-icon { color: #0f0f10; }
.social-button--yt .social-icon { color: #ff0000; }

/* --- 縦向き ------------------------------------------------
   16:9の1枚絵は縦画面に収まらないので、絵を部品に分解して
   縦向きに組み直す。使う素材はすべて送っていただいた絵から抜いたもの：
     title_chara.webp … 立ち絵（背景を抜いて透過）
     title_logo.webp  … 舞衣乃妹ロゴ（同上）
   背景の斜めとピンクは、同じ色・同じ傾きでCSSで引き直している。
   ----------------------------------------------------------- */
@media (max-aspect-ratio: 3 / 4) {
  .title-frame {
    aspect-ratio: auto;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    overflow: hidden;
    background: linear-gradient(196deg, #ffffff 0 27%, #edb6f6 27.15% 100%);
  }

  .title-logo {
    position: absolute;
    top: 4.5%;
    left: 50%;
    display: block;
    width: min(68%, 420px);
    height: auto;
    transform: translateX(-50%);
  }

  .title-chara {
    position: absolute;
    bottom: 27%;
    left: 50%;
    display: block;
    height: 58%;
    width: auto;
    aspect-ratio: 79 / 72;
    background: url("./assets/images/title_chara.webp") center bottom / contain no-repeat;
    /* 元絵の下端で断ち切られているので、裾は溶かして隠す */
    -webkit-mask-image: linear-gradient(180deg, #000 86%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 86%, transparent 100%);
    transform: translateX(-50%);
  }

  .title-box {
    top: auto;
    bottom: 17%;
    left: 50%;
    width: min(84%, 460px);
    height: auto;
    padding: min(7.5cqw, 40px) min(6cqw, 32px);
    border: 3px solid #dc4fff;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 12px 34px rgba(122, 31, 180, 0.2);
    transform: translateX(-50%);
  }

  .title-start {
    min-width: 74%;
    padding: min(3.8cqw, 20px) min(6cqw, 32px);
    box-shadow: 0 min(2.2cqw, 12px) min(5cqw, 26px) rgba(122, 31, 180, 0.34);
    font-size: min(5.4cqw, 28px);
  }

  .title-socials {
    top: auto;
    bottom: 6.5%;
    left: 50%;
    gap: 4cqw;
  }

  .social-button {
    gap: min(1.8cqw, 10px);
    padding: min(2.8cqw, 15px) min(5.2cqw, 28px);
    border-width: 2px;
    box-shadow: 0 min(1.6cqw, 9px) min(4cqw, 22px) rgba(122, 31, 180, 0.16);
    font-size: min(3.9cqw, 20px);
  }

  .social-icon {
    width: min(4.6cqw, 24px);
    height: min(4.6cqw, 24px);
  }
}

/* ============================================================
   v33 — メニューのクレジット
   ------------------------------------------------------------
   甘茶の音楽工房は表記を必須としていないが、推奨されているので
   メニューの末尾に小さく置く。
   ============================================================ */

.menu-credit {
  margin: clamp(14px, 1.4vw, 20px) 0 0;
  padding-top: clamp(12px, 1.2vw, 16px);
  border-top: 1px solid var(--edge);
  color: var(--ink-low);
  text-align: center;
  font-size: clamp(0.72rem, 0.82vw, 0.86rem);
  letter-spacing: 0.04em;
}

.menu-credit a {
  color: var(--ink-mid);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-line);
  transition: color 160ms ease;
}

.menu-credit a:hover {
  color: var(--accent);
}

/* 版数表示。クレジット行の右端に小さく。 */
.menu-build {
  margin-left: 0.9em;
  opacity: 0.62;
  font-size: 0.92em;
  letter-spacing: 0.08em;
}

/* ============================================================
   v39 — エンド後のムービーとアウトロ
   ------------------------------------------------------------
   エンド画面の「妹との出会いを振り返る」を押すと、
   ティザーPVの抜粋を全画面で流し、終わったら外向きの導線を出す。
   ============================================================ */

/* --- ムービー層 --------------------------------------------- */
.movie-layer {
  position: absolute;
  z-index: 60;
  inset: 0;
  display: grid;
  place-items: center;
  visibility: hidden;
  opacity: 0;
  background: #0b0710;
  transition: opacity 420ms ease, visibility 420ms;
}

.movie-layer.is-visible {
  visibility: visible;
  opacity: 1;
}

.movie-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b0710;
}

.movie-skip {
  position: absolute;
  right: clamp(16px, 2.4vw, 34px);
  bottom: clamp(16px, 2.4vw, 34px);
  padding: clamp(9px, 1vw, 14px) clamp(18px, 2vw, 28px);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  opacity: 0;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(16, 10, 22, 0.52);
  backdrop-filter: blur(10px);
  cursor: pointer;
  font-family: inherit;
  font-size: clamp(0.78rem, 0.9vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  pointer-events: none;
  transition: opacity 320ms ease, background 180ms ease, border-color 180ms ease;
}

.movie-skip.is-ready {
  opacity: 1;
  pointer-events: auto;
}

.movie-skip:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(30, 20, 40, 0.72);
}

/* --- アウトロ画面（エンド画面と同じ作り） ------------------- */
.outro-screen {
  z-index: 55;
  place-items: center;      /* .end-screen と同じ中央寄せ */
  padding: 6%;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 245, 235, 0.55), transparent 62%),
    rgba(252, 251, 253, 0.8);
  backdrop-filter: blur(26px) saturate(1.06) brightness(1.04);
}

.outro-screen.is-bad {
  background:
    radial-gradient(ellipse at 50% 38%, rgba(226, 228, 238, 0.5), transparent 62%),
    rgba(244, 244, 247, 0.84);
  backdrop-filter: blur(26px) saturate(0.55) brightness(0.98);
}

.outro-screen.is-visible .end-card {
  animation: end-rise 620ms cubic-bezier(0.22, 0.9, 0.24, 1) 120ms forwards;
}

/* アウトロは見出しだけ。2行とも同じ大きさで見せる。 */
.outro-title {
  display: grid;
  gap: 0.34em;
  max-width: 100%;
}

.outro-screen .end-card h2 {
  max-width: 100%;
  margin-bottom: 0;
  font-size: clamp(1.5rem, 2.75vw, 2.7rem);
  line-height: 1.5;
  text-wrap: balance;
}

/* --- 「振り返る」ボタンは1行ぶん広く取る -------------------- */
.end-actions .cta-button--wide {
  max-width: 420px;
  flex-basis: 340px;
}

/* --- スマホ（縦） ------------------------------------------- */
@media (max-aspect-ratio: 3 / 4) {
  .end-actions .cta-button--wide {
    width: 100%;
    max-width: none;
  }

  .outro-screen .end-card h2 {
    max-width: 100%;
    font-size: clamp(1.15rem, 5.6vw, 1.6rem);
    line-height: 1.55;
  }

  .outro-title {
    gap: 0.4em;
  }

  .movie-skip {
    right: 14px;
    bottom: 14px;
  }
}

/* ============================================================
   v40 — 見出しの書体
   ------------------------------------------------------------
   「ティザーPVで。」のような大きい文字だけ、丸くて太い
   Mochiy Pop One に切り替える。本文・台詞は Zen Maru Gothic のまま。
   この書体はウェイトが1つしかないので、font-weight は 400 固定。
   ============================================================ */

.end-card h2,
.outro-screen .end-card h2,
.end-label,
.modal-heading h2 {
  font-family: "Mochiy Pop One", "Zen Maru Gothic", system-ui, sans-serif;
  font-weight: 400;
}

/* 太さが出るぶん、字間を少し開けたほうが読みやすい */
.end-card h2 {
  letter-spacing: 0.04em;
}

.end-label {
  letter-spacing: 0.18em;
}

/* ============================================================
   v43 — 導線をふたつに分ける
   ------------------------------------------------------------
   上段：妹との出会いの始まり（短編・いますぐ見られる）
   下段：ティザーPV（プレミア公開）と Xシェア
   同じ紫が2つ並ぶと迷うので、ティザーPV側は白地の枠線にする。
   ============================================================ */

.cta-button--pv {
  border: 2px solid var(--accent);
  color: var(--accent);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 26px rgba(122, 31, 180, 0.14);
}

.cta-button--pv:hover {
  color: #ffffff;
  background: var(--accent);
}

.cta-button--pv .cta-icon--play {
  border-left-color: currentColor;
}

/* ============================================================
   v48 — スマホのミュート
   ------------------------------------------------------------
   ・ボタンが 33×30px と指には小さいので、見た目はそのままに
     押せる範囲だけ上下に広げる（Appleの推奨は44px以上）
   ・ミュート中がひと目で分かるよう、♪に斜線を引く
   ============================================================ */

.utility-button--sound {
  position: relative;
}

.utility-button--sound::after {
  content: "";
  position: absolute;
  inset: -8px -3px;
}

.utility-button--sound.is-active i {
  position: relative;
  text-decoration: none;
}

.utility-button--sound.is-active i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.35em;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ============================================================
   v48 — エンド本文・見出しの折り返し
   ============================================================ */

.end-copy-line {
  display: block;
  text-wrap: balance;
  /* 日本語を文節で折り返す（Chrome / Edge）。「反省｜待ち」のような
     語の途中での折り返しを避ける。未対応のブラウザは通常の折り返し */
  word-break: auto-phrase;
}

/* 見出しも文節で折り返す。「2｜時間コース」のような割れ方を防ぐ */
.end-card h2 {
  word-break: auto-phrase;
}

/* ============================================================
   v49 — バッドエンドは「書体」ではなく「演出」で残念にする
   ------------------------------------------------------------
   ・背景：色を抜いた青灰色＋周辺を暗く（夕立のあとの部屋）
   ・細い雨の筋をうっすら流す
   ・割れたクッキーが落ちてきて、ヒビが入る
   ・ラベルは斜めのスタンプ風、カードは上から「しおれる」ように出る
   見出しの書体は本編と同じ丸ゴシック（太字）に戻し、
   ポップ体だけ外して明るさを抑える。
   ============================================================ */

.end-mark {
  display: none;
}

.end-screen.is-bad {
  background:
    radial-gradient(ellipse at 50% 42%, rgba(222, 226, 236, 0.62), transparent 60%),
    linear-gradient(180deg, rgba(196, 202, 216, 0.9), rgba(160, 167, 184, 0.92));
  backdrop-filter: blur(26px) saturate(0.2) brightness(0.92);
  -webkit-backdrop-filter: blur(26px) saturate(0.2) brightness(0.92);
  overflow: hidden;
}

/* 周辺減光 */
.end-screen.is-bad::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 45%, rgba(44, 48, 64, 0.34) 100%);
}

/* 雨の筋 */
.end-screen.is-bad::before {
  content: "";
  position: absolute;
  inset: -20% -10%;
  pointer-events: none;
  opacity: 0;
  background-image:
    repeating-linear-gradient(103deg, transparent 0 46px, rgba(255, 255, 255, 0.34) 46px 47px, transparent 47px 131px),
    repeating-linear-gradient(101deg, transparent 0 83px, rgba(255, 255, 255, 0.22) 83px 84px, transparent 84px 197px);
  background-size: 131px 260px, 197px 380px;
  -webkit-mask-image: repeating-linear-gradient(180deg, #000 0 38px, transparent 38px 90px);
  mask-image: repeating-linear-gradient(180deg, #000 0 38px, transparent 38px 90px);
  transition: opacity 1.2s ease 0.3s;
}

.end-screen.is-bad.is-visible::before {
  opacity: 1;
  animation: end-rain 1.1s linear infinite;
}

@keyframes end-rain {
  from { transform: translate3d(0, -90px, 0); }
  to   { transform: translate3d(-19px, 0, 0); }
}

.end-screen.is-bad .end-card {
  position: relative;
  z-index: 1;
  transform: translateY(-16px);
}

.end-screen.is-bad.is-visible .end-card {
  animation: end-sag 1100ms cubic-bezier(0.3, 0.7, 0.3, 1) 200ms forwards;
}

@keyframes end-sag {
  0%   { opacity: 0; transform: translateY(-16px); }
  60%  { opacity: 1; transform: translateY(4px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* --- 割れたクッキー ----------------------------------------- */
.end-screen.is-bad .end-mark {
  display: block;
  width: clamp(52px, 5.4vw, 72px);
  height: auto;
  margin: 0 auto 0.9em;
  overflow: visible;
}

.end-mark-body {
  fill: #b9aa9c;
  stroke: #7d6e62;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.end-mark-chip {
  fill: #6f6560;
}

.end-mark-crack {
  fill: none;
  stroke: #4f4540;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 60;
  stroke-dashoffset: 60;
}

.end-mark-crumbs circle {
  fill: #9d8f84;
  opacity: 0;
}

.end-mark-cookie {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  transform: translateY(-26px);
  opacity: 0;
}

.end-screen.is-bad.is-visible .end-mark-cookie {
  animation: end-cookie-drop 720ms cubic-bezier(0.55, 0, 0.8, 0.4) 650ms forwards;
}

.end-screen.is-bad.is-visible .end-mark-crack {
  animation: end-crack 380ms ease-out 1330ms forwards;
}

.end-screen.is-bad.is-visible .end-mark-crumbs circle {
  animation: end-crumb 500ms ease-out 1330ms forwards;
}

@keyframes end-cookie-drop {
  0%   { opacity: 0; transform: translateY(-26px) rotate(0deg); }
  25%  { opacity: 1; }
  80%  { transform: translateY(0) rotate(-6deg); }
  90%  { transform: translateY(-3px) rotate(-10deg); }
  100% { opacity: 1; transform: translateY(0) rotate(-12deg); }
}

@keyframes end-crack {
  to { stroke-dashoffset: 0; }
}

@keyframes end-crumb {
  from { opacity: 0; transform: translate(-6px, -4px); }
  to   { opacity: 1; transform: translate(0, 0); }
}

/* --- スタンプ風ラベル --------------------------------------- */
.end-screen.is-bad .end-label {
  display: inline-block;
  margin-bottom: 1.1em;
  padding: 0.3em 0.9em 0.3em 1.2em;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  color: #8a5566;
  font-family: "Zen Maru Gothic", sans-serif;
  font-weight: 700;
  letter-spacing: 0.3em;
  opacity: 0;
  transform: rotate(-4deg) scale(1.5);
}

.end-screen.is-bad.is-visible .end-label {
  animation: end-stamp 260ms cubic-bezier(0.5, 0, 0.7, 1.4) 1500ms forwards;
}

@keyframes end-stamp {
  to { opacity: 0.88; transform: rotate(-4deg) scale(1); }
}

/* --- 見出し・本文 ------------------------------------------- */
.end-screen.is-bad .end-card h2 {
  color: #3c4152;
  font-family: "Zen Maru Gothic", sans-serif;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.end-screen.is-bad #endCopy {
  color: #4c5262;
}

@media (prefers-reduced-motion: reduce) {
  .end-screen.is-bad.is-visible::before { animation: none; opacity: 0.6; }
  .end-screen.is-bad.is-visible .end-card,
  .end-screen.is-bad.is-visible .end-mark-cookie,
  .end-screen.is-bad.is-visible .end-mark-crack,
  .end-screen.is-bad.is-visible .end-mark-crumbs circle,
  .end-screen.is-bad.is-visible .end-label {
    animation-duration: 1ms;
    animation-delay: 0ms;
  }
}

/* 横向きスマホは高さが足りないので、クッキーをラベルの左に並べて
   縦の場所を取らないようにする */
@media (max-width: 900px) and (orientation: landscape) {
  .end-screen.is-bad .end-mark {
    position: absolute;
    top: -0.35em;
    left: 50%;
    width: 40px;
    margin: 0;
    transform: translateX(-128px);
  }

  .end-screen.is-bad .end-label {
    margin-bottom: 0.5em;
    padding: 0.2em 0.7em 0.2em 1em;
  }

  .end-screen.is-bad .end-card h2 {
    margin-bottom: 0.3em;
  }
}
