:root {
  --primary: #ff5f97;
  --primary-dark: #f23d82;
  --bg-app: linear-gradient(180deg, #ffe4ef 0%, #ffeef5 25%, #f9f6f8 100%);
  --bg-scene: linear-gradient(180deg, #e7c8d6 0%, #d8a9bf 24%, #d9b8c6 42%, #efdfe7 70%, #faf7f9 100%);
  --bg-bottom-fade: linear-gradient(180deg, rgba(255, 246, 250, 0) 0%, rgba(255, 246, 250, 0.8) 35%, rgba(255, 246, 250, 1) 100%);
  --text-main: #22252b;
  --text-sub: #7d8590;
  --text-speaker: #f23d82;
  --panel-bg: rgba(255, 255, 255, 0.92);
  --panel-bg-solid: rgba(255, 255, 255, 0.98);
  --panel-border: rgba(255, 255, 255, 0.55);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --shadow-soft: 0 12px 34px rgba(174, 81, 124, 0.12);
  --shadow-btn: 0 8px 18px rgba(255, 145, 186, 0.08);
  --overlay-bg: rgba(31, 21, 27, 0.42);
  --font-main: "Pretendard", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  font-family: var(--font-main);
  background-color: #f5f7fa;
  color: var(--text-main);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow-y: auto;
}

button,
input,
textarea {
  font: inherit;
}

.topbar,
.top-meta,
.dialogue-box,
.dialogue-head,
.dialogue-text,
.script-block,
.narration-copy,
.speech-block,
.speech-name-tag,
.speech-bubble,
.action-slot,
.logo-state-panel,
.scene-counter,
.utility-row,
.util-btn,
.choice-btn,
.title-menu-btn,
.icon-btn,
.chat-bubble {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.dialogue-box,
.choice-btn,
.util-btn,
.title-menu-btn,
.icon-btn,
.chat-bubble {
  touch-action: manipulation;
}

#app-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.app {
  width: 100%;
  max-width: 430px;
  height: 100%;
  max-height: 932px;
  position: relative;
  overflow: hidden;
  background: var(--bg-app);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
  isolation: isolate;
  display: flex;
  flex-direction: column;
  --dialogue-box-min: 136px;
  --dialogue-box-max: 246px;
  --portrait-base-bottom: 18%;
  --portrait-base-height: 62%;
}

@media (min-width: 431px) {
  .app {
    height: 844px;
    border-radius: 36px;
    border: 6px solid rgba(255, 255, 255, 0.9);
  }
}

.scene-bg {
  position: absolute;
  inset: 0;
  background: var(--bg-scene);
  transition: background 0.5s ease;
  z-index: 1;
}

.portrait-container {
  position: absolute;
  left: 0;
  bottom: var(--portrait-base-bottom);
  transform: none;
  width: 100%;
  height: var(--portrait-base-height);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.portrait-container .portrait-card {
  width: min(280px, 62vw);
  height: min(420px, 62vh);
  border-radius: 999px 999px 40px 40px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(242, 61, 130, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 24px 80px rgba(174, 81, 124, 0.18);
  display: grid;
  place-items: center;
  color: rgba(242, 61, 130, 0.58);
  font-size: clamp(48px, 14vw, 96px);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.app.has-portrait .portrait-container {
  opacity: 1;
}

.scene-cutin {
  position: absolute;
  top: 92px;
  right: 16px;
  z-index: 7;
  width: min(176px, 39vw);
  opacity: 0;
  transform: translate3d(14px, 0, 0) scale(0.94);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}

.scene-cutin[hidden] {
  display: none !important;
}

.scene-cutin.is-active {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.scene-cutin__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(255, 250, 252, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 18px 38px rgba(49, 38, 49, 0.16);
  backdrop-filter: blur(18px);
}

.scene-cutin__card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 23px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  pointer-events: none;
}

.scene-cutin__badge {
  align-self: flex-start;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: rgba(103, 77, 92, 0.82);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.scene-cutin__image {
  width: 100%;
  display: block;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 10px 24px rgba(78, 57, 76, 0.14);
}

.scene-cutin__caption {
  font-size: 12px;
  font-weight: 700;
  color: rgba(83, 67, 79, 0.88);
  letter-spacing: 0.02em;
}

.scene-cutin.is-interview .scene-cutin__card {
  background: linear-gradient(180deg, rgba(252, 245, 247, 0.82), rgba(255, 255, 255, 0.64));
}

.scene-cutin.is-interview .scene-cutin__image {
  aspect-ratio: 4 / 5;
}

.scene-cutin.is-letter {
  top: 108px;
  width: min(148px, 34vw);
}

.scene-cutin.is-letter .scene-cutin__card {
  background: rgba(255, 248, 238, 0.84);
  box-shadow: 0 18px 32px rgba(95, 74, 52, 0.14);
}

.scene-cutin.is-letter .scene-cutin__image {
  aspect-ratio: 0.72;
  object-fit: contain;
  background: linear-gradient(180deg, rgba(255, 253, 248, 0.94), rgba(247, 236, 219, 0.72));
  padding: 10px;
}

@media (max-width: 430px) {
  .scene-cutin {
    top: 88px;
    right: 12px;
    width: min(160px, 38vw);
  }

  .scene-cutin.is-letter {
    top: 100px;
    width: min(136px, 33vw);
  }
}

.dev-scene-label {
  position: absolute;
  top: 108px;
  left: 20px;
  z-index: 3;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(14px);
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
  pointer-events: none;
}

.app:not(.dev-mode) .dev-scene-label {
  display: none;
}

.topbar {
  position: relative;
  z-index: 10;
  padding: max(14px, env(safe-area-inset-top)) 18px 0;
  color: white;
}

.topbar-inner {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 12px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  color: white;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.top-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.top-meta .day,
.top-meta .time {
  min-height: 14px;
  font-size: 12px;
  letter-spacing: 0.16em;
  font-weight: 800;
}

.top-meta .place {
  min-height: 16px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.95;
}

.bottom-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  padding: 14px 14px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-bottom-fade);
  pointer-events: none;
}

.bottom-ui > * {
  pointer-events: auto;
}

.dialogue-box,
.action-slot {
  border-radius: var(--radius-xl);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow-soft);
}

.dialogue-box {
  backdrop-filter: blur(16px);
  padding: 13px 14px 14px;
  min-height: var(--dialogue-box-min);
  max-height: var(--dialogue-box-max);
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: hidden;
}

.dialogue-text {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: hidden;
  overflow-x: hidden;
  color: var(--text-main);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.app:not(.has-portrait) {
  --dialogue-box-min: 152px;
  --dialogue-box-max: clamp(152px, 36vh, 288px);
}

/* Mobile readability guard:
   긴 텍스트가 페이지 분할 한계를 넘더라도 잘리지 않게 세로 스크롤 허용 */
@media (max-width: 430px) {
  .app {
    --dialogue-box-min: 128px;
    --dialogue-box-max: clamp(128px, 33vh, 238px);
    --portrait-base-bottom: 24%;
    --portrait-base-height: 54%;
  }

  .dialogue-box {
    padding: 12px 14px 14px;
  }

  .dialogue-text {
    min-height: 0;
    max-height: none;
    padding-right: 2px;
  }

  .app:not(.has-portrait) {
    --dialogue-box-min: 144px;
    --dialogue-box-max: clamp(144px, 36vh, 264px);
  }
}

@media (max-width: 390px) and (max-height: 760px), (max-height: 680px) {
  .dialogue-text {
    overflow-y: hidden;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding-right: 4px;
  }
}

.dialogue-text.is-scrollable {
  overflow-y: auto;
}

.dialogue-text::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.script-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.narration-copy {
  font-size: 15px;
  line-height: 1.65;
  color: var(--text-main);
  word-break: keep-all;
  white-space: pre-line;
  font-weight: 500;
}

.speech-block {
  align-items: flex-start;
}

.speech-name-tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(242, 61, 130, 0.14);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.speech-bubble {
  width: 100%;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 135, 184, 0.2);
  box-shadow: var(--shadow-btn);
  padding: 12px 14px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-main);
  word-break: keep-all;
  white-space: pre-line;
  font-weight: 600;
}

.speech-block.is-quote-only .speech-bubble {
  background: rgba(255, 248, 251, 0.86);
  border-style: dashed;
  font-weight: 550;
}

.speech-block.is-player-speech .speech-bubble {
  background: linear-gradient(180deg, rgba(239, 247, 255, 0.98), rgba(232, 242, 251, 0.94));
  border-color: rgba(164, 194, 221, 0.42);
  color: #20242a;
  box-shadow: 0 12px 24px rgba(125, 163, 194, 0.12);
}

.action-slot {
  backdrop-filter: blur(14px);
  padding: 12px 14px;
  position: relative;
  min-height: 154px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  transition: min-height 0.24s ease, padding 0.24s ease;
}

.state-panel {
  position: absolute;
  inset: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.logo-state-panel {
  align-items: center;
  gap: 6px;
  text-align: center;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: white;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 15px;
}

.logo-text {
  font-size: 12px;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: 0.04em;
}

.logo-handle {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(125, 133, 144, 0.9);
}

.choice-state-panel {
  width: 100%;
  margin: 0;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.choice-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: min(100%, 420px);
  margin: 0 auto;
}

.choice-btn {
  width: 100%;
  border: 1px solid rgba(255, 135, 184, 0.22);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.96);
  padding: 14px 16px;
  min-height: 62px;
  text-align: left;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.45;
  word-break: keep-all;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-btn);
  transition: all 0.2s ease;
}

.choice-btn:active,
.choice-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  background: #fff8fb;
}

.choice-btn .arrow {
  color: var(--primary);
  font-weight: 800;
  flex-shrink: 0;
}

.app.is-idle .action-slot {
  min-height: 44px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.app.is-idle #logo-state-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  gap: 0;
}

.app.is-idle #choice-state-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  position: absolute;
}

.app.is-idle .action-slot > #logo-state-panel {
  inset: 4px 12px;
}

.app.is-idle .logo-mark {
  width: 96px;
  height: 18px;
  overflow: hidden;
}

.app.is-idle .logo-mark::after {
  inset: -10px -2px;
  background-size: auto 40px;
  background-position: center;
  opacity: 0.56;
}

.app.is-idle .logo-handle {
  color: rgba(125, 133, 144, 0.72);
  opacity: 0.82;
}

.app.is-choice #logo-state-panel {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
}

.app.is-choice #choice-state-panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.app.is-choice .action-slot {
  min-height: 188px;
  max-height: min(34svh, 286px);
  justify-content: flex-start;
}

.app.is-choice .action-slot > #choice-state-panel {
  position: relative;
  inset: auto;
  flex: 1 1 auto;
  justify-content: flex-start;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}

.utility-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.utility-group {
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.utility-group:first-child {
  flex: 1 1 auto;
}

.utility-group:last-child {
  flex: 0 0 auto;
}

.util-btn {
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  border-radius: 999px;
  padding: 9px 13px;
  min-height: 44px;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 0;
  white-space: nowrap;
}

.util-btn.is-active,
.util-btn:hover {
  border-color: rgba(242, 61, 130, 0.32);
  color: var(--primary-dark);
}

.util-btn-primary,
.util-btn-primary:hover {
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(242, 61, 130, 0.2);
}

.util-btn[disabled] {
  opacity: 0.45;
  cursor: default;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 180;
  background: var(--overlay-bg);
  backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.app.overlay-open .overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

.system-card {
  width: 100%;
  background: var(--panel-bg-solid);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  padding: 30px 20px 20px;
  text-align: center;
  transform: scale(0.95) translateY(10px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
  overflow: hidden;
}

.overlay.is-active .system-card {
  transform: scale(1) translateY(0);
}

.sys-accent-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

.sys-icon {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 12px;
}

.sys-title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.sys-desc {
  margin: 0 0 24px;
  font-size: 14px;
  color: var(--text-sub);
  line-height: 1.5;
  word-break: keep-all;
  font-weight: 500;
}

.sys-actions {
  display: flex;
  gap: 8px;
}

.sys-actions button {
  flex: 1;
  padding: 14px;
  min-height: 44px;
  border-radius: var(--radius-md);
  border: none;
  font-weight: 800;
  cursor: pointer;
  font-size: 14px;
}

.sys-btn-confirm {
  background: var(--primary);
  color: white;
}

.phone-sheet {
  width: 100%;
  height: 75%;
  max-height: 600px;
  background: #f8f9fa;
  border-radius: 32px 32px 24px 24px;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.1);
  position: absolute;
  bottom: 0;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.overlay.is-active .phone-sheet {
  transform: translateY(0);
}

.phone-header {
  padding: 20px 24px 16px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-radius: 32px 32px 0 0;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#btn-phone-close {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  gap: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
}

.phone-close-label {
  line-height: 1;
  white-space: nowrap;
}

#btn-phone-close.is-attention {
  animation: phoneClosePulse 1.2s ease-in-out infinite;
  background: rgba(255, 255, 255, 0.92) !important;
  color: var(--primary-dark) !important;
  border-color: rgba(242, 61, 130, 0.24) !important;
  box-shadow: 0 0 0 0 rgba(242, 61, 130, 0.24);
}

.phone-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.phone-avatar {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  background: linear-gradient(135deg, #ffe8f0, #ffb7d1);
  color: var(--primary-dark);
  font-weight: 900;
  font-size: 16px;
  display: grid;
  place-items: center;
}

.phone-name {
  font-weight: 800;
  font-size: 16px;
  color: var(--text-main);
  line-height: 1.2;
}

.phone-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
}

.phone-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-time {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: #a0aab5;
  margin: 8px 0;
}

.chat-bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 500;
  word-break: keep-all;
}

.chat-in {
  background: white;
  color: var(--text-main);
  border-top-left-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  align-self: flex-start;
}

.chat-out {
  background: linear-gradient(180deg, rgba(231, 245, 255, 0.98), rgba(217, 237, 252, 0.96));
  color: #20242a;
  border-top-right-radius: 4px;
  border: 1px solid rgba(154, 192, 220, 0.34);
  box-shadow: 0 6px 16px rgba(111, 160, 196, 0.14);
  align-self: flex-end;
}

#overlay-ending {
  background: linear-gradient(180deg, #fff8fb 0%, #ffffff 100%);
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  isolation: isolate;
}

.ending-cg {
  width: 100%;
  height: 58%;
  background-color: #ffeef5;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transform: scale(1.05);
  transition: all 1.5s ease;
}

.overlay.is-active .ending-cg {
  opacity: 1;
  transform: scale(1);
}

.ending-text-area {
  position: absolute;
  bottom: 22%;
  left: 0;
  right: 0;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all 1.2s ease 0.8s;
  padding: 0 24px;
}

.overlay.is-active .ending-text-area {
  opacity: 1;
  transform: translateY(0);
}

.ending-quote {
  font-size: 18px;
  line-height: 1.6;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
}

.ending-result {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
}

.ending-actions {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: max(26px, env(safe-area-inset-bottom));
  z-index: 2;
  opacity: 0;
  transform: translateY(18px);
  transition: all 0.4s ease;
}

#overlay-ending.is-ready .ending-actions {
  opacity: 1;
  transform: translateY(0);
}

.ending-title-btn {
  width: 100%;
  border: none;
  border-radius: 20px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 16px 18px;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(242, 61, 130, 0.22);
  cursor: pointer;
}

.chat-bubble.role-x {
  background: linear-gradient(135deg, #fff6f8, #ffe4eb);
  border: 1px solid rgba(232, 129, 166, 0.28);
}

.chat-bubble.role-new {
  background: linear-gradient(135deg, #fff8f1, #ffe9d9);
  border: 1px solid rgba(255, 168, 120, 0.24);
}

.chat-bubble.role-default {
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

.chat-out.role-x,
.chat-out.role-new,
.chat-out.role-default {
  background: linear-gradient(180deg, rgba(231, 245, 255, 0.98), rgba(217, 237, 252, 0.96));
  color: #20242a;
  border: 1px solid rgba(154, 192, 220, 0.34);
  box-shadow: 0 6px 16px rgba(111, 160, 196, 0.14);
}

.chat-bubble.is-selectable {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  border-radius: 22px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.chat-bubble.is-selectable:hover,
.chat-bubble.is-selectable.is-selected {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(194, 102, 140, 0.12);
}

.chat-bubble.is-selectable.is-selected {
  border-color: rgba(242, 61, 130, 0.5);
}

.phone-reply-panel {
  position: sticky;
  bottom: -20px;
  margin-top: auto;
  padding-top: 14px;
  background: linear-gradient(180deg, rgba(248, 249, 250, 0), rgba(248, 249, 250, 0.94) 18%, rgba(248, 249, 250, 1) 100%);
}

.phone-reply-hint {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  text-align: center;
}

.phone-reply-context {
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 10px 24px rgba(60, 42, 34, 0.08);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-main);
  text-align: left;
}

.phone-reply-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phone-reply-btn {
  width: 100%;
  border: 1px solid rgba(255, 135, 184, 0.2);
  border-radius: 18px;
  background: white;
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.04);
}

.phone-reply-btn.is-secondary {
  background: #f3f5f7;
  color: var(--text-sub);
  border-color: rgba(125, 133, 144, 0.12);
}




.app.setup-open .topbar,
.app.setup-open .bottom-ui,
.app.setup-open .dev-scene-label,
.app.setup-open .portrait-container,
.app.setup-open .scene-cutin {
  opacity: 0;
  pointer-events: none;
}

.app.setup-open {
  overflow: hidden;
}

.app.setup-open .title-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  display: none;
  overflow: hidden;
}

.app.setup-open .setup-screen {
  position: absolute;
  inset: 0;
  width: 100%;
  min-height: 0;
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.app.setup-open .title-screen.is-active,
.app.setup-open .setup-screen.is-active {
  display: block;
}

.app.setup-open .setup-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin-top: auto;
  padding-top: 12px;
  padding-bottom: max(10px, calc(6px + env(safe-area-inset-bottom)));
  background: linear-gradient(180deg, rgba(255, 245, 249, 0) 0%, rgba(255, 245, 249, 0.5) 30%, rgba(255, 245, 249, 0.5) 100%);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.title-screen {
  position: absolute;
  inset: 0;
  z-index: 130;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.36), transparent 24%),
    radial-gradient(circle at 82% 18%, rgba(255, 210, 225, 0.38), transparent 24%),
    linear-gradient(180deg, rgba(255, 226, 238, 0.96) 0%, rgba(255, 243, 247, 0.98) 45%, rgba(248, 246, 249, 1) 100%);
  transition: opacity 0.25s ease;
}

.title-screen.is-active {
  opacity: 1;
  pointer-events: auto;
}

.title-screen__inner {
  width: 100%;
  height: 100%;
  padding: max(32px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
}

.title-screen__brand {
  margin-top: 14vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.setup-screen {
  position: absolute;
  inset: 0;
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, 0.36), transparent 26%),
    linear-gradient(180deg, rgba(255, 237, 244, 0.92) 0%, rgba(250, 244, 247, 0.98) 100%);
  transition: opacity 0.25s ease;
  padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
}

.setup-screen.is-active {
  opacity: 1;
  pointer-events: auto;
}

.setup-screen__panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.setup-brand {
  padding-top: 4px;
}

.setup-brand__kicker {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: var(--primary-dark);
  text-transform: uppercase;
}

.setup-brand__title {
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: -0.04em;
  color: #1f1f25;
}

.setup-brand__desc {
  margin-top: 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-sub);
  word-break: keep-all;
}

.setup-progress {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.setup-progress__step {
  appearance: none;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  padding: 10px 12px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.68);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.setup-progress__step:hover:not(.is-disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(174, 81, 124, 0.08);
}

.setup-progress__step.is-disabled {
  opacity: 0.44;
  cursor: default;
  box-shadow: none;
}

.setup-progress__step:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(255, 196, 220, 0.72),
    0 8px 20px rgba(174, 81, 124, 0.08);
}

.setup-progress__step.is-active {
  color: white;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-color: transparent;
}

.setup-progress__step.is-complete {
  color: var(--primary-dark);
  border-color: rgba(242, 61, 130, 0.18);
  background: rgba(255, 245, 249, 0.96);
}

.setup-step {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

.setup-step.is-active {
  display: flex;
}

.setup-block {
  flex: 1;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 38px rgba(174, 81, 124, 0.08);
  display: flex;
  flex-direction: column;
}

.setup-label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.setup-input {
  width: 100%;
  border: 1px solid rgba(255, 135, 184, 0.22);
  border-radius: 18px;
  background: white;
  padding: 15px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
}

.setup-input:focus {
  border-color: rgba(242, 61, 130, 0.5);
  box-shadow: 0 0 0 4px rgba(255, 95, 151, 0.12);
}

.setup-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.setup-section-kicker {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--primary-dark);
  text-transform: uppercase;
}

.setup-section-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
}

.setup-section-desc {
  max-width: 154px;
  font-size: 12px;
  line-height: 1.45;
  text-align: right;
  color: var(--text-sub);
}

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

.cast-card {
  min-height: 104px;
  border: 1px solid rgba(255, 135, 184, 0.18);
  border-radius: 20px;
  background: white;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.cast-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(174, 81, 124, 0.09);
}

.cast-card.is-selected {
  border-color: rgba(242, 61, 130, 0.58);
  box-shadow: 0 12px 26px rgba(242, 61, 130, 0.12);
}

.cast-card.is-disabled {
  opacity: 0.35;
  cursor: default;
}

.cast-card__role {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  margin-bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  color: white;
}

.cast-card__name {
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.cast-card__tagline {
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-sub);
  word-break: keep-all;
}

.route-preview {
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(255, 244, 247, 0.98));
  border: 1px solid rgba(255, 210, 225, 0.7);
  box-shadow: 0 18px 34px rgba(174, 81, 124, 0.08);
}

.route-preview__code {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.24em;
  color: var(--primary-dark);
}

.route-preview__title {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 800;
  color: var(--text-main);
}

.route-preview__tone {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-sub);
  word-break: keep-all;
}

.route-preview__status {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-dark);
}

.setup-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-shrink: 0;
}

.setup-nav-btn,
.setup-start-btn {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 16px 18px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.setup-nav-btn {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 16px 30px rgba(242, 61, 130, 0.18);
}

.setup-nav-btn--ghost {
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-main);
  border: 1px solid rgba(255, 210, 225, 0.78);
  box-shadow: none;
}

.setup-start-btn {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: white;
  box-shadow: 0 16px 30px rgba(242, 61, 130, 0.22);
}

.setup-start-btn[hidden],
.setup-nav-btn[hidden] {
  display: none;
}

.setup-nav-btn:disabled,
.setup-start-btn:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}


.chat-bubble,
.choice-btn,
.route-preview__title,
.route-preview__tone,
.route-preview__status,
.setup-brand__desc,
.setup-section-desc,
.cast-card__tagline,
.ending-quote,
.ending-result {
  white-space: pre-line;
  overflow-wrap: anywhere;
}



:root {
  --dialogue-font-scale: 1;
  --page-reveal-duration: 240ms;
}

.dialogue-box.has-more-pages::after {
  content: none;
}

.dialogue-page-indicator {
  display: none !important;
}

.dialogue-page-indicator.is-active {
  display: none !important;
}

.dialogue-text.is-revealing .script-block {
  animation: pageReveal var(--page-reveal-duration) ease both;
}

.narration-copy {
  font-size: calc(15px * var(--dialogue-font-scale));
}

.speech-bubble {
  font-size: calc(15px * var(--dialogue-font-scale));
}

.choice-btn {
  font-size: calc(14px * var(--dialogue-font-scale));
}

.chat-bubble {
  font-size: calc(14px * var(--dialogue-font-scale));
}

.choice-btn__copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}

.choice-btn.is-entering {
  animation: choiceRise 0.42s cubic-bezier(0.2, 0.9, 0.2, 1) both;
  animation-delay: var(--choice-delay, 0ms);
}

.choice-btn.is-selected {
  border-color: rgba(242, 61, 130, 0.7);
  background: #fff7fa;
  box-shadow: 0 18px 28px rgba(242, 61, 130, 0.14);
}

.choice-btn.is-locked {
  pointer-events: none;
}

.choice-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(242, 61, 130, 0.1);
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.util-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.util-btn-primary {
  position: relative;
  padding-inline: 12px;
}

.util-btn.has-unread,
.util-btn.has-unread:hover {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4), 0 12px 22px rgba(242, 61, 130, 0.18);
}

.util-badge {
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 999px;
  background: #ff3f66;
  color: white;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(255, 63, 102, 0.24);
}

.title-screen__menu {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.title-menu-btn {
  width: 100%;
  border: 1px solid rgba(255, 210, 225, 0.85);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-main);
  padding: 16px 18px;
  min-height: 48px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.title-menu-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 24px rgba(174, 81, 124, 0.1);
  border-color: rgba(242, 61, 130, 0.32);
}

.title-menu-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.title-menu-btn--primary {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: transparent;
  box-shadow: 0 18px 30px rgba(242, 61, 130, 0.18);
}

.title-screen__status {
  min-height: 18px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-sub);
}

.overlay-sheet {
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.info-sheet {
  width: 100%;
  height: min(80%, 720px);
  background: rgba(250, 251, 253, 0.98);
  border-radius: 28px 28px 0 0;
  box-shadow: 0 -20px 46px rgba(0, 0, 0, 0.16);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  padding: 10px 18px max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.overlay.is-active .info-sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: rgba(125, 133, 144, 0.22);
  margin: 2px auto 0;
}

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

.sheet-kicker {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--primary-dark);
  text-transform: uppercase;
}

.sheet-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
}

.sheet-close-btn {
  border: 1px solid rgba(125, 133, 144, 0.18);
  border-radius: 999px;
  background: white;
  color: var(--text-sub);
  padding: 9px 14px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.log-filters,
.settings-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip,
.settings-option {
  border: 1px solid rgba(255, 210, 225, 0.8);
  border-radius: 999px;
  background: white;
  color: var(--text-sub);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.filter-chip.is-active,
.settings-option.is-selected {
  background: rgba(255, 244, 248, 1);
  border-color: rgba(242, 61, 130, 0.42);
  color: var(--primary-dark);
}

.log-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

.log-entry {
  border-radius: 18px;
  background: white;
  border: 1px solid rgba(255, 220, 232, 0.6);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-sub);
}

.log-entry__kind {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(242, 61, 130, 0.08);
  color: var(--primary-dark);
}

.log-entry__speaker {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.log-entry__text {
  font-size: 14px;
  line-height: 1.58;
  color: var(--text-main);
  white-space: pre-line;
  word-break: keep-all;
}

.log-empty {
  flex: 1;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 24px;
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid rgba(255, 220, 232, 0.72);
  padding-top: 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
}

.sheet-footer__label {
  color: var(--primary-dark);
}

.settings-sheet {
  height: min(82%, 760px);
  overflow-y: auto;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px solid rgba(255, 220, 232, 0.72);
}

.settings-group:first-of-type {
  border-top: none;
}

.settings-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

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

.settings-range-value {
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-dark);
  min-width: 38px;
  text-align: right;
}

.settings-range {
  display: block;
  width: 100%;
}

.settings-range--inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 132px;
  width: auto;
  min-width: 132px;
}

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

.settings-range--inline input[type="range"] {
  flex: 1 1 auto;
  min-width: 84px;
}

.settings-options--compact {
  flex: 0 0 auto;
}

.gallery-progress {
  padding: 14px 16px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(255, 244, 248, 0.96));
  border: 1px solid rgba(255, 220, 232, 0.72);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
}

.gallery-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.gallery-card {
  border-radius: 22px;
  border: 1px solid rgba(255, 220, 232, 0.72);
  background: white;
  min-height: 168px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.gallery-card__art {
  position: relative;
  height: 94px;
  flex: 0 0 94px;
  background: linear-gradient(135deg, #fff1f6, #ffe4ec);
  background-size: cover;
  background-position: center;
}

.gallery-card.is-locked .gallery-card__art::after {
  content: "LOCKED";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(34, 37, 43, 0.4);
  color: rgba(255, 255, 255, 0.78);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.gallery-card__body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.gallery-card__title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.4;
  min-height: calc(1.4em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.gallery-card__preview {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-sub);
  word-break: keep-all;
  min-height: calc(1.5em * 2);
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.gallery-card__action {
  margin-top: auto;
  border: none;
  border-radius: 14px;
  background: rgba(255, 244, 248, 1);
  color: var(--primary-dark);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.scene-transition-card {
  position: absolute;
  inset: 0;
  z-index: 95;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.24s ease;
}

.scene-transition-card.is-active {
  opacity: 1;
}

.scene-transition-card.is-fade-only {
  background: rgba(0, 0, 0, 0.82);
  transition: opacity 0.32s ease;
}

.scene-transition-card.is-fade-only .scene-transition-card__inner {
  opacity: 0;
  transform: none;
  box-shadow: none;
}

.scene-transition-card__inner {
  min-width: min(78vw, 280px);
  padding: 20px 22px;
  border-radius: 28px;
  background: rgba(28, 23, 29, 0.66);
  color: white;
  text-align: center;
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.18);
  transform: translateY(10px) scale(0.98);
  transition: transform 0.3s ease;
}

.scene-transition-card.is-active .scene-transition-card__inner {
  transform: translateY(0) scale(1);
}

.tap-feedback-layer {
  position: absolute;
  inset: 0;
  z-index: 240;
  pointer-events: none;
  overflow: hidden;
}

.tap-feedback {
  --tap-size: 88px;
  position: absolute;
  width: var(--tap-size);
  height: var(--tap-size);
  transform: translate(-50%, -50%) scale(0.28);
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  animation: tapRipple 0.62s cubic-bezier(0.2, 0.72, 0.18, 1) forwards;
}

.tap-feedback::before,
.tap-feedback::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.tap-feedback::before {
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.34) 0%, rgba(255, 247, 250, 0.24) 18%, rgba(255, 171, 201, 0.16) 46%, rgba(255, 171, 201, 0) 72%);
  filter: blur(0.5px);
}

.tap-feedback::after {
  inset: 14%;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow:
    0 0 0 1px rgba(255, 156, 193, 0.2),
    0 0 22px rgba(255, 177, 205, 0.16);
}

@keyframes phoneClosePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(242, 61, 130, 0.22);
  }

  45% {
    transform: scale(1.04);
    box-shadow: 0 0 0 10px rgba(242, 61, 130, 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(242, 61, 130, 0);
  }
}

.scene-transition-card__day {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.scene-transition-card__time,
.scene-transition-card__place,
.scene-transition-card__label {
  margin-top: 8px;
}

.scene-transition-card__time {
  font-size: 18px;
  font-weight: 700;
}

.scene-transition-card__place {
  font-size: 24px;
  font-weight: 800;
}

.scene-transition-card__label {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.84);
}

.app.reduced-motion *,
.app.reduced-motion *::before,
.app.reduced-motion *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}

@keyframes pagePrompt {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

@keyframes pageReveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes choiceRise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tapRipple {
  0% {
    opacity: 0.34;
    transform: translate(-50%, -50%) scale(0.28);
  }
  68% {
    opacity: 0.12;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.08);
  }
}

.room-visual-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  overflow: hidden;
}

.room-visual-overlay > div {
  position: absolute;
  inset: 0;
}

.room-visual-overlay__wash {
  background: transparent;
}

.room-visual-overlay__frame {
  opacity: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 24px;
  inset: 9% 8%;
  transform: rotate(-2deg) scale(1.02);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.room-visual-overlay__frame--b {
  inset: 15% 16% 24% 12%;
  transform: rotate(2.5deg) scale(0.94);
}

.room-visual-overlay__glow {
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.app.has-room-theme .room-visual-overlay {
  opacity: 1;
}

.room-badge {
  position: absolute;
  top: 86px;
  left: 18px;
  z-index: 12;
  min-width: 138px;
  max-width: 220px;
  padding: 10px 12px;
  border-radius: 18px;
  backdrop-filter: blur(18px);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.1);
  color: white;
}

.room-badge__label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.room-badge__copy {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.86);
  word-break: keep-all;
}

.app.setup-open .room-badge,
.app.setup-open .room-visual-overlay {
  opacity: 0 !important;
  pointer-events: none;
}

.app.room-theme-x .room-badge {
  background: linear-gradient(135deg, rgba(76, 42, 36, 0.78), rgba(118, 65, 52, 0.62));
  border: 1px solid rgba(246, 215, 190, 0.16);
}

.app.room-theme-new .room-badge {
  background: linear-gradient(135deg, rgba(71, 112, 138, 0.52), rgba(187, 219, 242, 0.22));
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.app.room-theme-x .room-visual-overlay__wash {
  background:
    linear-gradient(180deg, rgba(56, 29, 24, 0.24), rgba(130, 82, 58, 0.08) 42%, rgba(255, 248, 240, 0.02) 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 74px);
  mix-blend-mode: multiply;
}

.app.room-theme-x .room-visual-overlay__frame {
  opacity: 0.5;
  border-color: rgba(255, 228, 210, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 248, 240, 0.08);
}

.app.room-theme-x .room-visual-overlay__glow {
  opacity: 0.65;
  background:
    radial-gradient(circle at 18% 24%, rgba(255, 228, 196, 0.18), transparent 26%),
    radial-gradient(circle at 82% 68%, rgba(255, 206, 164, 0.14), transparent 30%),
    linear-gradient(180deg, rgba(255, 244, 232, 0.04), rgba(77, 41, 29, 0.08));
  filter: blur(2px);
}

.app.room-theme-new .room-visual-overlay__wash {
  background:
    linear-gradient(180deg, rgba(163, 213, 241, 0.16), rgba(255, 255, 255, 0.03) 38%, rgba(132, 182, 212, 0.12) 100%),
    radial-gradient(circle at 74% 18%, rgba(255,255,255,0.34), transparent 18%),
    linear-gradient(110deg, rgba(255,255,255,0) 26%, rgba(255,255,255,0.14) 40%, rgba(255,255,255,0.02) 56%);
}

.app.room-theme-new .room-visual-overlay__frame {
  opacity: 0.42;
  border-color: rgba(232, 246, 255, 0.32);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22);
}

.app.room-theme-new .room-visual-overlay__frame--a {
  transform: rotate(-1deg) scale(1.01);
}

.app.room-theme-new .room-visual-overlay__frame--b {
  transform: rotate(3deg) scale(0.96);
}

.app.room-theme-new .room-visual-overlay__glow {
  opacity: 0.7;
  background:
    radial-gradient(circle at 26% 16%, rgba(255,255,255,0.32), transparent 20%),
    radial-gradient(circle at 84% 28%, rgba(208, 236, 255, 0.22), transparent 22%),
    linear-gradient(180deg, rgba(255,255,255,0), rgba(211, 234, 246, 0.08) 68%, rgba(163, 205, 230, 0.12));
}

.app.room-theme-intense.room-theme-x .room-visual-overlay__wash {
  background:
    linear-gradient(180deg, rgba(48, 21, 18, 0.34), rgba(138, 79, 58, 0.12) 42%, rgba(255, 248, 240, 0.02) 100%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0 1px, transparent 1px 68px);
}

.app.room-theme-intense.room-theme-new .room-visual-overlay__wash {
  background:
    linear-gradient(180deg, rgba(148, 205, 236, 0.22), rgba(255,255,255,0.04) 34%, rgba(126, 181, 214, 0.18) 100%),
    radial-gradient(circle at 78% 22%, rgba(255,255,255,0.42), transparent 16%),
    linear-gradient(110deg, rgba(255,255,255,0) 24%, rgba(255,255,255,0.2) 42%, rgba(255,255,255,0.02) 58%);
}

.app.room-theme-x .dialogue-box,
.app.room-theme-x .action-slot {
  background: rgba(255, 248, 242, 0.9);
  border-color: rgba(202, 146, 112, 0.24);
}

.app.room-theme-x .speech-bubble {
  background: linear-gradient(180deg, rgba(255,250,246,0.96), rgba(255,244,233,0.94));
  border-color: rgba(166, 108, 79, 0.28);
  box-shadow: 0 12px 22px rgba(116, 67, 46, 0.1);
}

.app.room-theme-new .dialogue-box,
.app.room-theme-new .action-slot {
  background: rgba(249, 253, 255, 0.84);
  border-color: rgba(174, 216, 236, 0.34);
}

.app.room-theme-new .speech-bubble {
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(244,250,254,0.92));
  border-color: rgba(160, 208, 229, 0.34);
  padding: 14px 16px;
}

.app.room-theme-x .choice-btn:not(.choice-btn--room-card) {
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,250,246,0.98), rgba(252,240,231,0.96));
  border-color: rgba(160, 110, 82, 0.28);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.34), 0 10px 24px rgba(111, 66, 49, 0.08);
}

.app.room-theme-new .choice-btn:not(.choice-btn--room-card) {
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(245,251,255,0.9));
  border-color: rgba(171, 214, 233, 0.34);
  padding: 16px 18px;
  box-shadow: 0 14px 26px rgba(132, 176, 202, 0.08);
}

.choice-btn--room-card {
  min-height: 112px;
  align-items: stretch;
}

.choice-btn__eyebrow {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.choice-btn__title {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--text-main);
}

.choice-btn__desc {
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-sub);
  word-break: keep-all;
}

.choice-btn--room-x {
  background: linear-gradient(135deg, rgba(255,250,245,0.98), rgba(248,232,218,0.96));
  border-color: rgba(161, 106, 78, 0.28);
}

.choice-btn--room-x .choice-btn__eyebrow {
  color: #8f543d;
}

.choice-btn--room-x::before {
  content: '';
  position: absolute;
  inset: 8px;
  border-radius: 16px;
  border: 1px solid rgba(163, 105, 77, 0.14);
  pointer-events: none;
}

.choice-btn--room-new {
  background: linear-gradient(135deg, rgba(255,255,255,0.98), rgba(236,247,252,0.94));
  border-color: rgba(150, 205, 230, 0.38);
}

.choice-btn--room-new .choice-btn__eyebrow {
  color: #5089a7;
}

.choice-btn--room-new::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(110deg, rgba(255,255,255,0) 18%, rgba(255,255,255,0.26) 42%, rgba(255,255,255,0) 62%);
  pointer-events: none;
}

.choice-btn--room-card .arrow {
  align-self: flex-start;
  margin-top: 2px;
}

.scene-transition-card.is-room-x .scene-transition-card__inner {
  background: linear-gradient(180deg, rgba(73, 42, 33, 0.9), rgba(104, 61, 48, 0.78));
  box-shadow: 0 22px 48px rgba(67, 35, 26, 0.24);
}

.scene-transition-card.is-room-new .scene-transition-card__inner {
  background: linear-gradient(180deg, rgba(43, 74, 93, 0.86), rgba(96, 147, 173, 0.58));
  box-shadow: 0 22px 48px rgba(45, 86, 112, 0.24);
}

.scene-transition-card.is-room-intense .scene-transition-card__inner {
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.28);
}

.app.room-theme-x .ending-text-area {
  text-shadow: 0 4px 18px rgba(83, 43, 29, 0.18);
}

.app.room-theme-new .ending-text-area {
  text-shadow: 0 4px 18px rgba(50, 97, 122, 0.16);
}
.choice-btn--room-card {
  position: relative;
  overflow: hidden;
}

.choice-btn--room-card .choice-chip {
  margin-top: 2px;
}
.app.room-theme-x .narration-copy {
  color: #2f2621;
  font-weight: 560;
}

.app.room-theme-new .narration-copy {
  padding-right: 8px;
  letter-spacing: 0.01em;
}

.app.room-theme-intense.room-theme-x .dialogue-box,
.app.room-theme-intense.room-theme-x .action-slot {
  background: rgba(255, 243, 234, 0.94);
  border-color: rgba(171, 109, 78, 0.34);
}

.app.room-theme-intense.room-theme-new .dialogue-box,
.app.room-theme-intense.room-theme-new .action-slot {
  background: rgba(245, 251, 255, 0.9);
  border-color: rgba(129, 192, 224, 0.4);
}

.app.room-theme-intense .room-badge {
  box-shadow: 0 20px 34px rgba(0, 0, 0, 0.14);
}

.dialogue-box.is-compact {
  min-height: 92px;
  padding-top: 11px;
  padding-bottom: 12px;
}

.dialogue-box.is-compact .dialogue-text {
  min-height: 58px;
  max-height: none;
  padding-bottom: 0;
}

.dialogue-box.is-ultra-compact {
  min-height: 74px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.dialogue-box.is-ultra-compact .dialogue-text {
  min-height: 28px;
  max-height: none;
  gap: 6px;
  padding-bottom: 0;
}


/* Glass polish */
:root {
  --panel-bg: linear-gradient(180deg, rgba(255, 255, 255, 0.48) 0%, rgba(255, 255, 255, 0.24) 100%);
  --panel-bg-solid: linear-gradient(180deg, rgba(255, 255, 255, 0.82) 0%, rgba(241, 247, 255, 0.58) 100%);
  --panel-border: rgba(255, 255, 255, 0.5);
  --shadow-soft: 0 24px 44px rgba(93, 74, 110, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.76), inset 0 -18px 32px rgba(255, 255, 255, 0.04);
  --shadow-btn: 0 14px 28px rgba(93, 74, 110, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.62);
  --overlay-bg: rgba(16, 21, 35, 0.24);
  --bg-bottom-fade: linear-gradient(180deg, rgba(244, 248, 255, 0.02) 0%, rgba(244, 248, 255, 0.34) 18%, rgba(244, 248, 255, 0.74) 52%, rgba(244, 248, 255, 0.92) 100%);
}

.app {
  box-shadow: 0 28px 70px rgba(34, 30, 45, 0.14);
}

.scene-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0) 38%),
    radial-gradient(circle at 16% 14%, rgba(255, 255, 255, 0.26), transparent 28%),
    radial-gradient(circle at 84% 22%, rgba(210, 235, 255, 0.16), transparent 24%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  mix-blend-mode: screen;
  opacity: 0.9;
}

.dialogue-box,
.action-slot,
.util-btn,
.icon-btn,
.choice-btn,
.title-menu-btn,
.system-card,
.phone-sheet,
.info-sheet,
.gallery-card,
.cast-card,
.route-preview,
.setup-progress__step {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.dialogue-box::before,
.action-slot::before,
.util-btn::before,
.icon-btn::before,
.choice-btn::before,
.title-menu-btn::before,
.system-card::before,
.phone-sheet::before,
.info-sheet::before,
.gallery-card::before,
.cast-card::before,
.route-preview::before,
.setup-progress__step::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.58) 0%, rgba(255, 255, 255, 0.18) 34%, rgba(255, 255, 255, 0) 62%),
    radial-gradient(circle at 0% 0%, rgba(255, 255, 255, 0.42), transparent 36%);
  pointer-events: none;
}

.icon-btn,
.util-btn,
.title-menu-btn,
.choice-btn,
.dialogue-box,
.action-slot,
.cast-card,
.route-preview,
.setup-progress__step {
  backdrop-filter: blur(24px) saturate(170%);
}

.dialogue-box,
.action-slot {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.2));
  border-color: rgba(255, 255, 255, 0.46);
}

.speech-bubble {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.56));
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 12px 24px rgba(104, 88, 120, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.speech-name-tag {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(255, 204, 224, 0.26));
  border: 1px solid rgba(255, 255, 255, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.choice-btn,
.cast-card,
.route-preview,
.gallery-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.5));
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: var(--shadow-btn);
}

.choice-btn:active,
.choice-btn:hover,
.cast-card:hover,
.title-menu-btn:hover:not(:disabled),
.util-btn:hover,
.util-btn.is-active {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 241, 247, 0.34));
  border-color: rgba(255, 165, 203, 0.46);
  box-shadow: 0 18px 34px rgba(93, 74, 110, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.icon-btn,
.util-btn,
.title-menu-btn {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.12));
  border: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow: var(--shadow-btn);
}

.title-menu-btn--primary,
.util-btn-primary,
.util-btn-primary:hover {
  background: linear-gradient(180deg, rgba(255, 110, 170, 0.62), rgba(242, 61, 130, 0.42));
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 18px 30px rgba(242, 61, 130, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.phone-sheet,
.info-sheet,
.system-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(241, 247, 255, 0.58));
  border: 1px solid rgba(255, 255, 255, 0.46);
  backdrop-filter: blur(30px) saturate(180%);
}

.phone-header {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.22));
  border-bottom: 1px solid rgba(255, 255, 255, 0.32);
  backdrop-filter: blur(24px) saturate(165%);
}

.setup-screen,
.title-screen {
  backdrop-filter: blur(14px) saturate(140%);
}

.setup-progress__step {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.46), rgba(255, 255, 255, 0.24));
  border-color: rgba(255, 255, 255, 0.46);
  box-shadow: var(--shadow-btn);
}

.gallery-card__action {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(255, 244, 248, 0.48));
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.62);
}
/* ===== Final visual readability / logo / portrait pass ===== */
.scene-bg::after {
  opacity: 0.42;
}

.dialogue-box::before,
.action-slot::before,
.choice-btn::before,
.title-menu-btn::before,
.info-sheet::before,
.phone-sheet::before,
.gallery-card::before {
  opacity: 0.34;
}

.dialogue-box,
.action-slot {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.34));
  border-color: rgba(255, 255, 255, 0.58);
}

.narration-copy,
.speech-bubble,
.choice-btn,
.title-menu-btn,
.util-btn,
.sheet-title,
.sheet-kicker,
.sheet-close-btn,
.log-entry,
.filter-chip {
  text-shadow: none;
}

.narration-copy {
  color: #23262d;
  font-weight: 540;
}

.speech-bubble {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.84));
  border-color: rgba(255, 255, 255, 0.52);
  color: #20242a;
  box-shadow: 0 14px 28px rgba(91, 78, 108, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.title-screen__logo,
.logo-mark {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: transparent !important;
  font-size: 0 !important;
}

.title-screen__logo::after,
.logo-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url('./data/assets/titlelogo.png') center / contain no-repeat;
}

.logo-mark {
  width: 60px;
  height: 60px;
}

.action-slot > #logo-state-panel {
  position: absolute;
  inset: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.action-slot > #choice-state-panel {
  position: absolute;
  inset: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.portrait-container .portrait-card.is-image {
  position: relative;
  width: min(360px, 78vw);
  height: min(520px, 60vh);
  border: none;
  border-radius: 0;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  box-shadow: none;
}

.portrait-container .portrait-card.is-image::after {
  content: '';
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 2%;
  height: 14%;
  background: radial-gradient(ellipse at center, rgba(25, 19, 36, 0.26) 0%, rgba(25, 19, 36, 0.08) 48%, rgba(25, 19, 36, 0) 100%);
  filter: blur(14px);
  z-index: -1;
}
.cast-card.is-disabled,
.cast-card:disabled {
  opacity: 0.34;
  cursor: default;
  pointer-events: none;
  transform: none !important;
  box-shadow: none !important;
}

.cast-card.is-disabled .cast-card__role,
.cast-card:disabled .cast-card__role {
  filter: grayscale(0.2);
}
/* ===== Title hero / locked gallery polish ===== */
.title-screen__kicker,
.title-screen__title,
.title-screen__handle,
.title-screen__desc {
  display: none;
}

.title-screen__inner {
  position: relative;
  gap: 20px;
}

.title-screen__brand {
  position: relative;
  align-self: stretch;
  flex: 0 0 auto;
  width: 100%;
  min-height: clamp(360px, 58vh, 520px);
  margin-top: 0;
  margin-bottom: -56px;
  padding: 0 0 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: visible;
  z-index: 1;
}

.title-screen__brand::before {
  content: '';
  position: absolute;
  inset: 0 -24px -18px;
  background: url('./data/assets/title.png') center top / 100% auto no-repeat;
  pointer-events: none;
  filter: drop-shadow(0 22px 36px rgba(62, 44, 72, 0.12));
  animation: none;
  transform-origin: center bottom;
  z-index: 0;
}

.title-screen__logo::before {
  content: '';
  position: absolute;
  inset: 22% 18% 8%;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.42) 0%, rgba(255, 255, 255, 0) 74%);
  filter: blur(20px);
  pointer-events: none;
}

.gallery-card.is-locked .gallery-card__art {
  filter: blur(14px) saturate(0.18) brightness(1.06);
  transform: scale(1.08);
}

.gallery-card.is-locked .gallery-card__art::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.34), rgba(24, 22, 31, 0.42));
}

.gallery-card.is-locked .gallery-card__preview {
  color: rgba(125, 133, 144, 0.72);
}
/* ===== Ending readability ===== */
#overlay-ending::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 48%;
  z-index: 1;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(19, 18, 29, 0.16) 18%, rgba(255, 255, 255, 0.82) 54%, rgba(255, 255, 255, 0.96) 100%);
  pointer-events: none;
}

.ending-text-area {
  position: absolute;
  z-index: 2;
  width: min(calc(100% - 40px), 380px);
  margin: 0 auto;
  padding: 18px 20px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.76));
  border: 1px solid rgba(255, 255, 255, 0.64);
  box-shadow: 0 20px 44px rgba(43, 35, 56, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(22px) saturate(170%);
}

.ending-quote {
  color: #1f232a;
  font-weight: 700;
  text-shadow: none;
}

.ending-result {
  color: #e14d85;
  text-shadow: none;
}

/* ===== Route preview / title motion / portrait lift ===== */
.route-preview {
  display: flex;
  flex-direction: column;
}

.route-preview.is-placeholder {
  min-height: 164px;
  justify-content: center;
  align-items: center;
}

.route-preview.is-placeholder .route-preview__code,
.route-preview.is-placeholder .route-preview__title,
.route-preview.is-placeholder .route-preview__tone,
.route-preview.is-placeholder .route-preview__status {
  display: none;
}

.route-preview.is-placeholder::after {
  content: '';
  width: min(214px, 62vw);
  height: 108px;
  background: url('./data/assets/titlelogo.png') center / contain no-repeat;
  filter: drop-shadow(0 16px 28px rgba(72, 43, 63, 0.14));
  opacity: 0.96;
  animation: route-preview-logo-float 5.6s ease-in-out infinite;
}

.logo-text {
  display: none !important;
}

.title-screen__brand::after {
  content: '';
  position: absolute;
  inset: 6% 1% 5%;
  background:
    radial-gradient(circle at 20% 32%, rgba(255, 248, 252, 0.54), rgba(255, 248, 252, 0) 10%),
    radial-gradient(circle at 34% 26%, rgba(255, 231, 241, 0.34), rgba(255, 231, 241, 0) 14%),
    radial-gradient(circle at 68% 30%, rgba(255, 250, 253, 0.48), rgba(255, 250, 253, 0) 11%),
    radial-gradient(circle at 80% 42%, rgba(255, 218, 233, 0.28), rgba(255, 218, 233, 0) 16%),
    linear-gradient(118deg, rgba(255, 255, 255, 0) 20%, rgba(255, 247, 250, 0.22) 42%, rgba(255, 227, 238, 0.18) 52%, rgba(255, 255, 255, 0) 72%),
    linear-gradient(148deg, rgba(255, 255, 255, 0) 32%, rgba(255, 211, 229, 0.16) 50%, rgba(255, 255, 255, 0) 68%);
  mix-blend-mode: screen;
  opacity: 0.62;
  filter: blur(12px) saturate(1.08);
  pointer-events: none;
  z-index: 1;
  animation: title-bokeh-drift 14s ease-in-out infinite;
}

@keyframes route-preview-logo-float {
  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes title-hero-breathe {
  0%,
  100% {
    transform: scale(1) translateY(0);
  }

  50% {
    transform: scale(1.018) translateY(-4px);
  }
}

@keyframes title-ambient-drift {
  0%,
  100% {
    transform: translate3d(-1.5%, 0, 0) scale(0.98);
    opacity: 0.46;
  }

  50% {
    transform: translate3d(1.5%, -2.5%, 0) scale(1.03);
    opacity: 0.82;
  }
}

@keyframes title-bokeh-drift {
  0%,
  100% {
    transform: translate3d(-1.2%, 1.2%, 0) scale(0.985);
    opacity: 0.5;
  }

  35% {
    transform: translate3d(1.4%, -1.8%, 0) scale(1.02);
    opacity: 0.72;
  }

  68% {
    transform: translate3d(0.6%, -2.4%, 0) scale(1.03);
    opacity: 0.62;
  }
}

.title-screen__menu,
.title-screen__status {
  position: relative;
  z-index: 2;
}

/* ===== Choice chip hide ===== */
.choice-chip {
  display: none !important;
}
/* ===== Ending title banner ===== */
.ending-title-banner {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  left: 18px;
  right: 18px;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 38px;
  padding: 10px 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(36, 31, 46, 0.32), rgba(255, 255, 255, 0.16));
  border: 1px solid rgba(255, 255, 255, 0.52);
  backdrop-filter: blur(16px) saturate(150%);
  box-shadow: 0 10px 26px rgba(20, 15, 29, 0.14);
  color: #ffffff;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-shadow: 0 2px 12px rgba(12, 10, 18, 0.28);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.7s ease 0.18s, transform 0.7s ease 0.18s;
  pointer-events: none;
}

.overlay.is-active .ending-title-banner {
  opacity: 1;
  transform: translateY(0);
}

/* ===== Ending frame / title tune ===== */
.ending-cg {
  position: relative;
  overflow: hidden;
}

.ending-cg::before,
.ending-cg::after {
  content: "";
  position: absolute;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease 0.2s, transform 1s ease 0.2s;
}

.ending-cg::before {
  inset: 16px 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  transform: scale(1.02);
}

.ending-cg::after {
  left: 50%;
  top: 26px;
  width: 112px;
  height: 16px;
  transform: translateX(-50%) translateY(-4px);
  border-top: 1px solid rgba(255, 255, 255, 0.76);
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
}

.overlay.is-active .ending-cg::before,
.overlay.is-active .ending-cg::after {
  opacity: 1;
  transform: none;
}

.overlay.is-active .ending-cg::after {
  transform: translateX(-50%);
}

.ending-title-banner {
  top: max(18px, env(safe-area-inset-top));
  left: 20px;
  right: 20px;
  min-height: 62px;
  padding: 12px 22px 14px;
  border-radius: 26px;
  flex-direction: column;
  gap: 4px;
  background: linear-gradient(180deg, rgba(26, 20, 34, 0.4), rgba(255, 255, 255, 0.14));
  border-color: rgba(255, 255, 255, 0.62);
  box-shadow: 0 12px 32px rgba(20, 15, 29, 0.18);
  backdrop-filter: blur(18px) saturate(155%);
}

.ending-title-kicker {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: rgba(255, 244, 250, 0.82);
}

.ending-title-name {
  display: block;
  font-size: clamp(20px, 5.4vw, 28px);
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1.05;
  color: #ffffff;
  text-shadow: 0 4px 18px rgba(12, 10, 18, 0.34);
}

.ending-title-banner.is-love .ending-title-kicker {
  color: rgba(255, 232, 241, 0.92);
}

.ending-title-banner.is-love .ending-title-name {
  font-size: clamp(26px, 7vw, 36px);
  color: #fff7fb;
}

.ending-title-banner.is-miss .ending-title-name,
.ending-title-banner.is-solo .ending-title-name {
  font-size: clamp(22px, 5.8vw, 30px);
}
/* ===== end ending frame / title tune ===== */

/* ===== Topbar menu hide ===== */
#btn-dev-toggle {
  display: none !important;
}
/* ===== end topbar menu hide ===== */

#overlay-ending::before,
#overlay-ending::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

#overlay-ending::before {
  z-index: 1;
  background:
    radial-gradient(circle at 14% 26%, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0) 16%),
    radial-gradient(circle at 30% 20%, rgba(255, 236, 244, 0.22), rgba(255, 236, 244, 0) 18%),
    radial-gradient(circle at 58% 62%, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 20%);
  filter: blur(20px);
}

#overlay-ending::after {
  z-index: 1;
  background:
    radial-gradient(circle at 78% 24%, rgba(255, 252, 254, 0.3), rgba(255, 252, 254, 0) 14%),
    linear-gradient(118deg, rgba(255, 255, 255, 0) 18%, rgba(255, 255, 255, 0.24) 44%, rgba(255, 255, 255, 0) 72%);
  mix-blend-mode: screen;
  filter: blur(10px);
}

#overlay-ending.is-active::before {
  opacity: 0.95;
  animation: ending-light-cluster 8.4s ease-in-out infinite;
}

#overlay-ending.is-active::after {
  opacity: 0.78;
  animation: ending-light-ribbon 10.6s ease-in-out infinite;
}

.overlay.is-active .ending-cg {
  animation: none !important;
}

.ending-title-banner,
.ending-text-area,
.ending-actions {
  z-index: 2;
}

/* ===== title external links ===== */
.title-screen__social {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  left: 16px;
  z-index: 3;
  width: 70px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 6px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.07));
  box-shadow: 0 8px 16px rgba(92, 53, 81, 0.05);
  backdrop-filter: blur(10px);
}

.title-screen__social-handle {
  font-size: 8px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.06em;
  text-align: left;
  color: rgba(90, 84, 97, 0.72);
  word-break: break-all;
}

.title-screen__social-links {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.title-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 6px 5px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 10px rgba(174, 81, 124, 0.035);
  backdrop-filter: blur(6px);
  color: rgba(39, 38, 47, 0.8);
  text-decoration: none;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.title-link-btn:hover,
.title-link-btn:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 7px 14px rgba(174, 81, 124, 0.065);
  background: rgba(255, 255, 255, 0.16);
}

.title-link-btn:focus-visible {
  outline: 2px solid rgba(242, 61, 130, 0.24);
  outline-offset: 2px;
}

@media (max-width: 430px) {
  .title-screen__social {
    top: max(16px, env(safe-area-inset-top));
    left: 12px;
    width: 64px;
    gap: 4px;
    padding: 5px;
    border-radius: 14px;
  }

  .title-screen__social-links {
    gap: 4px;
  }

  .title-link-btn {
    padding: 5px 4px;
    font-size: 8px;
  }
}

/* ===== Mobile overflow guardrails ===== */
@supports (height: 100dvh) {
  html,
  body,
  #app-container {
    min-height: 100dvh;
  }

  .app {
    height: min(100dvh, 932px);
    max-height: 100dvh;
  }

  @media (min-width: 431px) {
    .app {
      height: min(844px, calc(100dvh - 24px));
      max-height: calc(100dvh - 24px);
    }
  }
}

@supports (height: 100svh) {
  html,
  body,
  #app-container {
    min-height: 100svh;
  }

  .app {
    height: min(100svh, 932px);
    max-height: 100svh;
  }

  @media (min-width: 431px) {
    .app {
      height: min(844px, calc(100svh - 24px));
      max-height: calc(100svh - 24px);
    }
  }
}

.title-screen {
  overflow: hidden;
}

.setup-screen {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

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

.setup-screen__panel {
  height: auto;
  min-height: 100%;
}

.settings-sheet {
  height: auto;
  max-height: min(760px, calc(100dvh - max(10px, env(safe-area-inset-top))));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 430px), (max-height: 820px) {
  #app-container {
    align-items: stretch;
  }

  .app {
    max-width: 100%;
    border-radius: 0;
  }

  .topbar {
    padding-left: 12px;
    padding-right: 12px;
  }

  .topbar-inner {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .top-meta {
    min-width: 0;
  }

  .top-meta .place {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .bottom-ui {
    padding: 12px 12px max(14px, env(safe-area-inset-bottom));
    gap: 10px;
  }

  .action-slot {
    min-height: 92px;
    padding: 10px 12px;
  }

  .state-panel,
  .action-slot > #logo-state-panel,
  .action-slot > #choice-state-panel {
    inset: 10px 12px;
  }

  .choice-list-container {
    gap: 7px;
  }

  .choice-btn {
    padding: 15px 16px;
    min-height: 64px;
    font-size: 14px;
    line-height: 1.4;
    align-items: flex-start;
  }

  .utility-row {
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
  }

  .utility-group {
    flex: 1 1 auto;
    flex-wrap: nowrap;
    min-width: 0;
    gap: 6px;
  }

  .utility-group:first-child .util-btn {
    flex: 1 1 0;
  }

  .utility-group:last-child .util-btn {
    width: auto;
    flex: 0 0 auto;
    min-width: 78px;
    justify-content: center;
  }

  .util-btn {
    flex: 0 1 auto;
    min-width: 0;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 11px;
  }

  .app.is-choice .action-slot {
    min-height: 204px;
    max-height: min(38svh, 320px);
  }

  .phone-sheet {
    height: min(82%, 680px);
    max-height: calc(100% - max(8px, env(safe-area-inset-top)));
    border-radius: 28px 28px 0 0;
  }

  .phone-header {
    padding: 16px 16px 12px;
  }

  #btn-phone-close {
    padding: 0 10px;
    gap: 4px;
    font-size: 11px;
  }

  .phone-profile {
    min-width: 0;
  }

  .phone-name {
    overflow-wrap: anywhere;
  }

  .phone-body {
    padding: 16px 14px max(18px, env(safe-area-inset-bottom));
  }

  .chat-bubble {
    max-width: min(100%, 86%);
  }

  .title-screen__inner {
    justify-content: flex-start;
    gap: 0;
    padding: max(14px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  }

  .title-screen__brand {
    align-self: center;
    aspect-ratio: 884 / 1222;
    min-height: 0;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .title-screen__brand::before {
    inset: 0 -10px -18px;
    background-position: center top;
    background-size: 100% auto;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 99.72%, rgba(0, 0, 0, 0.58) 99.9%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, #000 99.72%, rgba(0, 0, 0, 0.58) 99.9%, transparent 100%);
  }

  .title-screen__menu {
    gap: 10px;
    margin-top: auto;
    padding-top: clamp(8px, 1.6svh, 16px);
  }

  .title-menu-btn {
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 14px;
  }

  .title-screen__status {
    margin-top: 14px;
    padding-bottom: clamp(8px, 1.6svh, 14px);
  }

  .setup-screen__panel {
    padding: max(16px, env(safe-area-inset-top)) 14px max(24px, calc(12px + env(safe-area-inset-bottom)));
    gap: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .setup-brand__title {
    font-size: clamp(28px, 7vw, 34px);
  }

  .setup-brand__desc,
  .setup-section-desc {
    font-size: 13px;
    line-height: 1.45;
  }

  .setup-progress__step {
    padding: 9px 10px;
    font-size: 11px;
  }

  .setup-block,
  .route-preview {
    padding: 16px 14px;
    border-radius: 24px;
  }

  .setup-actions {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin-top: auto;
    padding-top: 12px;
    padding-bottom: max(10px, calc(6px + env(safe-area-inset-bottom)));
    background: linear-gradient(180deg, rgba(255, 245, 249, 0) 0%, rgba(255, 245, 249, 0.5) 30%, rgba(255, 245, 249, 0.5) 100%);
    backdrop-filter: blur(10px);
  }

  .setup-nav-btn,
  .setup-start-btn {
    padding: 14px 16px;
    border-radius: 18px;
    font-size: 14px;
  }

  .info-sheet {
    width: 100%;
    max-height: calc(100dvh - max(8px, env(safe-area-inset-top)));
    padding-left: 14px;
    padding-right: 14px;
  }

  .settings-sheet {
    max-height: calc(100dvh - max(8px, env(safe-area-inset-top)));
  }
}

@media (max-width: 430px) and (max-height: 720px) {
  .app {
    --dialogue-box-min: 124px;
    --dialogue-box-max: clamp(124px, 33vh, 228px);
  }

  .bottom-ui {
    padding: 10px 10px max(12px, env(safe-area-inset-bottom));
    gap: 8px;
  }

  .dialogue-box {
    padding: 11px 12px 12px;
  }

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

  .choice-btn {
    padding: 14px 15px;
    min-height: 60px;
    font-size: 13px;
  }

  .phone-sheet {
    height: min(86%, 640px);
  }

  .title-screen__inner {
    gap: 0;
    padding: max(12px, env(safe-area-inset-top)) 14px max(12px, env(safe-area-inset-bottom));
  }

  .title-screen__brand {
    aspect-ratio: auto;
    min-height: clamp(300px, 49svh, 388px);
    margin-bottom: 0;
  }

  .title-screen__brand::before {
    inset: 0 -8px -14px;
    background-position: center top;
    background-size: 100% auto;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .title-screen__menu {
    margin-top: auto;
    padding-top: clamp(8px, 1.6svh, 14px);
  }

  .title-menu-btn {
    padding: 13px 14px;
    font-size: 13px;
  }

  .app.is-choice .action-slot {
    min-height: 188px;
    max-height: min(40svh, 276px);
  }

  .title-screen__status {
    margin-top: 12px;
    padding-bottom: 6px;
  }

  .setup-brand__kicker,
  .setup-section-kicker {
    font-size: 11px;
  }

  .setup-brand__title {
    font-size: 26px;
  }

  .setup-block,
  .route-preview {
    padding: 14px 12px;
  }

  .setup-actions {
    gap: 8px;
    padding-top: 10px;
    padding-bottom: max(8px, calc(4px + env(safe-area-inset-bottom)));
  }

  .info-sheet,
  .settings-sheet {
    border-radius: 24px 24px 0 0;
  }
}

@media (max-width: 430px) and (min-height: 721px) and (max-height: 780px) {
  .title-screen__brand::before {
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 99.84%, rgba(0, 0, 0, 0.24) 99.94%, transparent 100%);
    mask-image: linear-gradient(180deg, #000 0%, #000 99.84%, rgba(0, 0, 0, 0.24) 99.94%, transparent 100%);
  }
}

/* ===== phone close cue / fade-only / player speech ===== */
#btn-phone-close.is-attention {
  animation: phone-close-attention 1.18s ease-in-out infinite;
  background: rgba(255, 250, 252, 0.96) !important;
  color: var(--primary-dark) !important;
  border-color: rgba(242, 61, 130, 0.26) !important;
  box-shadow: 0 0 0 0 rgba(242, 61, 130, 0.22), 0 10px 18px rgba(242, 61, 130, 0.1) !important;
}

#btn-phone-close.is-attention svg {
  filter: drop-shadow(0 0 8px rgba(242, 61, 130, 0.18));
}

.scene-transition-card.is-fade-only {
  background: rgba(7, 6, 10, 0.9);
  backdrop-filter: none;
}

.scene-transition-card.is-fade-only .scene-transition-card__inner {
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  backdrop-filter: none;
  box-shadow: none;
  opacity: 1;
  transform: none;
}

.scene-transition-card.is-fade-only .scene-transition-card__day,
.scene-transition-card.is-fade-only .scene-transition-card__time,
.scene-transition-card.is-fade-only .scene-transition-card__place,
.scene-transition-card.is-fade-only .scene-transition-card__label {
  display: none;
}

.speech-block.is-player-speech .speech-bubble {
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.96), rgba(248, 239, 225, 0.9));
  border-color: rgba(202, 181, 149, 0.42);
  color: #20242a;
  box-shadow: 0 14px 28px rgba(140, 112, 82, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.speech-block.is-player-speech .speech-name-tag {
  background: linear-gradient(180deg, rgba(255, 249, 240, 0.74), rgba(246, 233, 213, 0.5));
  border: 1px solid rgba(205, 183, 150, 0.38);
  color: #7a6046;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

@keyframes phone-close-attention {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.88;
    box-shadow: 0 0 0 0 rgba(242, 61, 130, 0.18), 0 10px 18px rgba(242, 61, 130, 0.08);
  }

  50% {
    transform: scale(1.08);
    opacity: 1;
    box-shadow: 0 0 0 12px rgba(242, 61, 130, 0), 0 14px 24px rgba(242, 61, 130, 0.12);
  }
}

.phone-confirm-panel {
  position: sticky;
  bottom: -20px;
  z-index: 4;
  margin-top: 14px;
  padding: 14px 14px 6px;
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, rgba(248, 249, 250, 0), rgba(248, 249, 250, 0.96) 24%, rgba(248, 249, 250, 1) 100%);
}

.phone-confirm-text {
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 800;
  color: #3a3f47;
  text-align: center;
  letter-spacing: -0.01em;
}

.phone-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.phone-confirm-btn {
  border: 1px solid rgba(255, 166, 204, 0.24);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  padding: 12px 14px;
  min-height: 44px;
  font-size: 13px;
  font-weight: 800;
  color: #2a2f37;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.04);
}

.phone-confirm-btn.is-confirm {
  background: linear-gradient(180deg, rgba(255, 118, 176, 0.92), rgba(242, 61, 130, 0.84));
  border-color: rgba(242, 61, 130, 0.3);
  color: white;
}

.phone-confirm-btn.is-cancel {
  background: rgba(245, 247, 250, 0.96);
  border-color: rgba(164, 176, 190, 0.2);
  color: #667180;
}

.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-end;
  max-width: 70%;
  padding: 11px 14px;
  border-radius: 18px;
  margin-top: 4px;
  background: linear-gradient(180deg, rgba(238, 247, 255, 0.96), rgba(228, 240, 252, 0.92));
  border: 1px solid rgba(167, 194, 219, 0.38);
  color: #20242a;
  box-shadow: 0 8px 18px rgba(111, 160, 196, 0.12);
}

.chat-typing__label {
  font-size: 12px;
  font-weight: 700;
  color: #51677c;
}

.chat-typing__dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chat-typing__dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(81, 103, 124, 0.75);
  animation: phone-typing-dot 1.05s ease-in-out infinite;
}

.chat-typing__dots i:nth-child(2) {
  animation-delay: 0.14s;
}

.chat-typing__dots i:nth-child(3) {
  animation-delay: 0.28s;
}

#btn-phone-close:disabled {
  opacity: 0.65;
  pointer-events: none;
}

@keyframes phone-typing-dot {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.34;
  }

  50% {
    transform: translateY(-2px);
    opacity: 1;
  }
}

/* ===== setup cast card refresh ===== */
.setup-screen__panel {
  padding: 18px 16px 20px;
  gap: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: calc(124px + env(safe-area-inset-bottom));
}

.setup-step {
  flex: 0 0 auto;
  min-height: auto;
}

.setup-block {
  flex: 0 0 auto;
  padding: 18px 16px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 245, 249, 0.72));
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 16px 36px rgba(153, 91, 121, 0.08);
}

.cast-grid {
  gap: 10px;
}

.cast-card {
  position: relative;
  min-height: 126px;
  padding: 0;
  border-radius: 24px;
  border: 1px solid rgba(255, 210, 228, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 244, 248, 0.92)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), rgba(255, 255, 255, 0));
  box-shadow: 0 14px 28px rgba(122, 80, 105, 0.08);
  overflow: hidden;
}

.cast-card::after {
  content: "";
  position: absolute;
  right: -12px;
  bottom: -10px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--cast-accent, #ff7fa6) 22%, white) 0%, rgba(255, 255, 255, 0) 72%);
  opacity: 0.92;
  pointer-events: none;
}

.cast-card__check {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 216, 228, 0.96);
  background: rgba(255, 255, 255, 0.86);
  color: color-mix(in srgb, var(--cast-accent, #ff7fa6) 80%, #ffffff);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.cast-card__body {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  min-height: 90px;
  padding: 16px 14px 14px;
}

.cast-card--text-only {
  min-height: 118px;
}

.cast-card--text-only .cast-card__body {
  display: block;
  min-height: 0;
  padding-top: 16px;
}

.cast-card__text {
  position: relative;
  z-index: 1;
  max-width: calc(100% - 86px);
}

.cast-card--text-only .cast-card__text {
  max-width: 100%;
  padding-right: 34px;
}

.cast-card__name {
  margin-bottom: 6px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #2f2530;
}

.cast-card__tagline {
  font-size: 12px;
  line-height: 1.5;
  color: rgba(72, 60, 74, 0.78);
  word-break: keep-all;
}

.cast-card__portrait {
  position: relative;
  z-index: 1;
  flex: 0 0 76px;
  width: 76px;
  height: 104px;
  align-self: flex-end;
  background-position: center bottom;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 12px 18px rgba(77, 53, 69, 0.12));
}

.cast-card__portrait.is-empty {
  opacity: 0;
}

.cast-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--cast-accent, #ff7fa6) 34%, white);
  box-shadow: 0 18px 34px rgba(111, 76, 97, 0.12);
}

.cast-card.is-selected {
  border-color: color-mix(in srgb, var(--cast-accent, #ff7fa6) 58%, white);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--cast-accent, #ff7fa6) 8%, white) 0%, rgba(255, 247, 250, 0.96) 100%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0));
  box-shadow: 0 20px 40px color-mix(in srgb, var(--cast-accent, #ff7fa6) 18%, rgba(98, 72, 91, 0.12));
}

.cast-card.is-selected .cast-card__check {
  border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--cast-accent, #ff7fa6) 80%, white), var(--cast-accent, #ff7fa6));
  color: #fff;
  box-shadow: 0 10px 18px color-mix(in srgb, var(--cast-accent, #ff7fa6) 28%, rgba(98, 72, 91, 0.08));
}

.cast-card.is-disabled,
.cast-card:disabled {
  opacity: 0.42;
  filter: grayscale(0.08);
}

.cast-card.is-disabled .cast-card__portrait,
.cast-card:disabled .cast-card__portrait {
  opacity: 0.66;
}

.cast-card:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px color-mix(in srgb, var(--cast-accent, #ff7fa6) 18%, white),
    0 20px 36px rgba(111, 76, 97, 0.14);
}

.route-preview {
  min-height: 118px;
  padding: 16px 18px 14px;
  border-radius: 28px;
  margin-bottom: 4px;
}

@media (max-width: 430px), (max-height: 820px) {
  .setup-screen__panel {
    padding: max(16px, env(safe-area-inset-top)) 14px max(24px, calc(12px + env(safe-area-inset-bottom)));
    gap: 12px;
    scroll-padding-bottom: calc(112px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 430px) and (max-height: 720px) {
  .setup-screen__panel {
    padding: max(14px, env(safe-area-inset-top)) 12px max(18px, calc(10px + env(safe-area-inset-bottom)));
    gap: 10px;
    scroll-padding-bottom: calc(104px + env(safe-area-inset-bottom));
  }
}

.route-preview:not(.is-placeholder) {
  min-height: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.route-preview__code {
  align-self: flex-start;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  letter-spacing: 0.14em;
}

.route-preview:not(.is-placeholder) .route-preview__code {
  align-self: center;
  margin-bottom: 0;
  flex: 0 0 auto;
}

.route-preview__title {
  font-size: 16px;
  line-height: 1.3;
}

.route-preview:not(.is-placeholder) .route-preview__title,
.route-preview:not(.is-placeholder) .route-preview__status {
  display: none !important;
}

.route-preview__tone {
  margin-top: 2px;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-preview:not(.is-placeholder) .route-preview__tone {
  margin-top: 0;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  line-height: 1.36;
  white-space: normal;
  word-break: keep-all;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.route-preview__status {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-top: 0;
}

.ending-cg::before,
.ending-cg::after {
  display: none !important;
  content: none !important;
}

.ending-cg {
  border-radius: 30px;
  -webkit-mask-image: radial-gradient(ellipse 88% 82% at 50% 42%, #000 68%, rgba(0, 0, 0, 0.88) 76%, rgba(0, 0, 0, 0.38) 88%, transparent 100%);
  mask-image: radial-gradient(ellipse 88% 82% at 50% 42%, #000 68%, rgba(0, 0, 0, 0.88) 76%, rgba(0, 0, 0, 0.38) 88%, transparent 100%);
}

/* ===== gameplay clarity pass ===== */
.app.is-playing .scene-bg {
  filter: none;
}

.app.is-playing .scene-bg::after {
  content: none;
  opacity: 0;
}

.app.is-playing .bottom-ui {
  background: transparent;
}

.app.is-playing .dialogue-box {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(248, 250, 255, 0.78));
  border-color: rgba(255, 236, 243, 0.9);
  backdrop-filter: blur(14px) saturate(132%);
  box-shadow: 0 18px 34px rgba(91, 78, 108, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.48);
}

.app.is-playing .dialogue-box::before {
  opacity: 0.12;
}

.app.is-playing .dialogue-box {
  padding-bottom: 14px;
}

.app.is-playing .dialogue-text {
  padding-bottom: 0;
}

.app.is-playing .dialogue-box.is-compact .dialogue-text {
  padding-bottom: 0;
}

.app.is-playing .dialogue-box.is-ultra-compact .dialogue-text {
  padding-bottom: 0;
}

.app.is-playing .dialogue-page-indicator {
  display: none !important;
}

.app.is-playing.has-portrait {
  --dialogue-box-min: 164px;
  --dialogue-box-max: 236px;
  --portrait-anchor-cover: 24px;
  --portrait-anchor-dialogue-reserve: 220px;
  --portrait-anchor-action-shell: 20px;
  --portrait-anchor-utility-row: 36px;
  --portrait-anchor-gap: 10px;
  --portrait-anchor-pad-top: 12px;
  --portrait-anchor-pad-bottom: max(14px, env(safe-area-inset-bottom));
  --portrait-anchor-fallback: calc(
    var(--portrait-anchor-dialogue-reserve)
    + var(--portrait-anchor-action-shell)
    + var(--portrait-anchor-utility-row)
    + (var(--portrait-anchor-gap) * 2)
    + var(--portrait-anchor-pad-top)
    + var(--portrait-anchor-pad-bottom)
    - var(--portrait-anchor-cover)
  );
}

.app.is-playing.has-portrait .portrait-container {
  bottom: var(--portrait-anchor-live, var(--portrait-anchor-fallback));
  height: 60%;
}

.app.is-playing.has-portrait .portrait-card.is-image {
  background-position: center calc(100% + 8px);
}

@media (max-width: 430px) {
  .app.is-playing.has-portrait {
    --dialogue-box-min: 154px;
    --dialogue-box-max: 226px;
    --portrait-anchor-cover: 22px;
    --portrait-anchor-dialogue-reserve: 206px;
    --portrait-anchor-action-shell: 20px;
    --portrait-anchor-utility-row: 34px;
    --portrait-anchor-gap: 10px;
    --portrait-anchor-pad-top: 12px;
    --portrait-anchor-pad-bottom: max(14px, env(safe-area-inset-bottom));
  }

  .app.is-playing.has-portrait .portrait-container {
    height: 58%;
  }

  .app.is-playing.has-portrait .portrait-card.is-image {
    background-position: center calc(100% + 10px);
  }
}

@media (max-width: 430px) and (max-height: 720px) {
  .app.is-playing.has-portrait {
    --dialogue-box-min: 148px;
    --dialogue-box-max: 214px;
    --portrait-anchor-cover: 20px;
    --portrait-anchor-dialogue-reserve: 194px;
    --portrait-anchor-action-shell: 20px;
    --portrait-anchor-utility-row: 34px;
    --portrait-anchor-gap: 8px;
    --portrait-anchor-pad-top: 10px;
    --portrait-anchor-pad-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .app.is-playing.has-portrait .portrait-container {
    height: 56%;
  }

  .app.is-playing.has-portrait .portrait-card.is-image {
    background-position: center calc(100% + 12px);
  }
}

@keyframes ending-light-cluster {
  0% {
    transform: translate3d(-12%, 6%, 0);
  }

  50% {
    transform: translate3d(14%, -4%, 0);
  }

  100% {
    transform: translate3d(-12%, 6%, 0);
  }
}

@keyframes ending-light-ribbon {
  0% {
    transform: translate3d(18%, 8%, 0) rotate(0deg);
  }

  50% {
    transform: translate3d(-16%, -6%, 0) rotate(-2deg);
  }

  100% {
    transform: translate3d(18%, 8%, 0) rotate(0deg);
  }
}
/* ===== Ending theme variants ===== */
#overlay-ending.ending-theme-love::before,
#overlay-ending.ending-theme-love::after,
#overlay-ending.ending-theme-solo::before,
#overlay-ending.ending-theme-solo::after,
#overlay-ending.ending-theme-miss::before,
#overlay-ending.ending-theme-miss::after {
  opacity: 0;
}

.ending-love-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: none;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
  transition: opacity .6s ease;
}

#overlay-ending.ending-theme-love .ending-love-overlay {
  display: block;
}

#overlay-ending.ending-theme-love.is-active .ending-love-overlay {
  opacity: 1;
}

#overlay-ending.ending-theme-love::before,
#overlay-ending.ending-theme-love::after {
  opacity: 0;
  animation: none;
}

.ending-love-heart,
.ending-love-dust {
  position: absolute;
  opacity: 0;
  will-change: transform, opacity;
}

.ending-love-heart {
  --ending-love-scale: 1;
  width: 18px;
  height: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 189, 214, 0.42));
  border-radius: 4px;
  transform: rotate(45deg);
  filter: blur(2px) drop-shadow(0 0 8px rgba(255, 255, 255, 0.74));
  mix-blend-mode: screen;
}

.ending-love-heart::before,
.ending-love-heart::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: inherit;
  border-radius: 50%;
}

.ending-love-heart::before {
  top: -9px;
  left: 0;
}

.ending-love-heart::after {
  top: 0;
  left: -9px;
}

.ending-love-dust {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  filter: blur(4px);
  mix-blend-mode: overlay;
}

.ending-love-overlay > :nth-child(1) {
  left: 18%;
  top: 56%;
  animation: ending-love-heart-drift 4.6s infinite ease-in-out;
}

.ending-love-overlay > :nth-child(2) {
  --ending-love-scale: 0.78;
  left: 71%;
  top: 42%;
  animation: ending-love-heart-drift 5.4s infinite ease-in-out 1.1s;
}

.ending-love-overlay > :nth-child(3) {
  --ending-love-scale: 1.14;
  left: 43%;
  top: 70%;
  animation: ending-love-heart-drift 4.9s infinite ease-in-out 0.45s;
}

.ending-love-overlay > :nth-child(4) {
  --ending-love-scale: 0.92;
  left: 79%;
  top: 78%;
  animation: ending-love-heart-drift 6.1s infinite ease-in-out 2.3s;
}

.ending-love-overlay > :nth-child(5) {
  left: 28%;
  top: 63%;
  animation: ending-love-dust-drift 3.7s infinite ease-in-out 0.75s;
}

.ending-love-overlay > :nth-child(6) {
  left: 59%;
  top: 31%;
  animation: ending-love-dust-drift 4.4s infinite ease-in-out 1.9s;
}

.ending-love-overlay > :nth-child(7) {
  left: 84%;
  top: 57%;
  animation: ending-love-dust-drift 4.9s infinite ease-in-out 1.4s;
}

#overlay-ending.ending-theme-solo::before,
#overlay-ending.ending-theme-solo::after {
  z-index: 1;
  inset: 0;
  mix-blend-mode: screen;
}

#overlay-ending.ending-theme-solo::before {
  background:
    radial-gradient(circle at 14% 24%, rgba(255,255,255,.34) 0 1.2%, rgba(255,255,255,0) 3.8%),
    radial-gradient(circle at 28% 58%, rgba(255,247,226,.28) 0 1.1%, rgba(255,247,226,0) 4%),
    radial-gradient(circle at 64% 16%, rgba(255,255,255,.24) 0 1%, rgba(255,255,255,0) 3.5%),
    radial-gradient(circle at 76% 48%, rgba(255,245,219,.3) 0 1.3%, rgba(255,245,219,0) 4.3%),
    radial-gradient(circle at 88% 72%, rgba(255,255,255,.22) 0 1%, rgba(255,255,255,0) 3.5%),
    radial-gradient(circle at 44% 84%, rgba(255,248,232,.26) 0 1.1%, rgba(255,248,232,0) 3.9%);
  filter: blur(2px);
}

#overlay-ending.ending-theme-solo::after {
  background:
    linear-gradient(118deg, rgba(255,255,255,0) 18%, rgba(255,255,255,.16) 46%, rgba(255,255,255,0) 74%),
    radial-gradient(circle at 20% 18%, rgba(255,255,255,.16), rgba(255,255,255,0) 18%),
    radial-gradient(circle at 72% 62%, rgba(255,245,225,.14), rgba(255,245,225,0) 20%);
  filter: blur(8px);
}

#overlay-ending.ending-theme-solo.is-active::before {
  opacity: .92;
  animation: ending-solo-glints 12s ease-in-out infinite;
}

#overlay-ending.ending-theme-solo.is-active::after {
  opacity: .72;
  animation: ending-solo-ribbon 14s ease-in-out infinite;
}

#overlay-ending.ending-theme-miss::before,
#overlay-ending.ending-theme-miss::after {
  z-index: 1;
  inset: -6% -8%;
  mix-blend-mode: screen;
  filter: blur(18px);
}

#overlay-ending.ending-theme-miss::before {
  background:
    radial-gradient(circle at 18% 28%, rgba(255, 236, 208, .34) 0 8%, rgba(255, 236, 208, 0) 20%),
    radial-gradient(circle at 82% 22%, rgba(255, 229, 188, .28) 0 10%, rgba(255, 229, 188, 0) 24%),
    radial-gradient(circle at 58% 76%, rgba(255, 244, 220, .22) 0 12%, rgba(255, 244, 220, 0) 30%);
}

#overlay-ending.ending-theme-miss::after {
  background:
    radial-gradient(circle at 34% 68%, rgba(255, 239, 214, .2) 0 12%, rgba(255, 239, 214, 0) 30%),
    radial-gradient(circle at 72% 54%, rgba(255, 232, 198, .18) 0 14%, rgba(255, 232, 198, 0) 34%);
}

#overlay-ending.ending-theme-miss.is-active::before {
  opacity: .76;
  animation: ending-miss-orbs-a 8.8s ease-in-out infinite;
}

#overlay-ending.ending-theme-miss.is-active::after {
  opacity: .62;
  animation: ending-miss-orbs-b 11.6s ease-in-out infinite;
}

@keyframes ending-love-heart-drift {
  0% {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(calc(0.62 * var(--ending-love-scale))) rotate(35deg);
  }

  20% {
    opacity: .72;
  }

  50% {
    opacity: .5;
    transform: translate3d(8px, -28px, 0) scale(calc(1.06 * var(--ending-love-scale))) rotate(45deg);
  }

  80% {
    opacity: .18;
  }

  100% {
    opacity: 0;
    transform: translate3d(-6px, -82px, 0) scale(calc(0.84 * var(--ending-love-scale))) rotate(58deg);
  }
}

@keyframes ending-love-dust-drift {
  0% {
    opacity: 0;
    transform: translate3d(0, 10px, 0) scale(0.55);
  }

  30% {
    opacity: .58;
    transform: translate3d(4px, -18px, 0) scale(1.45);
  }

  100% {
    opacity: 0;
    transform: translate3d(-3px, -52px, 0) scale(0.86);
  }
}

@keyframes ending-solo-glints {
  0%,
  100% {
    transform: translate3d(-3%, 4%, 0);
    opacity: .84;
  }

  50% {
    transform: translate3d(4%, -5%, 0);
    opacity: 1;
  }
}

@keyframes ending-solo-ribbon {
  0% {
    transform: translate3d(12%, 8%, 0) rotate(0deg);
  }

  50% {
    transform: translate3d(-10%, -6%, 0) rotate(-2deg);
  }

  100% {
    transform: translate3d(12%, 8%, 0) rotate(0deg);
  }
}

@keyframes ending-miss-orbs-a {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1);
    opacity: .52;
  }

  50% {
    transform: translate3d(3%, -2%, 0) scale(1.05);
    opacity: .88;
  }
}

@keyframes ending-miss-orbs-b {
  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1.02);
    opacity: .4;
  }

  50% {
    transform: translate3d(-4%, 3%, 0) scale(1.08);
    opacity: .72;
  }
}
/* ===== end ending theme variants ===== */

/* ===== ending backdrop refresh ===== */
#overlay-ending {
  background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.1), rgba(20, 16, 28, 0.22) 56%, rgba(12, 10, 18, 0.42) 100%);
}

.ending-backdrop {
  position: absolute;
  inset: -8%;
  z-index: 0;
  background-position: center;
  background-size: cover;
  filter: blur(26px) saturate(120%);
  transform: scale(1.16);
  opacity: 0.92;
  pointer-events: none;
}

.ending-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(12, 10, 18, 0.18) 0%, rgba(12, 10, 18, 0.06) 18%, rgba(255, 255, 255, 0.08) 36%, rgba(12, 10, 18, 0.28) 100%),
    radial-gradient(circle at 50% 24%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 28%);
}

.ending-cg {
  position: relative;
  z-index: 1;
}

.ending-title-banner,
.ending-text-area,
.ending-actions {
  z-index: 2;
}

/* ===== title logo motion terminal override ===== */
.title-screen__logo {
  --title-logo-offset-x: 0px;
  --title-logo-offset-y: 0px;
  --title-logo-rotate-offset: 0deg;
  position: absolute;
  left: auto !important;
  right: clamp(-136px, -6.2vw, -28px) !important;
  top: clamp(-76px, -4.6vw, -12px) !important;
  width: min(416px, 82vw) !important;
  height: min(416px, 82vw) !important;
  margin: 0;
  transform: translate3d(var(--title-logo-offset-x), var(--title-logo-offset-y), 0) rotate(calc(12deg + var(--title-logo-rotate-offset))) !important;
  transform-origin: top right;
  animation: none !important;
  filter: none;
  opacity: 0.96;
  text-shadow: none;
  z-index: 3;
  will-change: transform;
}

.title-screen__logo::before {
  inset: 18% 12% 10%;
}

.app.reduced-motion .title-screen__logo {
  --title-logo-offset-x: 0px;
  --title-logo-offset-y: 0px;
  --title-logo-rotate-offset: 0deg;
}

@media (max-width: 430px) {
  .title-screen__logo {
    right: clamp(-92px, -10vw, -24px) !important;
    top: clamp(-48px, -5.4vw, -10px) !important;
    width: min(252px, 60vw) !important;
    height: min(252px, 60vw) !important;
  }

  .title-screen__logo::before {
    inset: 22% 16% 16%;
  }
}

@media (max-width: 390px) and (max-height: 760px), (max-height: 680px) {
  .title-screen__logo {
    right: clamp(-76px, -8vw, -18px) !important;
    top: clamp(-34px, -4.4vw, -6px) !important;
    width: min(224px, 56vw) !important;
    height: min(224px, 56vw) !important;
  }
}
/* ===== end title logo motion terminal override ===== */

/* ===== setup screen mobile scroll safety ===== */
@media (pointer: coarse) {
  .app.setup-open .setup-screen,
  .app.setup-open .setup-screen.is-active {
    display: flex;
    flex-direction: column;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .app.setup-open .setup-screen__panel {
    flex: 0 0 auto;
    min-height: 100%;
    height: auto !important;
    overflow: visible !important;
    padding-bottom: calc(28px + env(safe-area-inset-bottom));
    scroll-padding-bottom: calc(136px + env(safe-area-inset-bottom));
  }

  .app.setup-open .setup-step,
  .app.setup-open .setup-step.is-active {
    flex: 0 0 auto !important;
    min-height: auto !important;
    overflow: visible;
  }

  .app.setup-open .setup-actions {
    position: static !important;
    bottom: auto;
    margin-top: 18px;
    padding-top: 12px;
    padding-bottom: max(18px, calc(12px + env(safe-area-inset-bottom)));
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
/* ===== end setup screen mobile scroll safety ===== */
