/* DreamWeavers - Kid-friendly Theme - GOATED v3 */

/* === Light Theme (Default) === */
body[data-theme="light"] {
  --bg: #f7fbff;
  --bg-alt: #fffaf8;
  --card: #ffffff;
  --text: #172033;
  --text-muted: #6b7482;
  --primary: #5842c3;
  --primary-glow: rgba(124, 92, 255, 0.3);
  --accent: #7c5cff;
  --accent-2: #ff7aa2;
  --accent-3: #a8edea;
  --magic-word: var(--accent-2);
  --dict-word: var(--accent);
  --active-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --hover-gradient: linear-gradient(135deg, var(--accent-3), var(--accent));
  --shadow: 0 10px 30px rgba(47, 61, 109, 0.08);
  --border-color: #f0f0f8;
  --border-color-light: #eef3fb;
  --btn-bg: #f0f0f8;
  --btn-text: #555;
  --modal-bg: rgba(255, 255, 255, 0.85);
  --modal-border: rgba(255, 255, 255, 0.3);
  --modal-shadow: rgba(0, 0, 0, 0.3);
  --skeleton-bg: #f3f6fb;
  --skeleton-shine: #eef4ff;
  --bubble-color: rgba(124, 92, 255, 0.1);
}

/* === Dark Magic Theme === */
body[data-theme="dark"] {
  --bg: #111425;
  --bg-alt: #1a1e35;
  --card: #1f233f;
  --text: #f0f0ff;
  --text-muted: #a0a8c2;
  --primary: #9e8aff;
  --primary-glow: rgba(158, 138, 255, 0.3);
  --accent: #9e8aff;
  --accent-2: #ff9ec1;
  --accent-3: #a8edea;
  --magic-word: var(--accent-2);
  --dict-word: var(--accent-3);
  --active-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --hover-gradient: linear-gradient(135deg, var(--accent-3), var(--accent));
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --border-color: #30365f;
  --border-color-light: #2a2f50;
  --btn-bg: #30365f;
  --btn-text: #f0f0ff;
  --modal-bg: rgba(31, 35, 63, 0.85);
  --modal-border: rgba(255, 255, 255, 0.1);
  --modal-shadow: rgba(0, 0, 0, 0.5);
  --skeleton-bg: #2a2f50;
  --skeleton-shine: #30365f;
  --bubble-color: rgba(158, 138, 255, 0.1);
}

/* === Evening Glow Theme === */
body[data-theme="evening"] {
  --bg: #2b2a4c;
  --bg-alt: #4a4872;
  --card: #373561;
  --text: #fde9d1;
  --text-muted: #b9b8d3;
  --primary: #ffc9a3;
  --primary-glow: rgba(255, 163, 114, 0.3);
  --accent: #f7a072;
  --accent-2: #ffb0a3;
  --accent-3: #b088f9;
  --magic-word: var(--accent-2);
  --dict-word: var(--accent-3);
  --active-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --hover-gradient: linear-gradient(135deg, var(--accent-3), var(--accent));
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  --border-color: #4a4872;
  --border-color-light: #5f5c90;
  --btn-bg: #4a4872;
  --btn-text: #fde9d1;
  --modal-bg: rgba(55, 53, 97, 0.85);
  --modal-border: rgba(255, 255, 255, 0.1);
  --modal-shadow: rgba(0, 0, 0, 0.5);
  --skeleton-bg: #4a4872;
  --skeleton-shine: #5f5c90;
  --bubble-color: rgba(247, 160, 114, 0.1);
}

/* === Fairy Forest Theme === */
body[data-theme="fairy"] {
  --bg: #f4fffb;
  --bg-alt: #f0fff6;
  --card: #ffffff;
  --text: #0b3d2c;
  --text-muted: #2f6b55;
  --primary: #de5b9d;
  --primary-glow: rgba(222, 91, 157, 0.3);
  --accent: #de5b9d;
  --accent-2: #f7b2dd;
  --accent-3: #86e4b4;
  --magic-word: var(--accent);
  --dict-word: var(--primary);
  --active-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --hover-gradient: linear-gradient(135deg, var(--accent-3), var(--accent));
  --shadow: 0 10px 30px rgba(47, 107, 85, 0.1);
  --border-color: #dff7ea;
  --border-color-light: #e6fcf0;
  --btn-bg: #e6fcf0;
  --btn-text: #0b3d2c;
  --modal-bg: rgba(255, 255, 255, 0.85);
  --modal-border: rgba(255, 255, 255, 0.3);
  --modal-shadow: rgba(0, 0, 0, 0.3);
  --skeleton-bg: #e6fcf0;
  --skeleton-shine: #dff7ea;
  --bubble-color: rgba(222, 91, 157, 0.1);
}

/* === Underwater Theme === */
body[data-theme="underwater"] {
  --bg: #f0f8ff;
  --bg-alt: #e6f3ff;
  --card: #ffffff;
  --text: #003e5c;
  --text-muted: #005f8c;
  --primary: #008c9e;
  --primary-glow: rgba(0, 140, 158, 0.3);
  --accent: #00a0b0;
  --accent-2: #6ed3cf;
  --accent-3: #ffd700; /* Gold */
  --magic-word: var(--accent-2);
  --dict-word: var(--primary);
  --active-gradient: linear-gradient(135deg, var(--accent), var(--accent-2));
  --hover-gradient: linear-gradient(135deg, var(--accent-3), var(--accent));
  --shadow: 0 10px 30px rgba(0, 95, 140, 0.1);
  --border-color: #d6ecff;
  --border-color-light: #e0f0ff;
  --btn-bg: #e0f0ff;
  --btn-text: #003e5c;
  --modal-bg: rgba(255, 255, 255, 0.85);
  --modal-border: rgba(255, 255, 255, 0.3);
  --modal-shadow: rgba(0, 0, 0, 0.3);
  --skeleton-bg: #e0f0ff;
  --skeleton-shine: #d6ecff;
  --bubble-color: rgba(0, 160, 176, 0.1);
}


:root {
  --timing: cubic-bezier(0.25, 0.8, 0.25, 1);
}

* { box-sizing: border-box; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--border-color); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(var(--accent-3), var(--accent));
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(var(--accent-3), var(--primary));
}

html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  margin: 0; padding: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background 0.3s var(--timing), color 0.3s var(--timing);
}

/* === NEW: Stardust Cursor === */
#stardust-trail {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}
.stardust {
  position: absolute;
  background: var(--accent-2);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-2), 0 0 12px var(--accent);
  animation: fadeOut 0.8s forwards;
  pointer-events: none;
}
@keyframes fadeOut {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(0); }
}

/* === NEW: Magic Bubbles Background === */
.bubbles-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  overflow: hidden;
}
.bubble {
  position: absolute;
  bottom: -100px;
  background: var(--bubble-color);
  border-radius: 50%;
  animation: rise 25s infinite;
  opacity: 0;
}
@keyframes rise {
  0% { transform: translateY(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-100vh); opacity: 0; }
}
.bubble:nth-child(1) { width: 80px; height: 80px; left: 10%; animation-duration: 20s; }
.bubble:nth-child(2) { width: 40px; height: 40px; left: 20%; animation-duration: 15s; animation-delay: 2s; }
.bubble:nth-child(3) { width: 60px; height: 60px; left: 35%; animation-duration: 30s; animation-delay: 4s; }
.bubble:nth-child(4) { width: 20px; height: 20px; left: 50%; animation-duration: 12s; }
.bubble:nth-child(5) { width: 50px; height: 50px; left: 55%; animation-duration: 18s; animation-delay: 5s; }
.bubble:nth-child(6) { width: 70px; height: 70px; left: 65%; animation-duration: 22s; animation-delay: 1s; }
.bubble:nth-child(7) { width: 30px; height: 30px; left: 75%; animation-duration: 14s; animation-delay: 3s; }
.bubble:nth-child(8) { width: 100px; height: 100px; left: 85%; animation-duration: 28s; animation-delay: 6s; }
.bubble:nth-child(9) { width: 45px; height: 45px; left: 25%; animation-duration: 17s; animation-delay: 7s; }
.bubble:nth-child(10) { width: 55px; height: 55px; left: 60%; animation-duration: 24s; animation-delay: 8s; }


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

.header {
  text-align: center;
  padding: 2.5rem 1rem 2rem;
  animation: float 6s ease-in-out infinite;
  z-index: 10;
  position: relative;
}
.header-title {
  font-family: 'Luckiest Guy', cursive;
  font-size: 3.5rem;
  margin: 0;
  letter-spacing: 1px;
  background: var(--active-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.header-subtitle {
  font-size: 1.1rem;
  margin: 0;
  color: var(--text-muted);
}

.theme-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  background: var(--btn-bg);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  width: 90px;
  height: 40px;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: all 0.3s var(--timing);
}
.theme-toggle:hover {
    box-shadow: var(--primary-glow);
}
.theme-toggle span {
  font-size: 1.25rem;
  transition: transform 0.3s var(--timing), opacity 0.3s var(--timing);
  line-height: 1;
}

.parallax-layer-hero {
    position: absolute;
    border-radius: 50%;
    z-index: -1;
    filter: blur(40px);
    transition: transform 0.2s var(--timing);
}
#parallax-1 {
    top: 10%; left: 25%;
    width: 300px; height: 300px;
    background: radial-gradient(circle, var(--primary-glow) 0%, rgba(255,255,255,0) 70%);
}
#parallax-2 {
    top: 30%; left: 55%;
    width: 200px; height: 200px;
    background: radial-gradient(circle, rgba(255, 122, 162, 0.2) 0%, rgba(255,255,255,0) 70%);
}


.main-container {
  max-width: 768px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
  position: relative;
  z-index: 5;
}
.hero-section {
  text-align: center;
  padding: 2rem 0;
  position: relative;
  overflow: hidden;
  /* NEW: 3D Tilt */
  perspective: 1000px;
}
.hero-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.hero-description {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}
.hero-section .btn-primary {
  margin-right: 0.5rem;
  animation: pulse 2.5s infinite;
}
.hero-section .btn-secondary {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
    border: 1px solid var(--border-color);
    color: var(--text);
}

@keyframes pulse {
  0% { transform: scale(1); box-shadow: 0 4px 15px var(--primary-glow); }
  50% { transform: scale(1.03); box-shadow: 0 6px 25px var(--primary-glow); }
  100% { transform: scale(1); box-shadow: 0 4px 15px var(--primary-glow); }
}

.card {
  background: var(--card);
  border-radius: 20px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background 0.3s var(--timing);
}
@media (min-width: 768px) { .card { padding: 2rem; } }

.form-section { margin-bottom: 2rem; }
.field { margin-bottom: 1.5rem; }
.field label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 0.75rem;
}
/* NEW: Pulse Step Bubble */
@keyframes pulse-bubble {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.step-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--active-gradient);
    color: white;
    font-size: 0.8rem;
    font-weight: 700;
    animation: pulse-bubble 2s infinite ease-in-out;
}

input[type='text'],
textarea,
select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 15px;
  border: 1px solid var(--border-color-light);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  font-family: 'Poppins', sans-serif;
  transition: all 0.2s var(--timing);
}
input[type='text']:focus {
    border-color: var(--accent);
    box-shadow: var(--focus);
    outline: none;
}
.custom-input {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.4s ease-out;
  margin-top: 0;
  padding-top: 0;
  padding-bottom: 0;
  border: 0;
}
.custom-input:not(.hidden) {
  max-height: 100px;
  opacity: 1;
  margin-top: 0.75rem;
  padding-top: 14px;
  padding-bottom: 14px;
  background: var(--bg-alt);
  border: 1px solid var(--border-color);
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.choice-option input[type='radio'] { opacity: 0; position: fixed; width: 0; }
.choice-option label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 0.5rem;
  border-radius: 15px;
  border: 2px solid var(--border-color);
  background: var(--bg-alt);
  cursor: pointer;
  transition: all 0.3s var(--timing);
  text-align: center;
  min-height: 90px;
  font-weight: 600;
  color: var(--text-muted);
}
.choice-option .emoji {
  font-size: 1.75rem;
  line-height: 1;
  margin-bottom: 0.25rem;
  transition: transform 0.3s var(--timing);
}
/* NEW: Wiggle Emoji on Hover */
@keyframes wiggle {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  50% { transform: rotate(10deg); }
  75% { transform: rotate(-5deg); }
  100% { transform: rotate(0deg); }
}
.choice-option label:hover .emoji { animation: wiggle 0.5s ease-in-out; }
.choice-option label:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 6px 15px var(--primary-glow);
  border-color: transparent;
  background: var(--hover-gradient);
  color: white;
}
.choice-option input[type='radio']:checked + label {
  background: var(--active-gradient);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px var(--primary-glow);
  transform: translateY(-2px) scale(1.02);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 15px;
  border: none;
  cursor: pointer;
  font-family: 'Poppins', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  transition: all 0.3s var(--timing);
  position: relative;
  overflow: hidden;
  /* NEW: 3D Tilt Prep */
  transform-style: preserve-3d;
  transform: perspective(1000px);
}
.btn-primary::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(120deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3) 50%, rgba(255,255,255,0) 100%);
    transition: left 0.6s var(--timing);
    opacity: 0.8;
}
.btn-primary:hover::before { left: 100%; }
.btn-primary {
  background: var(--active-gradient);
  color: white;
  box-shadow: 0 4px 15px var(--primary-glow);
}
.btn-primary:hover {
  transform: translateY(-3px) perspective(1000px);
  box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-primary:active {
  transform: translateY(-1px) scale(0.99) perspective(1000px);
  box-shadow: 0 2px 10px var(--primary-glow);
}
.btn-submit {
  width: 100%;
  padding: 16px 20px;
  font-size: 1.1rem;
  margin-top: 1rem;
  animation: none;
}
.btn-secondary {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: var(--border-color);
  transform: translateY(-2px) perspective(1000px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.btn-icon {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--border-color);
  font-size: 1.25rem;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  padding: 0;
}
.btn-icon::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  transform: scale(0.8);
  opacity: 0;
  transition: all 0.4s var(--timing);
}
.btn-icon:hover::after {
  transform: scale(1.2);
  opacity: 1;
  border-color: transparent;
  background: var(--primary-glow);
}
.btn-icon:hover {
    transform: translateY(-2px) scale(1.05) perspective(1000px);
}
.btn-icon.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-font-toggle {
    font-weight: 800;
    font-size: 1.1rem;
}
body[data-font-size="small"] .btn-font-toggle { font-size: 0.9rem; }
body[data-font-size="medium"] .btn-font-toggle { font-size: 1.1rem; }
body[data-font-size="large"] .btn-font-toggle { font-size: 1.3rem; }


.story-container {
    max-width: 1024px;
    margin: 0 auto 4rem;
    padding: 0 1rem;
    position: relative;
    z-index: 5;
}

/* NEW: Magic Reveal Animation */
@keyframes magicReveal {
  0% {
    transform: scale(0.95);
    opacity: 0;
    box-shadow: 0 0 0 0 var(--primary-glow);
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
    box-shadow: var(--shadow);
  }
}
#storyDisplay { animation: magicReveal 0.6s var(--timing) both; }

.story-header {
  text-align: center;
  margin-bottom: 1.5rem;
}
.story-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  background: var(--active-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.3;
}

@keyframes magicGlow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
.story-image-wrapper {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    margin-bottom: 1rem;
    padding: 3px;
    z-index: 1;
}
.story-image-wrapper::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: conic-gradient(
      from 180deg at 50% 50%,
      var(--accent-3), var(--accent-2), var(--accent), var(--accent-3)
    );
    z-index: -1;
    animation: magicGlow 4s linear infinite;
    opacity: 0.7;
}
.story-image {
  width: 100%;
  height: auto;
  max-height: 500px;
  object-fit: cover;
  border-radius: 16px;
  display: block;
  margin-bottom: 0;
  position: relative;
  z-index: 2;
}
#generateImageBtn {
    width: 100%;
    max-width: 300px;
    margin: 0.5rem auto 0;
}
.story-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 0;
  padding: 1rem 0 0;
  flex-wrap: wrap;
}
.magic-divider {
    border: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent-3), var(--accent), var(--accent-2), var(--accent), var(--accent-3), transparent);
    opacity: 0.3;
    margin: 1.5rem 0;
}
body[data-theme="dark"] .magic-divider { opacity: 0.6; }

.story-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
}
.stat-item {
    background: var(--bg-alt);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 0.75rem 1.25rem;
    text-align: center;
    flex: 1;
    min-width: 150px;
}
.stat-item .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-2);
}
.stat-item .label {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.stat-item .skeleton {
    height: 1.5rem;
    width: 50%;
    margin: 0 auto 0.5rem;
}
.stat-item .skeleton.label {
    height: 0.85rem;
    width: 80%;
    margin-bottom: 0;
}

.story-content {
  color: var(--text);
  transition: font-size 0.3s var(--timing);
}
body[data-font-size="small"] .story-content {
  font-size: 0.9rem;
  line-height: 1.7;
}
body[data-font-size="medium"] .story-content {
  font-size: 1.1rem;
  line-height: 1.9;
}
body[data-font-size="large"] .story-content {
  font-size: 1.25rem;
  line-height: 2.0;
}
#storyBody p { margin: 0 0 1.25rem; }

.story-word {
    opacity: 0;
    transform: translateY(5px);
    transition: opacity 0.2s ease-out, transform 0.2s ease-out;
}
.magic-word {
    color: var(--magic-word);
    font-weight: 600;
    text-shadow: 0 0 8px var(--primary-glow);
}
.dictionary-word {
    color: var(--dict-word);
    font-weight: 600;
    border-bottom: 2px dashed var(--dict-word);
    cursor: pointer;
}

@keyframes readAloudPulse {
  0% { background-color: rgba(255, 235, 59, 0.4); box-shadow: 0 0 5px rgba(255, 235, 59, 0.2); }
  50% { background-color: rgba(255, 235, 59, 0.7); box-shadow: 0 0 15px 5px rgba(255, 235, 59, 0.5); }
  100% { background-color: rgba(255, 235, 59, 0.4); box-shadow: 0 0 5px rgba(255, 235, 59, 0.2); }
}
.story-word.highlight {
  animation: readAloudPulse 1s infinite;
  color: #000;
  border-radius: 4px;
}
body[data-theme="dark"] .story-word.highlight { color: #000; }
body[data-theme="evening"] .story-word.highlight { color: #000; }
body[data-theme="fairy"] .story-word.highlight { color: #000; }
body[data-theme="underwater"] .story-word.highlight { color: #000; }

.moral {
  font-style: italic;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--bg-alt);
  border-radius: 15px;
  border-top: 2px dashed var(--border-color);
}
.story-footer {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 0;
  padding-top: 1.5rem;
}
.skeleton {
  background: linear-gradient( 90deg, var(--skeleton-bg) 0%, var(--skeleton-shine) 50%, var(--skeleton-bg) 100% );
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border-radius: 10px;
  color: transparent;
}
.skeleton.title { width: 60%; height: 2.5rem; margin: 0 auto 1.5rem; }
.skeleton.line { width: 100%; height: 1.1rem; margin: 0.75rem 0; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* === Glassmorphism Modals === */
.modal {
  position: fixed; inset: 0;
  display: none; align-items: center; justify-content: center;
  background: rgba(12, 18, 35, 0.5);
  backdrop-filter: blur(12px) saturate(150%);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s var(--timing);
}
.modal.active { display: flex; opacity: 1; }
.modal .modal-card,
.modal-card {
  width: 90%; max-width: 500px;
  background: var(--modal-bg);
  padding: 1.5rem;
  border-radius: 20px;
  box-shadow: 0 10px 40px var(--modal-shadow);
  transform: scale(0.95); opacity: 0;
  transition: all 0.3s var(--timing);
  border: 1px solid var(--modal-border);
}
.modal.active .modal-card {
    transform: scale(1); opacity: 1;
    transition-delay: 0.05s;
}
.modal-dictionary {
    max-width: 400px;
}
.modal-dictionary #dictionaryWord {
    color: var(--primary);
    text-transform: capitalize;
}
.modal-dictionary #dictionaryDefinition {
    font-size: 1.1rem;
    color: var(--text);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary);
}
.modal-body { max-height: 60vh; overflow-y: auto; color: var(--text-muted); }
.modal-footer { margin-top: 1.5rem; text-align: right; }
.close-modal { width: 40px; height: 40px; font-size: 1rem; }

.modal-welcome-graphic {
    font-size: 3.5rem;
    text-align: center;
    line-height: 1;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}
.onboard .modal-header { justify-content: center; }
.onboard .modal-body ul { padding-left: 20px; color: var(--text); }
.onboard .modal-body li { margin-bottom: 0.5rem; }
.onboard .modal-footer { text-align: center; }

#pastContent div {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 10px;
}
#pastContent div:last-child { border-bottom: none; }
#pastContent div:hover { background: var(--bg-alt); }
#pastContent strong { color: var(--accent); }

.share-options { display: grid; gap: 0.75rem; }
.share-btn {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 12px;
  font-weight: 600; border-radius: 12px;
  background: var(--card); color: var(--text);
  border: 2px solid var(--border-color-light);
  cursor: pointer; text-align: left;
  font-size: 1rem;
  transition: all 0.2s ease;
}
.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.share-btn[data-platform="whatsapp"]:hover { border-color: #25D366; color: #25D366; }
.share-btn[data-platform="linkedin"]:hover { border-color: #0A66C2; color: #0A66C2; }
.share-btn[data-platform="twitter"]:hover { border-color: #1DA1F2; color: #1DA1F2; }
.share-btn[data-platform="email"]:hover { border-color: #777; color: #777; }
.share-btn[data-platform="facebook"]:hover { border-color: #1877F2; color: #1877F2; }
.share-btn.copy-link:hover { border-color: var(--accent); color: var(--accent); }
.download-pdf {
    display: flex; align-items: center; gap: 10px;
    font-weight: 600;
    background: var(--card); color: var(--text);
    border: 2px solid var(--border-color-light);
}
.download-pdf:hover { border-color: #D93025; color: #D93025; }

#dw-toast {
  position: fixed;
  right: 20px; bottom: 20px;
  padding: 12px 18px;
  background: var(--primary);
  color: white;
  border-radius: 15px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  z-index: 2000;
  transition: all 0.4s var(--timing);
  opacity: 0; transform: translateY(10px);
}
.footer {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
.hidden { display: none !important; }
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible,
.choice-option input[type='radio']:focus-visible + label {
  outline: none;
  box-shadow: var(--focus);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  body, .btn, .story-image-wrapper::before,
  .story-card.enter, #particles, .header,
  .choice-option label, .modal, .modal-card,
  .hero-section .btn-primary, .parallax-layer-hero,
  .custom-input, .story-word, .story-word.highlight,
  .bubble, .stardust, .step-bubble {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 1080px) {
  .story-container { max-width: 768px; }
  .story-title { font-size: 2.2rem; }
}

@media (max-width: 768px) {
  .main-container { max-width: 100%; }
  .header-title { font-size: 2.8rem; }
  .hero-title { font-size: 1.8rem; }
  .story-title { font-size: 1.8rem; }
  .card { padding: 1.25rem; }
  .story-actions { flex-wrap: wrap; }
  .story-footer { flex-direction: column; }
  .story-footer button { width: 100%; }
  .choice-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .choice-option label { min-height: 80px; padding: 0.75rem 0.25rem; }
  .theme-toggle {
    width: 70px; height: 34px;
    padding: 4px;
    top: 15px; right: 15px;
  }
  .theme-toggle span { font-size: 0.9rem; }
  .story-stats { flex-direction: column; }
}