/* =========================================================== */
/* COMPONENT: LÁ BÀI CSS THUẦN                                 */
/* FIX: Chống Force Dark Mode trên mọi trình duyệt Android     */
/* =========================================================== */

/*
  Trick quan trọng nhất: dùng `forced-color-adjust: none` và
  `color-scheme: light` để trình duyệt KHÔNG được tự đảo màu.
  Kiwi Browser, Samsung Internet, Firefox Android đều tôn trọng rule này.
*/

.card {
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    width: 64px;
    height: 96px;
    padding: 4px 6px;
    border-radius: 8px;
    border: 1px solid #c8c8c8;

    /* ── CHỐNG DARK MODE: 3 lớp bảo vệ ── */
    background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%) !important;
    color-scheme: light !important;
    forced-color-adjust: none !important; /* Chặn Forced Colors mode */
    -webkit-forced-color-adjust: none !important;

    box-shadow: 2px 3px 6px rgba(0,0,0,0.45), inset 0 0 8px rgba(0,0,0,0.04);
    position: relative;
    user-select: none;
    box-sizing: border-box;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    margin: 0 -15px;
    flex-shrink: 0;
}

@media (hover: hover) {
    .card:hover {
        transform: translateY(-10px) !important;
        box-shadow: 0 16px 32px rgba(0,0,0,0.6), 0 4px 8px rgba(0,0,0,0.4);
        z-index: 100 !important;
    }
}

/* ── SIZE: NHỎ ── */
.card.small {
    width: 44px;
    height: 66px;
    padding: 3px 5px;
    border-radius: 6px;
    margin: 0 -12px;
}

/* ── SIZE: LỚN ── */
.card.large {
    width: 80px;
    height: 120px;
    margin: 0 10px;
}

/* ── GÓC BÀI (số + chất) ── */
.card .corner {
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
    color: #111111 !important; /* !important để đè dark mode */
    text-shadow: 0px 0px 1px rgba(0,0,0,0.15);
    text-align: left !important;
    width: 100%;
    forced-color-adjust: none;
}

.card.small .corner { font-size: 12px; }
.card.large .corner { font-size: 20px; }

/* Bài đỏ (♥ ♦) */
.card.red .corner {
    color: #cc0000 !important;
    text-shadow: 0px 0px 1px rgba(204,0,0,0.2);
}

.card .corner-bottom {
    transform: rotate(180deg);
    align-self: flex-end;
}

/* ── CHẤT Ở GIỮA (mờ, trang trí) ── */
.card .suit-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 36px;
    color: #111111 !important;
    opacity: 0.12;
    pointer-events: none;
    forced-color-adjust: none;
}

.card.small .suit-center { font-size: 24px; }
.card.large .suit-center { font-size: 48px; }
.card.red .suit-center { color: #cc0000 !important; }

/* ── LƯNG BÀI (MẶT ÚP) ── */
.card.hidden {
    /* Dùng gradient thay vì màu phẳng để lừa thuật toán Force Dark */
    background:
        repeating-linear-gradient(
            45deg,
            rgba(0,0,0,0.12) 0px,
            rgba(0,0,0,0.12) 2px,
            transparent 2px,
            transparent 5px
        ),
        repeating-linear-gradient(
            -45deg,
            rgba(0,0,0,0.12) 0px,
            rgba(0,0,0,0.12) 2px,
            transparent 2px,
            transparent 5px
        ),
        linear-gradient(160deg, #c62828 0%, #b71c1c 50%, #8b0000 100%) !important;

    border: 2px solid rgba(255,255,255,0.35) !important;
    box-shadow: 2px 3px 8px rgba(0,0,0,0.55), inset 0 0 18px rgba(0,0,0,0.4);
    align-items: center;
    justify-content: center;
    color-scheme: light !important;
}

.card.hidden .card-back-icon {
    display: none;
}

/* ── TRẠNG THÁI SELECTED (khi chọn bài) ── */
.card.selected {
    transform: translateY(-12px) scale(1.05) !important;
    box-shadow: 0 0 0 3px #4caf50, 0 12px 24px rgba(0,0,0,0.5) !important;
    z-index: 50 !important;
}

/* ── FIX THÊM: Ngăn trình duyệt đảo màu toàn bộ card ── */
@media (prefers-color-scheme: dark) {
    .card:not(.hidden) {
        background: linear-gradient(180deg, #ffffff 0%, #f0f0f0 100%) !important;
        color: #111111 !important;
        border-color: #c0c0c0 !important;
    }
    .card:not(.hidden) .corner { color: #111111 !important; }
    .card:not(.hidden) .suit-center { color: #111111 !important; }
    .card.red:not(.hidden) .corner { color: #cc0000 !important; }
    .card.red:not(.hidden) .suit-center { color: #cc0000 !important; }
}
