/* ==========================================================================
   RPG Child & Parent Personality Quiz - Modern Aesthetics & Styling
   ========================================================================== */

:root {
  --font-primary: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-heading: 'Fredoka', 'Noto Sans TC', sans-serif;

  /* Color Palette */
  --color-warrior: #e74c3c;
  --color-warrior-light: #ff7675;
  --color-warrior-bg: #fff5f5;
  
  --color-mage: #8e44ad;
  --color-mage-light: #a29bfe;
  --color-mage-bg: #f8f0fc;
  
  --color-priest: #27ae60;
  --color-priest-light: #55efc4;
  --color-priest-bg: #f0fdf4;
  
  --color-rogue: #d35400;
  --color-rogue-light: #fdcb6e;
  --color-rogue-bg: #fffbf0;

  --bg-main: #f4f6fb;
  --text-main: #2d3748;
  --text-muted: #718096;
  --border-color: #e2e8f0;
  
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
}

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

body {
  font-family: var(--font-primary);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Dynamic Animated Background Shapes */
.app-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.bg-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: floatShape 20s infinite alternate ease-in-out;
}

.shape-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #ffeaa7, #fab1a0);
  top: -100px;
  left: -100px;
}

.shape-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #a29bfe, #74b9ff);
  bottom: -150px;
  right: -100px;
  animation-delay: -5s;
}

.shape-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #55efc4, #81ecec);
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -10s;
}

@keyframes floatShape {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.1); }
  100% { transform: translate(-30px, 50px) scale(0.95); }
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* Header & Version Switcher */
.main-header {
  text-align: center;
  margin-bottom: 28px;
}

.version-tab-switcher {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 5px;
  border-radius: 50px;
  border: 2px solid #cbd5e0;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.version-tab {
  font-family: var(--font-primary);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 10px 28px;
  border-radius: 50px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.25s ease;
}

.version-tab.active {
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  color: white;
  box-shadow: 0 4px 14px rgba(108, 92, 231, 0.4);
}

.version-tab:hover:not(.active) {
  color: #2d3748;
}

.header-badge {
  display: inline-block;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 6px 18px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #4a5568;
  box-shadow: var(--shadow-sm);
  margin-bottom: 10px;
}

.main-header h1 {
  font-family: var(--font-heading);
  font-size: 2.3rem;
  font-weight: 900;
  background: linear-gradient(135deg, #2d3748 0%, #4a5568 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.main-header .subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
}

/* Mode Toggle Banner */
.mode-toggle-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f7fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 12px 20px;
  margin-bottom: 24px;
  font-weight: 700;
  font-size: 1.02rem;
  color: #2d3748;
  box-shadow: var(--shadow-sm);
}

@media (max-width: 600px) {
  .mode-toggle-banner {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
}

/* General Card Layout */
.card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
}

/* Screen 1: Intro Screen */
.intro-card {
  text-align: center;
}

.intro-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.preview-item {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 20px 12px;
  box-shadow: var(--shadow-sm);
  border: 2px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-item:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
}

.preview-item img {
  width: 105px;
  height: 105px;
  object-fit: cover;
  border-radius: 50%;
  margin-bottom: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
  border: 3px solid #ffffff;
}

.preview-tag {
  font-weight: 700;
  font-size: 1.05rem;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 6px;
}

.warrior-theme .preview-tag { background: var(--color-warrior-bg); color: var(--color-warrior); }
.mage-theme .preview-tag { background: var(--color-mage-bg); color: var(--color-mage); }
.priest-theme .preview-tag { background: var(--color-priest-bg); color: var(--color-priest); }
.rogue-theme .preview-tag { background: var(--color-rogue-bg); color: var(--color-rogue); }

.preview-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.intro-instructions {
  background: #f7fafc;
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: left;
  margin-bottom: 32px;
  border-left: 5px solid #6c5ce7;
}

.intro-instructions h3 {
  margin-bottom: 12px;
  font-size: 1.15rem;
  color: #2d3748;
}

.intro-instructions ul {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.intro-instructions li {
  font-size: 0.95rem;
  color: #4a5568;
  position: relative;
  padding-left: 24px;
}

.intro-instructions li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: #6c5ce7;
  font-weight: bold;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-primary);
  font-weight: 700;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
  outline: none;
}

.btn-sm {
  padding: 8px 18px;
  font-size: 0.92rem;
}

.btn-lg {
  padding: 16px 36px;
  font-size: 1.15rem;
}

.btn-primary {
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  color: white;
  box-shadow: 0 8px 20px rgba(108, 92, 231, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(108, 92, 231, 0.45);
}

.btn-success {
  background: linear-gradient(135deg, #00b894 0%, #05c46b 100%);
  color: white;
  box-shadow: 0 8px 20px rgba(0, 184, 148, 0.35);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0, 184, 148, 0.45);
}

.btn-outline {
  background: white;
  color: #4a5568;
  border: 2px solid #cbd5e0;
}

.btn-outline:hover {
  background: #edf2f7;
  border-color: #a0aec0;
}

.btn-secondary {
  background: #4a5568;
  color: white;
}

.btn-secondary:hover {
  background: #2d3748;
}

.pulse {
  animation: pulseBtn 2s infinite;
}

@keyframes pulseBtn {
  0% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0.5); }
  70% { box-shadow: 0 0 0 16px rgba(108, 92, 231, 0); }
  100% { box-shadow: 0 0 0 0 rgba(108, 92, 231, 0); }
}

/* Screen 2: Sticky Progress Bar */
.sticky-progress-container {
  position: sticky;
  top: 12px;
  z-index: 100;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 50px;
  padding: 12px 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  border: 1px solid rgba(226, 232, 240, 0.8);
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: #2d3748;
}

.progress-bar-track {
  width: 100%;
  height: 12px;
  background: #edf2f7;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6c5ce7, #00b894);
  border-radius: 10px;
  transition: width 0.3s ease;
}

/* Questions Grid */
.questions-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
}

.question-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 2px solid #edf2f7;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.question-card.answered {
  border-color: #c6f6d5;
  background: #fafdfb;
}

.question-card.unanswered-error {
  border-color: #feb2b2;
  background: #fff5f5;
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.question-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.question-num {
  background: #ebf8ff;
  color: #3182ce;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 4px 10px;
  border-radius: 8px;
  flex-shrink: 0;
}

.question-text {
  font-size: 1.05rem;
  font-weight: 500;
  color: #2d3748;
  line-height: 1.5;
}

/* 1-5 Custom Range Slider Styling */
.rating-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
}

.slider-wrapper {
  position: relative;
  width: 100%;
}

.custom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 10px;
  border-radius: 10px;
  background: #e2e8f0;
  outline: none;
  cursor: pointer;
  transition: background 0.2s ease;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid #6c5ce7;
  box-shadow: 0 4px 10px rgba(108, 92, 231, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.custom-slider::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 4px solid #6c5ce7;
  box-shadow: 0 4px 10px rgba(108, 92, 231, 0.4);
  cursor: pointer;
}

/* Rating Labels Bar below Slider */
.rating-labels-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.rating-step {
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  text-align: center;
  flex: 1;
}

.rating-step.active {
  font-weight: 700;
  color: #6c5ce7;
  transform: scale(1.1);
}

.current-rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: center;
  background: #f7fafc;
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 0.95rem;
  color: #4a5568;
  border: 1px solid #e2e8f0;
  margin-top: 4px;
  transition: all 0.2s ease;
}

/* Rating colors */
.val-1 { border-color: #fc8181; color: #e53e3e; background: #fff5f5; }
.val-2 { border-color: #fbd38d; color: #dd6b20; background: #fffaf0; }
.val-3 { border-color: #faf089; color: #d69e2e; background: #fffff0; }
.val-4 { border-color: #9ae6b4; color: #38a169; background: #f0fff4; }
.val-5 { border-color: #68d391; color: #276749; background: #e6fffa; }

.quiz-footer-actions {
  text-align: center;
  padding: 20px 0;
}

.validation-warning {
  background: #fff5f5;
  border: 2px solid #feb2b2;
  color: #c53030;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 700;
  margin-bottom: 16px;
  display: inline-block;
}

/* Screen 3: Result Screen */
.result-header {
  text-align: center;
  margin-bottom: 28px;
}

.celebration-badge {
  display: inline-block;
  background: #fefcbf;
  color: #744210;
  font-weight: 700;
  font-size: 1rem;
  padding: 6px 20px;
  border-radius: 50px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.result-header h2 {
  font-size: 1.8rem;
  color: #2d3748;
}

.result-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 36px;
}

@media (max-width: 860px) {
  .result-main-grid {
    grid-template-columns: 1fr;
  }
}

/* Left Column */
.result-left-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.hero-class-badge {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-md);
  color: white;
  font-weight: 900;
}

.hero-class-badge h3 {
  font-size: 2rem;
  letter-spacing: 0.5px;
}

.hero-class-badge .sub-title {
  font-size: 1.1rem;
  opacity: 0.95;
  font-weight: 500;
}

.hero-image-wrapper {
  text-align: center;
  margin: 0 auto;
}

.hero-image-wrapper img {
  width: 100%;
  max-width: 280px;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
  border: 4px solid #ffffff;
}

.soul-core-box {
  background: #ebf8ff;
  border-left: 5px solid #3182ce;
  border-radius: var(--radius-sm);
  padding: 16px 20px;
}

.soul-core-box h3 {
  font-size: 1.1rem;
  color: #2b6cb0;
  margin-bottom: 6px;
}

.soul-core-box p {
  font-size: 1.05rem;
  font-weight: 700;
  color: #2d3748;
}

.traits-box h3, .parenting-tips-box h3, .chart-box h3, .percentage-box h3 {
  font-size: 1.15rem;
  color: #2d3748;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.traits-box ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.traits-box li {
  background: #f7fafc;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  border-left: 3px solid #cbd5e0;
  line-height: 1.5;
}

.tips-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tip-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.tip-card h4 {
  font-size: 0.98rem;
  color: #2b6cb0;
  margin-bottom: 4px;
}

.tip-card p {
  font-size: 0.92rem;
  color: #4a5568;
}

/* Right Column */
.result-right-col {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.canvas-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid #edf2f7;
  box-shadow: var(--shadow-sm);
}

#radar-chart {
  width: 100%;
  max-width: 450px;
  height: auto;
}

.percentage-bars-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.perc-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.perc-header {
  display: flex;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.perc-track {
  width: 100%;
  height: 10px;
  background: #edf2f7;
  border-radius: 8px;
  overflow: hidden;
}

.perc-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.8s ease-out;
}

.secondary-analysis-box {
  background: #faf5ff;
  border: 1px solid #e9d8fd;
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.secondary-analysis-box h4 {
  color: #6b46c1;
  margin-bottom: 6px;
  font-size: 1rem;
}

.secondary-analysis-box p {
  font-size: 0.92rem;
  color: #4a5568;
}

/* Actions Footer */
.result-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 24px;
}

.main-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 40px;
}

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

/* Print Stylesheet */
@media print {
  body {
    background: white;
    color: black;
  }
  .app-background, .sticky-progress-container, .result-actions, .main-header, .main-footer {
    display: none !important;
  }
  .card {
    box-shadow: none;
    border: none;
    padding: 0;
  }
  .result-main-grid {
    display: block;
  }
  .result-left-col, .result-right-col {
    page-break-inside: avoid;
    margin-bottom: 20px;
  }
}
