@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

/* ==========================================
   [HISTORY START: STEP 61] [2025-12-25 20:41]
   CHANGE: Aktivierung des "Living Gradient" direkt im Body für globalen Effekt
   STATUS: ACTIVE
   ==========================================
*/
body { 
    font-family: 'Nunito', sans-serif; 
    -webkit-tap-highlight-color: transparent;
    /* Sanfter Farbverlauf (Pastell-Mix aus Rose, Pfirsich, Lavendel, Sanftblau) */
    background: linear-gradient(-45deg, #ff9a9e, #fad0c4, #fbc2eb, #a18cd1, #a6c0fe, #ff9a9e);
    background-size: 400% 400%;
    animation: livingGradientShift 60s ease infinite;
}

/* ==========================================
   [HISTORY END: STEP 61]
   [OLD-CODE (COMMENTED OUT) START]
   /* body { font-family: 'Nunito', sans-serif; -webkit-tap-highlight-color: transparent; } */
   /* [OLD-CODE END]
   ==========================================
*/

/* ==========================================
   [HISTORY START: STEP 60] [2025-12-25 20:30]
   CHANGE: Hinzufügen des "Living Gradient" für sanfte, globale Hintergrundanimation
   STATUS: ACTIVE
   ==========================================
*/
.living-gradient-bg {
    /* Sanfter Farbverlauf (Pastell-Mix aus Rose, Pfirsich, Lavendel, Sanftblau)
       Ändert sich sehr langsam für "unbemerktes" Wohlbefinden 
    */
    background: linear-gradient(-45deg, #ff9a9e, #fad0c4, #fbc2eb, #a18cd1, #a6c0fe, #ff9a9e);
    background-size: 400% 400%;
    animation: livingGradientShift 60s ease infinite;
}

@keyframes livingGradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
/* ==========================================
   [HISTORY END: STEP 60]
   ==========================================
*/

/* 3D Flip Styles */
.perspective-1000 { perspective: 1000px; }
.preserve-3d { transform-style: preserve-3d; }
.backface-hidden { backface-visibility: hidden; }
.rotate-y-180 { transform: rotateY(180deg); }
.card-inner { transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.is-flipped { transform: rotateY(180deg); }

/* New Soothing Card Background */
.card-face-style {
    /* Gentle abstract background with white overlay for readability */
    background-image: linear-gradient(rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.92)), 
                      url('https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80');
    background-size: cover;
    background-position: center;
}

.card-face-style-back {
    /* Slightly different tint for the back if desired, currently keeping consistent but distinct class */
    background-image: linear-gradient(rgba(250, 250, 255, 0.9), rgba(250, 250, 255, 0.9)), 
                      url('https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-4.0.3&auto=format&fit=crop&w=1000&q=80');
    background-size: cover;
    background-position: center;
}

/* Animations */
@keyframes pop { 0% { transform: scale(0.9); } 50% { transform: scale(1.1); } 100% { transform: scale(1); } }
.animate-pop { animation: pop 0.3s ease-out; }

@keyframes gradientShift { 
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.animate-gradient {
    background-size: 400% 400%;
    animation: gradientShift 60s ease infinite;
}

.floating-bg {
    position: absolute;
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
    animation: float 6s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }

/* Motivation & Zen Animations */
@keyframes float-slow { 0%, 100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-15px) rotate(5deg); } }
.animate-float-slow { animation: float-slow 4s ease-in-out infinite; }

@keyframes breath { 
    0%, 100% { transform: scale(1); opacity: 0.4; box-shadow: 0 0 20px rgba(255,255,255,0.1); } 
    50% { transform: scale(1.3); opacity: 0.8; box-shadow: 0 0 40px rgba(255,255,255,0.3); } 
}
.animate-breath { animation: breath 6s ease-in-out infinite; }

.zen-enter { transition: opacity 2s ease-in-out; }

@keyframes zen-colors {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.animate-zen-bg {
    background: linear-gradient(135deg, #0f172a, #134e4a, #1e1b4b, #312e81);
    background-size: 300% 300%;
    animation: zen-colors 15s ease infinite;
}

.animate-zen-start-bg {
    background: linear-gradient(135deg, #047857, #be185d, #065f46, #9d174d); 
    background-size: 300% 300%;
    animation: zen-colors 15s ease infinite;
}

/* SCREEN GLOW EFFECT (Rainbow Pulse) - Applied ONLY to Body */
@keyframes rainbow-glow {
    0% { box-shadow: inset 0 0 0px 0px rgba(255, 255, 255, 0); }
    20% { box-shadow: inset 0 0 30px 10px rgba(59, 130, 246, 0.4); } /* Blue */
    50% { box-shadow: inset 0 0 60px 20px rgba(168, 85, 247, 0.5); } /* Purple */
    80% { box-shadow: inset 0 0 30px 10px rgba(236, 72, 153, 0.4); } /* Pink */
    100% { box-shadow: inset 0 0 0px 0px rgba(255, 255, 255, 0); }
}
/* Specific selector to ensure it stays on body */
body.glow-active {
    animation: rainbow-glow 2s ease-in-out forwards;
}

/* Focus Timer Animation */
@keyframes progress-fill { from { width: 0%; } to { width: 100%; } }
.animate-timer { animation: progress-fill 5s linear forwards; }

.btn-press:active { transform: translateY(2px); box-shadow: none; border-bottom-width: 0; margin-top: 4px; }

/* SCROLLBAR STYLES & MOBILE TOUCH FIXES */
.custom-scrollbar {
    /* Critical for iOS smooth scrolling */
    -webkit-overflow-scrolling: touch;
    /* Ensure vertical pan is allowed */
    touch-action: pan-y;
    
    /* Aesthetics for Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(203, 213, 225, 0.5) transparent;
}

/* Webkit Scrollbar Styling (Chrome, Safari, Edge) */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: rgba(203, 213, 225, 0.5); /* Slate-300 with opacity */
    border-radius: 20px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(148, 163, 184, 0.8); /* Slate-400 */
}

/* --- ARCADE GAME STYLES --- */
.game-canvas {
    image-rendering: pixelated;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    perspective: 1000px; 
}
.memory-card {
    aspect-ratio: 1;
    background: #fff;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.6s, background-color 0.3s, box-shadow 0.3s;
    transform-style: preserve-3d;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 2px solid #e5e7eb;
    user-select: none;
    position: relative;
}
.memory-card span {
    transform: rotateY(180deg);
    backface-visibility: visible;
}
.memory-card.flipped {
    background: #dbeafe;
    border-color: #3b82f6;
    transform: rotateY(180deg);
}
.memory-card.matched {
    background: #d1fae5;
    border-color: #10b981;
    animation: match-glow 0.8s ease-out forwards;
    transform: rotateY(180deg); 
    box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.2);
}
@keyframes match-glow {
    0% { 
        transform: rotateY(180deg) scale(1);
        box-shadow: inset 0 0 0 0 rgba(16, 185, 129, 0);
        border-color: #10b981;
    }
    50% { 
        transform: rotateY(180deg) scale(1.05);
        box-shadow: inset 0 0 25px 5px rgba(16, 185, 129, 0.8);
        border-color: #34d399;
        background: #ecfdf5;
    }
    100% { 
        transform: rotateY(180deg) scale(1);
        box-shadow: inset 0 0 10px rgba(16, 185, 129, 0.3);
        border-color: #10b981;
        background: #d1fae5;
    }
}
@keyframes tile-glow {
    0% { 
        transform: scale(1);
        box-shadow: inset 0 0 0 0 rgba(16, 185, 129, 0);
        border-color: #e5e7eb;
    }
    50% { 
        transform: scale(1.1);
        box-shadow: inset 0 0 15px 2px rgba(16, 185, 129, 0.8);
        border-color: #10b981;
        background: #ecfdf5;
        color: #065f46;
    }
    100% { 
        transform: scale(1);
        box-shadow: inset 0 0 5px rgba(16, 185, 129, 0.2);
        border-color: #10b981;
        background: #f0fdf4;
        color: #10b981;
    }
}
#limit-overlay {
    opacity: 0;
    pointer-events: none;
    transition: opacity 3s ease-in-out; 
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(5px);
}
#limit-overlay.active {
    opacity: 1;
    pointer-events: auto;
    background-image: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
}
@keyframes strong-pulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.15); filter: brightness(1.1) drop-shadow(0 0 4px rgba(220, 38, 38, 0.4)); }
}
.animate-strong-pulse {
    animation: strong-pulse 2s infinite ease-in-out;
}
.d-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 180px;
    margin: 0 auto;
}
.d-btn {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    user-select: none;
    touch-action: manipulation;
}
.d-btn:active { background: #ddd; }
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.game-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    margin: 2px;
    padding: 4px 8px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #e5e7eb;
    font-weight: bold;
    min-width: 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.game-char.word-spacing { margin-right: 8px; padding: 4px 10px; }
.game-char.eaten { color: #10b981; border-color: #10b981; background: #f0fdf4; }
.game-char.just-eaten { animation: tile-glow 0.6s ease-out forwards; }
.game-char.active {
    color: #ef4444; border-color: #ef4444;
    transform: scale(1.1); box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
    z-index: 10;
}
.game-char.pending { color: #94a3b8; opacity: 0.7; }

/* --- Audio Match Specific Styles --- */
.match-btn { transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.audio-circle {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3), 0 2px 4px -1px rgba(99, 102, 241, 0.06);
    color: white;
    border: none;
}
.audio-circle:active { transform: scale(0.9); }
.audio-circle.selected {
    background: linear-gradient(135deg, #3b82f6, #06b6d4);
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
}
.audio-circle.matched {
    background: linear-gradient(135deg, #22c55e, #10b981);
    opacity: 0.4;
    transform: scale(0.8);
    pointer-events: none;
}
.word-capsule {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.word-capsule.selected {
    background: #eff6ff; 
    border-color: #3b82f6; 
    color: #1d4ed8; 
    transform: translateX(5px);
}
.word-capsule.matched {
    background: #f0fdf4; 
    border-color: #86efac; 
    color: #15803d; 
    opacity: 0.6; 
    pointer-events: none;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}
.match-btn.error {
    animation: shake 0.4s ease-in-out; 
    background: #fef2f2 !important; 
    border-color: #f87171 !important; 
    color: #b91c1c !important;
}

/* --- UPDATED MATCH-3 STYLES --- */
#match3-board {
    /* Now absolute positioning for true sliding */
    position: relative; 
    width: 100%;
    max-width: 340px; 
    aspect-ratio: 1 / 1;
    /* Modern Glassmorphism Look */
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.2), inset 0 0 20px rgba(255, 255, 255, 0.2);
    padding: 0; /* Padding handled by logic */
    overflow: hidden;
    margin: 0 auto;
}

.tile {
    position: absolute;
    /* Size determined by JS (12.5% for 8x8) */
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    /* Smooth sliding animation */
    transition: left 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), top 0.3s cubic-bezier(0.4, 0.0, 0.2, 1), transform 0.2s, opacity 0.2s; 
    z-index: 10;
}

.tile-inner {
    width: 85%;
    height: 85%;
    border-radius: 50%; /* Circle shape */
    background-color: rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05), inset 0 -2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(16px, 5vw, 24px);
    border: 2px solid rgba(255,255,255,0.9);
    transition: all 0.2s ease;
}

.tile:active .tile-inner { transform: scale(0.9); }

.tile.selected .tile-inner {
    transform: scale(1.1);
    background-color: #ffffff;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.6);
    border-color: #3b82f6;
    z-index: 20;
    animation: pulse-select 1.5s infinite;
}

@keyframes pulse-select {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.tile.match .tile-inner {
    animation: pop-fade 0.3s ease-out forwards;
}

@keyframes pop-fade {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); opacity: 0.8; }
    100% { transform: scale(0); opacity: 0; }
}

.particle {
    position: absolute;
    pointer-events: none;
    animation: particle-fade 0.8s ease-out forwards;
    z-index: 30;
}

@keyframes particle-fade {
    0% { transform: translate(0, 0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* --- UPDATED GAME CONTAINER & TIMER LAYOUT --- */

/* Ensure games stack vertically so timers can sit at bottom */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    /* Padding to ensure nothing touches the very edges */
    padding-bottom: 20px; 
}

/* NEW: The 'Already Break' Timer Styling with Rounded Green Background */
#playtime-warning {
    position: relative !important;
    
    /* Viel mehr Abstand nach oben */
    margin-top: 4rem !important; 
    margin-bottom: 2rem !important;
    
    /* Kapsel-Design */
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    padding: 0.75rem 2rem;
    
    /* Hellgrüner Hintergrund */
    background-color: #dcfce7; /* Hellgrün */
    border: 2px solid #86efac;
    border-radius: 9999px; /* Pillen-Form */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    /* Text */
    text-align: center;
    font-weight: 800;
    z-index: 100;
    font-size: 1.2rem;
    pointer-events: none;
}

/* --- 3D MENU STYLES (IMPORTED) --- */

/* Container für das 3D Menü - standardmäßig versteckt */
#three-menu-overlay {
    display: none; 
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background-color: #050510;
    z-index: 9000; /* Sehr hoch, um alles zu überlagern */
    overflow: hidden;
}

/* UI Hinweise im 3D Menü */
.ui-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.5);
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8rem;
    z-index: 9010;
    font-family: sans-serif;
}

/* Rainbow Glow Overlay */
.rainbow-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; 
    z-index: 9005;
    box-shadow: inset 0 0 40vw 5vw rgba(255, 0, 0, 0.5);
    animation: rainbowCycle 10s infinite linear; 
    mix-blend-mode: screen; 
}

@keyframes rainbowCycle {
    0%   { box-shadow: inset 0 0 40vw 10vw rgba(255, 0, 50, 0.5); }
    20%  { box-shadow: inset 0 0 40vw 10vw rgba(255, 200, 0, 0.5); }
    40%  { box-shadow: inset 0 0 40vw 10vw rgba(0, 255, 50, 0.5); }
    60%  { box-shadow: inset 0 0 40vw 10vw rgba(0, 200, 255, 0.5); }
    80%  { box-shadow: inset 0 0 40vw 10vw rgba(150, 0, 255, 0.5); }
    100% { box-shadow: inset 0 0 40vw 10vw rgba(255, 0, 50, 0.5); }
}