@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700;800;900&display=swap');

/* ทุก overlay ต้องไม่แสดง scrollbar ใน OBS/CEF — ซ่อน scrollbar ทุก browser (ไม่แตะ overflow/layout) */
html, body { scrollbar-width: none; -ms-overflow-style: none; }
::-webkit-scrollbar { display: none; }

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --card-w: 300px;
    --box-sz: 64px;
    --card-bg: #34465f;
    --box-bg: #2a3850;
    --box-border: #9fb0c4;
    --theme-accent: #ffd86a;
    --theme-glow: rgba(255, 196, 61, 0.55);
}

body {
    font-family: 'Noto Sans Thai', sans-serif;
    background: transparent;
    min-height: 100vh;
    padding: 16px;
}

.win-table {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    width: var(--card-w);
    border-radius: 22px;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    padding: 20px 18px;
    transition: background 260ms ease, border-color 260ms ease, box-shadow 260ms ease;
}

/* Count-up: a bright victory podium with gold light and celebratory sparkles. */
.win-table[data-mode="up"] {
    --card-bg: linear-gradient(145deg, rgba(69, 35, 111, 0.96), rgba(31, 20, 67, 0.97));
    --box-bg: linear-gradient(145deg, #fff0a8, #e6a72d);
    --box-border: #fff1a8;
    --theme-accent: #ffd86a;
    --theme-glow: rgba(255, 196, 61, 0.62);
    border-color: rgba(255, 225, 126, 0.78);
    box-shadow: 0 18px 44px rgba(25, 10, 55, 0.55),
                0 0 30px rgba(255, 194, 64, 0.24),
                inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.win-table[data-mode="up"]::before {
    content: '✦  ·  ✧  ·  ✦';
    position: absolute;
    z-index: -1;
    top: 8px;
    left: 16px;
    right: 16px;
    color: rgba(255, 231, 146, 0.55);
    font-size: 18px;
    letter-spacing: 18px;
    text-align: center;
    animation: victory-sparkle 1.8s ease-in-out infinite;
}

/* Count-down: a darker survival board with warning red and tactical green. */
.win-table[data-mode="down"] {
    --card-bg: linear-gradient(145deg, rgba(17, 48, 41, 0.98), rgba(8, 20, 24, 0.98));
    --box-bg: linear-gradient(145deg, #4a1f29, #24141b);
    --box-border: #ff5c68;
    --theme-accent: #ff5c68;
    --theme-glow: rgba(255, 55, 75, 0.58);
    border-color: rgba(255, 92, 104, 0.72);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.58),
                0 0 24px rgba(255, 55, 75, 0.2),
                inset 0 0 28px rgba(41, 151, 99, 0.08);
}

.win-table[data-mode="down"]::before {
    content: '';
    position: absolute;
    z-index: -1;
    inset: 0;
    opacity: 0.16;
    background: repeating-linear-gradient(-45deg, transparent 0 10px, #ff5968 10px 12px);
    mask-image: linear-gradient(to bottom, #000, transparent 24%, transparent 76%, #000);
    pointer-events: none;
}

/* Hidden entirely when the table is disabled or empty. */
.win-table.empty {
    display: none;
}

.win-table-header {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

#win-title {
    display: inline-block;
    min-width: 64%;
    padding: 10px 32px;
    border-radius: 11px;
    text-align: center;
    background: linear-gradient(180deg, #fdfdfd 0%, #e2e5ea 55%, #cbd0d8 100%);
    color: #1a2433;
    font-size: 24px;
    font-weight: 800;
    line-height: 1.1;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

.win-table[data-mode="up"] #win-title {
    background: linear-gradient(180deg, #fffbe5 0%, #ffd86a 54%, #e09a20 100%);
    color: #5b2d00;
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.38), 0 0 18px var(--theme-glow), inset 0 1px 0 #fff;
}

.win-table[data-mode="down"] #win-title {
    background: linear-gradient(180deg, #314b40 0%, #192c27 100%);
    color: #fff4ef;
    border: 1px solid rgba(255, 92, 104, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 0 14px rgba(255, 92, 104, 0.12);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.win-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.win-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.win-table[data-mode="up"] .win-row {
    padding: 6px 8px;
    border-radius: 15px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), transparent);
}

.win-table[data-mode="down"] .win-row {
    padding: 6px 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid rgba(93, 201, 139, 0.48);
}

.win-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 28px;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.win-stat-icon {
    flex-shrink: 0;
    font-size: 24px;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.win-table[data-mode="up"] .win-stat-icon {
    animation: trophy-float 1.8s ease-in-out infinite;
}

.win-table[data-mode="down"] .win-stat-icon {
    animation: survival-heartbeat 1.15s ease-in-out infinite;
}

.win-num-box {
    flex-shrink: 0;
    width: var(--box-sz);
    height: var(--box-sz);
    border-radius: 14px;
    background: var(--box-bg);
    border: 2px solid var(--box-border);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

.win-stat-num {
    font-size: 34px;
    font-weight: 900;
    color: #fff;
    line-height: 1;
    text-shadow: 0 0 4px rgba(0, 0, 0, 0.6);
    display: inline-block;
}

.win-table[data-mode="up"] .win-stat-num {
    color: #4b2600;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.65), 0 0 8px rgba(255, 242, 174, 0.75);
}

.win-table[data-mode="down"] .win-stat-num {
    color: #fff5f5;
    text-shadow: 0 0 9px var(--theme-glow);
}

.win-stat-num.bump {
    animation: value-bump 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes value-bump {
    0% { transform: scale(1); }
    35% { transform: scale(1.45); }
    100% { transform: scale(1); }
}

@keyframes victory-sparkle {
    0%, 100% { opacity: 0.35; transform: translateY(0) scale(0.96); }
    50% { opacity: 0.9; transform: translateY(-2px) scale(1.04); }
}

@keyframes trophy-float {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-3px) rotate(3deg); }
}

@keyframes survival-heartbeat {
    0%, 42%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(255, 70, 84, 0.45)); }
    14% { transform: scale(1.16); filter: drop-shadow(0 0 8px rgba(255, 70, 84, 0.9)); }
    28% { transform: scale(1.05); }
}

@media (prefers-reduced-motion: reduce) {
    .win-table::before,
    .win-stat-icon,
    .win-stat-num.bump {
        animation: none !important;
    }
}

/* ── OUT state (number reached 0) — mirrors the ranking "out" look ── */
.win-out-badge {
    display: none;
    width: 70%;
    height: 70%;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.win-out-badge svg {
    width: 100%;
    height: 100%;
    display: block;
}

.win-row.out .win-name,
.win-row.out .win-stat-icon {
    opacity: 0.35;
}

.win-table[data-mode="down"] .win-row.out {
    border-left-color: #ff3f52;
    background: linear-gradient(90deg, rgba(130, 19, 35, 0.34), rgba(0, 0, 0, 0.22));
}

.win-row.out .win-num-box {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.win-row.out .win-stat-num {
    display: none;
}

.win-row.out .win-out-badge {
    display: flex;
}
