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

:root {
  --indigo-deep: #0a1628;
  --indigo-dark: #0f1f3a;
  --indigo-mid: #1a3355;
  --indigo-blue: #2a5a8c;
  --indigo-light: #4a8ab5;
  --indigo-pale: #8ab8d5;
  --white: #ffffff;
  --white-90: rgba(255, 255, 255, 0.9);
  --white-80: rgba(255, 255, 255, 0.8);
  --white-60: rgba(255, 255, 255, 0.6);
  --white-30: rgba(255, 255, 255, 0.3);
  --white-20: rgba(255, 255, 255, 0.2);
  --white-15: rgba(255, 255, 255, 0.15);
  --white-10: rgba(255, 255, 255, 0.1);
  --white-5: rgba(255, 255, 255, 0.05);
  --card-bg: rgba(255, 255, 255, 0.12);
  --card-border: rgba(255, 255, 255, 0.2);
  --btn-bg: rgba(255, 255, 255, 0.18);
  --btn-hover: rgba(255, 255, 255, 0.28);
  --correct-green: #4ade80;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
  background: var(--indigo-deep);
  color: var(--white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}

#canvas-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.pages-container {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px 80px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.page.active {
  opacity: 1;
  visibility: visible;
}

.page.exit-up {
  opacity: 0;
  transform: translateY(-30px);
  transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s 0.5s;
}

.page.enter-up {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.page.exit-down {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease, visibility 0s 0.5s;
}

.page.enter-down {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

/* Music toggle */
.music-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--white-15);
  border: 1px solid var(--white-30);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.3s ease, background 0.3s ease;
  font-size: 20px;
  color: var(--white-80);
}

.music-toggle:active {
  transform: scale(0.9);
}

.music-toggle.muted {
  opacity: 0.5;
}

/* Scroll indicator */
.scroll-indicator {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.scroll-indicator.hidden {
  opacity: 0;
}

.scroll-indicator .arrow-icon {
  width: 24px;
  height: 24px;
  border-right: 2.5px solid var(--white-60);
  border-bottom: 2.5px solid var(--white-60);
  transform: rotate(45deg);
  animation: arrowFloat 1.5s ease-in-out infinite;
}

.scroll-indicator .scroll-text {
  font-size: 11px;
  color: var(--white-60);
  letter-spacing: 2px;
}

@keyframes arrowFloat {
  0%, 100% { transform: rotate(45deg) translateY(0); opacity: 0.6; }
  50% { transform: rotate(45deg) translateY(6px); opacity: 1; }
}

/* Page title */
.page-title {
  font-size: clamp(26px, 5vw, 36px);
  font-weight: 800;
  text-align: center;
  color: var(--white);
  letter-spacing: 4px;
  margin-bottom: 12px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.page-subtitle {
  font-size: clamp(14px, 2.5vw, 18px);
  color: var(--white-80);
  text-align: center;
  letter-spacing: 2px;
  margin-bottom: 24px;
  font-weight: 400;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 48px;
  border-radius: 50px;
  background: var(--btn-bg);
  border: 1px solid var(--white-30);
  color: var(--white);
  font-size: clamp(15px, 2.8vw, 18px);
  font-weight: 600;
  letter-spacing: 3px;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-decoration: none;
  min-width: 200px;
}

.btn:active {
  transform: scale(0.95);
  background: var(--btn-hover);
}

.btn-small {
  padding: 12px 36px;
  font-size: clamp(13px, 2.4vw, 16px);
  min-width: 160px;
}

/* === P1 Cover === */
#page-1 {
  justify-content: center;
  gap: 0;
}

.p1-decor {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.p1-title-area {
  text-align: center;
  z-index: 2;
  position: relative;
}

.p1-title {
  font-size: clamp(32px, 7vw, 48px);
  font-weight: 900;
  color: var(--white);
  letter-spacing: 6px;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  line-height: 1.3;
  margin-bottom: 8px;
}

.p1-title .highlight {
  background: linear-gradient(135deg, #8ab8d5, #4a8ab5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.p1-divider {
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--white-60), transparent);
  margin: 12px auto;
}

.p1-subtitle {
  font-size: clamp(14px, 2.5vw, 18px);
  color: var(--white-80);
  letter-spacing: 4px;
  font-weight: 300;
  margin-bottom: 24px;
}

/* Tie-dye showcase on cover */
.p1-tiedye {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  margin: 16px auto 32px;
  position: relative;
  animation: tiedyeFloat 4s ease-in-out infinite;
  overflow: hidden;
  border: 3px solid var(--white-30);
  box-shadow: 0 0 40px rgba(74, 138, 181, 0.3), 0 0 80px rgba(74, 138, 181, 0.1);
}

.p1-tiedye img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.p1-tiedye-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--white-20);
  animation: ringPulse 3s ease-in-out infinite;
  pointer-events: none;
}

.p1-tiedye-ring:nth-child(1) {
  top: -12px; left: -12px; right: -12px; bottom: -12px;
  animation-delay: 0s;
}

.p1-tiedye-ring:nth-child(2) {
  top: -24px; left: -24px; right: -24px; bottom: -24px;
  animation-delay: 0.5s;
  border-color: var(--white-10);
}

.p1-tiedye-ring:nth-child(3) {
  top: -36px; left: -36px; right: -36px; bottom: -36px;
  animation-delay: 1s;
  border-color: var(--white-5);
  border-style: dashed;
}

@keyframes tiedyeFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.05); opacity: 0.3; }
}

/* Decorative hanging fabric strips */
.p1-fabric {
  position: absolute;
  width: 40px;
  height: 120px;
  border-radius: 4px;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.p1-fabric.left {
  left: 12px;
  top: 20%;
  background: linear-gradient(180deg, #2a5a8c, #4a8ab5, #2a5a8c);
  transform: rotate(-8deg);
  animation: fabricSway 4s ease-in-out infinite;
}

.p1-fabric.right {
  right: 12px;
  top: 25%;
  background: linear-gradient(180deg, #4a8ab5, #2a5a8c, #4a8ab5);
  transform: rotate(8deg);
  animation: fabricSway 4s ease-in-out infinite reverse;
}

@keyframes fabricSway {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(8deg); }
}

/* Tie-dye decorative circles */
.p1-dot {
  position: absolute;
  border-radius: 50%;
  background: var(--white-10);
  pointer-events: none;
  z-index: 0;
  animation: dotPulse 3s ease-in-out infinite;
}

.p1-dot.dot-1 {
  width: 60px; height: 60px;
  top: 10%; left: 8%;
  background: radial-gradient(circle, rgba(74, 138, 181, 0.2), transparent);
}

.p1-dot.dot-2 {
  width: 40px; height: 40px;
  bottom: 15%; right: 10%;
  background: radial-gradient(circle, rgba(138, 184, 213, 0.15), transparent);
  animation-delay: 1s;
}

.p1-dot.dot-3 {
  width: 80px; height: 80px;
  bottom: 30%; left: 5%;
  background: radial-gradient(circle, rgba(74, 138, 181, 0.1), transparent);
  animation-delay: 0.5s;
}

@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.3); opacity: 0.8; }
}

/* === P2 Introduction === */
#page-2 {
  gap: 8px;
}

.p2-image-area {
  width: 80%;
  max-width: 280px;
  height: 160px;
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 16px;
  position: relative;
  border: 1px solid var(--white-20);
}

.p2-image-area img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.p2-text {
  width: 100%;
  max-width: 340px;
  font-size: clamp(14px, 2.6vw, 16px);
  line-height: 1.8;
  color: var(--white-90);
  text-align: justify;
  margin-bottom: 8px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* === P3-P8 Steps === */
.step-page {
  gap: 8px;
}

.step-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border-radius: 20px;
  border: 1px solid var(--card-border);
  overflow: hidden;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.step-card-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  position: relative;
  background: var(--indigo-dark);
}

.step-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.step-card:hover .step-card-image img {
  transform: scale(1.03);
}

.step-number {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: var(--white);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.step-card-body {
  padding: 20px;
}

.step-card-body h3 {
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 700;
  color: var(--white);
  margin-bottom: 10px;
  letter-spacing: 1px;
}

.step-card-body p {
  font-size: clamp(13px, 2.4vw, 15px);
  line-height: 1.7;
  color: var(--white-80);
}

.step-girl {
  position: fixed;
  right: 12px;
  bottom: 80px;
  width: 80px;
  height: 120px;
  z-index: 10;
  opacity: 0.6;
  pointer-events: none;
  animation: dancerFloat 4s ease-in-out infinite;
}

.step-girl svg {
  width: 100%;
  height: 100%;
}

/* === P9 Gallery === */
#page-9 {
  gap: 8px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 360px;
  padding: 0 4px;
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--white-15);
  background: var(--card-bg);
  transition: transform 0.3s ease;
}

.gallery-item:active {
  transform: scale(0.95);
}

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

.gallery-item.wide {
  grid-column: span 2;
}

.gallery-item.tall {
  grid-row: span 2;
}

.gallery-label {
  font-size: 11px;
  color: var(--white-60);
  text-align: center;
  margin-top: 12px;
  letter-spacing: 1px;
}

/* === P10-P11 Quiz === */
.quiz-page {
  gap: 8px;
}

.quiz-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border-radius: 20px;
  border: 1px solid var(--card-border);
  padding: 28px 20px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.quiz-question {
  font-size: clamp(15px, 2.8vw, 18px);
  font-weight: 600;
  color: var(--white);
  line-height: 1.6;
  margin-bottom: 20px;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-option {
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--white-10);
  border: 1px solid var(--white-15);
  color: var(--white-90);
  font-size: clamp(14px, 2.5vw, 16px);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
}

.quiz-option .option-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--white-15);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.quiz-option:active {
  transform: scale(0.98);
  background: var(--white-20);
}

.quiz-option.correct {
  background: rgba(74, 222, 128, 0.2);
  border-color: var(--correct-green);
}

.quiz-option.correct .option-label {
  background: var(--correct-green);
  color: var(--indigo-deep);
}

.quiz-option .check-mark {
  margin-left: auto;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.quiz-option.correct .check-mark {
  opacity: 1;
}

.quiz-explanation {
  margin-top: 16px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  font-size: clamp(12px, 2.2vw, 14px);
  line-height: 1.6;
  color: var(--white-70);
  display: none;
  border-left: 3px solid var(--indigo-light);
}

.quiz-explanation.show {
  display: block;
  animation: fadeIn 0.4s ease;
}

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

/* === P12 Share === */
#page-12 {
  gap: 8px;
  justify-content: center;
}

.p12-quote {
  font-size: clamp(18px, 3.5vw, 24px);
  font-weight: 700;
  color: var(--white);
  text-align: center;
  letter-spacing: 3px;
  line-height: 1.6;
  margin-bottom: 16px;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.p12-poster {
  width: 240px;
  height: 340px;
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid var(--white-20);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
  position: relative;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.p12-poster:active {
  transform: scale(0.97);
}

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

.p12-save-hint {
  font-size: 12px;
  color: var(--white-50);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 1px;
}

.p12-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
}

.p12-buttons .btn-share {
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.3), rgba(52, 211, 153, 0.2));
  border-color: rgba(74, 222, 128, 0.4);
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--white);
  padding: 16px 28px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  text-align: center;
  border: 1px solid var(--white-10);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* Loading screen */
#loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--indigo-deep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

#loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
}

.loading-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.loading-sub {
  font-size: 13px;
  color: var(--white-50);
  margin-bottom: 32px;
  letter-spacing: 2px;
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: var(--white-10);
  border-radius: 2px;
  overflow: hidden;
}

.loading-bar-inner {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--indigo-light), var(--white));
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* Responsive */
@media (max-width: 360px) {
  .page {
    padding: 32px 16px 70px;
  }
  .step-card-image {
    height: 160px;
  }
  .p12-poster {
    width: 200px;
    height: 280px;
  }
}

@media (min-width: 420px) {
  .page {
    padding: 48px 32px 90px;
  }
  .step-card-image {
    height: 220px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  :root {
    --indigo-deep: #050e1a;
    --indigo-dark: #0a1628;
  }
  .page {
    color: var(--white-95);
  }
}
