/* Memory Kids - Styles */
/* Mobile-first design for kids game */

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

:root {
    --color-bg: #E8F5E9;
    --color-primary: #4CAF50;
    --color-primary-dark: #388E3C;
    --color-secondary: #FF9800;
    --color-card-back: #7C4DFF;
    --color-card-back-dark: #651FFF;
    --color-card-front: #FFFFFF;
    --color-match: #FFD54F;
    --color-text: #333333;
    --color-text-light: #666666;

    --card-size: 70px;
    --card-gap: 8px;
    --border-radius: 12px;
    --transition-speed: 0.3s;
}

html, body {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* Buttons */
.btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 60px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 0 var(--color-primary-dark);
}

.btn-primary:active {
    box-shadow: 0 2px 0 var(--color-primary-dark);
    transform: translateY(2px);
}

.btn-secondary {
    background: white;
    color: var(--color-text);
    border: 2px solid var(--color-primary);
}

.btn-difficulty {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 4px 0 var(--color-primary-dark);
}

.btn-difficulty:active {
    box-shadow: 0 2px 0 var(--color-primary-dark);
    transform: translateY(2px);
}

.btn-label {
    font-size: 20px;
}

.btn-sublabel {
    font-size: 14px;
    font-weight: 400;
    opacity: 0.9;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: white;
    border: none;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Menu Screen */
#screen-menu {
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(180deg, #E8F5E9 0%, #C8E6C9 100%);
}

.menu-content {
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.title {
    font-size: 32px;
    color: var(--color-primary-dark);
    margin-bottom: 20px;
}

.emoji-decoration {
    font-size: 40px;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.emoji-decoration span {
    animation: bounce 2s infinite;
}

.emoji-decoration span:nth-child(2) {
    animation-delay: 0.2s;
}

.emoji-decoration span:nth-child(3) {
    animation-delay: 0.4s;
}

.emoji-decoration span:nth-child(4) {
    animation-delay: 0.6s;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.difficulty-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.best-score {
    font-size: 16px;
    color: var(--color-text-light);
}

.best-score:not(:empty)::before {
    content: '🏆 ';
}

/* Game Screen */
#screen-game {
    background: var(--color-bg);
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.game-stats {
    display: flex;
    gap: 16px;
    font-size: 16px;
    font-weight: 600;
}

.game-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: auto;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    gap: var(--card-gap);
    justify-content: center;
}

.cards-grid.grid-4x3 {
    grid-template-columns: repeat(4, var(--card-size));
}

.cards-grid.grid-4x4 {
    grid-template-columns: repeat(4, var(--card-size));
}

.cards-grid.grid-5x4 {
    grid-template-columns: repeat(5, var(--card-size));
}

/* Card */
.card {
    width: var(--card-size);
    height: var(--card-size);
    perspective: 1000px;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.5s;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.card-back {
    background: linear-gradient(135deg, var(--color-card-back) 0%, var(--color-card-back-dark) 100%);
}

.card-back::after {
    content: '❓';
    font-size: 28px;
    opacity: 0.8;
}

.card-front {
    background: var(--color-card-front);
    transform: rotateY(180deg);
}

.card.matched .card-front {
    background: var(--color-match);
    animation: matchPulse 0.5s ease;
}

@keyframes matchPulse {
    0% {
        transform: rotateY(180deg) scale(1);
    }
    50% {
        transform: rotateY(180deg) scale(1.1);
    }
    100% {
        transform: rotateY(180deg) scale(1);
    }
}

.card.matched {
    animation: matchCelebrate 0.6s ease;
}

@keyframes matchCelebrate {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-5deg);
    }
    75% {
        transform: rotate(5deg);
    }
}

/* Win Screen */
#screen-win {
    justify-content: center;
    align-items: center;
    padding: 20px;
    background: linear-gradient(180deg, #FFF9C4 0%, #FFE082 100%);
}

.win-content {
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.celebration {
    font-size: 48px;
    margin-bottom: 16px;
    animation: celebrationBounce 0.8s ease infinite;
}

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

.win-title {
    font-size: 32px;
    color: var(--color-primary-dark);
    margin-bottom: 16px;
}

.win-message {
    font-size: 18px;
    color: var(--color-text);
    margin-bottom: 16px;
    line-height: 1.5;
}

.win-message strong {
    font-size: 28px;
    color: var(--color-secondary);
}

.new-record {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-secondary);
    margin-bottom: 24px;
    min-height: 28px;
}

.win-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Responsive adjustments */
@media (min-width: 400px) {
    :root {
        --card-size: 80px;
    }

    .card-front,
    .card-back {
        font-size: 42px;
    }

    .card-back::after {
        font-size: 32px;
    }
}

@media (min-width: 500px) {
    :root {
        --card-size: 90px;
        --card-gap: 12px;
    }

    .card-front,
    .card-back {
        font-size: 48px;
    }
}

@media (min-width: 768px) {
    :root {
        --card-size: 100px;
        --card-gap: 16px;
    }

    .title {
        font-size: 40px;
    }

    .emoji-decoration {
        font-size: 50px;
    }

    .card-front,
    .card-back {
        font-size: 56px;
    }
}

/* Small screens adjustment for hard mode */
@media (max-width: 380px) {
    :root {
        --card-size: 58px;
        --card-gap: 6px;
    }

    .card-front,
    .card-back {
        font-size: 28px;
    }

    .card-back::after {
        font-size: 22px;
    }
}
