* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Zen-inspired color palette */
    --sage-green: #7c9885;
    --soft-sage: #a8c09a;
    --warm-sand: #f5e6d3;
    --deep-forest: #3a4a3c;
    --morning-mist: #e8ede7;
    --earth-brown: #8b7355;
    --sky-blue: #a8c4d4;
    --sunset-peach: #f4c7ab;
    --charcoal: #2c3e3b;
    --pure-white: #ffffff;
    --soft-shadow: rgba(58, 74, 60, 0.1);
    --vh: 1vh;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #e8ede7 0%, #c3d4c7 50%, #a8c09a 100%);
    min-height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    color: var(--deep-forest);
    position: relative;
    -webkit-overflow-scrolling: touch;
}

/* Add subtle animated background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(168, 192, 154, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(124, 152, 133, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(245, 230, 211, 0.15) 0%, transparent 50%);
    animation: float 20s ease-in-out infinite;
    pointer-events: none;
    z-index: -1;
    background-attachment: fixed;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

.screen {
    position: fixed;
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    display: none;
    opacity: 0;
    transition: opacity 0.8s ease;
    top: 0;
    left: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    opacity: 1;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    width: 90%;
    margin: 40px auto;
    text-align: center;
    padding: 30px;
    padding-bottom: 40px;
}

/* Welcome Screen */
.app-title {
    font-size: 3.5rem;
    font-weight: 200;
    margin-bottom: 12px;
    letter-spacing: 3px;
    color: var(--deep-forest);
    text-shadow: 2px 2px 4px var(--soft-shadow);
    animation: gentle-fade 1.5s ease-out;
}

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

.tagline {
    font-size: 1.1rem;
    color: var(--sage-green);
    margin-bottom: 60px;
    font-weight: 300;
    letter-spacing: 1px;
    animation: gentle-fade 1.5s ease-out 0.2s both;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 25px;
    margin-top: 40px;
    animation: gentle-fade 1.5s ease-out 0.4s both;
}

.mode-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.75));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(124, 152, 133, 0.2);
    border-radius: 20px;
    padding: 35px 25px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--deep-forest);
    box-shadow: 0 4px 20px var(--soft-shadow);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mode-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent, rgba(168, 192, 154, 0.1));
    opacity: 0;
    transition: opacity 0.4s ease;
}

.mode-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(124, 152, 133, 0.25);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.85));
}

.mode-card:hover::before {
    opacity: 1;
}

.mode-card.selected {
    background: linear-gradient(135deg, var(--soft-sage), var(--sage-green));
    color: white;
    transform: scale(1.03);
    box-shadow: 0 8px 35px rgba(124, 152, 133, 0.35);
}

.mode-icon {
    font-size: 2.8rem;
    margin-bottom: 18px;
    filter: grayscale(20%);
    display: inline-block;
    animation: gentle-pulse 3s ease-in-out infinite;
}

@keyframes gentle-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.mode-card h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.mode-card p {
    font-size: 0.95rem;
    opacity: 0.75;
    font-weight: 300;
}

/* Duration Section */
.duration-section {
    margin-top: 40px;
    animation: fadeInUp 0.5s ease;
}

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

.duration-section h3, .scene-selection h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    font-weight: 300;
    color: var(--sage-green);
    letter-spacing: 1px;
}

.duration-options {
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    margin-bottom: 25px;
}

.duration-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 2px solid var(--soft-sage);
    border-radius: 15px;
    padding: 14px 28px;
    color: var(--deep-forest);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    font-weight: 400;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.duration-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    border-color: var(--sage-green);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(124, 152, 133, 0.2);
}

.duration-btn.selected {
    background: var(--sage-green);
    color: white;
    border-color: var(--sage-green);
    transform: scale(1.05);
}

.scene-selection {
    margin: 25px 0;
    animation: fadeInUp 0.5s ease;
}

.scene-options {
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
}

.scene-btn {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--soft-sage);
    color: var(--deep-forest);
    padding: 14px 28px;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1rem;
    font-weight: 400;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.scene-btn:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(124, 152, 133, 0.2);
}

.scene-btn.selected {
    background: var(--sage-green);
    color: white;
    border-color: var(--sage-green);
}

.begin-btn {
    background: linear-gradient(135deg, var(--sage-green), var(--soft-sage));
    color: white;
    border: none;
    padding: 18px 70px;
    border-radius: 35px;
    font-size: 1.15rem;
    font-weight: 400;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    margin-top: 35px;
    box-shadow: 0 8px 25px rgba(124, 152, 133, 0.3);
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.begin-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.begin-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(124, 152, 133, 0.4);
}

.begin-btn:hover::before {
    width: 300px;
    height: 300px;
}

.hidden {
    display: none !important;
}

/* Session Screen */
#meditationCanvas {
    width: 100%;
    height: 100vh;
    display: block;
    touch-action: none;
}

.session-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 50px;
    padding: env(safe-area-inset-top, 50px) env(safe-area-inset-right, 50px) env(safe-area-inset-bottom, 50px) env(safe-area-inset-left, 50px);
}

.session-timer {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 1.1rem;
    color: var(--deep-forest);
    pointer-events: auto;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--soft-shadow);
    font-weight: 300;
    letter-spacing: 1px;
}

.session-timer:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
}

.breathing-guide, .body-scan-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 200;
    letter-spacing: 3px;
    color: white;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    animation: breatheText 4s ease-in-out;
}

@keyframes breatheText {
    0% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    50% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

.gratitude-prompt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    padding: 40px 50px;
    border-radius: 25px;
    max-width: 650px;
    font-size: 1.25rem;
    line-height: 1.8;
    color: var(--deep-forest);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    animation: gentleAppear 0.8s ease-out;
}

@keyframes gentleAppear {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.end-btn {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(15px);
    border: none;
    color: var(--deep-forest);
    padding: 12px 35px;
    border-radius: 30px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px var(--soft-shadow);
}

.end-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 152, 133, 0.25);
}

/* Complete Screen */
.complete-content {
    text-align: center;
    animation: fadeInUp 0.8s ease;
}

.complete-content h2 {
    font-size: 2.8rem;
    font-weight: 200;
    margin-bottom: 25px;
    color: var(--deep-forest);
    letter-spacing: 2px;
}

.affirmation {
    font-size: 1.25rem;
    color: var(--sage-green);
    margin-bottom: 35px;
    font-style: italic;
    font-weight: 300;
    line-height: 1.6;
}

.session-stats {
    margin: 35px 0;
    font-size: 1.1rem;
    color: var(--deep-forest);
    opacity: 0.8;
}

.primary-btn, .secondary-btn {
    margin: 12px;
    padding: 14px 45px;
    border-radius: 30px;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    font-weight: 400;
    letter-spacing: 0.5px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--sage-green), var(--soft-sage));
    color: white;
    box-shadow: 0 6px 20px rgba(124, 152, 133, 0.3);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.8);
    color: var(--deep-forest);
    border: 2px solid var(--soft-sage);
    backdrop-filter: blur(10px);
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(124, 152, 133, 0.4);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-3px);
    border-color: var(--sage-green);
}

/* Settings */
.settings-btn {
    position: fixed;
    top: 25px;
    right: 25px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 1.3rem;
    box-shadow: 0 4px 15px var(--soft-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 20px rgba(124, 152, 133, 0.25);
}

.settings-panel {
    position: fixed;
    top: 80px;
    right: 25px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 25px;
    z-index: 999;
    display: none;
    min-width: 280px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    animation: slideDown 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

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

.settings-panel.active {
    display: block;
}

.settings-panel h3 {
    margin-bottom: 25px;
    font-weight: 300;
    color: var(--deep-forest);
    letter-spacing: 1px;
    font-size: 1.3rem;
}

.settings-section {
    margin: 25px 0;
    padding: 20px 0;
    border-top: 1px solid rgba(124, 152, 133, 0.2);
    border-bottom: 1px solid rgba(124, 152, 133, 0.2);
}

.settings-section h4 {
    margin-bottom: 20px;
    font-weight: 400;
    color: var(--deep-forest);
    font-size: 1.1rem;
    letter-spacing: 0.5px;
}

.setting-item {
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-item label {
    font-size: 0.95rem;
    color: var(--deep-forest);
    font-weight: 400;
}

.setting-item input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: var(--sage-green);
    cursor: pointer;
}

.setting-item input[type="range"] {
    width: 110px;
    accent-color: var(--sage-green);
}

.setting-item select {
    background: rgba(124, 152, 133, 0.1);
    color: var(--deep-forest);
    border: 1px solid var(--soft-sage);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}

#closeSettings {
    width: 100%;
    margin-top: 25px;
    padding: 10px;
    background: var(--sage-green);
    border: none;
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 400;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

#closeSettings:hover {
    background: var(--deep-forest);
    transform: translateY(-1px);
}

/* Prevent touch scrolling issues */
html {
    overflow-x: hidden;
    touch-action: pan-y;
}

/* Mobile and Tablet Responsive */
@media (max-width: 768px) and (orientation: portrait) {
    body {
        background-attachment: fixed;
    }
    
    .screen.active {
        align-items: center;
        padding-top: 20px;
        padding-bottom: 20px;
    }
    
    .container {
        margin: 20px auto;
        padding: 15px;
        width: 95%;
    }

}

/* Landscape mode for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .screen.active {
        align-items: center;
        padding-top: 10px;
        padding-bottom: 10px;
    }
    
    .container {
        margin: 10px auto;
        padding: 10px;
    }
    
    .app-title {
        font-size: 1.6rem;
        margin-bottom: 5px;
    }
    
    .tagline {
        font-size: 0.85rem;
        margin-bottom: 12px;
    }
    
    .mode-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        margin-top: 15px;
    }
    
    .mode-card {
        padding: 12px 10px;
        min-height: auto;
    }
    
    .mode-icon {
        font-size: 1.4rem;
        margin-bottom: 6px;
    }
    
    .mode-card h3 {
        font-size: 0.9rem;
        margin-bottom: 3px;
    }
    
    .mode-card p {
        font-size: 0.75rem;
    }
    
    .duration-section, .scene-selection {
        margin-top: 12px;
    }
    
    .duration-section h3, .scene-selection h3 {
        font-size: 0.95rem;
        margin-bottom: 8px;
    }
    
    .duration-btn, .scene-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
    }
    
    .begin-btn {
        padding: 10px 35px;
        font-size: 0.95rem;
        margin-top: 12px;
    }
}

/* Existing mobile styles continue below */
@media (max-width: 768px) {
    .app-title {
        font-size: 2.2rem;
        margin-bottom: 8px;
    }
    
    .tagline {
        font-size: 0.95rem;
        margin-bottom: 25px;
    }
    
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-top: 20px;
    }
    
    .mode-card {
        padding: 18px 12px;
        min-height: auto;
    }
    
    .mode-icon {
        font-size: 1.8rem;
        margin-bottom: 10px;
    }
    
    .mode-card h3 {
        font-size: 1.1rem;
        margin-bottom: 5px;
    }
    
    .mode-card p {
        font-size: 0.85rem;
    }
    
    .duration-section {
        margin-top: 20px;
    }
    
    .duration-section h3, .scene-selection h3 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }
    
    .duration-options {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .duration-btn {
        width: auto;
        padding: 10px 20px;
        font-size: 0.95rem;
    }
    
    .scene-selection {
        margin: 15px 0;
    }
    
    .scene-options {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    
    .scene-btn {
        width: auto;
        padding: 10px 18px;
        font-size: 0.9rem;
    }
    
    .begin-btn {
        padding: 14px 50px;
        font-size: 1.05rem;
        margin-top: 20px;
    }
    
    .session-overlay {
        padding: 30px;
    }
    
    .breathing-guide, .body-scan-guide {
        font-size: 1.6rem;
    }
    
    .gratitude-prompt {
        padding: 30px 35px;
        font-size: 1.1rem;
        max-width: 90%;
    }
    
    .settings-panel {
        right: 15px;
        left: 15px;
        min-width: auto;
        max-height: calc(100vh - 100px);
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .screen.active {
        align-items: center;
    }
    
    .mode-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .mode-card {
        padding: 15px 10px;
        min-height: auto;
    }
    
    .app-title {
        font-size: 1.9rem;
        margin-bottom: 5px;
    }
    
    .tagline {
        font-size: 0.9rem;
        margin-bottom: 20px;
    }
    
    .mode-icon {
        font-size: 1.6rem;
        margin-bottom: 8px;
    }
    
    .mode-card h3 {
        font-size: 1rem;
    }
    
    .mode-card p {
        font-size: 0.8rem;
    }
    
    .duration-options, .scene-options {
        gap: 8px;
    }
    
    .duration-btn {
        padding: 9px 18px;
        font-size: 0.9rem;
    }
    
    .scene-btn {
        padding: 9px 16px;
        font-size: 0.85rem;
    }
    
    .begin-btn {
        padding: 12px 40px;
        font-size: 1rem;
        margin-top: 18px;
    }
}

/* Very small devices */
@media (max-width: 320px) {
    .container {
        padding: 10px;
    }
    
    .app-title {
        font-size: 1.7rem;
    }
    
    .tagline {
        font-size: 0.85rem;
        margin-bottom: 15px;
    }
    
    .mode-grid {
        gap: 8px;
    }
    
    .mode-card {
        padding: 12px 8px;
    }
    
    .mode-icon {
        font-size: 1.4rem;
    }
    
    .mode-card h3 {
        font-size: 0.95rem;
    }
    
    .mode-card p {
        font-size: 0.75rem;
    }
    
    .duration-btn {
        padding: 8px 15px;
        font-size: 0.85rem;
    }
    
    .scene-btn {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}

/* Extra smooth transitions for all interactive elements */
button, input, select {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Improve button touch targets for mobile */
button {
    min-height: 38px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Prevent text selection on UI elements */
.mode-card, .duration-btn, .scene-btn, .begin-btn, .primary-btn, .secondary-btn {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Touch device active states */
.touch-device button:active,
.touch-device .mode-card:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.touch-device .mode-card.active {
    animation: touchFeedback 0.3s ease;
}

@keyframes touchFeedback {
    0% { transform: scale(1); }
    50% { transform: scale(0.98); }
    100% { transform: scale(1); }
}

/* Custom scrollbar for settings panel */
.settings-panel::-webkit-scrollbar {
    width: 8px;
}

.settings-panel::-webkit-scrollbar-track {
    background: rgba(124, 152, 133, 0.1);
    border-radius: 10px;
}

.settings-panel::-webkit-scrollbar-thumb {
    background: var(--soft-sage);
    border-radius: 10px;
}

.settings-panel::-webkit-scrollbar-thumb:hover {
    background: var(--sage-green);
}