/* Base Custom properties & Design System tokens */
:root {
  /* Pink/Romantic theme colors */
  --bg-primary: #0b0713;
  --bg-secondary: #170d24;
  --text-primary: #fff0f5;
  --text-secondary: #e2b4d4;
  --text-muted: #9c789a;
  
  /* Accent Colors */
  --accent-1: #ff4b82; /* Romantic Hot Pink */
  --accent-2: #ff7bac; /* Bright Pink */
  --accent-3: #e024ff; /* Magenta Purple */
  --accent-gold: #ffd700;
  --accent-gradient: linear-gradient(135deg, var(--accent-1) 0%, var(--accent-2) 50%, var(--accent-3) 100%);
  
  /* Card backgrounds */
  --card-bg: rgba(30, 15, 40, 0.65);
  --card-border: rgba(255, 75, 130, 0.15);
  --card-glow: rgba(255, 75, 130, 0.25);

  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  
  --transition-smooth: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: all 0.2s ease;
}

/* Light theme colors override */
html.light {
  --bg-primary: #fff0f5;
  --bg-secondary: #ffe3ee;
  --text-primary: #2d0016;
  --text-secondary: #8a3f65;
  --text-muted: #b57c9a;
  
  --accent-1: #e0115f;
  --accent-2: #ff4081;
  --accent-3: #9c27b0;
  
  --card-bg: rgba(255, 255, 255, 0.8);
  --card-border: rgba(224, 17, 95, 0.2);
  --card-glow: rgba(224, 17, 95, 0.15);
}

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

html {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow: hidden;
}

body.galgame-body {
  height: 100vh;
  width: 100vw;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Pink ambient glow backgrounds */
.pink-glow-1 {
  position: absolute;
  top: 10%;
  left: 15%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, rgba(255, 75, 130, 0.18) 0%, rgba(224, 36, 255, 0.04) 70%, transparent 100%);
  z-index: -2;
  pointer-events: none;
  filter: blur(80px);
}

.pink-glow-2 {
  position: absolute;
  bottom: 10%;
  right: 15%;
  width: 45vw;
  height: 45vw;
  background: radial-gradient(circle, rgba(224, 36, 255, 0.18) 0%, rgba(255, 75, 130, 0.04) 70%, transparent 100%);
  z-index: -2;
  pointer-events: none;
  filter: blur(80px);
}

.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(255, 75, 130, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 75, 130, 0.02) 1px, transparent 1px);
  background-size: 50px 50px;
  z-index: -1;
  pointer-events: none;
}

/* Custom Cursor Trailer containing Jiahui's face */
.jiahui-cursor {
  width: 46px;
  height: 46px;
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  background-image: url('zhangjiahui.jpg');
  background-size: cover;
  background-position: center;
  border-radius: 50%;
  border: 2px solid var(--accent-1);
  box-shadow: 0 0 15px var(--accent-1);
  display: block;
}

/* Glassmorphism General Cards */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

/* Utility classes */
.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 2rem;
  border-radius: 30px;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(255, 75, 130, 0.3);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 6px 24px rgba(255, 75, 130, 0.5);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--card-border);
}

.btn-secondary:hover {
  background: rgba(255, 75, 130, 0.08);
  border-color: var(--accent-1);
  transform: translateY(-3px);
}

/* Galgame Wrapper and Screens */
.galgame-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  position: absolute;
  top: 0;
  left: 0;
}

/* 1. Title Screen */
.title-card {
  width: 100%;
  max-width: 550px;
  padding: 3.5rem;
  text-align: center;
}

.game-logo {
  margin-bottom: 1rem;
}

.heart-pulse {
  font-size: 3.5rem;
  display: inline-block;
  animation: logoPulse 1.2s infinite;
}

@keyframes logoPulse {
  0% { transform: scale(1); }
  30% { transform: scale(1.25); }
  60% { transform: scale(1); }
}

.game-logo h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 2.2rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-top: 1rem;
}

.subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: 2px;
  margin-bottom: 2.5rem;
}

.character-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.avatar-ring {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  border: 4px solid var(--accent-1);
  box-shadow: 0 0 25px rgba(255, 75, 130, 0.5);
  overflow: hidden;
  animation: spinRing 12s linear infinite;
}

.avatar-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes spinRing {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.char-tags {
  display: flex;
  gap: 0.5rem;
}

.badge {
  font-size: 0.75rem;
  padding: 4px 10px;
  background: rgba(255, 75, 130, 0.12);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  border-radius: 12px;
}

.start-btn {
  width: 100%;
  padding: 1rem;
  border-radius: 30px;
}

/* 2. Gameplay Screen Layout */
#game-screen {
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem;
}

.game-header-bar {
  width: 100%;
  max-width: 800px;
  padding: 0.8rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

.player-info span {
  font-size: 0.95rem;
}

.player-info strong {
  color: var(--accent-1);
}

.love-meter-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.love-bar {
  width: 150px;
  height: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  overflow: hidden;
}

.love-fill {
  height: 100%;
  background: var(--accent-gradient);
  transition: width 0.5s ease-out;
}

.pulse-love {
  animation: fillPulse 1s infinite alternate;
}

@keyframes fillPulse {
  0% { filter: brightness(1); }
  100% { filter: brightness(1.25) drop-shadow(0 0 5px var(--accent-1)); }
}

/* Character Stage */
.stage {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  position: relative;
  z-index: 2;
  margin-bottom: 120px; /* offset textbox overlap */
}

.character-container {
  position: relative;
  width: 320px;
  height: 320px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}

.jiahui-sprite {
  width: 250px;
  height: 250px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--accent-1);
  box-shadow: 0 0 30px var(--card-glow);
  z-index: 2;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Emoji Bubble */
.emoji-bubble {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 48px;
  height: 48px;
  background: #ffffff;
  border: 2px solid var(--accent-1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  z-index: 3;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  animation: bubbleFloat 2s infinite ease-in-out;
}

@keyframes bubbleFloat {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-8px) scale(1.1); }
  100% { transform: translateY(0) scale(1); }
}

/* Stage Avatar Glow */
.avatar-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 380px;
  height: 380px;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.5;
  pointer-events: none;
  z-index: 1;
  transition: var(--transition-smooth);
}

.glow-pink { background: radial-gradient(circle, var(--accent-1) 0%, transparent 70%); }
.glow-cyan { background: radial-gradient(circle, #00f2fe 0%, transparent 70%); }
.glow-purple { background: radial-gradient(circle, var(--accent-3) 0%, transparent 70%); }
.glow-gold { background: radial-gradient(circle, var(--accent-gold) 0%, transparent 70%); }
.glow-heart-pink { background: radial-gradient(circle, #ff007f 0%, transparent 70%); opacity: 0.8; }

/* Sprite Animations for Moods */
.float-sway {
  animation: spriteSway 3s ease-in-out infinite;
}

@keyframes spriteSway {
  0% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

.bounce-up-down {
  animation: spriteBounce 0.5s ease infinite alternate;
}

@keyframes spriteBounce {
  0% { transform: translateY(0) scaleY(1); }
  100% { transform: translateY(-25px) scaleY(0.95); }
}

.scale-large {
  transform: scale(1.15) translateY(-10px);
}

.spin-rapid {
  animation: spriteSpin 2s linear infinite;
}

@keyframes spriteSpin {
  0% { transform: rotate(0deg) scale(1.1); }
  100% { transform: rotate(360deg) scale(1.1); }
}

.laughing-heavy {
  animation: spriteLaugh 0.1s infinite;
}

@keyframes spriteLaugh {
  0% { transform: translate(1px, 1px) rotate(0deg); }
  10% { transform: translate(-1px, -2px) rotate(-1deg); }
  20% { transform: translate(-3px, 0px) rotate(1deg); }
  30% { transform: translate(0px, 2px) rotate(0deg); }
  40% { transform: translate(1px, -1px) rotate(1deg); }
  50% { transform: translate(-1px, 2px) rotate(-1deg); }
  60% { transform: translate(-3px, 1px) rotate(0deg); }
  70% { transform: translate(2px, 1px) rotate(-1deg); }
  80% { transform: translate(-1px, -1px) rotate(1deg); }
  90% { transform: translate(2px, 2px) rotate(0deg); }
  100% { transform: translate(1px, -2px) rotate(-1deg); }
}

.tietie-zoom {
  animation: spriteTietie 0.15s infinite alternate;
  width: 320px;
  height: 320px;
}

@keyframes spriteTietie {
  0% { transform: scale(1.35) rotate(-1deg) translateY(-20px); }
  100% { transform: scale(1.4) rotate(1deg) translateY(-25px); }
}

/* Choices Panel */
.choices-container {
  position: absolute;
  bottom: 170px;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 650px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 15;
  padding: 0 1rem;
}

.choice-btn {
  width: 100%;
  background: rgba(45, 15, 60, 0.85);
  border: 1px solid var(--card-border);
  padding: 1rem 1.5rem;
  border-radius: 30px;
  color: var(--text-primary);
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.choice-btn:hover {
  background: var(--accent-gradient);
  border-color: transparent;
  transform: scale(1.02);
  box-shadow: 0 5px 15px rgba(255, 75, 130, 0.4);
}

/* Text Box Panel */
.textbox-container {
  width: 100%;
  max-width: 800px;
  min-height: 120px;
  padding: 1.5rem 2rem;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  cursor: pointer;
}

.char-name {
  position: absolute;
  top: -16px;
  left: 24px;
  background: var(--accent-gradient);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 4px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(255, 75, 130, 0.3);
}

.dialogue-text-box {
  width: 100%;
}

.dialogue-text {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-primary);
}

.next-indicator {
  position: absolute;
  bottom: 10px;
  right: 20px;
  font-size: 0.75rem;
  color: var(--accent-2);
  animation: flash 1s infinite alternate;
}

@keyframes flash {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* Heart particles */
.heart-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

.heart-particle {
  position: fixed;
  font-size: 1.5rem;
  pointer-events: none;
  animation: heartExplode 1s cubic-bezier(0.1, 0.8, 0.3, 1) forwards;
}

@keyframes heartExplode {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--tx)), calc(-50% + var(--ty))) scale(1.2);
    opacity: 0;
  }
}

/* Falling Jiahui Hearts */
.falling-jiahui-head {
  position: fixed;
  top: -150px;
  z-index: 9998;
  pointer-events: none;
}

@keyframes fallDown {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(115vh) rotate(360deg); opacity: 0.2; }
}

/* Ending Screen */
.ending-card {
  width: 100%;
  max-width: 600px;
  padding: 3rem;
  text-align: center;
}

.ending-card h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--accent-1);
  margin-bottom: 0.5rem;
}

.ending-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.8rem;
  margin-bottom: 1.5rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ending-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.ending-photo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 4px solid var(--accent-1);
  box-shadow: 0 0 30px var(--accent-1);
  margin: 0 auto 2.5rem;
  overflow: hidden;
}

.ending-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spin-slow {
  animation: spinRing 25s linear infinite;
}

.ending-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .title-card, .ending-card {
    padding: 2rem 1.5rem;
  }
  
  .textbox-container {
    width: calc(100% - 20px);
    padding: 1.2rem 1.5rem;
  }
  
  .character-container {
    width: 220px;
    height: 220px;
  }
  
  .jiahui-sprite {
    width: 180px;
    height: 180px;
  }
  
  .avatar-glow {
    width: 280px;
    height: 280px;
  }

  .love-bar {
    width: 100px;
  }
}
