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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 5px;
}

.subtitle {
    color: #666;
    font-size: 0.95rem;
}

.controls {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 30px;
    align-items: center;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.control-group label {
    font-weight: 600;
    color: #333;
}

.control-group select {
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    background-color: white;
    color: #333;
    transition: all 0.3s ease;
}

.control-group select:hover {
    border-color: #764ba2;
}

.btn-restart {
    padding: 12px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-restart:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

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

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    color: #666;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
}

.status-message {
    text-align: center;
    color: #666;
    margin-bottom: 25px;
    font-size: 1rem;
    min-height: 24px;
}

.memory-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.memory-card {
    aspect-ratio: 1;
    background: transparent;
    border: none;
    cursor: pointer;
    perspective: 1000px;
    padding: 0;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.memory-card:focus {
    outline: none;
}

.memory-card:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

.memory-card.is-flipped,
.memory-card.is-matched {
    transform: rotateY(180deg);
}

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

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    font-weight: 600;
    backface-visibility: hidden;
    transition: all 0.3s ease;
}

.card-back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 2.5rem;
}

.card-back::after {
    content: '?';
}

.card-front {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    transform: rotateY(180deg);
    padding: 15px;
    text-align: center;
    gap: 8px;
}

.memory-card.is-matched .card-front {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.memory-card.is-matched {
    cursor: default;
}

.card-language {
    display: block;
    font-size: 0.7rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-word {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 8px 0;
    word-break: break-word;
}

.card-word[lang="en"] {
    direction: ltr;
}

.card-word[lang="he"] {
    direction: rtl;
}

.card-hint {
    display: block;
    font-size: 0.65rem;
    opacity: 0.8;
    margin-top: 5px;
}

@media (max-width: 768px) {
    .container {
        padding: 25px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .controls {
        flex-direction: column;
        gap: 15px;
    }

    .control-group {
        width: 100%;
    }

    .btn-restart {
        width: 100%;
    }

    .stats {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 15px;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .memory-board {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }

    .card-front {
        padding: 12px;
    }

    .card-word {
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) {
    .memory-board {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .container {
        padding: 20px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .stats {
        grid-template-columns: 1fr;
    }
}
