﻿* {
    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;
    --nature-bark: #5d4037;
    --nature-stone: #9e9e9e;
}

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 {
    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: hidden;
    overflow-x: hidden;
    padding: 15px;
    animation: fadeInNature 0.5s ease-in;
    box-sizing: border-box;
}

.hidden {
    display: none !important;
}

/* Главное меню может скроллиться */
#mainMenu.screen {
    overflow-y: auto;
    box-sizing: border-box;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

#mainMenu.screen::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#mainMenu .games-grid {
    padding-right: 0;
}

.screen.active {
    display: block;
}

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

/* Главное меню */
.menu-header {
    text-align: center;
    margin-bottom: 40px;
    padding-top: 30px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.menu-header::after {
    content: '🌿';
    position: absolute;
    font-size: 3rem;
    opacity: 0.3;
    top: -10px;
    right: 10%;
    animation: float 3s ease-in-out infinite;
}

.menu-header::before {
    content: '🍃';
    position: absolute;
    font-size: 2.5rem;
    opacity: 0.3;
    top: 20px;
    left: 10%;
    animation: float 4s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

.app-title {
    font-size: 3rem;
    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;
    position: relative;
}

.app-subtitle {
    font-size: 1.2rem;
    color: rgba(255,255,255,0.95);
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
    font-weight: 300;
    text-align: center;
    margin: 10px 0 20px;
    width: 100%;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    max-width: 1400px;
    margin: 0 auto;
    padding-bottom: 40px;
}

.game-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(232,245,233,0.98) 100%);
    border-radius: 25px;
    padding: 30px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 8px 25px rgba(45, 80, 22, 0.2),
        0 3px 10px rgba(0,0,0,0.1),
        inset 0 1px 0 rgba(255,255,255,0.9);
    text-align: center;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(127, 176, 105, 0.3);
}

.game-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(127, 176, 105, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

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

.game-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 15px 40px rgba(45, 80, 22, 0.3),
        0 5px 15px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.9);
    border-color: rgba(127, 176, 105, 0.6);
}

.game-card-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    filter: drop-shadow(0 4px 8px rgba(45, 80, 22, 0.2));
    animation: iconPulse 2s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.game-card:nth-child(1) .game-card-icon {
    animation-delay: 0s;
}

.game-card:nth-child(2) .game-card-icon {
    animation-delay: 0.3s;
}

.game-card:nth-child(3) .game-card-icon {
    animation-delay: 0.6s;
}

.game-card:nth-child(4) .game-card-icon {
    animation-delay: 0.9s;
}

.game-card:nth-child(5) .game-card-icon {
    animation-delay: 1.2s;
}

.game-card-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #2d5016;
    margin-bottom: 15px;
    position: relative;
    z-index: 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.game-card-description {
    font-size: 1rem;
    color: #4a7c2a;
    line-height: 1.8;
    position: relative;
    z-index: 1;
}

.game-card-description p {
    margin: 8px 0;
    font-weight: 400;
}

/* Заголовок игры */
.game-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px 0;
    position: relative;
}

.game-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(127, 176, 105, 0.5), transparent);
}

.game-header h2 {
    font-size: 1.8rem;
    color: #fff;
    text-shadow: 
        2px 2px 4px rgba(0,0,0,0.3),
        0 0 15px rgba(127, 176, 105, 0.4);
    font-weight: 700;
    letter-spacing: 1px;
    justify-self: end;
}

.back-btn {
    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);
    color: #fff;
    padding: 12px 25px;
    border-radius: 15px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.back-arrow {
    font-size: 1.3em;
    line-height: 1;
    display: inline-block;
}

.back-btn:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.35) 0%, rgba(255,255,255,0.25) 100%);
    transform: scale(1.05) translateX(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.6);
}

.iq-tests-btn {
    justify-self: center;
    background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.12) 100%);
    border: 2px solid rgba(255,255,255,0.35);
    color: #fff;
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.18);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
    z-index: 2;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    white-space: nowrap;
}

button.iq-tests-btn {
    -webkit-appearance: none;
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.12) 100%) !important;
    border: 2px solid rgba(255,255,255,0.35) !important;
    color: #fff !important;
    border-radius: 14px !important;
    text-decoration: none !important;
}

button.iq-tests-btn.iq-tests-btn--below {
    background: linear-gradient(135deg, #ffb703 0%, #fb8500 100%) !important;
    border: 2px solid rgba(79, 52, 17, 0.22) !important;
    color: #1f1b12 !important;
    box-shadow: 0 10px 24px rgba(120, 70, 0, 0.22) !important;
    text-shadow: none !important;
}

.iq-tests-btn:hover {
    background: linear-gradient(135deg, rgba(255,255,255,0.32) 0%, rgba(255,255,255,0.22) 100%);
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    border-color: rgba(255,255,255,0.55);
}

.iq-tests-btn--below {
    display: inline-flex;
    position: static;
    transform: none;
    width: 100%;
    margin-top: 12px;
    background: linear-gradient(135deg, #ffb703 0%, #fb8500 100%) !important;
    border: 2px solid rgba(79, 52, 17, 0.22) !important;
    color: #1f1b12 !important;
    box-shadow: 0 10px 24px rgba(120, 70, 0, 0.22);
    text-shadow: none;
}

/* Контент игры */
.game-content {
    background: linear-gradient(135deg, rgba(255,255,255,0.98) 0%, rgba(232,245,233,0.95) 100%);
    border-radius: 20px;
    padding: 15px;
    max-width: 100%;
    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-instruction {
    text-align: center;
    font-size: 1rem;
    margin-bottom: 15px;
    color: #2d5016;
    font-weight: 600;
    line-height: 1.4;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.game-hint {
    text-align: center;
    font-size: 0.85rem;
    margin: -8px 0 12px;
    color: rgba(45, 80, 22, 0.75);
    line-height: 1.35;
}

/* Таймеры */
.matrix-timer,
.schulte-timer,
.arithmetic-timer,
.double-timer,
.sorter-timer {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    color: #2d5016;
    margin-bottom: 10px;
    padding: 8px 15px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 10px;
    box-shadow: 
        0 4px 15px rgba(45, 80, 22, 0.2),
        inset 0 1px 0 rgba(255,255,255,0.8);
    border: 2px solid rgba(127, 176, 105, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Матрица */
.matrix-container {
    display: grid;
    gap: 6px;
    width: min(70vmin, 520px);
    height: min(70vmin, 520px);
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto 10px;
    padding: 5px;
    box-sizing: border-box;
    grid-template-columns: repeat(var(--matrix-size, 2), 1fr);
    grid-auto-rows: auto;
    grid-auto-flow: row;
}

#gameMatrix .matrix-container {
    width: min(40vmin, 300px);
    height: min(40vmin, 300px);
    max-height: calc(100vh - 440px);
    margin-bottom: 4px;
    gap: 6px;
}

#gameMatrix .game-content {
    padding-bottom: 6px;
}

#gameMatrix .score-display {
    margin-top: 6px;
}

.matrix-cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #9fb982;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    min-height: 0;
    box-shadow: 
        0 3px 8px rgba(45, 80, 22, 0.15),
        inset 0 1px 0 rgba(255,255,255,0.8);
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.matrix-cell::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(127, 176, 105, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.matrix-cell:hover::before {
    width: 200%;
    height: 200%;
}

.matrix-cell.active {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    border-color: #2e7d32;
    transform: scale(1.02);
    box-shadow: 
        0 6px 20px rgba(76, 175, 80, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.matrix-cell.selected {
    background: linear-gradient(135deg, #ffc107 0%, #ffb300 100%);
    border-color: #ff8f00;
    transform: scale(1.03);
    box-shadow: 
        0 6px 20px rgba(255, 193, 7, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.matrix-cell.wrong {
    background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    border-color: #c62828;
    animation: shake 0.5s;
    transform: scale(1.02);
    box-shadow: 
        0 6px 20px rgba(244, 67, 54, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

@keyframes shake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-10px) rotate(-3deg); }
    75% { transform: translateX(10px) rotate(3deg); }
}

/* Арифметика */
.arithmetic-expression {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: #2d5016;
    margin: 15px 0;
    padding: 15px;
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%);
    border-radius: 15px;
    box-shadow: 
        0 6px 20px rgba(45, 80, 22, 0.15),
        inset 0 2px 5px rgba(255,255,255,0.8);
    border: 2px solid rgba(127, 176, 105, 0.3);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.arithmetic-answers {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.arithmetic-answers.locked {
    pointer-events: none;
}

.arithmetic-btn {
    padding: 15px;
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4a7c2a 0%, #6b8e23 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 4px 15px 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);
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.arithmetic-btn.selected {
    background: linear-gradient(135deg, #7fb069 0%, #9fb982 100%);
    box-shadow:
        0 6px 18px rgba(45, 80, 22, 0.35),
        inset 0 0 0 4px rgba(255,255,255,0.7);
}

.arithmetic-btn.selected::before {
    display: none;
}

.arithmetic-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;
}

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

.arithmetic-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);
}

.arithmetic-btn:hover::before {
    display: none;
}

.arithmetic-btn.correct {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    animation: pulse 0.5s;
    box-shadow: 
        0 8px 25px rgba(76, 175, 80, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

.arithmetic-btn.wrong {
    background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    animation: shake 0.5s;
    box-shadow: 
        0 8px 25px rgba(244, 67, 54, 0.5),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

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

/* Таблица Шульте */
.schulte-container {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 6px;
    max-width: 100%;
    margin: 0 auto 10px;
    padding: 5px;
    box-sizing: border-box;
    max-height: calc(100vh - 250px);
}

.schulte-cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border: 2px solid #9fb982;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    color: #2d5016;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 
        0 3px 8px rgba(45, 80, 22, 0.15),
        inset 0 1px 0 rgba(255,255,255,0.8);
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.schulte-cell::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(127, 176, 105, 0.2);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.schulte-cell:hover::before {
    width: 150%;
    height: 150%;
}

.schulte-cell:hover {
    background: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%);
    transform: scale(1.08);
    border-color: #7fb069;
    box-shadow: 
        0 6px 15px rgba(45, 80, 22, 0.25),
        inset 0 1px 0 rgba(255,255,255,0.9);
}

.schulte-cell.found {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    color: #fff;
    border-color: #2e7d32;
    transform: scale(1.05);
    box-shadow: 
        0 6px 20px rgba(76, 175, 80, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.schulte-cell.wrong {
    background: linear-gradient(135deg, #f44336 0%, #e53935 100%);
    color: #fff;
    border-color: #c62828;
    animation: shake 0.5s;
    box-shadow: 
        0 6px 20px rgba(244, 67, 54, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Дубль */
.double-container {
    display: grid;
    gap: 6px;
    max-width: 100%;
    margin: 0 auto 10px;
    width: 100%;
    padding: 5px;
    box-sizing: border-box;
    max-height: calc(100vh - 250px);
    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: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #fff;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 3px 8px rgba(45, 80, 22, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.2);
    border: 1.5px solid rgba(127, 176, 105, 0.5);
    min-height: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.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);
}

/* Сортировщик */
.sorter-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    margin: 0 auto 10px;
    padding: 6px 8px;
    box-sizing: border-box;
    max-height: calc(100vh - 250px);
    overflow-y: hidden;
    overflow-x: hidden;
    touch-action: manipulation;
    overflow: hidden;
}

.sorter-container.disabled {
    pointer-events: none;
}

.sorter-item {
    padding: 12px;
    background: linear-gradient(135deg, #4a7c2a 0%, #6b8e23 100%);
    color: #fff;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    box-shadow: 
        0 4px 15px rgba(45, 80, 22, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.2);
    border: 2px solid rgba(127, 176, 105, 0.5);
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.sorter-item:hover {
    transform: scale(1.01);
    box-shadow: 
        0 8px 25px rgba(45, 80, 22, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
    background: linear-gradient(135deg, #6b8e23 0%, #7fb069 100%);
}


.sorter-item.selected {
    background: linear-gradient(135deg, #7fb069 0%, #9fb982 100%);
    border-color: rgba(255, 255, 255, 0.9);
    color: #ffffff;
    transform: scale(1);
    box-shadow:
        0 6px 18px rgba(45, 80, 22, 0.35),
        inset 0 0 0 3px rgba(255, 255, 255, 0.55);
}

.sorter-item.correct {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    border-color: #2e7d32;
    box-shadow: 
        0 6px 20px rgba(76, 175, 80, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.3);
}

/* Кнопки */
.game-btn {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4a7c2a 0%, #6b8e23 100%);
    color: #fff;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: 10px auto;
    max-width: 200px;
    box-shadow: 
        0 4px 15px 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);
    position: relative;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.subscribe-btn {
    max-width: 260px;
}

.game-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;
}

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

.game-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);
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 100%;
    margin: 0 auto;
}

/* Счет */
.score-display {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: #2d5016;
    margin-top: 10px;
    padding: 10px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 12px;
    box-shadow: 
        0 4px 15px rgba(45, 80, 22, 0.15),
        inset 0 1px 0 rgba(255,255,255,0.8);
    border: 2px solid rgba(127, 176, 105, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}


.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    margin: 10px auto 0;
    width: 100%;
    max-width: 100%;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.neutral-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #ced1d5;
    font-size: 14px;
    cursor: pointer;
    transition: all .2s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.neutral-btn * {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

.neutral-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}

.neutral-btn svg {
    flex-shrink: 0;
}

/* Адаптивность */
@media (max-width: 768px) {
    .game-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }

    .game-header h2 {
        justify-self: auto;
        margin: 0;
        text-align: right;
        flex: 1;
        min-width: 0;
    }

    .back-btn {
        padding: 10px 16px;
        border-radius: 14px;
        font-size: 0.95rem;
        flex: 0 0 auto;
    }
    .app-subtitle {
        width: 100%;
        margin: 10px 0 20px;
    }
    .actions {
        justify-content: center;
        width: 100%;
    }
    .app-title {
        font-size: 2.2rem;
    }
    
    .games-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .game-content {
        padding: 12px;
    }
    
    .arithmetic-expression {
        font-size: 1.8rem;
        padding: 12px;
        margin: 12px 0;
    }
    
    .arithmetic-answers {
        gap: 8px;
        margin-top: 12px;
    }
    
    .arithmetic-btn {
        padding: 12px;
        font-size: 1rem;
    }
    
    .matrix-container,
    .schulte-container,
    .double-container {
        gap: 5px;
        padding: 3px;
        max-height: calc(100vh - 220px);
    }
    
    .matrix-cell,
    .schulte-cell,
    .double-card {
        font-size: 0.9rem;
        border-radius: 6px;
    }
    
    .game-header h2 {
        font-size: 1.6rem;
    }

    .iq-tests-btn {
        padding: 9px 12px;
        font-size: 0.85rem;
        border-radius: 12px;
    }

    .game-header .iq-tests-btn {
        display: none;
    }
    
    .game-instruction {
        font-size: 0.9rem;
        margin-bottom: 12px;
    }
    
    .matrix-timer,
    .schulte-timer,
    .arithmetic-timer,
    .double-timer,
    .sorter-timer {
        font-size: 1rem;
        padding: 6px 12px;
        margin-bottom: 8px;
    }
    
    .score-display {
        font-size: 0.9rem;
        padding: 8px;
        margin-top: 8px;
    }
    
    .game-btn {
        padding: 10px;
        font-size: 0.9rem;
        margin: 8px auto;
    }
    
    .sorter-container {
        gap: 8px;
        max-height: calc(100vh - 220px);
        overflow-y: hidden;
        overflow-x: hidden;
    }
    
    .sorter-item {
        padding: 10px;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.8rem;
    }
    
    .game-content {
        padding: 10px;
    }
    
    .game-header h2 {
        font-size: 1.4rem;
    }

    .iq-tests-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
        border-radius: 12px;
        max-width: 56vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .iq-tests-btn--below {
        max-width: 100%;
    }
    
    .matrix-container,
    .schulte-container,
    .double-container {
        gap: 4px;
        padding: 2px;
        max-height: calc(100vh - 200px);
        max-width: 100%;
    }
    
    .matrix-cell,
    .schulte-cell,
    .double-card {
        font-size: 0.8rem;
        border-radius: 5px;
    }
    #gameMatrix .matrix-cell.active,
    #gameMatrix .matrix-cell.selected,
    #gameMatrix .matrix-cell.wrong {
        transform: scale(1);
    }
    
    .arithmetic-expression {
        font-size: 1.5rem;
        padding: 10px;
        margin: 10px 0;
    }
    
    .arithmetic-answers {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    
    .arithmetic-btn {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    .game-instruction {
        font-size: 0.85rem;
        margin-bottom: 10px;
    }
    
    .matrix-timer,
    .schulte-timer,
    .arithmetic-timer,
    .double-timer,
    .sorter-timer {
        font-size: 0.9rem;
        padding: 5px 10px;
        margin-bottom: 6px;
    }
    
    .score-display {
        font-size: 0.85rem;
        padding: 6px;
        margin-top: 6px;
    }
    
    .game-btn {
        padding: 8px;
        font-size: 0.85rem;
        margin: 6px auto;
    }
    
    .sorter-container {
        gap: 6px;
        max-height: calc(100vh - 200px);
        overflow-y: hidden;
        overflow-x: hidden;
    }
    
    .sorter-item {
        padding: 8px;
        font-size: 0.9rem;
    }
}


/* ===== Bright Vivid Theme Layer ===== */
:root {
  --v-bg-a:#6a5cff;
  --v-bg-b:#00c2ff;
  --v-bg-c:#37e38a;
  --v-bg-d:#ff6ec7;
  --v-card:#ffffff;
  --v-card-soft:#f4f7ff;
  --v-text:#1f2450;
  --v-text-muted:#5e679a;
  --v-accent-1:#ff7a59;
  --v-accent-2:#ffd166;
  --v-accent-3:#6c7bff;
  --v-good:#20c997;
  --v-bad:#ff4d6d;
  --v-shadow:0 14px 36px rgba(34,38,94,.22);
}

body {
  background: linear-gradient(130deg, var(--v-bg-a) 0%, var(--v-bg-b) 35%, var(--v-bg-c) 70%, var(--v-bg-d) 100%);
  background-size: 220% 220%;
  animation: vividFlow 16s ease infinite;
  color: var(--v-text);
}

body::before {
  background-image:
    radial-gradient(circle at 12% 20%, rgba(255,255,255,.22) 0, transparent 35%),
    radial-gradient(circle at 85% 15%, rgba(255,255,255,.2) 0, transparent 30%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,.16) 0, transparent 32%);
}

@keyframes vividFlow {
  0% { background-position: 0% 40%; }
  50% { background-position: 100% 60%; }
  100% { background-position: 0% 40%; }
}

.game-card,
.game-content,
.matrix-timer,
.schulte-timer,
.arithmetic-timer,
.double-timer,
.sorter-timer,
.score-display {
  background: linear-gradient(145deg, var(--v-card) 0%, var(--v-card-soft) 100%);
  color: var(--v-text);
  box-shadow: var(--v-shadow);
  border-color: rgba(108,123,255,.28);
}

.app-title {
  text-shadow: 0 6px 18px rgba(17, 22, 78, .35);
  background: linear-gradient(135deg, #ffffff 0%, #fff8d6 35%, #ffd6f2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-btn,
.arithmetic-btn,
.sorter-item,
.double-card {
  background: linear-gradient(135deg, var(--v-accent-3) 0%, var(--v-accent-1) 60%, var(--v-accent-2) 100%);
  border-color: rgba(255,255,255,.45);
  box-shadow: 0 10px 24px rgba(68,54,150,.28);
}

.game-btn:hover,
.arithmetic-btn:hover,
.sorter-item:hover,
.double-card:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 30px rgba(68,54,150,.36);
}

.matrix-cell.active,
.schulte-cell.found,
.arithmetic-btn.correct,
.sorter-item.correct,
.double-card.matched {
  background: linear-gradient(135deg, #19d68c 0%, #4fe3b2 100%);
  border-color: #0f9c67;
}

.matrix-cell.wrong,
.schulte-cell.wrong,
.arithmetic-btn.wrong {
  background: linear-gradient(135deg, #ff5b7f 0%, #ff7b54 100%);
  border-color: #d83a5b;
}

.neutral-btn {
  background: rgba(255,255,255,.2);
  color: #ffffff;
  border: 1px solid rgba(255,255,255,.35);
}

.neutral-btn:hover {
  background: rgba(255,255,255,.32);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
