/* =========================================================
   Базовые стили и сброс
   ========================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: #f0f7f0;
    color: #2e7d32;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 500px;
}

/* =========================================================
   Панель статистики
   ========================================================= */
.stats-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    width: 100%;
}

.stat-item {
    font-size: 0.9rem;
    font-weight: 600;
}

.lives-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    flex-grow: 1;
}

.stat__bar {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.stat__bar-fill {
    height: 100%;
    background-color: #4caf50;
    transition: width 0.3s ease, background-color 0.3s ease;
}

.stat__bar-fill--low {
    background-color: #e53935;
}

.btn-restart {
    padding: 8px 16px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.btn-restart:hover {
    background: #388e3c;
}

/* =========================================================
   Игровое поле и УМЕНЬШЕННЫЕ карточки
   ========================================================= */
.board {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 колонки */
    gap: 12px;
    width: 100%;
    max-width: 400px; /* Ограничиваем ширину под маленькие карточки */
    margin: 0 auto;
}

.card {
    width: 85px;  /* Компактная ширина */
    height: 100px; /* Компактная высота */
    perspective: 1000px;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0;
}

.card__inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.5s;
    transform-style: preserve-3d;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

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

.card__face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 2px solid #4caf50;
}

.card__face--back {
    background: linear-gradient(135deg, #a5d6a7 0%, #81c784 100%);
    font-size: 1.5rem;
}

/* Декоративный элемент на рубашке */
.card__face--back::after {
    content: '🧬';
    opacity: 0.5;
}

.card__face--front {
    background-color: #ffffff;
    transform: rotateY(180deg);
    padding: 4px;
}

.card__icon {
    font-size: 1.8rem;
    line-height: 1;
    margin-bottom: 4px;
}

.card__label {
    font-size: 0.65rem;
    font-weight: 600;
    color: #2e7d32;
    line-height: 1.1;
    word-wrap: break-word;
    width: 90%;
}

/* Состояния карточек */
.card.is-matched .card__face--front {
    background-color: #e8f5e9;
    border-color: #2e7d32;
    opacity: 0.7;
}

.card.is-disabled {
    cursor: default;
    pointer-events: none;
}

.card.is-error .card__inner {
    animation: shake 0.4s ease-in-out;
    border-color: #e53935;
}

@keyframes shake {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    25% { transform: rotateY(180deg) translateX(-4px); }
    75% { transform: rotateY(180deg) translateX(4px); }
}

/* =========================================================
   Модальное окно
   ========================================================= */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal__content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 320px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal__title {
    margin-bottom: 10px;
    font-size: 1.4rem;
}

.modal__title--lose {
    color: #e53935;
}

.modal__text {
    margin-bottom: 15px;
    color: #555;
    font-size: 0.95rem;
}

.modal__stats {
    list-style: none;
    text-align: left;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #333;
}

.modal__stats li {
    margin-bottom: 6px;
}

/* =========================================================
   Адаптив для мобильных
   ========================================================= */
@media (max-width: 480px) {
    .board {
        grid-template-columns: repeat(3, 1fr); /* 3 колонки на узких экранах */
        max-width: 280px;
        gap: 8px;
    }
    .card {
        width: 75px;
        height: 90px;
    }
    .card__icon {
        font-size: 1.5rem;
    }
    .card__label {
        font-size: 0.6rem;
    }
    .stats-panel {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
}