/**
 * Cards Screen - Экран выбора карт (веер)
 */

.cards-screen {
    z-index: 600;
}

.cards-container {
    /* Используем 100dvh для мобильных (dynamic viewport height) */
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-primary);
    /* Убираем возможность скролла */
    overflow: hidden;
}

.cards-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    flex-shrink: 0;
}

.back-btn-cards {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.back-btn-cards:hover {
    background: rgba(255, 255, 255, 0.2);
}

.cards-title-area {
    flex: 1;
    text-align: center;
}

.cards-title-area h1 {
    font-size: 20px;
    color: var(--accent);
    margin-bottom: 4px;
}

.counter {
    font-size: 14px;
    color: var(--text-secondary);
}

.counter span {
    color: var(--accent);
    font-weight: 600;
}

/* === Fans Container === */
.fans-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    position: relative;
    overflow: hidden;
    min-height: 0;
}

.cards-loading {
    text-align: center;
    color: var(--accent);
    font-size: 16px;
    padding: 40px;
}

/* === Card Fan === */
.card-fan {
    position: relative;
    flex: 1;
    min-height: 60px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* === Individual Card === */
.card {
    position: absolute;
    width: 42px;
    height: 68px;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease, opacity 0.3s ease;
    transform-style: preserve-3d;
}

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

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

.card-face, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 6px;
    overflow: hidden;
}

.card-back {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border: 2px solid var(--accent);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.3);
}

.card-back svg {
    width: 100%;
    height: 100%;
}

.card-face {
    transform: rotateY(180deg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.card-face img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card:hover:not(.disabled):not(.selected) {
    transform: translateY(-15px) scale(1.1);
    z-index: 100;
    filter: drop-shadow(0 8px 16px rgba(212, 165, 116, 0.5));
}

.card.glow:not(.disabled):not(.selected) {
    animation: glowPulse 2s ease-in-out infinite;
}

.card.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.card.selecting {
    pointer-events: none;
    cursor: wait;
}

.card.flying {
    z-index: 1000;
    pointer-events: none;
}

/* === Selected Cards Area === */
.selected-area {
    flex-shrink: 0;
    min-height: 70px;
    max-height: 85px;
    background: rgba(26, 26, 46, 0.6);
    border-radius: var(--border-radius);
    padding: 8px;
    display: flex;
    gap: 6px;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(212, 165, 116, 0.3);
    margin-bottom: 8px;
    overflow-x: auto;
}

.selected-card {
    width: 40px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--accent);
    box-shadow: 0 4px 12px rgba(212, 165, 116, 0.4);
    animation: cardAppear 0.3s ease-out;
}

.selected-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.selected-card.reversed img {
    transform: rotate(180deg);
}

.empty-slot {
    width: 40px;
    height: 60px;
    border: 2px dashed rgba(212, 165, 116, 0.3);
    border-radius: 4px;
    flex-shrink: 0;
}

/* === Submit Button === */
.submit-button {
    flex-shrink: 0;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    border: none;
    border-radius: var(--border-radius);
    color: var(--bg-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 16px rgba(212, 165, 116, 0.4);
}

.submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.6);
}

.submit-button:active {
    transform: translateY(0);
}

.submit-button.hidden {
    display: none;
}
