:root {
  --bg-deep: #f4f5f8;
  --surface: rgba(255, 255, 255, 0.93);
  --surface-solid: #ffffff;
  --surface-soft: #f7f8fb;
  --border: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text-main: #161822;
  --text-sub: #52586e;
  --text-muted: #8b91a7;
  --accent: #e80b76;
  --accent-soft: rgba(232, 11, 118, 0.1);
  --blue: #2563eb;
  --gold: #d97706;
  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  background: #e9ecf2;
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg-deep);
  box-shadow: 0 0 50px rgba(15, 23, 42, 0.16);
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  z-index: 0;
}

.bg-vignette {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(255, 255, 255, 0.04) 28%,
    rgba(15, 23, 42, 0.06) 65%,
    rgba(255, 255, 255, 0.72) 100%
  );
  z-index: 1;
  pointer-events: none;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

/* ==================== TITLE SCREEN ==================== */
.screen-title {
  gap: clamp(12px, 2.6dvh, 24px);
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 24px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: #fff;
}

.title-hero {
  flex-shrink: 0;
}

.title-sub-en {
  margin-bottom: 10px;
  color: #cf096b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.title-season {
  margin-bottom: 10px;
  color: #cf096b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.title-num {
  margin-left: 4px;
  font-style: normal;
  font-size: 0.42em;
  vertical-align: 0.62em;
  color: #cf096b;
  letter-spacing: 0;
}

.title-main {
  color: #1b1935;
  font-size: clamp(44px, 9dvh, 76px);
  font-weight: 800;
  letter-spacing: -0.08em;
  line-height: 0.98;
}

.title-tagline {
  margin-top: 14px;
  color: var(--text-sub);
  font-size: 14px;
  line-height: 1.55;
}

.title-photo {
  min-height: 80px;
  flex: 1;
  border-radius: 3px 28px 3px 3px;
  background: linear-gradient(125deg, #2b244742, #18152b10),
    url('assets/bg_hall.webp') center 48% / cover;
}

.screen-title .title-actions {
  flex-shrink: 0;
}

.screen-title .btn-primary {
  background: #cf096b;
}

.title-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary {
  width: 100%;
  padding: 15px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #e80b76 0%, #c70068 100%);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(232, 11, 118, 0.28);
  transition: transform 0.12s ease;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-ghost span {
  color: var(--accent);
  font-weight: 700;
}

.title-foot {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== MODAL ==================== */
.screen-modal {
  z-index: 20;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(10px);
  justify-content: center;
  padding: 24px;
}

.modal-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 26px 22px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
}

.modal-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent);
}

.modal-card h2 {
  margin-top: 6px;
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
}

.modal-desc {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.5;
}

.name-input-grid {
  display: grid;
  grid-template-columns: 1fr 1.6fr;
  gap: 10px;
  margin-top: 16px;
}

.field-lbl {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.modal-card input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #f8f9fc;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  outline: none;
}

.modal-card input:focus {
  border-color: var(--accent);
  background: #ffffff;
}

.field-error {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 10px;
  margin-top: 18px;
}

/* ==================== GAME SCREEN ==================== */
.screen-game {
  justify-content: space-between;
}

.top-bar {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 10px) + 10px) 14px 10px;
}

.top-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 5px 9px;
  border-left: 3px solid #ef167d;
  background: #fff;
  border-radius: 0 5px 5px 0;
}

.hud-day {
  color: #cf096b;
  font-size: 14px;
  font-weight: 800;
}

.hud-scene {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 3px;
  color: var(--text-sub);
  font-size: 10px;
}

.date-pass {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 7px;
  border-radius: 5px;
  background: #cf096b;
  color: #fff;
  white-space: nowrap;
  font-size: 10px;
}

.date-pass strong {
  font-size: 13px;
}

.top-tools {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 5px;
}

.icon-btn {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* 예능 자막 / 토스트 */
.cue-banner {
  position: absolute;
  top: calc(env(safe-area-inset-top, 10px) + 56px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  max-width: calc(100% - 36px);
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(232, 11, 118, 0.25);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
  font-size: 12px;
  font-weight: 700;
  color: #be123c;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: fadeSlideDown 0.25s ease;
}

.toast-stack {
  position: absolute;
  top: calc(env(safe-area-inset-top, 10px) + 94px);
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.toast-pill {
  padding: 7px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(232, 11, 118, 0.35);
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.14);
  animation: fadeSlideDown 0.22s ease;
}

/* 타이머 */
.timer-bar-wrap {
  position: relative;
  z-index: 9;
  margin: 4px 18px 0;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(232, 11, 118, 0.45);
  box-shadow: 0 6px 18px rgba(232, 11, 118, 0.15);
}

.timer-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.timer-track {
  height: 5px;
  border-radius: 999px;
  background: #ffe4e6;
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e80b76, #fb7185);
  transition: width 0.2s linear;
}

/* ==================== CHARACTER CUTOUT STANDING ==================== */
.stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  overflow: hidden;
  pointer-events: none;
}

.stand-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
}

.char-stand {
  max-width: 92%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 12px 24px rgba(15, 23, 42, 0.25));
}

/* ==================== DIALOGUE & CHOICES (WHITE TONE) ==================== */
.dialogue-dock {
  position: relative;
  z-index: 8;
  padding: 0 14px 26px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choices-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.choice-btn {
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.42;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
}

.choice-btn:active {
  transform: scale(0.985);
  border-color: var(--accent);
  background: #fff1f2;
}

.dialogue-box {
  position: relative;
  min-height: 112px;
  padding: 14px 16px 12px;
  border-radius: 20px;
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.18);
  cursor: pointer;
  user-select: none;
  display: flex;
  flex-direction: column;
}

.dialogue-head {
  display: flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 6px;
}

.dialogue-head.empty {
  display: none;
}

.speaker-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.speaker-badge.female {
  border-color: #94a3b8;
  background: #f1f5f9;
  color: #475569;
}

.speaker-badge.sion {
  border-color: #8b5cf6;
  background: #f5f3ff;
  color: #6d28d9;
}

.speaker-badge.yushi {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1d4ed8;
}

.speaker-badge.sakuya {
  border-color: #ec4899;
  background: #fdf2f8;
  color: #be185d;
}

.speaker-badge.riku {
  border-color: #ef4444;
  background: #fef2f2;
  color: #b91c1c;
}

.dialogue-text {
  font-size: 15px;
  line-height: 1.62;
  font-weight: 500;
  color: var(--text-main);
  word-break: keep-all;
  flex: 1;
}

.dialogue-text.narration {
  color: #3f4458;
}

.dialogue-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.dialogue-controls {
  display: flex;
  gap: 6px;
}

.mini-ctrl {
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f1f5f9;
  color: var(--text-sub);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.mini-ctrl.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.next-arrow {
  font-size: 13px;
  color: var(--accent);
  animation: bob 1.1s infinite ease-in-out;
}

/* ==================== BOTTOM NAV (WHITE 4 TABS) ==================== */
.bottom-nav {
  position: relative;
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(env(safe-area-inset-bottom, 8px) + 8px);
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
}

.nav-item {
  position: relative;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 4px;
  cursor: pointer;
}

.nav-item.active {
  color: var(--accent);
}

.nav-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: #f48bb8;
  transition: color 0.15s ease, transform 0.15s ease;
}

.nav-item.active .nav-ico {
  color: #ec167c;
}

.nav-lbl {
  font-size: 11px;
  font-weight: 700;
}

.nav-badge {
  position: absolute;
  top: 3px;
  right: 22%;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==================== MIDNIGHT REVEAL ==================== */
.screen-reveal {
  z-index: 25;
  background: radial-gradient(circle at 50% 42%, rgba(232, 11, 118, 0.16), #0d0f17 72%);
  justify-content: center;
  align-items: center;
  padding: 28px;
  text-align: center;
}

.reveal-inner {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.reveal-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: #fb7185;
}

.reveal-lead {
  margin-top: 14px;
  font-size: 15px;
  color: #cbd5e1;
}

.reveal-status {
  margin-top: 6px;
  font-size: 26px;
  font-weight: 800;
  color: #ffffff;
}

.reveal-status.no {
  color: #94a3b8;
}

.reveal-msg-list {
  width: 100%;
  max-height: 46dvh;
  overflow-y: auto;
  margin: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reveal-msg-card {
  width: 100%;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  text-align: left;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.reveal-from {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  margin-bottom: 6px;
}

.reveal-msg-card p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-main);
  font-weight: 500;
}

.day-jump-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.day-jump-btn {
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #ffffff;
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.day-jump-btn:active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ==================== BOTTOM SHEET PANELS (WHITE) ==================== */
.sheet-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
}

.sheet-panel {
  width: 100%;
  max-height: 84dvh;
  background: #ffffff;
  border-top: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheetUp 0.22s ease-out;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.sheet-head h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
}

.sheet-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #f8f9fc;
  color: var(--text-sub);
  font-size: 14px;
  cursor: pointer;
}

.sheet-body {
  padding: 16px 18px calc(env(safe-area-inset-bottom, 16px) + 20px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cast-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.cast-card {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.cast-avatar {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}

.cast-avatar-text {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--accent);
  background: #fff1f2;
  border: 1px solid rgba(232, 11, 118, 0.22);
}

.cast-info {
  flex: 1;
  min-width: 0;
}

.cast-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.cast-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.cast-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #be123c;
}

.cast-badge.catfish {
  background: #fef3c7;
  color: #b45309;
}

.cast-badge.girl {
  background: #eff6ff;
  color: #1d4ed8;
}

.cast-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-sub);
}

.cast-note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-muted);
}

.meter-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.meter-item {
  flex: 1;
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 600;
}

.meter-bar {
  height: 5px;
  border-radius: 999px;
  background: #e2e8f0;
  margin-top: 4px;
  overflow: hidden;
}

.meter-fill-like {
  height: 100%;
  background: var(--accent);
}

.meter-fill-jealous {
  height: 100%;
  background: var(--gold);
}

.signal-card, .ending-card, .log-item {
  padding: 14px;
  border-radius: 14px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.signal-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 6px;
}

.signal-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
}

.ending-card.locked {
  opacity: 0.55;
}

.ending-card h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.ending-card p {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.45;
}

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

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

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

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

.title-main { font-size: clamp(38px, 12vw, 55px); white-space: nowrap; }
.title-hero { padding-top: 12px; }
.title-photo { min-height: 96px; }
.btn-primary, .screen-title .btn-primary { background: #d80a71; color: white; }
.btn-ghost, .icon-btn, .mini-ctrl, .day-jump-btn { color: #ac095b; border-color: #f3afcd; }
.day-jump-btn:disabled { opacity: 0.45; cursor: not-allowed; color: #9ca3af; border-color: #e5e7eb; background: #f3f4f6; }
.choice-btn { color: #930747; background: #fff7fb; border-color: #ee9fc2; }
.choice-btn:focus-visible, button:focus-visible { outline: 3px solid #ec167c; outline-offset: 2px; }
.choice-btn:disabled { color: #64545c; }
.dialogue-text, .choice-btn, .signal-body, .reveal-msg-card p, .ending-card p {
  word-break: keep-all; overflow-wrap: break-word; text-wrap: pretty;
  line-height: 1.65; white-space: pre-line;
}
.choices-wrap { max-height: 67dvh; overflow-y: auto; }
