/* Base reset & variables */
*:where(:not(html, iframe, canvas, img, svg, video):not(svg *, symbol *)) {
  all: unset;
  display: revert;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: light; }
body { 
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; 
  line-height: 1.6; 
  color: var(--text); 
  background: radial-gradient(ellipse at top, #1a1a2e 0%, #0f0f23 100%);
  min-height: 100vh;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

:root {
  --bg: #0f0f23;
  --bg-secondary: #1a1a2e;
  --text: #ffffff;
  --text-secondary: #a0a0a0;
  --muted: #666;
  --primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --primary-hover: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  --accent1: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
  --accent2: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
  --accent3: linear-gradient(135deg, #fad0c4 0%, #ffd1ff 100%);
  --glass: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
  --shadow-lg: 0 35px 60px -15px rgba(0, 0, 0, 0.9);
  --radius: 20px;
  --radius-sm: 12px;
  --vh: 100dvh;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: 8px; z-index: 50;
  background: #fff; color: #000; padding: 8px 12px; border-radius: 8px; box-shadow: var(--shadow);
  transform: translateY(-120%);
}
.skip-link:focus { transform: translateY(0); }

/* Scene */
.scene { min-height: var(--vh); display: grid; grid-template-rows: 1fr auto; align-items: center; justify-items: center; position: relative; overflow: hidden; }

/* Balloon Layer */
#balloon-layer { position: absolute; inset: 0; z-index: 0; overflow: hidden; }
.balloon { position: absolute; bottom: -20%; width: var(--size, 36px); aspect-ratio: 1 / 1.3; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: var(--color, #ffd6e7); opacity: var(--opacity, .9); box-shadow: inset 0 -6px 12px rgba(0,0,0,.08); will-change: transform; }
.balloon::after { content: ""; position: absolute; bottom: -10px; left: 50%; width: 2px; height: 40px; background: rgba(0,0,0,.12); transform: translateX(-50%); border-radius: 1px; }
.balloon-img { position: absolute; bottom: -20%; width: var(--size, 48px); aspect-ratio: 1 / 1.3; background-position: center; background-size: contain; background-repeat: no-repeat; will-change: transform; filter: drop-shadow(0 6px 10px rgba(0,0,0,.12)); }
@keyframes floatUp { from { transform: translate3d(var(--x,0), 0, 0); } to { transform: translate3d(calc(var(--x,0) + var(--sway, 12px)), -120vh, 0); } }

/* Cake */
.cake-area { position: relative; z-index: 1; padding-top: 10vh; }
.cake-stack { position: relative; display: grid; place-items: center; }
.cake-image { width: clamp(220px, 64vw, 360px); height: auto; filter: drop-shadow(0 8px 20px rgba(0,0,0,.12)); border-radius: 12px; }
.cake { position: absolute; left: 50%; transform: translateX(-50%); bottom: 0; width: clamp(220px, 64vw, 360px); height: auto; pointer-events: none; filter: drop-shadow(0 8px 20px rgba(0,0,0,.12)); }
#cake-body { display: none; }

/* Greeting text above cake */
.greeting { 
  position: absolute; top: -80px; left: 0; right: 0; 
  display: grid; gap: 8px; justify-items: center; z-index: 2; 
}
.greet-line { 
  font-weight: 700; letter-spacing: 4px; 
  font-size: clamp(18px, 5vw, 26px); 
  text-transform: uppercase; 
  background: var(--accent1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 4px 12px rgba(255, 154, 158, 0.3));
}
.greet-name { 
  font-weight: 800; 
  font-size: clamp(36px, 12vw, 64px); 
  letter-spacing: 6px; 
  filter: drop-shadow(0 8px 24px rgba(255, 107, 107, 0.4));
}
.greet-letter { 
  display: inline-block; 
  padding: 0 2px; 
  animation: bounce 2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.1s);
  text-shadow: 0 4px 8px rgba(0,0,0,0.3);
}
@keyframes shimmer {
  0%, 100% { filter: drop-shadow(0 8px 24px rgba(255, 107, 107, 0.4)) hue-rotate(0deg); }
  50% { filter: drop-shadow(0 8px 24px rgba(255, 107, 107, 0.8)) hue-rotate(90deg); }
}
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
  60% { transform: translateY(-4px); }
}

.flame { transform-origin: 0 -20px; animation: flameSway 1.8s ease-in-out infinite alternate; animation-delay: var(--delay, 0s); }
.flame-outer { transform-origin: 0 -22px; animation: flameBreath 1.6s ease-in-out infinite; }
.flame-middle { transform-origin: 0 -22px; animation: flameBreath 1.3s ease-in-out infinite; }
.flame-core { transform-origin: 0 -22px; animation: flameBreath 1.1s ease-in-out infinite, flameFlicker .16s steps(2,end) infinite; }
.flame-glow { animation: glowPulse 1.6s ease-in-out infinite; }
@keyframes flameSway { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-1.5px) rotate(4deg); } }
@keyframes flameBreath { 0%,100% { transform: scale(1) translateY(0); } 50% { transform: scale(1.06) translateY(-0.6px); } }
@keyframes flameFlicker { 0%,100% { opacity: .88; } 50% { opacity: 1; } }
@keyframes glowPulse { 0%,100% { opacity: .45; } 50% { opacity: .7; } }

/* Actions */
.actions { display: grid; gap: 12px; padding: 24px 16px 40px; z-index: 1; width: 100%; max-width: 420px; }
.primary-button, .secondary-button, .icon-button, .tab { cursor: pointer; user-select: none; }
.primary-button { 
  min-height: 56px; padding: 16px 28px; border-radius: var(--radius); 
  background: var(--primary); color: #fff; text-align: center; 
  font-weight: 600; font-size: 16px; letter-spacing: 0.5px;
  box-shadow: var(--shadow); 
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
  position: relative;
  overflow: hidden;
}
.primary-button::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--primary-hover);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.primary-button:hover { 
  transform: translateY(-4px) scale(1.02);
  box-shadow: var(--shadow-lg);
}
.primary-button:hover::before {
  opacity: 1;
}
.primary-button:active { 
  transform: translateY(-2px) scale(0.98); 
}
.secondary-button { min-height: 42px; padding: 10px 14px; border-radius: 10px; background: #fff; border: 1px solid #e8e8ee; color: #222; box-shadow: 0 2px 6px rgba(0,0,0,.06); }
.icon-button { 
  width: 40px; height: 40px; border-radius: 10px; 
  background: rgba(255, 255, 255, 0.1); 
  border: 1px solid rgba(255, 255, 255, 0.2); 
  color: var(--text); 
  display: grid; place-items: center; 
  backdrop-filter: blur(10px);
  transition: all 0.2s ease;
}
.icon-button:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.05);
}

.primary-button:focus-visible, .secondary-button:focus-visible, .icon-button:focus-visible, .tab:focus-visible { outline: 3px solid #222; outline-offset: 2px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(15, 15, 35, 0.6); opacity: 0; transition: opacity 0.2s ease; }
.modal__dialog { 
  position: relative; z-index: 1; width: min(100%, 840px); height: 100dvh; 
  background: var(--glass); 
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  border-radius: var(--radius) var(--radius) 0 0; 
  transform: translateY(20px); opacity: 0; 
  transition: all 0.2s ease; 
  display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; 
  box-shadow: var(--shadow);
}
.modal.is-open .modal__backdrop { opacity: 1; }
.modal.is-open .modal__dialog { transform: translateY(0); opacity: 1; }

.modal__header { 
  position: sticky; top: 0; z-index: 2; 
  display: grid; grid-template-columns: 50px 1fr 50px; align-items: center; gap: 12px; 
  padding: 20px 24px; 
  background: var(--glass); 
  backdrop-filter: blur(20px); 
  border-bottom: 1px solid var(--glass-border); 
}
.modal__header h2 { 
  text-align: center; font-size: 22px; font-weight: 700; 
  color: var(--text); 
  background: var(--accent2);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.modal__footer { 
  padding: 20px 24px; 
  border-top: 1px solid var(--glass-border); 
  background: var(--glass); 
  backdrop-filter: blur(20px);
  position: sticky; bottom: 0; 
}

/* Tabs */
.tabs { display: grid; grid-auto-flow: column; gap: 8px; padding: 10px 12px; background: #fafafe; border-bottom: 1px solid #f0f0f4; position: sticky; top: 48px; z-index: 1; }
.tab { padding: 10px 12px; border-radius: 999px; background: #fff; border: 1px solid #ececf3; color: #333; font-weight: 600; text-align: center; }
.tab.is-active { background: var(--primary); color: #fff; border-color: transparent; }

/* Story */
.tabpanel { height: calc(100dvh - 48px - 48px - 48px); overflow: auto; }
.tabpanel.is-hidden { display: none; }
.story-card { margin: 16px; padding: 16px; border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); display: grid; align-content: space-between; gap: 12px; min-height: 280px; }
.story-from { color: var(--muted); font-weight: 600; }
.story-text { font-size: 16px; line-height: 1.6; color: #111; }
.story-footer { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.counter { text-align: center; color: #555; font-variant-numeric: tabular-nums; }

/* WhatsApp View */
.wa-list { 
  padding: 10px; display: grid; gap: 8px; 
  overflow-y: auto; height: 600px; 
  background-image: url('assets/img/whatsapp-bg.webp');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: #e5ddd5;
}
.wa-item { display: grid; grid-template-columns: 36px 1fr; gap: 8px; align-items: start; position: relative; z-index: 1; }
.wa-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.wa-bubble { background: #fff; border-radius: 14px; padding: 8px 10px; box-shadow: 0 2px 8px rgba(0,0,0,.08); position: relative; z-index: 2; }
.wa-name { font-weight: 700; margin-bottom: 4px; color: #1a1a1a; font-size: 14px; }
.wa-text { color: #333; line-height: 1.6; font-size: 14px; }

/* Audio List */
.audio-list { 
  padding: 12px; display: grid; gap: 6px; 
  overflow-y: auto; height: 600px; 
  background: rgba(26, 26, 46, 0.3); 
  border-radius: var(--radius); 
}
.audio-row { 
  position: relative; overflow: hidden; 
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  background: var(--glass); 
  border: 1px solid var(--glass-border); 
  border-radius: 12px; padding: 10px 14px; 
  box-shadow: var(--shadow); 
  transition: all 0.2s ease; 
  height: 150px;
}
.audio-row:hover { 
  transform: translateY(-1px); 
  border-color: rgba(255, 255, 255, 0.3);
}
.audio-row.is-active { 
  background: rgba(139, 92, 246, 0.15); 
  border-color: rgba(139, 92, 246, 0.4); 
}
.audio-progress { 
  position: absolute; bottom: 0; left: 0; right: 0; height: 2px; 
  background: linear-gradient(90deg, #ff6b6b 0%, #feca57 50%, #48dbfb 100%); 
  transform-origin: left; 
  transform: scaleX(calc(var(--progress, 0) / 100)); 
  border-radius: 0 0 12px 12px;
}
.audio-row > * { position: relative; z-index: 1; }
.audio-play-btn { 
  width: 36px; height: 36px; border-radius: 50%; 
  background: var(--primary); 
  display: grid; place-items: center; 
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4); 
  transition: all 0.2s ease;
}
.audio-play-btn:hover { 
  transform: scale(1.05); 
}
.audio-play-btn::after { 
  content: "▶"; color: white; font-size: 12px; margin-left: 1px; 
}
.audio-row.is-active .audio-play-btn::after { content: "⏸"; margin-left: 0; }
.audio-content { 
  display: flex; gap: 8px; align-items: center;
  justify-self: center;
}
.audio-name { 
  font-weight: 600; font-size: 14px; 
  color: var(--text); 
}
.audio-hint { 
  color: var(--text-secondary); font-size: 12px; 
  background: rgba(255, 255, 255, 0.1); 
  padding: 4px 8px; border-radius: 12px; 
}
.audio-icon { 
  display: none;
}
@keyframes eq { 0% { height: 6px; } 25% { height: 12px; } 50% { height: 18px; } 75% { height: 10px; } 100% { height: 6px; } }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.15); } }

/* Desktop enhancements */
@media (min-width: 768px) {
  .scene { grid-template-rows: 1fr auto; }
  .actions { max-width: 520px; }
  .modal__dialog { border-radius: 12px; height: min(92dvh, 820px); }
  .tabs { top: 60px; }
  .modal__header h2 { font-size: 20px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}


