/* ═══════════════════════════════════════════════════════
   sac-te.css — UI Sắc Tê v1.0
   Bàn tròn 2–6 người, 6 lượt, đánh/úp bài
   ═══════════════════════════════════════════════════════ */

/* ── Biến màu riêng ── */
:root {
    --st-gold: #f5c842;
    --st-gold-dim: #a8892e;
    --st-red: #e84040;
    --st-green: #2ecc71;
    --st-blue: #3d9eff;
    --st-folded: #888;
    --st-card-bg: #fff;
    --st-card-radius: 8px;
    --st-shadow: 0 4px 18px rgba(0,0,0,0.55);
}

/* ── Layout chính ── */
.st-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    flex: 1;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

body.is-sacte #dynamic-game-area {
    overflow: hidden !important;
    padding: 0 !important;
}

/* ── Bàn chơi ── */
.st-board {
    flex: 1;
    position: relative;
    min-height: 0;
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(ellipse at 50% 40%,
            var(--felt-light, #2d7a2d) 0%,
            var(--felt-mid, #1e5e1e) 40%,
            var(--felt-dark, #143d14) 100%);
    border: 3px solid var(--felt-border, #1a4d1a);
    box-shadow:
        inset 0 0 60px rgba(0,0,0,0.4),
        0 0 0 4px var(--felt-outer, #0f2d0f),
        0 6px 24px rgba(0,0,0,0.6);
    margin: 6px;
}

/* ── Round info bar ── */
.st-round-info {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10;
    pointer-events: none;
}

.st-round-badge {
    background: rgba(0,0,0,0.65);
    color: var(--st-gold);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid var(--st-gold-dim);
    letter-spacing: 0.05em;
}

.st-status-msg {
    background: rgba(0,0,0,0.5);
    color: #eee;
    font-size: 0.75rem;
    padding: 4px 12px;
    border-radius: 20px;
    max-width: 200px;
    text-align: center;
}

/* ── Vùng người chơi (đặt quanh bàn) ── */
.st-players {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.st-player-slot {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

/* Vị trí các slot theo số người chơi — JS set style.left/top */
.st-player-slot .st-player-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: border-color 0.3s, box-shadow 0.3s;
}

.st-player-slot.is-turn .st-player-avatar {
    border-color: var(--st-gold);
    box-shadow: 0 0 0 3px var(--st-gold), 0 0 14px var(--st-gold);
    animation: st-pulse 1.2s infinite;
}

.st-player-slot.is-eliminated .st-player-avatar {
    opacity: 0.35;
    border-color: #555;
    filter: grayscale(1);
}

@keyframes st-pulse {
    0%, 100% { box-shadow: 0 0 0 3px var(--st-gold), 0 0 14px var(--st-gold); }
    50% { box-shadow: 0 0 0 5px var(--st-gold), 0 0 24px var(--st-gold); }
}

.st-player-name {
    font-size: 0.65rem;
    font-weight: 600;
    color: #ddd;
    background: rgba(0,0,0,0.55);
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.st-player-slot.is-me .st-player-name {
    color: var(--st-gold);
}

.st-player-cards-count {
    font-size: 0.6rem;
    color: rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.3);
    padding: 1px 6px;
    border-radius: 8px;
}

/* Indicator lá vừa đánh của đối thủ */
.st-player-last-card {
    width: 28px;
    height: 40px;
    border-radius: 5px;
    background: var(--st-card-bg);
    border: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    margin-top: 2px;
}

.st-player-last-card.folded {
    background: #444;
    color: #888;
    border-color: #555;
}

.st-player-last-card.red { color: var(--st-red); }
.st-player-last-card.black { color: #111; }

/* ── Vùng giữa bàn ── */
.st-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 5;
}

.st-center-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.st-played-cards {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 240px;
}

/* Lá bài trên bàn (lá đầu tiên của lượt) */
.st-board-card {
    width: 44px;
    height: 64px;
    border-radius: var(--st-card-radius);
    background: var(--st-card-bg);
    border: 1.5px solid #ccc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: var(--st-shadow);
    transition: transform 0.2s;
}
.st-board-card.red { color: var(--st-red); }
.st-board-card.black { color: #111; }
.st-board-card.beat { 
    border-color: var(--st-green); 
    box-shadow: 0 0 8px var(--st-green);
}
.st-board-card .card-suit { font-size: 1.1rem; }

/* ── Tay bài (người chơi) ── */
.st-hand-area {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 8px 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 100%);
    z-index: 20;
}

.st-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.st-btn-play {
    background: var(--st-gold);
    color: #111;
    font-weight: 700;
    font-size: 0.85rem;
    padding: 8px 22px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    box-shadow: 0 2px 10px rgba(245,200,66,0.5);
}

.st-btn-play:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: none;
}

.st-btn-play:not(:disabled):hover { transform: translateY(-1px); }

.st-btn-fold {
    font-size: 0.85rem;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.st-btn-fold:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* Tay bài — các lá xếp ngang */
.st-hand {
    display: flex;
    gap: -8px;
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 4px 8px;
    max-width: 100%;
}

.st-card {
    width: 46px;
    height: 68px;
    border-radius: var(--st-card-radius);
    background: var(--st-card-bg);
    border: 1.5px solid #ccc;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    position: relative;
    flex-shrink: 0;
    margin-right: -6px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.4);
    user-select: none;
}

.st-card:last-child { margin-right: 0; }

.st-card.red { color: var(--st-red); }
.st-card.black { color: #111; }

.st-card .card-suit { font-size: 1rem; line-height: 1; }
.st-card .card-rank { font-size: 0.9rem; line-height: 1; }

.st-card:hover:not(.disabled) {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0,0,0,0.5);
    z-index: 5;
}

.st-card.selected {
    transform: translateY(-14px) scale(1.06);
    border-color: var(--st-gold);
    box-shadow: 0 0 0 2px var(--st-gold), 0 8px 20px rgba(245,200,66,0.4);
    z-index: 6;
}

.st-card.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Lá bài mặt sau (đối thủ) */
.st-card-back {
    width: 32px;
    height: 46px;
    border-radius: 5px;
    background: linear-gradient(135deg, #1a3a6e 0%, #2d5bbf 100%);
    border: 1.5px solid rgba(255,255,255,0.2);
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    display: inline-block;
    margin-right: -10px;
    position: relative;
}

.st-card-back::after {
    content: '🂠';
    font-size: 1.2rem;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}

/* ── Modal kết thúc lượt ── */
.st-round-result-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: st-fadein 0.3s ease;
}

@keyframes st-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

.st-round-result-box {
    background: #1a2a1a;
    border: 2px solid var(--st-gold-dim);
    border-radius: 16px;
    padding: 20px 28px;
    min-width: 280px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}

.st-round-result-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--st-gold);
    margin-bottom: 12px;
}

.st-round-plays {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.st-play-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.85rem;
    color: #ccc;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
}

.st-play-row.winner-row {
    background: rgba(245,200,66,0.12);
    color: var(--st-gold);
    font-weight: 700;
}

.st-play-card-badge {
    font-weight: 700;
    font-size: 0.9rem;
}
.st-play-card-badge.red { color: var(--st-red); }
.st-play-card-badge.folded { color: var(--st-folded); font-style: italic; }

.st-round-winner {
    font-size: 1rem;
    font-weight: 700;
    color: var(--st-green);
    margin-bottom: 14px;
}

.st-btn-next {
    background: var(--st-gold);
    color: #111;
    font-weight: 700;
    padding: 8px 24px;
    border-radius: 20px;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
}

/* ── Modal game over ── */
.st-gameover-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.78);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    animation: st-fadein 0.4s ease;
}

.st-gameover-box {
    background: #141e14;
    border: 2px solid var(--st-gold);
    border-radius: 18px;
    padding: 24px 32px;
    min-width: 300px;
    max-width: 92%;
    text-align: center;
    box-shadow: 0 8px 50px rgba(0,0,0,0.8);
}

.st-gameover-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--st-gold);
    margin-bottom: 16px;
}

.st-gameover-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.st-result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    gap: 10px;
}

.st-result-row.win-row {
    background: rgba(46,204,113,0.15);
    border: 1px solid rgba(46,204,113,0.3);
    color: var(--st-green);
    font-weight: 700;
}

.st-result-row.lose-row {
    background: rgba(232,64,64,0.08);
    color: #bbb;
}

.st-result-delta {
    font-weight: 700;
    font-size: 0.95rem;
}

.st-result-delta.positive { color: var(--st-green); }
.st-result-delta.negative { color: var(--st-red); }

/* ── Eliminated badge ── */
.st-eliminated-badge {
    display: inline-block;
    font-size: 0.58rem;
    background: rgba(232,64,64,0.2);
    color: #e84040;
    border: 1px solid rgba(232,64,64,0.4);
    padding: 1px 6px;
    border-radius: 8px;
    margin-top: 2px;
}

/* ── Animations ── */
@keyframes st-card-fly {
    from { transform: scale(0.5) translateY(-20px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.st-card { animation: st-card-fly 0.2s ease both; }

@keyframes st-win-flash {
    0%, 100% { box-shadow: 0 0 0 3px var(--st-green); }
    50% { box-shadow: 0 0 0 8px var(--st-green), 0 0 20px var(--st-green); }
}

.st-player-slot.round-winner .st-player-avatar {
    animation: st-win-flash 0.6s ease 3;
    border-color: var(--st-green);
}
