/* ===== Общие настройки ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background-color: #1b1b1b;
    color: #f5f5f5;
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.gold-text {
    color: #f2c94c;
    font-weight: bold;
}

/* ===== Кнопки ===== */
.btn {
    font-size: 16px;
    padding: 12px 24px;
    border: 2px solid #f2c94c;
    border-radius: 8px;
    background-color: #3a2a12;
    color: #f2c94c;
    cursor: pointer;
    min-height: 48px;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:hover {
    background-color: #5a4220;
}

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

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-gold {
    background-color: #f2c94c;
    color: #2b1d05;
    font-weight: bold;
}

.btn-gold:hover {
    background-color: #ffd96a;
}

.btn-small {
    font-size: 14px;
    padding: 6px 12px;
    min-height: 36px;
}

/* ===== Экран входа ===== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, #1f7a3f 0%, #0e3d1f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}

.login-box {
    background-color: rgba(0, 0, 0, 0.45);
    border: 3px solid #f2c94c;
    border-radius: 16px;
    padding: 32px 24px;
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.logo {
    font-size: 70px;
    color: #f2c94c;
    text-shadow: 2px 2px 0 #000;
}

.login-text {
    margin: 8px 0 24px;
}

.nick-input {
    width: 100%;
    font-size: 18px;
    padding: 12px;
    border: 2px solid #f2c94c;
    border-radius: 8px;
    margin-bottom: 8px;
}

.login-error {
    color: #ff8a8a;
    min-height: 20px;
    margin-bottom: 8px;
    font-size: 14px;
}

.login-box .btn {
    width: 100%;
}

/* ===== Раскладка: баннер — игра — баннер ===== */
.page {
    display: grid;
    grid-template-columns: 260px 1fr 260px;
    gap: 16px;
    max-width: 1300px;
    margin: 0 auto;
    padding: 16px;
}

/* Баннеры-заглушки */
.banner {
    width: 260px;
    aspect-ratio: 414 / 867; /* как у картинки баннера, высота считается сама */
    background-color: #2c2c2c;
    border: 2px dashed #777;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 18px;
    align-self: start;
    position: sticky;
    top: 16px;
    overflow: hidden; /* ничего не вылезает за границы баннера */
}

/* picture — обёртка картинки, тоже занимает весь баннер */
.banner picture {
    display: block;
    width: 100%;
    height: 100%;
}

/* Картинка заполняет весь блок баннера */
.banner img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover; /* заполнить блок без искажений */
}

.game-area {
    min-width: 0; /* чтобы содержимое не растягивало колонку */
}

/* ===== Верхняя панель ===== */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.title {
    color: #f2c94c;
    font-size: 28px;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== Игровой стол ===== */
.table {
    background: radial-gradient(ellipse at center, #1f7a3f 0%, #125a2c 70%, #0e3d1f 100%);
    border: 8px solid #5a3a1a;
    outline: 2px solid #f2c94c;
    border-radius: 24px;
    padding: 20px;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5);
}

.zone {
    min-height: 190px;
}

.zone-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 18px;
}

.zone-name {
    color: #f2c94c;
    font-weight: bold;
    word-break: break-word;
}

.score {
    background-color: rgba(0, 0, 0, 0.35);
    padding: 4px 12px;
    border-radius: 16px;
    border: 1px solid #f2c94c;
}

.zone-status {
    min-height: 22px;
    margin-top: 6px;
    font-style: italic;
    color: #d8f0d8;
}

/* Ряд карт */
.cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 126px;
}

/* ===== Карта ===== */
.card {
    width: 84px;
    height: 120px;
    background-color: #fff;
    border-radius: 8px;
    border: 1px solid #ccc;
    box-shadow: 2px 3px 6px rgba(0, 0, 0, 0.4);
    position: relative;
    color: #111;
    animation: card-appear 0.4s ease-out;
}

.card.red {
    color: #d11a2a;
}

.card-corner {
    position: absolute;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
    text-align: center;
}

.card-corner.top {
    top: 6px;
    left: 6px;
}

.card-corner.bottom {
    bottom: 6px;
    right: 6px;
    transform: rotate(180deg);
}

.card-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 40px;
}

/* Анимация появления новой карты */
@keyframes card-appear {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Рубашка карты: красный ромбический узор и золотая рамка внутри */
.card-back {
    background-color: #8b1a1a;
    background-image:
        repeating-linear-gradient(45deg, transparent 0, transparent 6px, rgba(255, 255, 255, 0.15) 6px, rgba(255, 255, 255, 0.15) 8px),
        repeating-linear-gradient(-45deg, transparent 0, transparent 6px, rgba(255, 255, 255, 0.15) 6px, rgba(255, 255, 255, 0.15) 8px);
    border: 3px solid #fff;
    box-shadow: inset 0 0 0 2px #f2c94c, 2px 3px 6px rgba(0, 0, 0, 0.4);
}

/* Карта компьютера переворачивается лицом вверх в конце партии */
.card.flip {
    animation: card-flip 0.5s ease-out;
}

@keyframes card-flip {
    from {
        transform: rotateY(90deg);
    }
    to {
        transform: rotateY(0deg);
    }
}

/* Строка «Карт у соперника: N» */
.cards-count {
    margin-bottom: 8px;
    font-size: 14px;
    color: #d8f0d8;
}

/* ===== Середина стола ===== */
.table-middle {
    text-align: center;
    padding: 14px 0;
    margin: 10px 0;
    border-top: 1px dashed rgba(242, 201, 76, 0.5);
    border-bottom: 1px dashed rgba(242, 201, 76, 0.5);
}

.message {
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    min-height: 30px;
}

.message.win {
    color: #f2c94c;
}

.message.lose {
    color: #ff8a8a;
}

.moves {
    margin-top: 6px;
    font-size: 16px;
}

/* ===== Кнопки управления ===== */
.controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.controls .btn {
    min-width: 150px;
}

/* ===== Таблица рекордов ===== */
.records {
    margin-top: 20px;
    background-color: #262626;
    border: 2px solid #f2c94c;
    border-radius: 12px;
    padding: 16px;
}

.records-title {
    color: #f2c94c;
    margin-bottom: 4px;
}

.records-hint {
    font-size: 13px;
    color: #aaa;
    margin-bottom: 12px;
}

.records-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
}

.records-table th,
.records-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #444;
}

.records-table th {
    color: #f2c94c;
}

.records-table td {
    word-break: break-word;
}

.records-empty {
    text-align: center !important;
    color: #888;
}

/* ===== Средние экраны: баннеры поуже, чтобы игре хватало места ===== */
@media (max-width: 1100px) {
    .page {
        grid-template-columns: 160px 1fr 160px;
    }

    .banner {
        width: 160px;
    }
}

/* ===== Мобильная версия ===== */
@media (max-width: 768px) {
    .page {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 10px;
    }

    /* Баннеры становятся горизонтальными полосами */
    /* Здесь показываются горизонтальные картинки bannerg (примерно 16:9) */
    .banner {
        width: 100%;
        aspect-ratio: 1000 / 561; /* как у мобильной картинки баннера */
        position: static;
    }

    .title {
        font-size: 22px;
    }

    .table {
        padding: 12px;
        border-width: 5px;
        border-radius: 16px;
    }

    .zone {
        min-height: 140px;
    }

    .zone-header {
        font-size: 16px;
    }

    .cards {
        gap: 5px;
        min-height: 88px;
    }

    /* Уменьшенные карты */
    .card {
        width: 58px;
        height: 84px;
        border-radius: 6px;
    }

    .card-corner {
        font-size: 13px;
    }

    .card-corner.top {
        top: 4px;
        left: 4px;
    }

    .card-corner.bottom {
        bottom: 4px;
        right: 4px;
    }

    .card-center {
        font-size: 28px;
    }

    .message {
        font-size: 18px;
    }

    /* Крупные кнопки для пальца */
    .controls .btn {
        flex: 1;
        min-width: 0;
        min-height: 56px;
        font-size: 18px;
    }

    .records-table th,
    .records-table td {
        padding: 6px 4px;
        font-size: 14px;
    }
}
