* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --nature-green: #2d5016;
    --nature-light-green: #4a7c2a;
    --nature-mint: #7fb069;
    --nature-sage: #9fb982;
    --nature-earth: #8b6f47;
    --nature-sand: #d4c5a9;
    --nature-sky: #87ceeb;
    --nature-water: #4682b4;
    --nature-forest: #1a3d1a;
    --nature-grass: #6b8e23;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #1a3d1a 0%, #2d5016 25%, #4a7c2a 50%, #6b8e23 75%, #87ceeb 100%);
    background-size: 400% 400%;
    animation: natureGradient 15s ease infinite;
    min-height: 100vh;
    max-height: 100vh;
    overflow-x: hidden;
    overflow-y: hidden;
    color: #2d5016;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(127, 176, 105, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(135, 206, 235, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 40% 20%, rgba(107, 142, 35, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

@keyframes natureGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.app-container {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.screen {
    display: none;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    animation: fadeInNature 0.5s ease-in;
    box-sizing: border-box;
}

.screen.active {
    display: block;
}

@keyframes fadeInNature {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Welcome Screen */
.welcome-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 40px 20px;
}

.welcome-icon {
    font-size: 8rem;
    margin-bottom: 30px;
    animation: iconFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(45, 80, 22, 0.3));
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(10deg); }
}

.welcome-title {
    font-size: 4rem;
    color: #fff;
    margin-bottom: 15px;
    text-shadow: 
        2px 2px 4px rgba(0,0,0,0.3),
        0 0 20px rgba(127, 176, 105, 0.5);
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 0%, #e8f5e9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 1.5rem;
    color: rgba(255,255,255,0.95);
    margin-bottom: 10px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
    font-weight: 600;
}

.welcome-description {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.9);
    margin-bottom: 40px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    max-width: 500px;
    line-height: 1.6;
}

.welcome-btn {
    padding: 18px 50px;
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4a7c2a 0%, #6b8e23 100%);
    color: #fff;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 8px 25px rgba(45, 80, 22, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
}

.welcome-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.welcome-btn:hover::before {
    width: 300px;
    height: 300px;
}

.welcome-btn:hover {
    background: linear-gradient(135deg, #6b8e23 0%, #7fb069 100%);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 
        0 10px 30px rgba(45, 80, 22, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Game Content */
.game-content {
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(232,245,233,0.95) 100%);
    border-radius: 30px;
    padding: 40px;
    max-width: 700px;
    margin: 0 auto;
    box-shadow: 
        0 20px 60px rgba(45, 80, 22, 0.3),
        0 8px 25px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.9);
    border: 3px solid rgba(127, 176, 105, 0.3);
    position: relative;
    overflow: hidden;
}

.game-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, 
        #7fb069 0%, 
        #9fb982 25%, 
        #6b8e23 50%, 
        #9fb982 75%, 
        #7fb069 100%);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.game-title {
    font-size: 2.5rem;
    color: #2d5016;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-instruction {
    text-align: center;
    font-size: 1.3rem;
    margin-bottom: 30px;
    color: #2d5016;
    font-weight: 600;
    line-height: 1.6;
}

/* Mode Selection */
.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 30px 0;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 25px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 3px solid rgba(127, 176, 105, 0.4);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 6px 20px rgba(45, 80, 22, 0.2),
        inset 0 1px 0 rgba(255,255,255,0.8);
    text-align: left;
    width: 100%;
}

.mode-btn:hover {
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%);
    transform: translateX(5px) scale(1.02);
    border-color: rgba(127, 176, 105, 0.6);
    box-shadow: 
        0 8px 25px rgba(45, 80, 22, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.9);
}

.mode-icon {
    font-size: 3.5rem;
    filter: drop-shadow(0 4px 8px rgba(45, 80, 22, 0.2));
}

.mode-info {
    flex: 1;
}

.mode-size {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2d5016;
    margin-bottom: 5px;
}

.mode-time {
    font-size: 1.1rem;
    color: #4a7c2a;
    font-weight: 500;
}

/* Game Header */
.game-header {
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.15) 100%);
    backdrop-filter: blur(10px);
    padding: 15px 20px;
    border-radius: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.game-stats {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    flex: 1;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.9);
    font-weight: 500;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Double Container */
.double-container {
    display: grid;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto 30px;
    width: 100%;
    grid-template-columns: repeat(var(--grid-size, 4), 1fr);
    grid-auto-rows: auto;
    grid-auto-flow: row;
}

.double-card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #4a7c2a 0%, #6b8e23 100%);
    border-radius: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: #fff;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 6px 20px rgba(45, 80, 22, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.2);
    border: 3px solid rgba(127, 176, 105, 0.5);
}

.double-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.double-card:hover::before {
    opacity: 1;
}

.double-card:hover {
    transform: scale(1.05) rotate(2deg);
    box-shadow: 
        0 8px 25px rgba(45, 80, 22, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.double-card.flipped {
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%);
    color: #2d5016;
    border: 3px solid #7fb069;
    box-shadow: 
        0 6px 20px rgba(127, 176, 105, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.9);
}

.double-card.matched {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    border-color: #2e7d32;
    opacity: 0.8;
    pointer-events: none;
    transform: scale(0.95);
    box-shadow: 
        0 4px 15px rgba(76, 175, 80, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Buttons */
.back-btn {
    background: linear-gradient(135deg, #4a7c2a 0%, #6b8e23 100%);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 6px 20px rgba(45, 80, 22, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 300px;
    margin: 20px auto 0;
    display: block;
}

.back-btn:hover {
    background: linear-gradient(135deg, #6b8e23 0%, #7fb069 100%);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(45, 80, 22, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

.exit-btn {
    background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 15px rgba(244, 67, 54, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    white-space: nowrap;
}

.exit-btn:hover {
    background: linear-gradient(135deg, #e53935 0%, #d32f2f 100%);
    transform: scale(1.05);
    box-shadow: 
        0 6px 20px rgba(244, 67, 54, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

/* Result Screen */
.result-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding: 40px 20px;
}

.result-icon {
    font-size: 6rem;
    margin-bottom: 30px;
    animation: iconFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 8px 16px rgba(45, 80, 22, 0.3));
}

.result-title {
    font-size: 3rem;
    color: #fff;
    margin-bottom: 40px;
    text-shadow: 
        2px 2px 4px rgba(0,0,0,0.3),
        0 0 20px rgba(127, 176, 105, 0.5);
    font-weight: 700;
    letter-spacing: 1px;
}

.result-stats {
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(232,245,233,0.95) 100%);
    border-radius: 25px;
    padding: 40px;
    margin-bottom: 30px;
    max-width: 500px;
    width: 100%;
    box-shadow: 
        0 20px 60px rgba(45, 80, 22, 0.3),
        0 8px 25px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.9);
    border: 3px solid rgba(127, 176, 105, 0.3);
}

.result-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 2px solid rgba(127, 176, 105, 0.2);
}

.result-stat:last-child {
    border-bottom: none;
}

.result-label {
    font-size: 1.2rem;
    color: #4a7c2a;
    font-weight: 600;
}

.result-value {
    font-size: 1.8rem;
    color: #2d5016;
    font-weight: 700;
}

.result-message {
    font-size: 1.3rem;
    color: rgba(255,255,255,0.95);
    margin-bottom: 30px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    font-weight: 500;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

.result-btn {
    padding: 18px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4a7c2a 0%, #6b8e23 100%);
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 6px 20px rgba(45, 80, 22, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.2);
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.result-btn:hover {
    background: linear-gradient(135deg, #6b8e23 0%, #7fb069 100%);
    transform: scale(1.05) translateY(-2px);
    box-shadow: 
        0 8px 25px rgba(45, 80, 22, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.result-btn.secondary {
    background: linear-gradient(135deg, rgba(255,255,255,0.25) 0%, rgba(255,255,255,0.15) 100%);
    border: 2px solid rgba(255,255,255,0.4);
    backdrop-filter: blur(10px);
}

.result-btn.secondary:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.25) 100%);
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeInNature 0.3s ease-in;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(232,245,233,0.95) 100%);
    border-radius: 25px;
    padding: 40px;
    max-width: 400px;
    width: 90%;
    box-shadow: 
        0 20px 60px rgba(45, 80, 22, 0.4),
        0 8px 25px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.9);
    border: 3px solid rgba(127, 176, 105, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-title {
    font-size: 1.8rem;
    color: #2d5016;
    margin-bottom: 20px;
    text-align: center;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.modal-message {
    font-size: 1.1rem;
    color: #4a7c2a;
    margin-bottom: 30px;
    text-align: center;
    line-height: 1.6;
    font-weight: 500;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 30px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    flex: 1;
    max-width: 150px;
}

.modal-btn-cancel {
    background: linear-gradient(135deg, #9e9e9e 0%, #757575 100%);
    color: #fff;
    box-shadow: 
        0 4px 15px rgba(158, 158, 158, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.2);
}

.modal-btn-cancel:hover {
    background: linear-gradient(135deg, #757575 0%, #616161 100%);
    transform: scale(1.05);
    box-shadow: 
        0 6px 20px rgba(158, 158, 158, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.modal-btn-confirm {
    background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    color: #fff;
    box-shadow: 
        0 4px 15px rgba(244, 67, 54, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
}

.modal-btn-confirm:hover {
    background: linear-gradient(135deg, #e53935 0%, #d32f2f 100%);
    transform: scale(1.05);
    box-shadow: 
        0 6px 20px rgba(244, 67, 54, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Responsive */
@media (max-width: 768px) {
    .welcome-title {
        font-size: 3rem;
    }
    
    .game-content {
        padding: 25px;
    }
    
    .double-container {
        max-width: 100%;
        gap: 6px;
    }
    
    .double-card {
        font-size: 2rem;
        min-height: 50px;
    }
    
    .result-title {
        font-size: 2.5rem;
    }
    
    .game-header {
        flex-wrap: wrap;
    }
    
    .game-stats {
        flex: 1;
        min-width: 200px;
    }
}

@media (max-width: 480px) {
    .welcome-title {
        font-size: 2.5rem;
    }
    
    .welcome-icon {
        font-size: 6rem;
    }
    
    .double-container {
        gap: 4px;
    }
    
    .double-card {
        font-size: 1.2rem;
        min-height: 40px;
    }
    
    /* Для 10x10 на мобильных делаем больше */
    .double-container[style*="repeat(10"] .double-card {
        font-size: 1rem;
        min-height: 35px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .result-title {
        font-size: 2rem;
    }
    
    .game-header {
        padding: 12px 15px;
    }
    
    .back-btn, .exit-btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
}

