.bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.glass-card {
  background: hsla(0, 0%, 100%, 0.1);
  backdrop-filter: blur(12px);
  border: 1px solid hsla(0, 0%, 100%, 0.2);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

.dark .glass-card {
  background: hsla(230, 40%, 10%, 0.4);
  border: 1px solid hsla(0, 0%, 100%, 0.1);
}

.ticker-wrap {
  width: 100%;
  overflow: hidden;
  background: hsla(var(--primary), 0.05);
  padding: 0.5rem 0;
  border-top: 1px solid hsla(var(--primary), 0.1);
  border-bottom: 1px solid hsla(var(--primary), 0.1);
}

.ticker {
  display: inline-block;
  white-space: nowrap;
  padding-right: 100%;
  animation: ticker 30s linear infinite;
}

@keyframes ticker {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}

.ticker-item {
  display: inline-block;
  padding: 0 2rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: hsl(var(--primary));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.focus-mode-overlay {
  position: fixed;
  inset: 0;
  background: hsl(var(--background));
  z-index: 40;
  opacity: 0.98;
  pointer-events: none;
}

:root {
  --background: 0 0% 100%;
  --foreground: 225 40% 10%;
  --primary: 260 100% 60%;
  --primary-foreground: 0 0% 100%;
  --secondary: 195 100% 50%;
  --secondary-foreground: 225 40% 10%;
  --accent: 40 100% 55%;
  --accent-foreground: 225 40% 10%;
  --muted: 220 30% 96%;
  --destructive: 0 100% 60%;
  --border: 220 20% 90%;
  --card: 0 0% 100%;
  --shadow-sm: 0 8px 24px hsla(225, 50%, 15%, 0.06);
  --shadow-md: 0 16px 48px hsla(225, 50%, 15%, 0.1);
  --shadow-lg: 0 24px 80px hsla(225, 50%, 15%, 0.14);
  --transition-fast: 160ms ease;
  --transition-smooth: 280ms cubic-bezier(0.22, 1, 0.36, 1);
  --radius-sm: 14px;
  --radius-md: 20px;
  --radius-lg: 32px;
}

.dark {
  --background: 230 45% 6%;
  --foreground: 210 20% 98%;
  --primary: 265 100% 70%;
  --primary-foreground: 0 0% 100%;
  --secondary: 190 100% 60%;
  --secondary-foreground: 230 45% 6%;
  --accent: 45 100% 60%;
  --accent-foreground: 230 45% 6%;
  --muted: 230 35% 12%;
  --destructive: 0 100% 65%;
  --border: 230 30% 18%;
  --card: 230 40% 10%;
  --shadow-sm: 0 10px 30px hsla(0, 0%, 0%, 0.3);
  --shadow-md: 0 20px 50px hsla(0, 0%, 0%, 0.4);
  --shadow-lg: 0 30px 100px hsla(0, 0%, 0%, 0.5);
}

* {
  box-sizing: border-box;
}

html, body, #root {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, hsla(260, 100%, 65%, 0.15), transparent 35%),
    radial-gradient(circle at top right, hsla(185, 100%, 50%, 0.12), transparent 30%),
    hsl(var(--background));
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  padding-bottom: env(safe-area-inset-bottom);
}

.pb-safe {
  padding-bottom: env(safe-area-inset-bottom);
}

.card-surface {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
}

.card-hero {
  background: linear-gradient(135deg, hsl(var(--primary)), hsl(var(--secondary)));
  border: 1px solid hsla(0, 0%, 100%, 0.2);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  color: white;
  position: relative;
  overflow: hidden;
}

.card-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(hsla(0, 0%, 100%, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, hsla(0, 0%, 100%, 0.1) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.card-hero::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at center, hsla(0, 0%, 100%, 0.15), transparent 60%);
  pointer-events: none;
}

.soft-ring {
  box-shadow: 0 0 0 4px hsla(260, 100%, 65%, 0.15);
}

button, a, input, select, textarea {
  transition: all var(--transition-fast);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px hsla(260, 100%, 65%, 0.25);
}

.glass-nav {
  backdrop-filter: blur(20px);
  background: hsla(0, 0%, 100%, 0.8);
}

.dark .glass-nav {
  background: hsla(230, 40%, 10%, 0.8);
}

.text-balance {
  text-wrap: balance;
}

.pulse-dot {
  animation: pulseDot 2s infinite;
}

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

.slide-up {
  animation: slideUp 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* Background Animation Styles */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 0.9;
  transition: background 1s ease;
}

.bg-fantasy-active {
  background: radial-gradient(circle at 50% 50%, hsla(260, 100%, 65%, 0.1), transparent 70%);
}

.dark .bg-scene {
  opacity: 0.6;
}

.castle-far {
  position: absolute;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  filter: blur(1.5px);
  animation: floatCastle 20s ease-in-out infinite;
}

@keyframes floatCastle {
  0%, 100% { transform: translate(-50%, 0) rotate(0deg) scale(1); }
  25% { transform: translate(-50%, -30px) rotate(1.5deg) scale(1.05); }
  75% { transform: translate(-50%, -15px) rotate(-1.5deg) scale(0.95); }
}

.child-animated {
  position: absolute;
  bottom: -30px;
  animation: walkAcross var(--duration) linear infinite;
  animation-delay: var(--delay);
}

@keyframes walkAcross {
  from { left: -250px; }
  to { left: calc(100% + 250px); }
}

.animate-bounce-walk {
  animation: bounceWalk 0.6s ease-in-out infinite alternate;
}

@keyframes bounceWalk {
  from { transform: translateY(0) rotate(-5deg); }
  to { transform: translateY(-20px) rotate(5deg); }
}

.animate-floating-head {
  animation: floatingHead 1.2s ease-in-out infinite alternate;
}

@keyframes floatingHead {
  from { transform: translateY(0) rotate(-3deg); }
  to { transform: translateY(-6px) rotate(3deg); }
}

.animate-hop {
  animation: hop 1.8s ease-in-out infinite;
}

@keyframes hop {
  0%, 100% { transform: translateY(0) scaleY(1); }
  40% { transform: translateY(-50px) scaleY(1.15); }
  50% { transform: translateY(-55px) scaleY(1); }
  60% { transform: translateY(-50px) scaleY(1.15); }
  90% { transform: translateY(0) scaleY(0.8); }
}

.animate-pet-follow {
  animation: petFollow 0.6s ease-in-out infinite alternate;
}

@keyframes petFollow {
  from { transform: translateY(0) scaleX(1); }
  to { transform: translateY(-12px) scaleX(1.2); }
}

.balloon-animated {
  position: absolute;
  bottom: -80px;
  animation: floatUp var(--duration) linear infinite;
  animation-delay: var(--delay);
}

@keyframes floatUp {
  from { transform: translateY(0) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  to { transform: translateY(-110vh) translateX(80px); opacity: 0; }
}

.cloud {
  position: absolute;
  background: white;
  border-radius: 999px;
  opacity: 0.8;
  animation: floatCloud var(--duration) linear infinite;
}

@keyframes floatCloud {
  from { left: -400px; }
  to { left: 100%; }
}

.bird-animated {
  position: absolute;
  animation: flyAcross var(--duration) linear infinite;
  animation-delay: var(--delay);
}

@keyframes flyAcross {
  from { left: -150px; transform: translateY(0) scaleX(1); }
  25% { transform: translateY(-50px) scaleX(1.3); }
  50% { transform: translateY(0) scaleX(1); }
  75% { transform: translateY(50px) scaleX(0.7); }
  to { left: calc(100% + 150px); transform: translateY(0) scaleX(1); }
}

.butterfly {
  position: absolute;
  animation: flutter 6s ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes flutter {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1); }
  25% { transform: translate(40px, -40px) rotate(25deg) scale(1.4); }
  50% { transform: translate(80px, 0) rotate(-20deg) scale(1); }
  75% { transform: translate(40px, 40px) rotate(15deg) scale(1.3); }
}

.animate-bloom {
  animation: bloom 5s ease-in-out infinite alternate;
  transform-origin: bottom center;
}

@keyframes bloom {
  from { transform: scale(0.6) rotate(-10deg); filter: brightness(0.7); }
  to { transform: scale(1.3) rotate(10deg); filter: brightness(1.4); }
}

.animate-wind-drift {
  animation: windDrift 20s linear infinite;
}

@keyframes windDrift {
  from { left: -200px; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  to { left: 100%; opacity: 0; }
}

.animate-slow-spin {
  animation: slowSpin 120s linear infinite;
}

@keyframes slowSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-spin-slow {
  animation: spinSlow 8s linear infinite;
}

@keyframes spinSlow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-sway {
  animation: sway 7s ease-in-out infinite alternate;
  transform-origin: bottom center;
}

@keyframes sway {
  from { transform: rotate(-5deg) scale(0.85); }
  to { transform: rotate(5deg) scale(1.15); }
}

.animate-bounce-slow {
  animation: bounceSlow 6s ease-in-out infinite;
}

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

/* New Flashy Animations */
.animate-wave {
  animation: wave 0.5s ease-in-out infinite alternate;
}

@keyframes wave {
  from { transform: rotate(-45deg); }
  to { transform: rotate(45deg); }
}

.animate-airplane-bob {
  animation: airplaneBob 1.5s ease-in-out infinite alternate;
}

@keyframes airplaneBob {
  0% { transform: translateY(-15px) rotate(-3deg) scale(1); }
  50% { transform: translateY(15px) rotate(3deg) scale(1.05); }
  100% { transform: translateY(-15px) rotate(-3deg) scale(1); }
}

.animate-rainbow-glow {
  animation: rainbowGlow 3s linear infinite;
}

@keyframes rainbowGlow {
  0% { filter: hue-rotate(0deg) brightness(1); }
  50% { filter: hue-rotate(180deg) brightness(1.5); }
  100% { filter: hue-rotate(360deg) brightness(1); }
}

.animate-whoosh {
  animation: whoosh 1.5s ease-in-out infinite;
}

@keyframes whoosh {
  0% { transform: scaleX(0.5); opacity: 0; }
  50% { transform: scaleX(1.5); opacity: 1; }
  100% { transform: scaleX(0.5); opacity: 0; }
}

.animate-progress-indefinite {
  animation: progressIndefinite 2s ease-in-out infinite;
}

@keyframes progressIndefinite {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

/* Page transition polish */
.page-transition {
  /* Fix for pink/yellowish subpixel antialiasing artifacts on text */
  transform: translateZ(0);
  backface-visibility: hidden;
}

.perspective-1000 {
  perspective: 1000px;
}

.preserve-3d {
  transform-style: preserve-3d;
}

.backface-hidden {
  backface-visibility: hidden;
}

.rotate-y-180 {
  transform: rotateY(180deg);
}

.transform-gpu {
  /* Removed to prevent text rendering artifacts */
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-thumb {
  background: hsla(260, 100%, 65%, 0.3);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: hsla(260, 100%, 65%, 0.5);
  background-clip: padding-box;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: hsla(var(--primary), 0.2);
  border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: hsla(var(--primary), 0.4);
}

/* Infinite Lab Grids */
.science-grid {
  background-image: radial-gradient(circle at 2px 2px, hsla(var(--foreground), 0.05) 1px, transparent 0);
  background-size: 24px 24px;
}

.math-grid {
  background-color: hsl(var(--card));
}
