/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #F9F8F4;
    color: #2D3748;
    overflow: hidden;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

#app {
    height: 100vh;
    height: -webkit-fill-available;
    position: relative;
    overflow: hidden;
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
}

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

/* Allow scrolling on main menu screen */
#main-menu.screen {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Loading Screen */
#loading-screen {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.loading-content {
    text-align: center;
}

.loading-content h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    font-weight: 700;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main Menu - Zen Design */
#main-menu {
    background: #F9F8F4;
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 2rem 0;
    align-items: flex-start;
    min-height: 100vh;
    height: auto;
    touch-action: pan-y;
}

.zen-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 0;
}

.gradient-orb {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(139, 195, 74, 0.15) 0%, rgba(139, 195, 74, 0.05) 50%, transparent 100%);
    border-radius: 50%;
    filter: blur(40px);
    animation: gentle-float 8s ease-in-out infinite;
}

@keyframes gentle-float {
    0%, 100% { transform: translateX(-50%) translateY(0px); }
    50% { transform: translateX(-50%) translateY(-20px); }
}

.menu-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 420px;
    padding: 1rem 1.5rem 2rem;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.header-section {
    position: relative;
    margin-bottom: 1rem;
    z-index: 10;
}

.zen-title {
    font-family: 'Merriweather', serif;
    font-size: 2.8rem;
    font-weight: 400;
    color: #1a202c;
    margin-bottom: 0;
    letter-spacing: -0.02em;
    line-height: 1.1;
    position: relative;
    z-index: 10;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.how-to-play {
    position: absolute;
    top: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #8BC34A;
    background: transparent;
    color: #8BC34A;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.how-to-play:hover {
    background: #8BC34A;
    color: white;
    transform: scale(1.1);
}

.flow-badge {
    display: inline-flex;
    align-items: center;
    gap: 1rem;
    background: rgba(139, 195, 74, 0.12);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(139, 195, 74, 0.2);
    border-radius: 50px;
    padding: 0.75rem 2rem;
    margin: 0 auto 2.5rem;
    transition: all 0.3s ease;
    animation: fadeInUp 0.6s ease forwards;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.flow-badge:hover {
    background: rgba(139, 195, 74, 0.12);
    transform: translateY(-1px);
}

.flow-text {
    font-size: 1rem;
    font-weight: 500;
    color: #6B7280;
    letter-spacing: 0.02em;
}

.flow-arrow {
    color: #8BC34A;
    animation: flow-pulse 2s ease-in-out infinite;
}

@keyframes flow-pulse {
    0%, 100% { 
        opacity: 0.6;
        transform: translateX(0);
    }
    50% { 
        opacity: 1;
        transform: translateX(3px);
    }
}

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

.daily-challenge-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.9);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.daily-challenge-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.daily-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.daily-label {
    color: #8BC34A;
    font-weight: 600;
}

.daily-date {
    color: #6B7280;
}

.room-preview-container {
    position: relative;
    width: 100%;
    height: 160px;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    background: #E5E7EB;
}

.room-preview-image {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(3px);
    transform: scale(1.05);
}

.btn-zen-primary {
    width: 100%;
    background: #8BC34A;
    color: white;
    border: none;
    border-radius: 50px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(139, 195, 74, 0.25);
}

.btn-zen-primary:hover {
    background: #7CB342;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 195, 74, 0.35);
}

.btn-zen-primary:active {
    transform: translateY(0);
}

.zen-caption {
    text-align: center;
    font-size: 0.85rem;
    color: #9CA3AF;
    font-style: italic;
    margin-top: 0.75rem;
    font-weight: 400;
}

.mindfulness-stats {
    display: flex;
    gap: 1rem;
    justify-content: center;
    background: rgba(139, 195, 74, 0.08);
    padding: 1rem;
    border-radius: 24px;
    border: 1px solid rgba(139, 195, 74, 0.15);
}

.stat-pill {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 0.75rem 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
    flex: 1;
    justify-content: center;
    min-height: 60px;
}

.stat-pill:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stat-icon {
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.stat-icon:not(:has(emoji)) {
    background: #8BC34A;
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.1rem;
}

.stat-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
}

.stat-number {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2D3748;
    line-height: 1;
}

.stat-label {
    font-size: 0.75rem;
    color: #6B7280;
    font-weight: 500;
    line-height: 1;
    white-space: nowrap;
}

/* Science of Zen Section */
.science-section {
    background: rgba(139, 195, 74, 0.08);
    border: 1px solid rgba(139, 195, 74, 0.15);
    border-radius: 20px;
    padding: 1.5rem;
    margin-top: 2rem;
    animation: fadeInUp 0.8s ease forwards;
    animation-delay: 0.4s;
    opacity: 0;
}

.science-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    justify-content: center;
}

.science-icon {
    color: #8BC34A;
    flex-shrink: 0;
}

.science-header h3 {
    font-family: 'Merriweather', serif;
    font-size: 1.3rem;
    font-weight: 400;
    color: #2D3748;
    margin: 0;
}

.science-body {
    font-family: 'Merriweather', serif;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #4B5563;
    margin-bottom: 1.25rem;
    text-align: left;
}

.science-body strong {
    color: #8BC34A;
    font-weight: 600;
}

.science-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.research-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6B7280;
    margin-bottom: 0.25rem;
}

.research-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: #8BC34A;
    text-decoration: none;
    transition: all 0.2s ease;
    padding: 0.25rem 0;
    border-bottom: 1px solid transparent;
}

.research-link:hover {
    color: #7CB342;
    border-bottom-color: #7CB342;
    transform: translateX(2px);
}

.research-link svg {
    width: 12px;
    height: 12px;
    opacity: 0.7;
}

.video-container {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(139, 195, 74, 0.2);
}

.video-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #6B7280;
    margin-bottom: 0.75rem;
}

.video-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.video-embed iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 12px;
}

/* Footer Logo */
.footer-logo {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(139, 195, 74, 0.15);
    text-align: center;
}

.logo-image {
    max-width: 200px;
    height: auto;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.logo-image:hover {
    opacity: 1;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-icon {
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.btn-primary {
    background: #4CAF50;
    color: white;
    padding: 12px 24px;
    min-width: 120px;
}

.btn-primary:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
    padding: 12px 24px;
    min-width: 120px;
}

.btn-secondary:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 8px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* Game Screen */
#game-screen {
    background: #000;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    z-index: 10;
}

.progress-container {
    flex: 1;
    max-width: 300px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: #4CAF50;
    width: 0%;
    transition: width 0.3s ease;
}

#progress-text {
    font-size: 0.9rem;
    color: #ccc;
}

.game-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
}

#game-canvas.dragging {
    cursor: grabbing;
}

.touch-feedback {
    position: absolute;
    pointer-events: none;
    z-index: 5;
}

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

.cleaning-zone {
    position: absolute;
    border: 2px dashed rgba(76, 175, 80, 0.6);
    border-radius: 8px;
    background: rgba(76, 175, 80, 0.1);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cleaning-zone.active {
    opacity: 1;
}

/* Timer removed for cleaner gameplay */

/* Completion Screen */
#completion-screen {
    background: white;
}

.completion-content {
    text-align: center;
    max-width: 500px;
    padding: 2rem;
}

.completion-content h1 {
    font-size: 2.5rem;
    color: #4CAF50;
    margin-bottom: 1.5rem;
}

.completion-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
}

.before-after {
    margin: 2rem 0;
}

.comparison {
    display: flex;
    gap: 1rem;
    justify-content: center;
    align-items: center;
}

.before, .after {
    text-align: center;
}

.before h3, .after h3 {
    margin-bottom: 0.5rem;
    color: #666;
}

#before-canvas, #after-canvas {
    width: 150px;
    height: 100px;
    border-radius: 8px;
    border: 2px solid #ddd;
}

.completion-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.next-challenge {
    color: #666;
    font-style: italic;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        overflow-y: hidden;
    }
    
    #main-menu {
        padding: 1rem 0 2rem;
        min-height: 100vh;
        height: auto;
        overflow-y: scroll;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .menu-content {
        padding: 0.5rem 1rem 2rem;
        gap: 1rem;
        min-height: auto;
    }
    
    .zen-title {
        font-size: 2rem;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .header-section {
        margin-bottom: 0.5rem;
    }
    
    .how-to-play {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    
    .flow-badge {
        gap: 0.75rem;
        padding: 0.625rem 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .flow-text {
        font-size: 0.9rem;
    }
    
    .flow-arrow {
        width: 18px;
        height: 18px;
    }
    
    .daily-challenge-card {
        margin: 0 0 1.5rem 0;
        padding: 1.25rem;
    }
    
    .room-preview-container {
        height: 140px;
    }
    
    .mindfulness-stats {
        flex-direction: row;
        gap: 0.75rem;
        align-items: stretch;
        padding: 0.75rem;
    }
    
    .stat-pill {
        min-width: auto;
        justify-content: center;
        flex: 1;
        min-height: 56px;
        padding: 0.625rem 0.875rem;
    }
    
    .stat-icon {
        font-size: 1.3rem;
        width: 28px;
        height: 28px;
    }
    
    .stat-number {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .gradient-orb {
        width: 300px;
        height: 300px;
    }
    
    .btn-zen-primary {
        font-size: 1rem;
        padding: 0.875rem 1.75rem;
    }
    
    .zen-caption {
        font-size: 0.8rem;
    }
    
    .science-section {
        padding: 1.25rem;
        margin-top: 1.5rem;
    }
    
    .science-header h3 {
        font-size: 1.15rem;
    }
    
    .science-body {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .research-link {
        font-size: 0.85rem;
    }
    
    .video-container {
        margin-top: 1.25rem;
        padding-top: 1.25rem;
    }
    
    .video-embed {
        border-radius: 10px;
    }
    
    .footer-logo {
        margin-top: 1.5rem;
        padding-top: 1.5rem;
    }
    
    .logo-image {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    body {
        overflow-x: hidden;
        overflow-y: hidden;
    }
    
    #main-menu {
        padding: 0.5rem 0 1.5rem;
        min-height: 100vh;
        height: auto;
        overflow-y: scroll;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }
    
    .menu-content {
        padding: 0.5rem 1rem 1.5rem;
        gap: 0.875rem;
        min-height: auto;
    }
    
    .zen-title {
        font-size: 1.75rem;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .header-section {
        margin-bottom: 0.25rem;
    }
    
    .how-to-play {
        width: 26px;
        height: 26px;
        font-size: 13px;
    }
    
    .flow-badge {
        gap: 0.5rem;
        padding: 0.5rem 1.25rem;
        margin-bottom: 1rem;
    }
    
    .flow-text {
        font-size: 0.85rem;
    }
    
    .flow-arrow {
        width: 16px;
        height: 16px;
    }
    
    .daily-challenge-card {
        padding: 1rem;
        border-radius: 20px;
        margin-bottom: 1.25rem;
    }
    
    .daily-header {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }
    
    .room-preview-container {
        height: 120px;
        border-radius: 12px;
        margin-bottom: 1.25rem;
    }
    
    .btn-zen-primary {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
        border-radius: 40px;
    }
    
    .zen-caption {
        font-size: 0.75rem;
        margin-top: 0.625rem;
    }
    
    .mindfulness-stats {
        padding: 0.625rem;
        gap: 0.625rem;
        flex-direction: row;
    }
    
    .stat-pill {
        padding: 0.625rem 0.75rem;
        min-height: 54px;
        flex: 1;
    }
    
    .stat-icon {
        font-size: 1.25rem;
        width: 26px;
        height: 26px;
    }
    
    .stat-number {
        font-size: 1.15rem;
    }
    
    .stat-label {
        font-size: 0.65rem;
    }
    
    .science-section {
        padding: 1rem;
        margin-top: 1.25rem;
        border-radius: 16px;
    }
    
    .science-header {
        margin-bottom: 0.875rem;
    }
    
    .science-header h3 {
        font-size: 1rem;
    }
    
    .science-icon {
        width: 20px;
        height: 20px;
    }
    
    .science-body {
        font-size: 0.85rem;
        line-height: 1.6;
        margin-bottom: 1rem;
    }
    
    .research-label {
        font-size: 0.8rem;
    }
    
    .research-link {
        font-size: 0.8rem;
    }
    
    .video-container {
        margin-top: 1rem;
        padding-top: 1rem;
    }
    
    .video-label {
        font-size: 0.8rem;
        margin-bottom: 0.625rem;
    }
    
    .video-embed {
        border-radius: 10px;
    }
    
    .footer-logo {
        margin-top: 1.25rem;
        padding-top: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .logo-image {
        max-width: 140px;
    }
    
    .gradient-orb {
        width: 250px;
        height: 250px;
        top: 10%;
    }
}

/* Touch and Drag Feedback */
.dragging-item {
    transform: scale(1.1);
    z-index: 1000;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.drop-zone-highlight {
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.3; }
    to { opacity: 0.8; }
}

/* Particle Effects */
.cleaning-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #4CAF50;
    border-radius: 50%;
    pointer-events: none;
    animation: particle-float 1s ease-out forwards;
}

@keyframes particle-float {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-50px) scale(0.5);
    }
}

/* PWA Styles */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* iOS Safari viewport height fix */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
    }
    
    #app {
        height: -webkit-fill-available;
    }
    
    #main-menu {
        min-height: -webkit-fill-available;
    }
}