/* ============================================
   Cat & Mushroom - Visual Novel Styles
   复古西幻 Retro Western Fantasy
   ============================================ */

#story-container {
  width: 100vw; height: 100vh; height: 100dvh;
  position: relative; overflow: hidden;
  font-family: var(--font-body);
  touch-action: manipulation;
}

/* ===== Scene Backgrounds ===== */
#scene-bg {
  position: absolute; inset: 0; z-index: 0;
  transition: background 1.2s ease;
}
#bg-overlay {
  position: absolute; inset: 0;
  transition: opacity 1s;
}
#bg-particles {
  position: absolute; inset: 0; pointer-events: none;
}

/* Room scene */
#scene-bg.room {
  background: radial-gradient(ellipse at 60% 30%, #2a1a3a 0%, #1a0e24 30%, #0e0818 70%, #060410 100%);
}
#scene-bg.room #bg-overlay {
  background:
    /* Window light */
    radial-gradient(ellipse at 60% 25%, rgba(180,160,200,0.15) 0%, transparent 50%),
    /* Stone wall texture hints */
    repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(255,255,255,0.01) 40px, rgba(255,255,255,0.01) 41px),
    /* Floor */
    linear-gradient(0deg, rgba(30,20,40,0.6) 0%, transparent 30%);
}

/* Forest scene */
#scene-bg.forest {
  background: radial-gradient(ellipse at 40% 50%, #0d1a0d 0%, #060d06 50%, #030603 100%);
}
#scene-bg.forest #bg-overlay {
  background:
    radial-gradient(ellipse at 30% 40%, rgba(100,160,80,0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(80,140,60,0.04) 0%, transparent 40%),
    repeating-linear-gradient(90deg, transparent, transparent 60px, rgba(255,255,255,0.008) 60px, rgba(255,255,255,0.008) 61px);
}

/* Mushroom scene */
#scene-bg.mushroom {
  background: radial-gradient(ellipse at 50% 40%, #1a1030 0%, #0e0a1e 50%, #060412 100%);
}
#scene-bg.mushroom #bg-overlay {
  background:
    radial-gradient(circle at 30% 55%, rgba(180,140,220,0.08) 0%, transparent 30%),
    radial-gradient(circle at 65% 45%, rgba(150,200,180,0.06) 0%, transparent 25%),
    radial-gradient(circle at 50% 60%, rgba(200,160,100,0.05) 0%, transparent 35%);
}

/* ===== Sprite Zone ===== */
#sprite-zone {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; z-index: 5;
  pointer-events: none;
}
.vn-sprite {
  position: absolute;
  left: 50%; top: 50%;
  margin-left: -225px; margin-top: -300px;
  opacity: 0; transition: opacity 0.8s ease;
  width: 450px; height: 600px;
  display: flex; align-items: center; justify-content: center;
}
.vn-sprite.show { opacity: 1; }
.sprite-img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* Avatar image */
.avatar-img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; }
#avatar-frame { overflow: hidden; }
@keyframes spriteSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ===== Dialogue Panel ===== */
#dialogue-panel {
  position: absolute; bottom: 0; left: 0; right: 0;
  z-index: 10;
  background: linear-gradient(0deg,
    rgba(12,8,20,0.97) 0%,
    rgba(16,12,28,0.94) 60%,
    rgba(20,14,32,0.7) 85%,
    transparent 100%);
  padding: 20px 24px 24px;
  display: flex; align-items: flex-start; gap: 16px;
  min-height: 170px;
  cursor: pointer;
  border-top: 1px solid rgba(180,150,120,0.15);
}

/* Avatar */
#dialogue-avatar { flex-shrink: 0; }
#avatar-frame {
  width: 64px; height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(200,170,130,0.5);
  background: radial-gradient(circle, rgba(30,20,40,0.9), rgba(10,8,20,0.95));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 20px rgba(180,150,120,0.15), inset 0 0 12px rgba(0,0,0,0.3);
}
#avatar-emoji { font-size: 2rem; }

/* Dialogue body */
#dialogue-body { flex: 1; padding-top: 2px; }
#speaker-name {
  font-family: 'MedievalSharp', var(--font-display), serif;
  font-size: 0.95rem; color: #c8b898;
  letter-spacing: 0.08em; margin-bottom: 10px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
#dialogue-text {
  font-size: 1.05rem; color: #d8d0c8; line-height: 1.85;
  max-width: 620px; min-height: 2em;
}

#dialogue-next {
  position: absolute; bottom: 10px; right: 20px;
  font-size: 0.7rem; color: rgba(200,180,150,0.4);
  animation: nextBlink 2s ease-in-out infinite;
}
@keyframes nextBlink { 0%,100%{opacity:0.3;} 50%{opacity:1;} }

/* Click hint — fades after first interaction */
#click-hint {
  position: absolute; bottom: 220px; left: 50%;
  transform: translateX(-50%); z-index: 15;
  font-family: var(--font-body); font-size: 0.85rem;
  color: rgba(200,180,150,0.5); pointer-events: none;
  animation: hintFade 3s ease-out forwards;
}
@keyframes hintFade {
  0% { opacity: 0; }
  20% { opacity: 0.7; }
  80% { opacity: 0.5; }
  100% { opacity: 0; }
}
#click-hint.gone { display: none; }

/* ===== Choices ===== */
#choices {
  position: absolute; bottom: 190px; left: 50%;
  transform: translateX(-50%); z-index: 20;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 420px; width: 90%;
}
#choices.hidden { display: none; }

.choice-btn {
  padding: 16px 24px;
  background: linear-gradient(135deg, rgba(30,20,45,0.92), rgba(20,12,35,0.92));
  border: 1.5px solid rgba(200,170,130,0.35);
  border-radius: 8px; color: #d0c8b8;
  font-family: var(--font-body); font-size: 1rem;
  text-align: left; cursor: pointer;
  transition: all 0.25s;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
  position: relative; overflow: hidden;
}
.choice-btn::before {
  content: '◆'; margin-right: 10px; color: rgba(200,170,130,0.5);
  font-size: 0.6rem; vertical-align: middle;
}
.choice-btn:hover {
  background: linear-gradient(135deg, rgba(50,30,70,0.95), rgba(30,20,50,0.95));
  border-color: rgba(220,190,140,0.7); color: #e8d8c0;
  transform: translateX(4px);
  box-shadow: 0 0 20px rgba(180,150,120,0.15);
}

/* ===== Combat ===== */
#combat-overlay {
  position: absolute; inset: 0; z-index: 50;
  background: radial-gradient(ellipse at 50% 40%, rgba(30,10,10,0.9), rgba(8,2,2,0.96));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
}
#combat-overlay.hidden { display: none; }
#combat-scene {
  display: flex; align-items: center; gap: 40px;
}
#combat-enemy, #combat-player { text-align: center; }
#enemy-avatar, #player-avatar {
  font-size: 5rem; transition: transform 0.2s;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}
#enemy-avatar.hit { transform: translateX(-15px); }
#player-avatar.hit { transform: translateX(15px); }
#enemy-name, #player-name {
  font-family: 'MedievalSharp', serif; font-size: 0.9rem;
  color: #c8b898; margin: 4px 0;
}
.hp-bar {
  width: 120px; height: 8px; background: rgba(255,255,255,0.08);
  border-radius: 4px; overflow: hidden; border: 1px solid rgba(255,255,255,0.1);
}
.hp-bar div {
  height: 100%; border-radius: 4px;
  background: linear-gradient(90deg, #c0392b, #e74c3c);
  transition: width 0.4s;
}
#combat-vs { font-size: 2rem; color: rgba(255,200,100,0.6); }
#combat-log {
  font-family: var(--font-body); color: #a09080; font-size: 0.9rem;
  text-align: center; min-height: 1.5em; max-width: 360px; line-height: 1.6;
}
#combat-actions { display: flex; gap: 16px; }
.combat-btn { padding: 12px 36px; font-size: 1.1rem; }

/* ===== Ending ===== */
#ending-screen {
  position: absolute; inset: 0; z-index: 60;
  background: radial-gradient(ellipse at 50% 40%, rgba(20,12,30,0.95), rgba(5,2,10,0.98));
  display: flex; align-items: center; justify-content: center;
}
#ending-screen.hidden { display: none; }
#ending-content {
  text-align: center; max-width: 480px; padding: 40px;
  animation: fadeUp 1s ease-out;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.ending-icon { font-size: 5rem; margin-bottom: 16px; }
.ending-title {
  font-family: 'MedievalSharp', var(--font-display), serif;
  font-size: 1.8rem; color: #c8b898; margin-bottom: 12px;
  letter-spacing: 0.08em; text-shadow: 0 0 30px rgba(200,180,150,0.3);
}
.ending-subtitle {
  font-family: var(--font-body); font-size: 1.05rem;
  color: #a098b0; line-height: 1.9; margin-bottom: 28px;
}

/* ===== Ambient particles (floating dust/motes) ===== */
.mote {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(200,180,150,0.3);
  animation: moteFloat linear infinite;
}
@keyframes moteFloat {
  0% { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(-80vh) translateX(20px); opacity: 0; }
}

@media (max-width: 480px) {
  #dialogue-text { font-size: 0.9rem; }
  #dialogue-panel { padding: 14px 14px 18px; min-height: 150px; }
  #avatar-frame { width: 48px; height: 48px; }
  #avatar-emoji { font-size: 1.4rem; }
  .vn-sprite { font-size: 4rem; }
  .choice-btn { font-size: 0.9rem; padding: 14px 18px; }
  #combat-scene { gap: 20px; }
  #enemy-avatar, #player-avatar { font-size: 3rem; }
  .hp-bar { width: 80px; }
}
