/* === Reset & Base === */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --app-height: 100dvh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --text-color: #f2eee7;
  --text-shadow: 0 1px 3px rgba(0, 0, 0, 0.82);
  --box-bg: rgba(10, 9, 12, 0.82);
  --accent: #d9c1a1;
  --accent-glow: rgba(217, 193, 161, 0.28);
  --accent-cool: #9bb6cc;
  --panel-edge: rgba(255, 236, 211, 0.12);
  --panel-edge-strong: rgba(255, 234, 205, 0.22);
  --panel-surface: rgba(12, 11, 14, 0.76);
  --panel-surface-strong: rgba(16, 14, 18, 0.9);
  --panel-shadow: 0 20px 44px rgba(0, 0, 0, 0.36);
  --ring-focus: rgba(217, 193, 161, 0.78);
}

html, body {
  width: 100%;
  height: var(--app-height);
  height: -webkit-fill-available;
  overflow: hidden;
  background: #090a0d;
  color: var(--text-color);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic Medium", "Noto Sans JP", sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior: none;
}

.hidden {
  display: none;
}

.noscript-overlay {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-content: center;
  gap: 0.75rem;
  text-align: center;
  padding: 2rem;
  background:
    radial-gradient(100% 70% at 50% 30%, rgba(132, 148, 168, 0.14) 0%, rgba(0, 0, 0, 0) 70%),
    #090a0d;
}

.noscript-overlay h1 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  letter-spacing: 0.14em;
  font-weight: 500;
}

.noscript-overlay p {
  color: rgba(242, 238, 231, 0.86);
  line-height: 1.7;
}

/* === Game Container === */
#game-container {
  position: relative;
  width: 100%;
  height: var(--app-height);
  height: -webkit-fill-available;
  overflow: hidden;
}

/* === Screen States === */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.screen.active {
  opacity: 1;
  visibility: visible;
}

/* === Title Screen === */
#title-screen {
  background:
    radial-gradient(110% 85% at 50% 25%, rgba(116, 142, 168, 0.18) 0%, rgba(18, 22, 28, 0) 55%),
    linear-gradient(180deg, #06070a 0%, #101319 48%, #1a1513 78%, #100d0d 100%);
  z-index: 10;
  overflow: hidden;
}

#title-screen::before,
#title-screen::after {
  content: "";
  position: absolute;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

#title-screen::before {
  width: min(80vw, 520px);
  height: min(80vw, 520px);
  left: -12%;
  top: 14%;
  background: radial-gradient(circle, rgba(157, 183, 208, 0.12) 0%, rgba(157, 183, 208, 0) 72%);
  filter: blur(8px);
}

#title-screen::after {
  width: min(90vw, 620px);
  height: min(90vw, 620px);
  right: -16%;
  bottom: -10%;
  background:
    radial-gradient(circle, rgba(188, 141, 110, 0.10) 0%, rgba(188, 141, 110, 0) 68%),
    radial-gradient(circle at 30% 30%, rgba(112, 126, 168, 0.08) 0%, rgba(112, 126, 168, 0) 72%);
  filter: blur(10px);
}

/* Title particles canvas */
#title-particles {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.title-content {
  width: min(96vw, 640px);
  padding:
    max(1rem, calc(1rem + var(--safe-top)))
    max(1rem, calc(1rem + var(--safe-right)))
    max(1rem, calc(1rem + var(--safe-bottom)))
    max(1rem, calc(1rem + var(--safe-left)));
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
}

.title-panel {
  width: 100%;
  text-align: center;
  position: relative;
  padding: clamp(1rem, 2.8vw, 1.25rem) clamp(1rem, 3.2vw, 1.35rem) clamp(1.1rem, 3vw, 1.35rem);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    radial-gradient(90% 120% at 50% 0%, rgba(157, 177, 199, 0.08) 0%, rgba(157, 177, 199, 0) 70%),
    linear-gradient(180deg, rgba(13, 12, 16, 0.84), rgba(10, 10, 12, 0.92));
  border: 1px solid rgba(255, 236, 211, 0.12);
  box-shadow: var(--panel-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px) saturate(1.05);
  -webkit-backdrop-filter: blur(12px) saturate(1.05);
  overflow: hidden;
}

.title-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    linear-gradient(130deg, rgba(217, 193, 161, 0.06), rgba(217, 193, 161, 0) 34%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.016) 0 1px, rgba(255,255,255,0) 1px 5px);
  opacity: 0.9;
}

.title-panel > * {
  position: relative;
  z-index: 1;
}

.title-kicker {
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  color: rgba(205, 215, 225, 0.66);
  margin-bottom: 0.7rem;
}

.title-text {
  font-size: clamp(1.8rem, 6vw, 3rem);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-shadow: 0 0 18px rgba(204, 224, 240, 0.13), 0 0 28px rgba(120, 98, 76, 0.15), var(--text-shadow);
  margin-bottom: 0.5rem;
  animation: titlePulse 3s ease-in-out infinite;
}

.title-subtitle {
  font-size: clamp(0.9rem, 3vw, 1.2rem);
  opacity: 0.78;
  letter-spacing: 0.26em;
  color: #c7d2dc;
  margin-bottom: 0.7rem;
}

.title-version {
  min-height: 1.25rem;
  margin-bottom: 0.4rem;
  color: rgba(217, 193, 161, 0.86);
  letter-spacing: 0.12em;
  font-size: clamp(0.72rem, 2.2vw, 0.88rem);
  opacity: 0.92;
}

.title-rating-note {
  max-width: min(92vw, 560px);
  margin: 0 auto 0.85rem;
  color: rgba(216, 226, 235, 0.78);
  font-size: clamp(0.68rem, 2vw, 0.82rem);
  line-height: 1.5;
  letter-spacing: 0.05em;
}

.title-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem 0.5rem;
  margin: 0 auto 1.2rem;
}

.title-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(227, 238, 248, 0.08), rgba(227, 238, 248, 0.03));
  border: 1px solid rgba(205, 220, 235, 0.14);
  color: rgba(233, 240, 247, 0.86);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

@keyframes titlePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.85; }
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  align-items: center;
  width: min(100%, 360px);
  margin: 0 auto;
}

.title-menu .menu-btn {
  width: 100%;
  min-width: 0;
}

.title-helper {
  margin-top: 0.8rem;
  color: rgba(216, 226, 235, 0.62);
  font-size: 0.72rem;
  line-height: 1.45;
  letter-spacing: 0.08em;
}

/* === Menu Buttons === */
.menu-btn {
  background:
    linear-gradient(180deg, rgba(255, 247, 236, 0.09) 0%, rgba(255, 247, 236, 0.01) 36%, rgba(24, 20, 19, 0.62) 100%);
  border: 1px solid rgba(217, 193, 161, 0.22);
  color: var(--text-color);
  font-family: inherit;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  padding: 0.8em 2.5em;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.14s, box-shadow 0.2s, opacity 0.2s;
  min-width: 200px;
  letter-spacing: 0.12em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.025), 0 10px 22px rgba(0, 0, 0, 0.22);
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
}

.menu-btn:active {
  background: linear-gradient(180deg, rgba(255, 245, 230, 0.12) 0%, rgba(40, 29, 23, 0.68) 100%);
  border-color: var(--accent);
  transform: translateY(1px) scale(0.985);
}

@media (hover: hover) {
  .menu-btn:hover {
    background: linear-gradient(180deg, rgba(255, 245, 230, 0.10) 0%, rgba(37, 28, 24, 0.66) 100%);
    border-color: rgba(217, 193, 161, 0.45);
    box-shadow: inset 0 0 0 1px rgba(255, 250, 240, 0.03), 0 14px 28px rgba(0, 0, 0, 0.24);
    transform: translateY(-1px);
  }
}

/* === Game Screen === */
#game-screen {
  z-index: 5;
  touch-action: manipulation;
}

.boot-status {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  background: radial-gradient(120% 85% at 50% 30%, rgba(120, 140, 162, 0.10) 0%, rgba(0,0,0,0) 60%), rgba(8, 8, 10, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.boot-status.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-status-panel {
  width: min(100%, 520px);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(145, 168, 190, 0.08) 0%, rgba(145, 168, 190, 0) 70%),
    linear-gradient(180deg, rgba(22, 20, 22, 0.90), rgba(12, 11, 13, 0.94));
  border: 1px solid rgba(217, 193, 161, 0.16);
  border-radius: 14px;
  padding: 1rem 1rem 0.9rem;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.boot-status-label {
  color: rgba(217, 193, 161, 0.88);
  letter-spacing: 0.12em;
  font-size: 0.82rem;
  margin-bottom: 0.35rem;
}

.boot-status-panel h2 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  font-size: clamp(1rem, 3.2vw, 1.2rem);
  font-weight: 500;
  letter-spacing: 0.06em;
  margin-bottom: 0.5rem;
}

.boot-status-body {
  color: rgba(242, 238, 231, 0.86);
  line-height: 1.65;
  font-size: 0.92rem;
}

.boot-status-detail {
  margin-top: 0.75rem;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 0.7rem;
  color: rgba(206, 219, 230, 0.9);
  font-size: 0.75rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.boot-status-actions {
  margin-top: 0.75rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.boot-status-actions .menu-btn {
  min-width: 0;
  width: 100%;
  padding-left: 1rem;
  padding-right: 1rem;
  letter-spacing: 0.08em;
}

.runtime-banner {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 26;
  padding:
    0 max(0.75rem, calc(0.75rem + var(--safe-right))) max(0.75rem, calc(0.75rem + var(--safe-bottom))) max(0.75rem, calc(0.75rem + var(--safe-left)));
  pointer-events: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s ease;
}

.runtime-banner.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.runtime-banner-panel {
  pointer-events: auto;
  width: min(100%, 720px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.55rem;
  padding: 0.8rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(155, 182, 204, 0.07) 0%, rgba(155, 182, 204, 0) 72%),
    linear-gradient(180deg, rgba(14, 14, 17, 0.88), rgba(10, 10, 12, 0.92));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px) saturate(1.04);
  -webkit-backdrop-filter: blur(10px) saturate(1.04);
}

.runtime-banner[data-tone="offline"] .runtime-banner-panel {
  border-color: rgba(210, 126, 126, 0.22);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(210, 126, 126, 0.08) 0%, rgba(210, 126, 126, 0) 72%),
    linear-gradient(180deg, rgba(18, 13, 14, 0.90), rgba(10, 9, 10, 0.94));
}

.runtime-banner[data-tone="update"] .runtime-banner-panel {
  border-color: rgba(231, 190, 134, 0.24);
  background:
    radial-gradient(120% 140% at 50% 0%, rgba(231, 190, 134, 0.08) 0%, rgba(231, 190, 134, 0) 72%),
    linear-gradient(180deg, rgba(18, 15, 11, 0.90), rgba(11, 10, 10, 0.94));
}

.runtime-banner[data-tone="online"] .runtime-banner-panel {
  border-color: rgba(138, 185, 213, 0.22);
}

.runtime-banner-copy {
  min-width: 0;
}

.runtime-banner-label {
  min-height: 1.05em;
  color: rgba(217, 193, 161, 0.92);
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.2rem;
}

.runtime-banner[data-tone="offline"] .runtime-banner-label {
  color: rgba(245, 198, 198, 0.92);
}

.runtime-banner[data-tone="online"] .runtime-banner-label {
  color: rgba(208, 231, 246, 0.92);
}

.runtime-banner-body {
  color: rgba(242, 238, 231, 0.9);
  font-size: 0.84rem;
  line-height: 1.45;
}

.runtime-banner-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.runtime-banner-actions .menu-btn {
  min-width: 0;
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  border-radius: 10px;
}

.runtime-banner-actions .menu-btn.hidden {
  display: none;
}

/* Background Layer */
#background-layer {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #1a1a3e 0%, #2a1a3e 100%);
  transition: background 1.2s ease, background-image 1.2s ease, filter 0.8s ease;
  filter: saturate(1.02) contrast(1.02);
  z-index: 1;
}

/* Character Layer */
#character-layer {
  position: absolute;
  inset: 0;
  display: block;
  padding-bottom: 25%;
  z-index: 2;
  pointer-events: none;
}

#character-layer .character {
  position: absolute;
  left: 50%;
  bottom: 0;
  max-height: 58%;
  width: auto;
  opacity: 0;
  --slot-x: -50%;
  --focus-scale: 1;
  transform: translate3d(var(--slot-x), 12px, 0) scale(var(--focus-scale));
  transform-origin: bottom center;
  transition: opacity 0.45s ease, transform 0.45s ease, filter 0.35s ease;
  filter: brightness(0.9) saturate(0.9) drop-shadow(0 12px 20px rgba(0, 0, 0, 0.35));
  z-index: 2;
}

#character-layer .character.visible {
  opacity: 0.95;
  transform: translate3d(var(--slot-x), 0, 0) scale(var(--focus-scale));
}

#character-layer .character.slot-left {
  --slot-x: -92%;
}

#character-layer .character.slot-right {
  --slot-x: -8%;
}

#character-layer .character.slot-center {
  --slot-x: -50%;
  max-height: 60%;
}

#character-layer .character.is-active {
  --focus-scale: 1.02;
  opacity: 1;
  filter: brightness(1.03) saturate(1.02) drop-shadow(0 18px 28px rgba(0, 0, 0, 0.42));
  z-index: 3;
}

#character-layer .character.is-idle {
  --focus-scale: 0.96;
  opacity: 0.58;
  filter: brightness(0.72) saturate(0.78) blur(0.15px) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.28));
  z-index: 2;
}

/* Still CG Layer (full-screen image overlay, text UI remains above) */
#still-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  background: transparent;
}

#still-layer.active {
  opacity: 1;
}

#still-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 6, 10, 0.18) 0%, rgba(4, 6, 10, 0.06) 30%, rgba(4, 6, 10, 0.22) 100%);
  opacity: 0;
  transition: opacity 0.45s ease;
}

#still-layer.active::after {
  opacity: 1;
}

#still-layer .still-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.02);
  filter: saturate(1.03) contrast(1.02);
  transition: opacity 0.45s ease, transform 0.9s ease;
}

#still-layer .still-image.visible {
  opacity: 1;
  transform: scale(1);
}

/* UI Layer */
#ui-layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  z-index: 4;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}

/* Text box top gradient fade */
#text-box-gradient {
  height: 40px;
  width: min(100%, calc(100% - 10px));
  align-self: center;
  background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.42));
  pointer-events: none;
  border-radius: 14px 14px 0 0;
}

/* Text Box */
#text-box {
  background:
    radial-gradient(120% 160% at 50% -10%, rgba(151, 176, 200, 0.07) 0%, rgba(151, 176, 200, 0) 50%),
    linear-gradient(180deg, rgba(11, 10, 13, 0.84), rgba(8, 8, 10, 0.88));
  backdrop-filter: blur(12px) saturate(1.04);
  -webkit-backdrop-filter: blur(12px) saturate(1.04);
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.02);
  padding: 1rem 1.2rem 1.45rem;
  min-height: 150px;
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  width: min(100%, calc(100% - 10px));
  align-self: center;
  margin-bottom: 6px;
  overflow: hidden;
}

#text-box::before {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(217,193,161,0), rgba(217,193,161,0.42), rgba(155,182,204,0.28), rgba(217,193,161,0));
  pointer-events: none;
}

#text-box::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,0.03) 0 1px, transparent 1px 100%),
    radial-gradient(circle at 60% 40%, rgba(255,255,255,0.02) 0 1px, transparent 1px 100%);
  opacity: 0.28;
}

#speaker-name {
  font-size: clamp(0.8rem, 2vw, 0.95rem);
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 0.5rem;
  min-height: 1.2em;
  letter-spacing: 0.09em;
  text-shadow: 0 0 8px rgba(217, 193, 161, 0.14);
}

#speaker-name:not(:empty) {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 0;
  padding: 0.22rem 0.6rem;
  background: linear-gradient(180deg, rgba(217, 193, 161, 0.10), rgba(217, 193, 161, 0.04));
  border: 1px solid rgba(217, 193, 161, 0.16);
  border-radius: 999px;
}

#speaker-name:not(:empty)::before {
  content: "";
  width: 0.36rem;
  height: 0.36rem;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(217,193,161,0.95) 0%, rgba(217,193,161,0.45) 70%, rgba(217,193,161,0) 100%);
  box-shadow: 0 0 10px rgba(217,193,161,0.35);
}

#message-text {
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  line-height: 1.85;
  text-shadow: var(--text-shadow);
  min-height: 3.6em;
  white-space: pre-line;
  color: rgba(246, 242, 234, 0.96);
  max-width: 40em;
  overflow-wrap: anywhere;
}

#tap-indicator {
  position: absolute;
  bottom: 0.6rem;
  right: 1rem;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s ease;
  color: var(--accent);
}

#tap-indicator.visible {
  opacity: 0.7;
  animation: tapBounce 1s ease-in-out infinite;
}

@keyframes tapBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* Choice Layer */
#choice-layer {
  counter-reset: choiceIndex;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  padding:
    max(1.2rem, calc(1rem + var(--safe-top)))
    max(1.2rem, calc(1rem + var(--safe-right)))
    max(1.2rem, calc(1rem + var(--safe-bottom)))
    max(1.2rem, calc(1rem + var(--safe-left)));
  background: rgba(0, 0, 0, 0);
  z-index: 6;
  pointer-events: none;
  transition: background 0.4s ease;
}

#choice-layer.active {
  background: radial-gradient(circle at 50% 40%, rgba(20, 18, 22, 0.45) 0%, rgba(8, 8, 10, 0.76) 100%);
  pointer-events: auto;
}

#choice-layer.active::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 15%, rgba(155, 182, 204, 0.05) 0%, rgba(155, 182, 204, 0) 42%),
    radial-gradient(circle at 80% 80%, rgba(217, 193, 161, 0.04) 0%, rgba(217, 193, 161, 0) 50%);
}

.choice-btn {
  counter-increment: choiceIndex;
  --choice-accent-rgb: 217, 193, 161;
  --choice-border: rgba(217, 193, 161, 0.18);
  --choice-chip-bg: rgba(217, 193, 161, 0.07);
  --choice-chip-border: rgba(217, 193, 161, 0.18);
  --choice-chip-text: rgba(217, 193, 161, 0.94);
  --choice-bg: linear-gradient(180deg, rgba(31, 28, 31, 0.92) 0%, rgba(16, 14, 16, 0.96) 100%);
  --choice-bg-hover: linear-gradient(180deg, rgba(44, 36, 32, 0.94) 0%, rgba(20, 18, 18, 0.96) 100%);
  --choice-bg-active: linear-gradient(180deg, rgba(55, 41, 30, 0.94) 0%, rgba(24, 18, 15, 0.96) 100%);
  background: var(--choice-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--choice-border);
  color: var(--text-color);
  font-family: inherit;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  padding: 0.95em 1rem 0.95em 0.95rem;
  border-radius: 14px;
  cursor: pointer;
  width: 100%;
  max-width: 460px;
  text-align: left;
  transition: background 0.2s, border-color 0.2s, transform 0.16s, box-shadow 0.2s;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(15px);
  animation: choiceEnter 0.4s ease forwards;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255,255,255,0.02);
  touch-action: manipulation;
  min-height: 48px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.choice-btn::before {
  content: counter(choiceIndex, decimal-leading-zero);
  align-self: start;
  margin-top: 0.05rem;
  min-width: 2.05em;
  text-align: center;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(var(--choice-accent-rgb), 0.20);
  background: rgba(var(--choice-accent-rgb), 0.08);
  color: rgba(var(--choice-accent-rgb), 0.96);
  font-size: 0.75em;
  letter-spacing: 0.08em;
}

.choice-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(110deg, rgba(var(--choice-accent-rgb), 0.08), rgba(var(--choice-accent-rgb), 0) 42%),
    linear-gradient(180deg, rgba(255,255,255,0.025), rgba(255,255,255,0) 35%);
  opacity: 0.8;
}

.choice-btn .choice-btn-text {
  grid-column: 2;
  min-width: 0;
  line-height: 1.45;
}

.choice-btn .choice-btn-chip {
  grid-column: 3;
  align-self: start;
  margin-top: 0.08rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--choice-chip-border);
  background: var(--choice-chip-bg);
  color: var(--choice-chip-text);
  font-size: 0.68em;
  letter-spacing: 0.08em;
  white-space: nowrap;
  line-height: 1.2;
}

.choice-btn .choice-btn-edge {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
}

.choice-btn.choice-fx-peak .choice-btn-edge {
  opacity: 1;
  border: 1px solid rgba(var(--choice-accent-rgb), 0.34);
  box-shadow:
    0 0 0 1px rgba(var(--choice-accent-rgb), 0.08) inset,
    0 0 16px rgba(var(--choice-accent-rgb), 0.12);
  animation: choicePeakGlow 2.4s ease-in-out infinite;
}

.choice-btn.choice-fx-peak .choice-btn-edge::before {
  content: "";
  position: absolute;
  inset: -18% -10%;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(var(--choice-accent-rgb), 0) 38%, rgba(var(--choice-accent-rgb), 0.16) 50%, rgba(var(--choice-accent-rgb), 0) 62%);
  transform: translateX(-38%) rotate(0.001deg);
  opacity: 0.65;
  filter: blur(0.5px);
  animation: choicePeakSweep 3.2s ease-in-out infinite;
}

.choice-btn.choice-fx-peak .choice-btn-edge::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(90deg, rgba(var(--choice-accent-rgb), 0.22), rgba(var(--choice-accent-rgb), 0) 26%) top left / 46% 1px no-repeat,
    linear-gradient(180deg, rgba(var(--choice-accent-rgb), 0.2), rgba(var(--choice-accent-rgb), 0) 30%) top right / 1px 46% no-repeat,
    linear-gradient(270deg, rgba(var(--choice-accent-rgb), 0.22), rgba(var(--choice-accent-rgb), 0) 26%) bottom right / 46% 1px no-repeat,
    linear-gradient(0deg, rgba(var(--choice-accent-rgb), 0.2), rgba(var(--choice-accent-rgb), 0) 30%) bottom left / 1px 46% no-repeat;
  opacity: 0.8;
  animation: choicePeakCorners 2.1s ease-in-out infinite;
}

.choice-btn.choice-importance-medium {
  --choice-accent-rgb: 154, 183, 206;
  --choice-border: rgba(154, 183, 206, 0.20);
  --choice-chip-bg: rgba(154, 183, 206, 0.09);
  --choice-chip-border: rgba(154, 183, 206, 0.18);
  --choice-chip-text: rgba(212, 229, 242, 0.94);
}

.choice-btn.choice-importance-high {
  --choice-accent-rgb: 217, 193, 161;
  --choice-border: rgba(217, 193, 161, 0.30);
  --choice-chip-bg: rgba(217, 193, 161, 0.12);
  --choice-chip-border: rgba(217, 193, 161, 0.24);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(217, 193, 161, 0.06), inset 0 1px 0 rgba(255,255,255,0.02);
}

.choice-btn.choice-importance-critical {
  --choice-accent-rgb: 233, 189, 132;
  --choice-border: rgba(233, 189, 132, 0.38);
  --choice-chip-bg: rgba(233, 189, 132, 0.14);
  --choice-chip-border: rgba(233, 189, 132, 0.28);
  --choice-chip-text: rgba(250, 233, 205, 0.95);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.26), 0 0 0 1px rgba(233, 189, 132, 0.08), inset 0 1px 0 rgba(255,255,255,0.025);
}

.choice-btn.choice-intent-trust {
  --choice-accent-rgb: 138, 185, 213;
  --choice-border: rgba(138, 185, 213, 0.26);
  --choice-chip-bg: rgba(138, 185, 213, 0.12);
  --choice-chip-border: rgba(138, 185, 213, 0.24);
  --choice-chip-text: rgba(222, 237, 247, 0.94);
  --choice-bg: linear-gradient(180deg, rgba(25, 31, 38, 0.94) 0%, rgba(13, 17, 22, 0.97) 100%);
  --choice-bg-hover: linear-gradient(180deg, rgba(30, 37, 44, 0.95) 0%, rgba(15, 19, 24, 0.98) 100%);
  --choice-bg-active: linear-gradient(180deg, rgba(34, 41, 49, 0.96) 0%, rgba(16, 19, 24, 0.99) 100%);
}

.choice-btn.choice-intent-danger {
  --choice-accent-rgb: 210, 126, 126;
  --choice-border: rgba(210, 126, 126, 0.30);
  --choice-chip-bg: rgba(210, 126, 126, 0.12);
  --choice-chip-border: rgba(210, 126, 126, 0.24);
  --choice-chip-text: rgba(248, 226, 226, 0.94);
  --choice-bg: linear-gradient(180deg, rgba(40, 26, 29, 0.94) 0%, rgba(17, 12, 13, 0.98) 100%);
  --choice-bg-hover: linear-gradient(180deg, rgba(52, 29, 34, 0.95) 0%, rgba(20, 13, 15, 0.98) 100%);
  --choice-bg-active: linear-gradient(180deg, rgba(61, 31, 36, 0.96) 0%, rgba(22, 13, 15, 0.99) 100%);
}

.choice-btn.choice-intent-caution {
  --choice-accent-rgb: 195, 174, 126;
  --choice-border: rgba(195, 174, 126, 0.26);
  --choice-chip-bg: rgba(195, 174, 126, 0.11);
  --choice-chip-border: rgba(195, 174, 126, 0.20);
}

.choice-btn.choice-intent-investigation {
  --choice-accent-rgb: 144, 176, 206;
  --choice-border: rgba(144, 176, 206, 0.24);
  --choice-chip-bg: rgba(144, 176, 206, 0.11);
  --choice-chip-border: rgba(144, 176, 206, 0.20);
}

.choice-btn.choice-intent-relationship {
  --choice-accent-rgb: 190, 150, 177;
  --choice-border: rgba(190, 150, 177, 0.24);
  --choice-chip-bg: rgba(190, 150, 177, 0.10);
  --choice-chip-border: rgba(190, 150, 177, 0.18);
  --choice-chip-text: rgba(236, 223, 233, 0.93);
}

.choice-btn.choice-intent-final {
  --choice-accent-rgb: 231, 190, 134;
  --choice-border: rgba(231, 190, 134, 0.34);
  --choice-chip-bg: rgba(231, 190, 134, 0.14);
  --choice-chip-border: rgba(231, 190, 134, 0.28);
  --choice-bg: linear-gradient(180deg, rgba(38, 31, 24, 0.95) 0%, rgba(17, 14, 11, 0.98) 100%);
  --choice-bg-hover: linear-gradient(180deg, rgba(46, 35, 25, 0.96) 0%, rgba(19, 15, 11, 0.99) 100%);
  --choice-bg-active: linear-gradient(180deg, rgba(54, 38, 25, 0.97) 0%, rgba(22, 16, 11, 1) 100%);
}

.choice-btn:nth-child(1) { animation-delay: 0.1s; }
.choice-btn:nth-child(2) { animation-delay: 0.25s; }
.choice-btn:nth-child(3) { animation-delay: 0.4s; }
.choice-btn:nth-child(4) { animation-delay: 0.55s; }

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

@keyframes choicePeakGlow {
  0%, 100% {
    box-shadow:
      0 0 0 1px rgba(var(--choice-accent-rgb), 0.06) inset,
      0 0 14px rgba(var(--choice-accent-rgb), 0.10);
    opacity: 0.88;
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(var(--choice-accent-rgb), 0.12) inset,
      0 0 26px rgba(var(--choice-accent-rgb), 0.18);
    opacity: 1;
  }
}

@keyframes choicePeakSweep {
  0%, 18% {
    transform: translateX(-44%);
    opacity: 0;
  }
  32% {
    opacity: 0.55;
  }
  54% {
    transform: translateX(44%);
    opacity: 0.15;
  }
  100% {
    transform: translateX(44%);
    opacity: 0;
  }
}

@keyframes choicePeakCorners {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.95; }
}

.choice-btn:active {
  background: var(--choice-bg-active);
  border-color: rgba(var(--choice-accent-rgb), 0.62);
  transform: translateY(1px) scale(0.992);
  box-shadow: 0 0 15px rgba(var(--choice-accent-rgb), 0.18);
}

.choice-btn.choice-fx-peak:active .choice-btn-edge {
  animation-duration: 1.4s;
  box-shadow:
    0 0 0 1px rgba(var(--choice-accent-rgb), 0.14) inset,
    0 0 30px rgba(var(--choice-accent-rgb), 0.22);
}

@media (hover: hover) {
  .choice-btn:hover {
    background: var(--choice-bg-hover);
    border-color: rgba(var(--choice-accent-rgb), 0.52);
    box-shadow: 0 0 10px rgba(var(--choice-accent-rgb), 0.14), 0 14px 30px rgba(0,0,0,0.24);
    transform: translateY(-1px);
  }

  .choice-btn.choice-fx-peak:hover .choice-btn-edge {
    box-shadow:
      0 0 0 1px rgba(var(--choice-accent-rgb), 0.14) inset,
      0 0 30px rgba(var(--choice-accent-rgb), 0.20);
  }
}

/* Menu Button */
#menu-button {
  position: absolute;
  top: calc(var(--safe-top) + 0.5rem);
  right: calc(var(--safe-right) + 0.5rem);
  z-index: 5;
  font-size: 1.5rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 11, 14, 0.62);
  color: var(--text-color);
  border: 1px solid rgba(217, 193, 161, 0.20);
  border-radius: 16px;
  cursor: pointer;
  opacity: 0.78;
  transition: opacity 0.3s, border-color 0.2s, background 0.2s, transform 0.14s, box-shadow 0.2s;
  padding: 0;
  line-height: 1;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#menu-button:active {
  opacity: 1;
  transform: translateY(1px);
}

@media (hover: hover) {
  #menu-button:hover {
    opacity: 0.95;
    border-color: rgba(217, 193, 161, 0.38);
    background: rgba(18, 15, 17, 0.76);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.28);
  }
}

.menu-btn:focus-visible,
.choice-btn:focus-visible,
#menu-button:focus-visible,
.save-slot:focus-visible {
  outline: 2px solid var(--ring-focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(217, 193, 161, 0.12);
}

/* === Ending Screen === */
#ending-screen {
  z-index: 10;
  text-align: center;
  padding:
    max(1.2rem, calc(1.2rem + var(--safe-top)))
    max(1rem, calc(1rem + var(--safe-right)))
    max(1.2rem, calc(1.2rem + var(--safe-bottom)))
    max(1rem, calc(1rem + var(--safe-left)));
}

/* Ending variants */
#ending-screen.ending-true {
  background:
    radial-gradient(90% 80% at 50% 18%, rgba(249, 227, 194, 0.18) 0%, rgba(0, 0, 0, 0) 60%),
    linear-gradient(135deg, #141822 0%, #263653 35%, #5b4f67 70%, #b8837a 100%);
}

#ending-screen.ending-bad {
  background:
    radial-gradient(95% 80% at 50% 20%, rgba(126, 84, 112, 0.15) 0%, rgba(0, 0, 0, 0) 55%),
    linear-gradient(135deg, #05060b 0%, #0a0d1a 38%, #180f19 74%, #12090d 100%);
}

#ending-screen.ending-normal,
#ending-screen.ending-default {
  background:
    radial-gradient(88% 72% at 50% 22%, rgba(170, 192, 214, 0.14) 0%, rgba(0, 0, 0, 0) 60%),
    linear-gradient(135deg, #0a1118 0%, #152231 40%, #223445 72%, #3b4853 100%);
}

.ending-content {
  width: min(100%, 620px);
  padding: clamp(1rem, 3vw, 1.4rem);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(10, 11, 15, 0.26), rgba(10, 11, 15, 0.40));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 1.2s ease 0.3s forwards;
}

#ending-title {
  font-size: clamp(1.5rem, 5vw, 2.5rem);
  font-weight: 300;
  letter-spacing: 0.1em;
  margin-bottom: 1.5rem;
  text-shadow: 0 0 20px var(--accent-glow);
}

#ending-screen.ending-true #ending-title {
  color: #f7ead8;
  text-shadow: 0 0 18px rgba(240, 210, 160, 0.18), 0 0 30px rgba(255, 184, 140, 0.12);
}

#ending-screen.ending-normal #ending-title,
#ending-screen.ending-default #ending-title {
  color: #dbe8f4;
  text-shadow: 0 0 18px rgba(143, 181, 217, 0.14);
}

#ending-screen.ending-bad #ending-title {
  color: #e8dce7;
  text-shadow: 0 0 20px rgba(170, 110, 160, 0.14);
}

#ending-text {
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  line-height: 2;
  opacity: 0.8;
  margin-bottom: 3rem;
  max-width: 500px;
  white-space: pre-line;
}

#ending-screen.ending-true #ending-text {
  color: rgba(248, 239, 229, 0.88);
}

#ending-screen.ending-normal #ending-text,
#ending-screen.ending-default #ending-text {
  color: rgba(224, 237, 248, 0.82);
}

#ending-screen.ending-bad #ending-text {
  color: rgba(228, 216, 230, 0.78);
}

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

/* === Overlay === */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0);
  z-index: 20;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  pointer-events: none;
  opacity: 0;
  transition: background 0.3s ease, opacity 0.3s ease;
}

.overlay.active {
  background:
    radial-gradient(circle at 50% 30%, rgba(120, 140, 162, 0.08) 0%, rgba(0,0,0,0) 55%),
    rgba(0, 0, 0, 0.72);
  pointer-events: auto;
  opacity: 1;
}

.overlay-panel {
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(155, 182, 204, 0.07) 0%, rgba(155, 182, 204, 0) 70%),
    linear-gradient(180deg, rgba(15, 15, 20, 0.92), rgba(10, 10, 13, 0.95));
  backdrop-filter: blur(16px) saturate(1.04);
  -webkit-backdrop-filter: blur(16px) saturate(1.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 2rem;
  width: 90%;
  max-width: 380px;
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  text-align: center;
  transform: scale(0.95);
  transition: transform 0.3s ease;
  box-shadow: 0 26px 54px rgba(0, 0, 0, 0.40), inset 0 1px 0 rgba(255,255,255,0.03);
  scrollbar-width: thin;
  scrollbar-color: rgba(217, 193, 161, 0.35) rgba(255,255,255,0.05);
}

.overlay.active .overlay-panel {
  transform: scale(1);
}

.overlay-panel h2 {
  font-size: 1.2rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  margin-bottom: 1.5rem;
  color: rgba(244, 238, 229, 0.95);
}

.overlay-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-bottom: 1.5rem;
}

.overlay-buttons .menu-btn {
  min-width: unset;
  width: 100%;
}

/* Save Slots */
#save-slots {
  display: none;
  flex-direction: column;
  gap: 0.6rem;
}

#save-slots.active {
  display: flex;
}

.save-slot {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015)),
    rgba(15, 15, 20, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.85rem 0.95rem 0.8rem;
  cursor: pointer;
  text-align: left;
  color: var(--text-color);
  font-family: inherit;
  font-size: 0.85rem;
  transition: background 0.2s, border-color 0.2s, transform 0.14s, box-shadow 0.2s;
  touch-action: manipulation;
  min-height: 52px;
  position: relative;
  overflow: hidden;
}

.save-slot:active {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.20);
  transform: translateY(1px);
}

@media (hover: hover) {
  .save-slot:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: 0 10px 22px rgba(0,0,0,0.22);
    transform: translateY(-1px);
  }
}

.save-slot .slot-label {
  font-weight: 600;
  margin-bottom: 0.18rem;
  letter-spacing: 0.05em;
  color: rgba(242, 238, 231, 0.95);
}

.save-slot .slot-info {
  opacity: 0.75;
  font-size: 0.8rem;
  line-height: 1.35;
  color: rgba(205, 216, 228, 0.78);
}

.save-slot.empty {
  opacity: 0.72;
}

.save-slot.empty .slot-info {
  color: rgba(242, 238, 231, 0.5);
}

/* Save toast */
.save-toast {
  position: fixed;
  top: calc(var(--safe-top) + 1rem);
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(110, 198, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(110, 198, 255, 0.3);
  border-radius: 8px;
  padding: 0.6rem 1.5rem;
  color: var(--accent);
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  z-index: 100;
  opacity: 0;
  animation: toastIn 0.3s ease forwards, toastOut 0.3s ease 1.2s forwards;
  pointer-events: none;
}

@keyframes toastIn {
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
}

/* === Landscape hint === */
@media (orientation: landscape) and (max-height: 500px) {
  #text-box {
    min-height: 100px;
    padding: 0.6rem 1rem 1rem;
  }

  #text-box-gradient {
    height: 20px;
  }

  #message-text {
    font-size: 0.85rem;
    line-height: 1.6;
    min-height: 2.4em;
  }

  #character-layer {
    padding-bottom: 15%;
  }

  #character-layer .character {
    max-height: 72%;
  }
}

@media (pointer: coarse) {
  .menu-btn {
    min-height: 48px;
    font-size: max(16px, 1rem);
    padding: 0.9em 1.4em;
  }

  #text-box {
    min-height: 166px;
    padding: 1rem 1rem 1.65rem;
  }

  #speaker-name {
    font-size: 0.9rem;
    margin-bottom: 0.45rem;
  }

  #message-text {
    font-size: 1rem;
    line-height: 1.9;
    min-height: 4em;
    letter-spacing: 0.01em;
    overflow-wrap: anywhere;
  }

  #tap-indicator {
    font-size: 0.95rem;
    right: 0.85rem;
    bottom: 0.5rem;
  }

  #choice-layer {
    gap: 0.8rem;
  }

  .choice-btn {
    min-height: 52px;
    font-size: 1rem;
    line-height: 1.45;
    padding: 0.95em 1.1em;
    max-width: min(92vw, 420px);
  }

  #menu-button {
    width: 50px;
    height: 50px;
    opacity: 0.78;
  }

  .save-slot {
    min-height: 56px;
    padding: 0.95rem 1rem;
  }

  .save-slot .slot-label {
    font-size: 0.92rem;
  }

  .save-slot .slot-info {
    font-size: 0.84rem;
  }

  #ending-text {
    font-size: 1rem;
    line-height: 1.9;
  }

  .runtime-banner-actions .menu-btn {
    min-height: 44px;
    font-size: max(15px, 0.88rem);
  }
}

/* === Tablet (iPad) tuning === */
@media (min-width: 744px) and (max-width: 1366px) {
  .title-content {
    width: min(92vw, 760px);
    padding-left: max(1.25rem, calc(1.25rem + var(--safe-left)));
    padding-right: max(1.25rem, calc(1.25rem + var(--safe-right)));
  }

  .title-panel {
    border-radius: 22px;
    padding: 1.35rem 1.5rem 1.5rem;
  }

  .title-subtitle {
    margin-bottom: 0.85rem;
    letter-spacing: 0.22em;
  }

  .title-menu {
    width: min(76vw, 460px);
  }

  .title-menu .menu-btn {
    width: 100%;
    min-width: 0;
  }

  #text-box-gradient,
  #text-box {
    width: min(100%, 920px);
    align-self: center;
  }

  #text-box-gradient {
    height: 48px;
  }

  #text-box {
    min-height: 144px;
    padding: 0.95rem 1.25rem 1.35rem;
    border-width: 1px;
    border-radius: 16px;
  }

  #speaker-name,
  #message-text {
    max-width: 62ch;
  }

  #message-text {
    margin-right: 2rem;
    line-height: 1.9;
  }

  #tap-indicator {
    right: 1.05rem;
  }

  #choice-layer {
    gap: 0.9rem;
    padding-left: max(1.4rem, calc(1.2rem + var(--safe-left)));
    padding-right: max(1.4rem, calc(1.2rem + var(--safe-right)));
  }

  .choice-btn {
    max-width: min(72vw, 600px);
    padding-left: 1rem;
    padding-right: 1.2rem;
  }

  #menu-button {
    top: calc(var(--safe-top) + 0.75rem);
    right: calc(var(--safe-right) + 0.75rem);
  }

  .ending-content {
    width: min(88vw, 760px);
  }

  #ending-text {
    max-width: 620px;
    margin-left: auto;
    margin-right: auto;
  }

  .overlay-panel {
    width: min(88vw, 560px);
    max-width: 560px;
    padding: 1.6rem 1.75rem;
    border-radius: 18px;
  }

  .overlay-buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .runtime-banner-panel {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.85rem;
  }

  .runtime-banner-actions {
    width: min(42vw, 280px);
  }
}

@media (min-width: 744px) and (max-width: 1366px) and (orientation: landscape) {
  #character-layer {
    padding-bottom: 18%;
  }

  #character-layer .character {
    max-height: 64%;
  }

  #character-layer .character.slot-center {
    max-height: 66%;
  }

  #text-box-gradient {
    height: 34px;
  }

  #text-box {
    min-height: 122px;
    padding: 0.75rem 1.15rem 1.1rem;
  }

  #speaker-name {
    margin-bottom: 0.35rem;
  }

  #message-text {
    min-height: 3.2em;
    line-height: 1.75;
  }

  #choice-layer {
    justify-content: center;
    padding-top: max(1.2rem, calc(1rem + var(--safe-top)));
    padding-bottom: max(8rem, calc(7rem + var(--safe-bottom)));
  }

  .choice-btn {
    max-width: min(64vw, 620px);
  }
}

@media (min-width: 744px) and (max-width: 1024px) and (orientation: portrait) {
  #character-layer {
    padding-bottom: 22%;
  }

  .choice-btn {
    max-width: min(78vw, 520px);
  }
}

@media (max-width: 430px) {
  .title-content {
    width: 100%;
    padding-left: max(0.9rem, calc(0.9rem + var(--safe-left)));
    padding-right: max(0.9rem, calc(0.9rem + var(--safe-right)));
  }

  .title-subtitle {
    letter-spacing: 0.18em;
    margin-bottom: 0.75rem;
  }

  .title-panel {
    border-radius: 16px;
    padding: 0.95rem 0.9rem 1rem;
  }

  .title-kicker {
    letter-spacing: 0.18em;
    font-size: 0.64rem;
  }

  .title-badges {
    gap: 0.4rem;
    margin-bottom: 1rem;
  }

  .title-badge {
    font-size: 0.68rem;
    padding: 0.3rem 0.6rem;
  }

  #text-box {
    padding-inline: 0.95rem;
    width: min(100%, calc(100% - 8px));
    margin-bottom: 4px;
  }

  #message-text {
    font-size: 1rem;
    line-height: 1.85;
  }

  #choice-layer {
    gap: 0.75rem;
  }

  .choice-btn {
    padding-right: 0.95rem;
    gap: 0.6rem;
  }

  .choice-btn .choice-btn-chip {
    font-size: 0.62em;
    padding: 0.2rem 0.45rem;
  }

  .overlay-panel {
    width: 94%;
    padding: 1.25rem;
  }

  .runtime-banner {
    padding-left: max(0.6rem, calc(0.6rem + var(--safe-left)));
    padding-right: max(0.6rem, calc(0.6rem + var(--safe-right)));
    padding-bottom: max(0.6rem, calc(0.6rem + var(--safe-bottom)));
  }

  .runtime-banner-panel {
    border-radius: 12px;
    padding: 0.7rem 0.75rem;
  }

  .runtime-banner-body {
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .title-text,
  #tap-indicator.visible,
  .ending-content,
  .choice-btn,
  .choice-btn.choice-fx-peak .choice-btn-edge,
  .choice-btn.choice-fx-peak .choice-btn-edge::before,
  .choice-btn.choice-fx-peak .choice-btn-edge::after {
    animation: none !important;
  }

  .screen,
  #background-layer,
  #still-layer,
  #still-layer::after,
  #still-layer .still-image,
  #character-layer .character,
  .overlay,
  .overlay-panel {
    transition-duration: 0.01s !important;
  }
}
