/* =========================================================
   正解はない。ただ、地雷はある。 / style.css
   Refactored: 2026-07-09

   方針:
   - 追記で重なっていた指定を、現在の見た目を基準に整理
   - 色・フォント・背景画像・ゲーム幅を :root に集約
   - タイトル / 扉絵 / ADV本編 / 演出 / レスポンシブを分離
   ========================================================= */

/* ---------------------------------------------------------
   1. Design tokens
   --------------------------------------------------------- */

:root {
  --adv-frame-width: 720px;

  --bg-title: url("../assets/title.webp");
  --bg-episode-0: url("../assets/episode-0.webp");
  --bg-episode-1: url("../assets/episode-1.webp");
  --bg-episode-2: url("../assets/episode-2.webp");
  --bg-episode-3: url("../assets/episode-3.webp");
  --bg-episode-4: url("../assets/episode-4.webp");
  --bg-ending: url("../assets/ending.webp");

  --font-base:
    system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic",
    "Yu Gothic UI", sans-serif;
  --font-title:
    system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic",
    "Yu Gothic UI", sans-serif;
  --font-story: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, serif;

  --color-bg-dark: #211f2a;
  --color-text: #2d2926;
  --color-text-strong: #312b29;
  --color-text-soft: #4b4640;
  --color-accent: #8a6f4d;

  --panel-bg: rgba(255, 252, 247, 0.82);
  --panel-bg-light: rgba(255, 252, 247, 0.8);
  --panel-border: rgba(255, 255, 255, 0.55);
  --panel-shadow: 0 18px 44px rgba(28, 22, 20, 0.22);
  --panel-blur: blur(10px);

  --dotted-border: 1px dotted rgba(138, 111, 77, 0.46);
}

/* ---------------------------------------------------------
   2. Base / utilities
   --------------------------------------------------------- */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-base);
  background: var(--color-bg-dark);
  color: var(--color-text);
}

[hidden],
.hidden {
  display: none !important;
}

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

h1 {
  margin: 0 0 16px;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.18;
}

pre {
  max-height: 44svh;
  padding: 12px;
  overflow-x: auto;
  background: rgba(244, 241, 234, 0.78);
  border-radius: 10px;
}

/* 旧ステータスバー系。デバッグや旧表示で残っても崩れないように保持 */
.param {
  display: grid;
  grid-template-columns: 70px 1fr 40px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar {
  height: 9px;
  overflow: hidden;
  background: #eee7dc;
  border-radius: 999px;
}

.fill {
  width: 0%;
  height: 100%;
  background: #6f6a5f;
  transition: width 0.25s ease;
}

/* ---------------------------------------------------------
   3. Shared visual screens: title / episode cover
   --------------------------------------------------------- */

.visual-screen {
  position: relative;
  min-height: 100svh;
  overflow: hidden;
  background-color: var(--color-bg-dark);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.top-title-screen {
  background-image: var(--bg-title);
}

.episode-cover-screen {
  background-image: var(--episode-bg);
  cursor: pointer;
}

.top-title-screen::after,
.episode-cover-screen::after {
  content: "";
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 0;
  width: min(100vw, var(--adv-frame-width));
  transform: translateX(-50%);
  pointer-events: none;
}

.top-title-screen::after {
  background: linear-gradient(
    to bottom,
    rgba(247, 243, 237, 0.04),
    rgba(247, 243, 237, 0.08) 50%,
    rgba(247, 243, 237, 0.56)
  );
}

.episode-cover-screen::after {
  background: linear-gradient(
    to bottom,
    rgba(247, 243, 237, 0.1),
    rgba(247, 243, 237, 0.24) 52%,
    rgba(247, 243, 237, 0.72)
  );
}

/* ---------------------------------------------------------
   4. Top title screen
   --------------------------------------------------------- */

.top-title-safe-area {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: min(100%, 680px);
  min-height: 100svh;
  margin: 0 auto;
  padding: 34px 18px max(28px, env(safe-area-inset-bottom));
}

.top-title-copy {
  padding-top: clamp(18px, 4svh, 52px);
  color: var(--color-text);
  text-align: center;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9),
    0 4px 18px rgba(255, 255, 255, 0.75);
}

.top-title-kicker {
  margin: 0 0 10px;
  color: var(--color-accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.top-title-copy h1 {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(36px, 10vw, 64px);
  font-weight: 800;
  line-height: 1.14;
  letter-spacing: 0.04em;
}

.top-title-sub {
  margin: 18px 0 0;
  color: var(--color-text-soft);
  font-size: clamp(14px, 3.6vw, 18px);
  line-height: 1.9;
  letter-spacing: 0.06em;
}

.top-title-actions {
  display: grid;
  gap: 12px;
  margin-top: 24px;
  padding-bottom: 4px;
}

.title-menu-button {
  width: 100%;
  min-height: 56px;
  border: 1px solid rgba(92, 74, 58, 0.28);
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.86);
  box-shadow: 0 10px 28px rgba(40, 30, 20, 0.12);
  color: var(--color-text);
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.title-menu-button:disabled,
#topContinueButton:disabled,
#topContinueButton.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* 全画面共通の音ON/OFFボタン */
.sound-toggle-button {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, calc((100vw - var(--adv-frame-width)) / 2 + 14px));
  z-index: 70;
  width: auto;
  min-width: 74px;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 252, 247, 0.54);
  border-radius: 999px;
  background-color: rgba(255, 252, 247, 0.42);
  box-shadow: 0 8px 22px rgba(40, 30, 20, 0.12);
  color: rgba(45, 41, 38, 0.82);
  font-family: var(--font-base);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition:
    background-color 0.18s ease,
    transform 0.18s ease,
    opacity 0.18s ease;
}

.sound-toggle-button:hover {
  background-color: rgba(255, 252, 247, 0.62);
  transform: translateY(-1px);
}

.sound-toggle-button:active {
  transform: translateY(0);
}

.sound-toggle-button.is-global-sound-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* 作品一覧へ戻る */
.top-title-actions .button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  min-height: 46px;
  padding: 10px 18px;

  border: 1px solid rgba(92, 74, 58, 0.22);
  border-radius: 14px;

  color: rgba(75, 70, 64, 0.82);
  background: rgba(255, 252, 247, 0.52);

  box-shadow: 0 7px 20px rgba(40, 30, 20, 0.08);

  font: inherit;
  font-size: 14px;
  letter-spacing: 0.06em;
  text-decoration: none;

  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);

  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.top-title-actions .button-link::before {
  content: "←";
  margin-right: 0.55em;
  font-size: 0.9em;
  opacity: 0.72;
}

.top-title-actions .button-link:hover {
  border-color: rgba(92, 74, 58, 0.34);
  background: rgba(255, 252, 247, 0.7);
  transform: translateY(-1px);
}

.top-title-actions .button-link:active {
  transform: translateY(0);
}

.top-title-actions .button-link:focus-visible {
  outline: 2px solid rgba(255, 247, 237, 0.88);
  outline-offset: 3px;
}

/* ---------------------------------------------------------
   5. Episode cover screen
   --------------------------------------------------------- */

.episode-cover-text {
  position: relative;
  z-index: 1;
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 46px 18px 0;
  color: var(--color-text);
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.76);
}

.episode-cover-number {
  margin: 0 0 8px;
  color: var(--color-accent);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.episode-cover-title {
  margin: 0;
  font-family: var(--font-title);
  font-size: clamp(32px, 9vw, 54px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: 0.04em;
}

.tap-guide {
  position: fixed;
  right: 0;
  bottom: max(28px, env(safe-area-inset-bottom));
  left: 0;
  z-index: 1;
  margin: 0;
  color: var(--color-text-soft);
  font-size: 14px;
  text-align: center;
  letter-spacing: 0.08em;
  opacity: 0.78;
  text-shadow: 0 1px 8px rgba(255, 255, 255, 0.85);
}

/* ---------------------------------------------------------
   6. ADV game layout
   --------------------------------------------------------- */

.game {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
  min-height: 100svh;
  padding: 0;
  overflow: hidden;
  background-color: var(--color-bg-dark);
  background-image: var(--episode-bg);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.game::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(
      to bottom,
      rgba(32, 28, 42, 0.28),
      rgba(32, 28, 42, 0.02) 30%,
      rgba(32, 28, 42, 0.06) 54%,
      rgba(32, 28, 42, 0.58) 100%
    ),
    radial-gradient(
      circle at 50% 28%,
      rgba(255, 247, 237, 0.14),
      rgba(255, 247, 237, 0) 52%
    );
}

.card {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: min(100%, var(--adv-frame-width));
  min-height: 100svh;
  padding: max(28px, env(safe-area-inset-top)) clamp(14px, 4vw, 28px)
    max(18px, env(safe-area-inset-bottom));
  color: var(--color-text-strong);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
}

.game .label {
  position: absolute;
  top: max(24px, env(safe-area-inset-top));
  left: clamp(18px, 5vw, 36px);
  z-index: 2;
  margin: 0;
  color: rgba(255, 247, 237, 0.78);
  font-size: clamp(10px, 2.8vw, 13px);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.16em;
  text-shadow: 0 2px 14px rgba(24, 18, 18, 0.35);
}

.game .card > h1 {
  position: absolute;
  top: calc(max(24px, env(safe-area-inset-top)) + 38px);
  left: clamp(18px, 5vw, 36px);
  z-index: 2;
  margin: 0;
  color: rgba(255, 247, 237, 0.86);
  font-family: var(--font-title);
  font-size: clamp(18px, 5.4vw, 30px);
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.08em;
  text-shadow: 0 2px 16px rgba(24, 18, 18, 0.38);
}

/* ---------------------------------------------------------
   7. Mood memo / scene / message
   --------------------------------------------------------- */

.status {
  position: absolute;
  top: clamp(128px, 18svh, 210px);
  right: clamp(14px, 4vw, 28px);
  left: auto;
  z-index: 2;
  display: grid;
  gap: 0;
  width: min(340px, calc(100% - 28px));
  margin: 0;
}

.status:empty {
  display: none;
}

.mood-box {
  padding: 14px 16px 16px;
  background: rgba(255, 252, 246, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 16px;
  box-shadow:
    0 16px 36px rgba(28, 22, 20, 0.13),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  font-family: var(--font-story);
  line-height: 1.85;
  backdrop-filter: var(--panel-blur);
}

.mood-title {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 0 0 8px;
  padding-bottom: 8px;
  border-bottom: var(--dotted-border);
  color: rgba(93, 76, 60, 0.9);
  font-family: var(--font-base);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  list-style: none;
  cursor: pointer;
}

.mood-title::-webkit-details-marker {
  display: none;
}

.mood-title::before {
  content: "□";
  font-size: 1.1em;
  opacity: 0.78;
}

.mood-details:not([open]) .mood-title {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.mood-details[open] .mood-title::before {
  content: "▣";
}

.mood-text {
  color: rgba(49, 43, 41, 0.86);
  font-size: clamp(13px, 3.3vw, 14px);
  white-space: pre-line;
}

.scene {
  width: 100%;
  min-height: clamp(172px, 23svh, 276px);
  max-height: min(44svh, 420px);
  margin-top: auto;
  padding: clamp(18px, 4vw, 28px);
  overflow-y: auto;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow:
    var(--panel-shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.58);
  backdrop-filter: var(--panel-blur);
  scrollbar-width: thin;
}

.turn-text {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: var(--dotted-border);
  color: rgba(49, 43, 41, 0.86);
  font-family: var(--font-story);
  font-size: clamp(13px, 3.4vw, 16px);
  font-weight: 600;
  line-height: 1.65;
  letter-spacing: 0.08em;
}

.message {
  margin: 0;
  color: rgba(38, 34, 32, 0.94);
  font-family: var(--font-story);
  font-size: clamp(15px, 3.9vw, 19px);
  line-height: 2.05;
  letter-spacing: 0.04em;
  white-space: pre-line;
}

.memory-hit {
  display: block;
  margin-top: 0.9em;
  padding: 0.85em 0 0.85em 1em;
  border-left: 2px solid rgba(138, 111, 77, 0.34);
  color: rgba(49, 43, 41, 0.72);
  font-size: 0.95em;
  line-height: 1.95;
  animation: memoryHit 0.7s ease;
}

/* ---------------------------------------------------------
   8. Choices / buttons
   --------------------------------------------------------- */

.choices {
  display: grid;
  gap: 9px;
  width: 100%;
  margin-top: 14px;
  padding: 14px clamp(12px, 3.4vw, 18px) 16px;
  background: var(--panel-bg-light);
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 18px;
  box-shadow:
    0 14px 36px rgba(28, 22, 20, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.52);
  backdrop-filter: var(--panel-blur);
}

.choices:empty {
  display: none;
}

.choices::before {
  content: "どう返す？";
  display: block;
  margin: 0 0 2px;
  padding: 0 0 9px;
  border-bottom: 1px dotted rgba(138, 111, 77, 0.38);
  color: rgba(93, 76, 60, 0.86);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.14em;
}

.choice {
  position: relative;
  width: 100%;
  min-height: 48px;
  padding: 10px 42px 10px 16px;
  border: 1px solid rgba(138, 111, 77, 0.2);
  border-radius: 12px;
  background-color: rgba(255, 255, 255, 0.34);
  box-shadow: none;
  color: rgba(49, 43, 41, 0.92);
  font-family: var(--font-story);
  font-size: clamp(14px, 3.7vw, 17px);
  line-height: 1.55;
  text-align: left;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: none;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

.choice::after {
  content: "›";
  position: absolute;
  top: 50%;
  right: 16px;
  color: rgba(138, 111, 77, 0.62);
  font-family: system-ui, sans-serif;
  font-size: 24px;
  line-height: 1;
  transform: translateY(-50%);
}

.choice:hover {
  background: rgba(255, 255, 255, 0.54);
  border-color: rgba(138, 111, 77, 0.34);
  transform: translateY(-1px);
}

.choice:active,
.choice.is-selected {
  transform: translateY(0);
}

.choice:active {
  box-shadow: none;
}

.choice.is-selected {
  background: rgba(255, 255, 255, 0.62);
  border-color: rgba(138, 111, 77, 0.46);
}

.retry {
  width: 100%;
  min-height: 52px;
  margin-top: 14px;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 14px;
  background: var(--panel-bg);
  box-shadow: 0 14px 36px rgba(28, 22, 20, 0.16);
  color: rgba(49, 43, 41, 0.92);
  font-size: 15px;
  cursor: pointer;
  backdrop-filter: var(--panel-blur);
}

.retry.start {
  background: rgba(255, 252, 247, 0.86);
}

.choice:focus-visible,
.retry:focus-visible,
.title-menu-button:focus-visible,
.sound-toggle-button:focus-visible {
  outline: 2px solid rgba(255, 247, 237, 0.78);
  outline-offset: 3px;
}

/* ---------------------------------------------------------
   9. Debug panel
   --------------------------------------------------------- */

.debug {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  right: max(104px, calc((100vw - var(--adv-frame-width)) / 2 + 104px));
  z-index: 3;
  margin: 0;
  color: rgba(255, 247, 237, 0.76);
  font-size: 11px;
  text-shadow: 0 2px 12px rgba(24, 18, 18, 0.35);
}

.debug[open] {
  width: min(92%, 560px);
  padding: 12px;
  color: var(--color-text-strong);
  background: rgba(255, 252, 247, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(28, 22, 20, 0.24);
  text-shadow: none;
  backdrop-filter: var(--panel-blur);
}

.debug summary {
  cursor: pointer;
}

/* ---------------------------------------------------------
   10. Landmine effect
   --------------------------------------------------------- */

.landmine-flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background: radial-gradient(
    circle at center,
    rgba(20, 18, 24, 0.02),
    rgba(20, 18, 24, 0.28)
  );
  opacity: 0;
}

.landmine-flash.is-active {
  animation: landmineFlash 0.42s ease both;
}

.landmine-toast {
  position: fixed;
  top: calc(max(18px, env(safe-area-inset-top)) + 44px);
  right: max(16px, calc((100vw - var(--adv-frame-width)) / 2 + 16px));
  z-index: 50;
  width: min(268px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 252, 247, 0.16);
  border-radius: 16px;
  background: rgba(45, 41, 38, 0.72);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.2);
  color: rgba(255, 252, 247, 0.96);
  font-size: 13px;
  line-height: 1.65;
  letter-spacing: 0.03em;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  backdrop-filter: var(--panel-blur);
}

.landmine-toast.is-active {
  animation: landmineToast 4.8s ease both;
}

.landmine-toast-title,
.landmine-toast-text {
  display: block;
}

.landmine-toast-title {
  margin-bottom: 2px;
  color: rgba(255, 252, 247, 0.72);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.12em;
}

/* ---------------------------------------------------------
   11. Scene transition animations
   --------------------------------------------------------- */

.status.ui-fade .mood-box,
.scene.ui-fade,
.choices.ui-fade,
.choices.ui-fade .choice,
.retry.ui-fade {
  animation: advCardFadeIn 1.42s ease both;
}

.scene.ui-fade {
  animation-delay: 0.68s;
}

.status.ui-fade .mood-box {
  animation-delay: 1.03s;
}

.retry.ui-fade {
  animation-delay: 1.18s;
}

.choices.ui-fade {
  animation-delay: 1.58s;
}

.choices.ui-fade .choice:nth-child(1) {
  animation-delay: 1.68s;
}

.choices.ui-fade .choice:nth-child(2) {
  animation-delay: 1.74s;
}

.choices.ui-fade .choice:nth-child(3) {
  animation-delay: 1.63s;
}

.choices.ui-fade .choice:nth-child(4) {
  animation-delay: 1.86s;
}

.card.is-scene-changing .status .mood-box,
.card.is-scene-changing .scene,
.card.is-scene-changing .choices,
.card.is-scene-changing .retry {
  animation: advCardFadeOut 0.64s ease both;
  pointer-events: none;
}

.card.is-scene-changing .choice {
  pointer-events: none;
}

/* ---------------------------------------------------------
   12. Result / ending image card
   --------------------------------------------------------- */

.game.is-result-image-card {
  background-image: var(--result-card-bg, var(--episode-bg));
}

.game.is-ending-image-card::after {
  background: linear-gradient(
    to bottom,
    rgba(22, 18, 32, 0.04),
    rgba(22, 18, 32, 0.02) 54%,
    rgba(22, 18, 32, 0.28) 100%
  );
}

.game.is-ending-image-card .label,
.game.is-ending-image-card .card > h1,
.game.is-ending-image-card .status,
.game.is-ending-image-card .scene,
.game.is-ending-image-card .choices,
.game.is-ending-image-card .debug {
  display: none;
}

.game.is-ending-image-card .card {
  justify-content: flex-end;
  padding-bottom: max(42px, calc(env(safe-area-inset-bottom) + 34px));
}

.game.is-ending-image-card .retry {
  width: min(360px, calc(100% - 44px));
  min-height: 56px;
  margin: 0 auto;
  border: 1px solid rgba(255, 252, 247, 0.54);
  border-radius: 999px;
  background: rgba(255, 252, 247, 0.16);
  box-shadow:
    0 0 22px rgba(255, 252, 247, 0.22),
    0 18px 38px rgba(10, 8, 18, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.38);
  color: rgba(255, 252, 247, 0.96);
  font-family: var(--font-story);
  font-size: clamp(16px, 4.2vw, 20px);
  letter-spacing: 0.08em;
  text-shadow: 0 2px 12px rgba(20, 16, 28, 0.38);
  backdrop-filter: blur(8px);
}

.game.is-ending-image-card .retry:hover {
  background: rgba(255, 252, 247, 0.24);
}

/* ---------------------------------------------------------
   Ending text card
   最終画面：ending画像にHTML文字を重ねる
   --------------------------------------------------------- */

.game.is-ending-text-card {
  overflow-y: auto;
}

.game.is-ending-text-card::after {
  background:
    linear-gradient(
      to bottom,
      rgba(20, 16, 30, 0.46),
      rgba(20, 16, 30, 0.24) 42%,
      rgba(20, 16, 30, 0.58) 100%
    ),
    radial-gradient(
      circle at 50% 26%,
      rgba(255, 247, 237, 0.16),
      rgba(255, 247, 237, 0) 58%
    );
}

.game.is-ending-text-card .card {
  justify-content: center;
  min-height: 100svh;
  padding: max(72px, env(safe-area-inset-top)) clamp(22px, 6vw, 42px)
    max(34px, env(safe-area-inset-bottom));
}

.game.is-ending-text-card .card > h1,
.game.is-ending-text-card .scene {
  display: block;
}

.game.is-ending-text-card .card > h1 {
  position: static;
  margin: 0 auto 34px;
  color: rgba(255, 252, 247, 0.96);
  font-family: var(--font-story);
  font-size: clamp(30px, 8vw, 52px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.24em;
  text-align: center;
  text-shadow:
    0 0 18px rgba(255, 252, 247, 0.48),
    0 4px 22px rgba(10, 8, 18, 0.54);
}

.game.is-ending-text-card .scene {
  width: min(92%, 560px);
  min-height: 0;
  max-height: none;
  margin: 0 auto;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  text-align: center;
  backdrop-filter: none;
}

.game.is-ending-text-card .turn-text {
  display: none;
}

.game.is-ending-text-card .message {
  color: rgba(255, 252, 247, 0.95);
  font-family: var(--font-story);
  font-size: clamp(13px, 3.45vw, 17px);
  line-height: 2.05;
  letter-spacing: 0.08em;
  text-shadow:
    0 2px 12px rgba(10, 8, 18, 0.52),
    0 0 16px rgba(255, 252, 247, 0.16);
}

.game.is-ending-text-card .retry {
  margin-top: 34px;
}

/* ---------------------------------------------------------
   13. Keyframes
   --------------------------------------------------------- */

@keyframes memoryHit {
  from {
    opacity: 0;
    transform: translateY(3px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes landmineFlash {
  0% {
    opacity: 0;
  }

  28% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes landmineToast {
  0% {
    opacity: 0;
    transform: translateY(-8px);
  }

  18%,
  78% {
    opacity: 1;
    transform: translateY(0);
  }

  100% {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes advCardFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(2px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes advCardFadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }

  to {
    opacity: 0;
    transform: translateY(-6px);
    filter: blur(2px);
  }
}

/* ---------------------------------------------------------
   14. Responsive / accessibility
   --------------------------------------------------------- */

@media (max-height: 720px) {
  .status {
    top: 112px;
    right: clamp(14px, 4vw, 28px);
    left: auto;
    width: min(330px, calc(100% - 28px));
  }

  .mood-box {
    padding: 11px 13px;
  }

  .mood-text {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
  }

  .scene {
    min-height: 148px;
    max-height: 38svh;
  }

  .choice {
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
  }
}

@media (max-width: 520px) {
  .status {
    width: min(300px, calc(100% - 28px));
  }

  .landmine-toast {
    top: calc(max(14px, env(safe-area-inset-top)) + 44px);
    right: 14px;
    width: min(248px, calc(100vw - 28px));
    padding: 11px 13px;
  }
}

@media (max-width: 575px) {
  .sound-toggle-button {
    min-width: 68px;
    min-height: 32px;
    padding: 5px 10px;
    font-size: 11px;
  }

  .card {
    padding: max(24px, env(safe-area-inset-top)) 14px
      max(14px, env(safe-area-inset-bottom));
  }

  .status {
    position: static;
    width: 100%;
    margin: 0 0 10px;
  }

  .mood-box {
    padding: 9px 12px;
    border-radius: 14px;
    line-height: 1.75;
  }

  .mood-title {
    margin: 0;
    padding-bottom: 0;
    border-bottom: 0;
    font-size: 11px;
    line-height: 1.4;
  }

  .mood-details[open] .mood-title {
    margin-bottom: 7px;
    padding-bottom: 7px;
    border-bottom: var(--dotted-border);
  }

  .mood-text {
    font-size: 12.5px;
    line-height: 1.75;
  }

  .scene {
    min-height: 0;
    max-height: clamp(220px, 43svh, 360px);
    padding: 16px;
  }

  .turn-text {
    margin-bottom: 12px;
    padding-bottom: 10px;
    font-size: 13px;
    line-height: 1.55;
  }

  .message {
    font-size: 14px;
    line-height: 1.9;
  }

  .choices {
    gap: 8px;
    margin-top: 10px;
    padding: 10px 11px 12px;
    border-radius: 16px;
  }

  .choice {
    min-height: 42px;
    padding: 8px 36px 8px 14px;
    font-size: 13.5px;
    line-height: 1.48;
  }

  .choice::after {
    right: 13px;
  }
}

@media (min-width: 760px) {
  .top-title-screen,
  .episode-cover-screen,
  .game,
  .game.is-result-image-card {
    background-size: min(100%, var(--adv-frame-width)) auto;
    background-position: center;
  }

  .game::after {
    background:
      linear-gradient(
        to right,
        rgba(33, 31, 42, 0.58),
        rgba(33, 31, 42, 0.04) 24%,
        rgba(33, 31, 42, 0.04) 76%,
        rgba(33, 31, 42, 0.58)
      ),
      linear-gradient(
        to bottom,
        rgba(32, 28, 42, 0.18),
        rgba(32, 28, 42, 0.02) 36%,
        rgba(32, 28, 42, 0.54) 100%
      );
  }

  .top-title-safe-area,
  .episode-cover-text {
    width: min(100%, 680px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .status.ui-fade .mood-box,
  .scene.ui-fade,
  .choices.ui-fade,
  .choices.ui-fade .choice,
  .retry.ui-fade,
  .landmine-flash.is-active,
  .landmine-toast.is-active,
  .card.is-scene-changing .status .mood-box,
  .card.is-scene-changing .scene,
  .card.is-scene-changing .choices,
  .card.is-scene-changing .retry {
    animation: none;
  }

  .landmine-flash.is-active {
    opacity: 0;
  }

  .landmine-toast.is-active {
    opacity: 1;
    transform: none;
  }
}

/* ---------------------------------------------------------
   本番公開用：内部情報ボタンを非表示
   --------------------------------------------------------- */

.debug {
  display: none !important;
}
