/* ====================================
   HOW I MET YOUR MOTHER — THE GAME
   Style Sheet · 手机端优先
   ==================================== */

/* CSS Variables */
:root {
  --bg-deep:       #0d0805;
  --bg-dark:       #1a100a;
  --bg-mid:        #2a1a10;
  --bg-warm:       #3d2515;
  --gold:          #f4c860;
  --gold-light:    #fde68a;
  --gold-dim:      #b8922a;
  --cream:         #fdf6e3;
  --cream-dim:     #d4c9a8;
  --red:           #e05252;
  --red-dim:       #9b3333;
  --blue:          #5b9bd5;
  --green:         #5db85d;
  --purple:        #9b6dcc;
  --orange:        #e07a30;
  --robin-color:   #e05252;
  --barney-color:  #2a6aad;
  --marshall-color:#5db85d;
  --lily-color:    #e07a30;
  --tracy-color:   #f4c860;
  --karen-color:   #9b6dcc;
  --victoria-color:#e8a8d4;
  --stella-color:  #7ec8c8;
  --font-display:  'Playfair Display', Georgia, serif;
  --font-body:     'Lora', 'Times New Roman', serif;
  --font-mono:     'Special Elite', monospace;
  --r-sm:          8px;
  --r-md:          14px;
  --r-lg:          20px;
  --shadow-gold:   0 0 20px rgba(244,200,96,0.3);
  --shadow-dark:   0 8px 32px rgba(0,0,0,0.8);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: var(--bg-deep);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: none;
}

/* ============================
   SCREENS
   ============================ */
.screen {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* Film Grain Overlay */
.film-grain, .main-film-grain {
  position: absolute; inset: 0; z-index: 100;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  opacity: 0.4;
  mix-blend-mode: overlay;
  animation: grain-shift 0.15s steps(1) infinite;
}

@keyframes grain-shift {
  0%   { background-position: 0px 0px; }
  10%  { background-position: -50px -100px; }
  20%  { background-position: 100px 50px; }
  30%  { background-position: -100px 100px; }
  40%  { background-position: 50px -50px; }
  50%  { background-position: -50px 150px; }
  60%  { background-position: 100px 100px; }
  70%  { background-position: -150px -50px; }
  80%  { background-position: 50px 100px; }
  90%  { background-position: -100px 50px; }
  100% { background-position: 0px 0px; }
}

/* ============================
   MAIN SCREEN
   ============================ */
#screen-main {
  background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
}

/* 英雄照片层 */
.main-hero-photo {
  position: absolute; inset: 0; z-index: 0;
  background: url('assets/hero.jpg') center 25% / cover no-repeat;
  /* 照片本身已有暖金色调，轻度增强对比度即可 */
  filter: brightness(0.75) contrast(1.08) saturate(1.1);
  transform: scale(1.04);
  animation: hero-drift 20s ease-in-out infinite alternate;
}
@keyframes hero-drift {
  from { transform: scale(1.04) translateY(0px); }
  to   { transform: scale(1.08) translateY(-12px); }
}

/* 照片上层：多层渐变融合 */
.main-bg {
  position: absolute; inset: 0; z-index: 1;
  background:
    /* 顶部压暗，让标题更清晰 */
    linear-gradient(to bottom,
      rgba(8,4,2,0.80) 0%,
      rgba(8,4,2,0.15) 28%,
      rgba(8,4,2,0.05) 50%,
      rgba(8,4,2,0.55) 72%,
      rgba(8,4,2,0.96) 100%
    ),
    /* 照片左侧边缘稍微压暗 */
    radial-gradient(ellipse 40% 80% at 0% 50%, rgba(4,2,1,0.3) 0%, transparent 60%),
    /* 右侧同样 */
    radial-gradient(ellipse 40% 80% at 100% 50%, rgba(4,2,1,0.25) 0%, transparent 60%);
}

/* 底部朦胧渐变，让按钮区可读 */
.main-vignette {
  position: absolute; inset: 0; z-index: 2;
  background:
    radial-gradient(ellipse 120% 80% at 50% 100%,
      rgba(8,4,2,0.9) 0%,
      rgba(8,4,2,0.4) 45%,
      transparent 70%
    ),
    radial-gradient(ellipse 80% 40% at 50% 0%,
      rgba(8,4,2,0.7) 0%,
      transparent 60%
    );
}

/* 胶片划痕装饰线 */
.main-film-scratch {
  position: absolute; inset: 0; z-index: 3;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 180px,
      rgba(255,220,120,0.018) 180px,
      rgba(255,220,120,0.018) 181px,
      transparent 181px,
      transparent 320px,
      rgba(255,255,255,0.012) 320px,
      rgba(255,255,255,0.012) 321px
    );
}

.main-content {
  position: relative; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  padding: 36px 28px 32px;
  width: 100%; max-width: 440px;
  /* 让内容偏下，给照片人物留出中间展示区域 */
  justify-content: space-between;
  height: 100%;
}

/* Logo 区 — 贴近顶部 */
.main-logo {
  text-align: center;
  margin-bottom: 0;
  padding-top: env(safe-area-inset-top, 8px);
}

/* 照片角色提示标签 — 中间位置漂浮 */
.main-cast-label {
  position: absolute;
  bottom: 42%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 11;
  display: flex; gap: 6px;
  pointer-events: none;
}
.cast-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(253,246,227,0.55);
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(244,200,96,0.2);
  padding: 3px 8px;
  border-radius: 10px;
  backdrop-filter: blur(2px);
  white-space: nowrap;
}

/* 按钮区 — 贴底部 */
.main-bottom {
  width: 100%;
  display: flex; flex-direction: column; gap: 0;
  padding-bottom: env(safe-area-inset-bottom, 8px);
}

.logo-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--gold-dim);
  text-transform: uppercase;
  margin-bottom: 12px;
  opacity: 0.8;
}

.logo-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 10vw, 52px);
  font-weight: 900;
  color: var(--cream);
  line-height: 1.1;
  letter-spacing: -1px;
  text-shadow:
    0 2px 4px rgba(0,0,0,0.9),
    0 6px 24px rgba(0,0,0,0.8),
    0 0 60px rgba(0,0,0,0.6);
}

.logo-accent {
  color: var(--gold);
  font-style: italic;
  display: block;
  text-shadow: 0 0 40px rgba(244,200,96,0.5), 0 4px 24px rgba(0,0,0,0.8);
}

.logo-subtitle {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13px;
  color: var(--cream-dim);
  margin-top: 10px;
  letter-spacing: 1px;
  opacity: 0.7;
}

/* Main Buttons */
.main-buttons {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%;
  margin-bottom: 20px;
}

.btn-main {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px 24px;
  border: none; border-radius: var(--r-md);
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative; overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, #d4a030, #f4c860, #d4a030);
  background-size: 200% 100%;
  color: var(--bg-deep);
  box-shadow: 0 4px 20px rgba(244,200,96,0.4), 0 2px 8px rgba(0,0,0,0.4);
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 10px rgba(244,200,96,0.3);
}
.btn-primary::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
  background-size: 200% 100%;
  animation: shimmer 3s ease infinite;
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.btn-secondary {
  background: rgba(244,200,96,0.12);
  color: var(--gold);
  border: 1.5px solid rgba(244,200,96,0.4);
}
.btn-secondary:active { transform: scale(0.97); background: rgba(244,200,96,0.2); }

.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--cream-dim);
  border: 1.5px solid rgba(255,255,255,0.1);
}
.btn-ghost:active { transform: scale(0.97); background: rgba(255,255,255,0.08); }

.btn-icon { font-size: 14px; }

.main-footer {
  margin-top: 40px;
  text-align: center;
}
.footer-quote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13px;
  color: var(--cream-dim);
  opacity: 0.5;
}
.footer-ted {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-dim);
  margin-top: 4px;
  opacity: 0.4;
}

/* Decorative elements */
.deco-beer-mug {
  position: absolute;
  font-size: 80px;
  opacity: 0.04;
  top: 10%;
  left: -5%;
  transform: rotate(-15deg);
  z-index: 2;
}
.deco-umbrella {
  position: absolute;
  font-size: 100px;
  opacity: 0.04;
  bottom: 10%;
  right: -5%;
  transform: rotate(20deg);
  z-index: 2;
  color: var(--gold);
}

/* ============================
   SCREEN HEADER (Seasons, Characters)
   ============================ */
.screen-header {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px;
  background: rgba(13,8,5,0.95);
  border-bottom: 1px solid rgba(244,200,96,0.15);
  z-index: 50;
  backdrop-filter: blur(10px);
}

.btn-back {
  background: none; border: none;
  color: var(--gold);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
  white-space: nowrap;
}

.screen-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--cream);
}

/* ============================
   SEASONS GRID
   ============================ */
#screen-seasons {
  background: var(--bg-deep);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.seasons-grid {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.season-card {
  background: var(--bg-mid);
  border: 1.5px solid rgba(244,200,96,0.15);
  border-radius: var(--r-md);
  padding: 20px 16px;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.season-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.season-card:active { transform: scale(0.97); }
.season-card.unlocked:active::before,
.season-card.unlocked:hover::before { transform: scaleX(1); }

.season-card.locked {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.season-num {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 900;
  color: rgba(244,200,96,0.3);
  line-height: 1;
}
.season-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--cream-dim);
  text-transform: uppercase;
  margin-top: 4px;
}
.season-title {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--cream);
  margin-top: 8px;
  line-height: 1.4;
}
.season-progress {
  margin-top: 10px;
  height: 2px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.season-progress-bar {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.5s ease;
}
.season-lock-icon {
  position: absolute; top: 12px; right: 12px;
  font-size: 16px; opacity: 0.5;
}

/* ============================
   CHARACTERS SCREEN
   ============================ */
#screen-characters {
  background: var(--bg-deep);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.characters-list {
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}

.character-card {
  background: var(--bg-mid);
  border-radius: var(--r-md);
  padding: 16px;
  display: flex; align-items: center; gap: 16px;
  border-left: 4px solid var(--gold);
  transition: all 0.2s ease;
}

.char-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  border: 2px solid rgba(255,255,255,0.15);
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}
/* 头像使用图片时隐藏 emoji */
.char-avatar.has-photo {
  font-size: 0;
  background-size: cover !important;
  background-position: center top !important;
  background-repeat: no-repeat !important;
  border-color: rgba(255,255,255,0.25);
}
.char-info { flex: 1; min-width: 0; }
.char-name {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700;
  color: var(--cream);
}
.char-role {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--cream-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
  opacity: 0.6;
}
.char-affinity-wrap {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
}
.char-affinity-bar {
  flex: 1; height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px; overflow: hidden;
}
.char-affinity-fill {
  height: 100%; border-radius: 4px;
  transition: width 0.6s ease;
}
.char-affinity-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cream-dim);
  min-width: 28px; text-align: right;
}

/* ============================
   GAME SCREEN
   ============================ */
#screen-game {
  background: var(--bg-deep);
  display: flex; flex-direction: column;
}

/* Top Bar */
.game-topbar {
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 60;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.btn-icon-sm {
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--cream);
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon-sm:active { transform: scale(0.9); background: rgba(244,200,96,0.3); }

.episode-info {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--cream-dim);
  text-transform: uppercase;
  background: rgba(0,0,0,0.5);
  padding: 6px 12px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255,255,255,0.1);
}

/* Scene Background */
.scene-bg {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 58%;
  background: var(--bg-dark);
  overflow: hidden;
  transition: background 0.6s ease;
}

.scene-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom,
    rgba(0,0,0,0.2) 0%,
    rgba(0,0,0,0.1) 60%,
    rgba(13,8,5,0.9) 100%);
  z-index: 2;
}

/* Scene backgrounds (CSS) */
.scene-bg.bg-mclarens {
  background:
    radial-gradient(circle at 70% 40%, rgba(200,120,30,0.4) 0%, transparent 50%),
    radial-gradient(circle at 20% 60%, rgba(180,100,20,0.3) 0%, transparent 40%),
    linear-gradient(to bottom, #1a0d05 0%, #2d1508 50%, #1a0d05 100%);
}
.scene-bg.bg-mclarens::before {
  content: '';
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 60px,
      rgba(180,100,20,0.05) 60px,
      rgba(180,100,20,0.05) 61px
    );
  z-index: 1;
}

.scene-bg.bg-apartment {
  background:
    radial-gradient(circle at 50% 30%, rgba(244,200,96,0.15) 0%, transparent 60%),
    linear-gradient(to bottom, #0d1a2a 0%, #1a2d3d 50%, #0d1219 100%);
}

.scene-bg.bg-gnb {
  background:
    radial-gradient(circle at 80% 20%, rgba(100,150,220,0.2) 0%, transparent 50%),
    linear-gradient(to bottom, #050d1a 0%, #0d1a2a 60%, #050d14 100%);
}

.scene-bg.bg-rooftop {
  background:
    radial-gradient(circle at 50% 0%, rgba(50,80,140,0.4) 0%, transparent 60%),
    radial-gradient(circle at 20% 80%, rgba(244,200,96,0.1) 0%, transparent 40%),
    linear-gradient(to bottom, #050810 0%, #0d1220 60%, #050810 100%);
}

.scene-bg.bg-university {
  background:
    radial-gradient(circle at 50% 40%, rgba(80,140,80,0.2) 0%, transparent 60%),
    linear-gradient(to bottom, #080d08 0%, #0f1a0f 60%, #080d08 100%);
}

/* 场景背景星空装饰 */
.scene-bg.bg-rooftop::after {
  content: '· · ⋆ · ✦ · ⋆ · · · ✦ ·';
  position: absolute;
  top: 20%;
  left: 10%;
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 8px;
  z-index: 1;
}

/* Character Area */
.character-area {
  position: absolute;
  /* 上移，避免与对话框重叠：scene-bg 占 58%，dialogue-box 从 55% 开始，留出足够间距 */
  bottom: 8%;
  left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center;
  z-index: 3;
  padding-top: 28px;
}

.character-sprite {
  width: 130px; height: 200px;
  display: flex; align-items: flex-end; justify-content: center;
  font-size: 90px;
  line-height: 1;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.8));
  transition: all 0.4s ease;
  animation: sprite-idle 4s ease-in-out infinite;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

/* 图片立绘模式 */
.character-sprite.photo-mode {
  font-size: 0;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  /* 底部渐变融入场景 */
  -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
  filter: drop-shadow(0 10px 40px rgba(0,0,0,0.9)) brightness(0.95) contrast(1.05);
}
@keyframes sprite-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.character-sprite.entering {
  animation: sprite-enter 0.4s ease forwards, sprite-idle 4s 0.4s ease-in-out infinite;
}
/* photo-mode + entering 组合时确保动画正常 */
.character-sprite.photo-mode.entering {
  animation: sprite-enter 0.4s ease forwards, sprite-idle 4s 0.4s ease-in-out infinite;
}
@keyframes sprite-enter {
  from { opacity: 0; transform: translateX(-30px) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.character-name-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(0,0,0,0.7);
  padding: 4px 12px;
  border-radius: 10px;
  border: 1px solid rgba(244,200,96,0.35);
  /* 脱离文档流，悬浮在立绘顶部左侧 */
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  backdrop-filter: blur(4px);
}
.character-name-tag.visible { opacity: 1; }

/* Vignette */
.vignette {
  position: absolute; inset: 0; z-index: 5;
  background: radial-gradient(ellipse 100% 100% at 50% 50%,
    transparent 50%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
}

/* Affinity Popup */
.affinity-popup {
  position: absolute;
  top: 60%; left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  font-family: var(--font-display);
  font-size: 18px; font-weight: 700;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(0,0,0,0.8);
  pointer-events: none;
  opacity: 0;
}
.affinity-popup.show {
  animation: popup-float 1.8s ease forwards;
}
@keyframes popup-float {
  0%   { opacity: 0; transform: translateX(-50%) translateY(0); }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* Affinity Panel */
.affinity-panel {
  position: absolute;
  top: 60px; right: 0;
  width: 200px;
  background: rgba(10,6,3,0.95);
  border: 1px solid rgba(244,200,96,0.2);
  border-radius: var(--r-md) 0 0 var(--r-md);
  padding: 16px;
  z-index: 65;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  backdrop-filter: blur(10px);
}
.affinity-panel.open { transform: translateX(0); }

.affinity-panel-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 12px;
}

.affinity-bars { display: flex; flex-direction: column; gap: 10px; }

.affinity-bar-row {
  display: flex; flex-direction: column; gap: 3px;
}
.affinity-bar-header {
  display: flex; justify-content: space-between; align-items: center;
}
.affinity-char-name {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--cream-dim);
  letter-spacing: 0.5px;
}
.affinity-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--cream-dim);
}
.affinity-bar-track {
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px; overflow: hidden;
}
.affinity-bar-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.6s ease;
}

.btn-close-panel {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none;
  color: var(--cream-dim);
  font-size: 14px; cursor: pointer;
}

/* ============================
   DIALOGUE BOX
   ============================ */
.dialogue-box {
  position: absolute;
  left: 0; right: 0;
  top: 55%;
  z-index: 50;
  background: linear-gradient(to bottom,
    rgba(8,4,2,0.97) 0%,
    rgba(13,8,5,0.98) 100%);
  border-top: 1.5px solid rgba(244,200,96,0.25);
  padding: 20px 20px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-height: 140px;
  display: flex; flex-direction: column;
}

.dialogue-speaker {
  font-family: var(--font-display);
  font-size: 15px; font-weight: 700;
  color: var(--gold);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.dialogue-text {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  color: var(--cream);
  flex: 1;
}
.dialogue-text .cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: var(--gold);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: blink 0.7s step-end infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.dialogue-advance {
  display: flex; gap: 4px;
  justify-content: flex-end;
  margin-top: 10px;
}
.advance-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--gold-dim);
  animation: bounce-dot 1.2s ease-in-out infinite;
}
.advance-dot:nth-child(2) { animation-delay: 0.15s; }
.advance-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce-dot {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-4px); opacity: 1; }
}

.dialogue-advance.hidden { opacity: 0; }

/* ============================
   CHOICES AREA
   ============================ */
.choices-area {
  position: absolute;
  left: 0; right: 0;
  top: 52%;
  bottom: 0;
  z-index: 55;
  background: rgba(8,4,2,0.98);
  border-top: 1.5px solid rgba(244,200,96,0.25);
  padding: 16px 16px 20px;
  display: flex; flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.choices-prompt {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-dim);
  text-align: center;
  margin-bottom: 12px;
  opacity: 0.7;
}

.choices-list {
  display: flex; flex-direction: column; gap: 10px;
  flex: 1;
}

.choice-btn {
  background: rgba(244,200,96,0.06);
  border: 1.5px solid rgba(244,200,96,0.2);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.choice-btn:active,
.choice-btn:hover {
  background: rgba(244,200,96,0.14);
  border-color: rgba(244,200,96,0.5);
  transform: translateX(4px);
}

.choice-btn::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--gold);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform 0.2s ease;
}
.choice-btn:active::before,
.choice-btn:hover::before { transform: scaleY(1); }

.choice-text {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--cream);
  line-height: 1.5;
}

.choice-effect {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-top: 6px;
}

.effect-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  letter-spacing: 0.5px;
}
.effect-tag.positive { color: #7ed98a; }
.effect-tag.negative { color: #e07070; }

/* ============================
   MENU OVERLAY
   ============================ */
.menu-overlay {
  position: absolute; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}

.menu-panel {
  background: var(--bg-dark);
  border: 1.5px solid rgba(244,200,96,0.2);
  border-radius: var(--r-lg);
  padding: 24px;
  width: min(300px, 85vw);
  display: flex; flex-direction: column; gap: 10px;
}

.menu-title {
  font-family: var(--font-display);
  font-size: 20px; font-weight: 700;
  color: var(--gold);
  margin-bottom: 6px;
  text-align: center;
}

.btn-menu-item {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--r-sm);
  padding: 13px 16px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--cream);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-menu-item:active { background: rgba(244,200,96,0.15); }

.btn-menu-close {
  background: none; border: none;
  color: var(--gold-dim);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 1px;
  cursor: pointer;
  padding: 8px;
  text-align: center;
  margin-top: 4px;
}

/* ============================
   ACHIEVEMENT POPUP
   ============================ */
.achievement-popup {
  position: absolute;
  top: 70px; left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  background: linear-gradient(135deg, var(--bg-dark), var(--bg-mid));
  border: 1.5px solid var(--gold);
  border-radius: var(--r-md);
  padding: 14px 18px;
  min-width: 220px;
  box-shadow: var(--shadow-gold), var(--shadow-dark);
  animation: achievement-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes achievement-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px) scale(0.8); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.achievement-inner {
  display: flex; align-items: center; gap: 12px;
}

.achievement-icon {
  font-size: 28px;
  animation: spin-once 0.6s ease;
}
@keyframes spin-once {
  from { transform: rotateY(90deg); }
  to   { transform: rotateY(0); }
}

.achievement-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 3px;
}

.achievement-name {
  font-family: var(--font-display);
  font-size: 16px; font-weight: 700;
  color: var(--gold);
}

/* ============================
   EPISODE END SCREEN
   ============================ */
#screen-episode-end {
  background: var(--bg-deep);
  display: flex; align-items: center; justify-content: center;
}

.episode-end-content {
  position: relative; z-index: 10;
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 28px;
  width: 100%; max-width: 440px;
  gap: 16px;
}

.episode-end-title {
  font-family: var(--font-display);
  font-size: 28px; font-weight: 900;
  color: var(--gold);
  text-align: center;
  font-style: italic;
}

.episode-end-subtitle {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--cream-dim);
  text-transform: uppercase;
  opacity: 0.6;
}

.episode-end-summary {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--cream-dim);
  text-align: center;
  line-height: 1.6;
  font-style: italic;
  max-width: 320px;
  opacity: 0.8;
}

.episode-affinity-changes {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin: 8px 0;
}
.affinity-change-item {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
}
.affinity-change-item.up { color: #7ed98a; border-color: rgba(126,217,138,0.3); }
.affinity-change-item.down { color: #e07070; border-color: rgba(224,112,112,0.3); }

/* ============================
   SCROLLBAR
   ============================ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(244,200,96,0.3); border-radius: 4px; }

/* Coming Soon Modal */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================
   SCENE TRANSITION
   ============================ */
.scene-transition {
  position: fixed; inset: 0; z-index: 999;
  background: var(--bg-deep);
  pointer-events: none;
  opacity: 0;
}
.scene-transition.flash {
  animation: film-flash 0.6s ease forwards;
}
@keyframes film-flash {
  0%   { opacity: 0; }
  30%  { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================
   RESPONSIVE
   ============================ */
@media (min-width: 480px) {
  .dialogue-text { font-size: 16px; }
  .choice-text { font-size: 15px; }
  .character-sprite { width: 160px; height: 240px; font-size: 110px; }
  .character-sprite.photo-mode { font-size: 0; }
}

@media (min-width: 768px) {
  .scene-bg { height: 55%; }
  .dialogue-box { top: 52%; }
  .choices-area { top: 50%; }
  .dialogue-text { font-size: 17px; }
}

/* Safe area for iPhone notch */
@supports (padding-top: env(safe-area-inset-top)) {
  .game-topbar { padding-top: max(12px, env(safe-area-inset-top)); }
  .choices-area { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
}

/* ============================
   手机端封面图切换（竖版）
   兼容微信WebView：同时检测宽度和触控设备
   ============================ */
@media (max-width: 767px) {
  .main-hero-photo {
    background-image: url('assets/hero-mobile.jpg');
    background-position: center 20%;
    background-size: cover;
  }
}
/* 微信/安卓 WebView 可能以980px渲染，用 pointer:coarse 识别触屏设备 */
@media (pointer: coarse) and (max-width: 1024px) {
  .main-hero-photo {
    background-image: url('assets/hero-mobile.jpg');
    background-position: center 20%;
    background-size: cover;
  }
}
