/* ==========================================================================
   Balap Karung Kaliwungu Merdeka - Master Stylesheet
   Dirancang untuk Papan Interaktif Digital (IFP 75 Inch / 16:9 Landscape)
   ========================================================================== */

:root {
    /* Palette Merah Putih & Agustusan */
    --color-primary: #D90429;
    --color-primary-dark: #8D0801;
    --color-primary-light: #EF233C;
    --color-white: #FFFFFF;
    --color-gold: #FFB703;
    --color-gold-dark: #FB8500;
    
    /* Player Distinct Colors */
    --p1-color: #E63946;   /* Merah */
    --p1-bg: #FFE3E6;
    --p2-color: #0077B6;   /* Biru */
    --p2-bg: #E0F2FE;
    --p3-color: #2D6A4F;   /* Hijau */
    --p3-bg: #D8F3DC;
    --p4-color: #D97706;   /* Oranye / Kuning Emas */
    --p4-bg: #FEF3C7;

    /* Theme Environment */
    --track-sky: linear-gradient(180deg, #38BDF8 0%, #BAE6FD 100%);
    --track-grass: #40916C;
    --track-dirt: #DDB892;
    --track-dirt-dark: #B08968;
    --ui-dark: #1E293B;
    --ui-gray: #F1F5F9;
    --ui-border: #CBD5E1;

    /* Typography */
    --font-heading: 'Fredoka', 'Comic Neue', cursive, sans-serif;
    --font-body: 'Nunito', 'Poppins', sans-serif;
}

/* Reset & Base Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background-color: #0F172A;
    font-family: var(--font-body);
    color: var(--ui-dark);
}

.no-select {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Canvas Confetti */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

/* ==========================================================================
   Top Navigation Bar
   ========================================================================== */
.top-nav-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.brand-btn {
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--color-white);
    letter-spacing: 0.5px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.brand-btn:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.97);
}

.home-tag {
    background: var(--color-gold);
    color: #431407;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 800;
    margin-left: 4px;
}

.nav-actions {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: var(--color-white);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 6px 14px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.nav-btn:active {
    transform: scale(0.95);
    background: var(--color-primary);
}

.nav-btn.active {
    background: var(--color-primary-light);
    border-color: var(--color-white);
}

/* ==========================================================================
   Screen Management (STRICT ISOLATION)
   ========================================================================== */
.game-screen {
    position: absolute;
    top: 48px;
    left: 0;
    width: 100%;
    height: calc(100% - 48px);
    display: none !important;
    overflow: hidden;
}

.game-screen.active {
    display: flex !important;
    flex-direction: column;
}

/* ==========================================================================
   1. HOMESCREEN (LAYAR AWAL BERSIH & ELEGAN)
   ========================================================================== */
#screen-home {
    background: linear-gradient(180deg, rgba(141, 8, 1, 0.35) 0%, rgba(30, 10, 10, 0.6) 100%),
                url('assets/homescreen_bg.jpg') center center / cover no-repeat;
    justify-content: center;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.home-container {
    width: 100%;
    max-width: 1100px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    padding: 10px 0 14px 0;
    text-align: center;
}

/* Bunting Garland Agustusan */
.bunting-decor {
    display: flex;
    justify-content: center;
    gap: 14px;
    width: 100%;
    margin-bottom: 2px;
}

.flag-triangle {
    width: 0;
    height: 0;
    border-left: 18px solid transparent;
    border-right: 18px solid transparent;
    animation: flagSway 2.5s ease-in-out infinite alternate;
}

.flag-triangle.red {
    border-top: 32px solid #D90429;
}

.flag-triangle.white {
    border-top: 32px solid #FFFFFF;
}

@keyframes flagSway {
    0% { transform: rotate(-4deg); }
    100% { transform: rotate(4deg); }
}

/* Home Header */
.home-header {
    margin-bottom: 2px;
}

.title-ribbon {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--color-gold);
    color: #431407;
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    padding: 5px 22px;
    border-radius: 30px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    margin-bottom: 8px;
}

.home-title {
    font-family: var(--font-heading);
    font-size: 3.6rem;
    font-weight: 700;
    line-height: 1.1;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.title-word.red-glow {
    color: #FFFFFF;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 35px rgba(255, 255, 255, 0.4);
}

.title-word.gold-glow {
    color: var(--color-gold);
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.8), 0 0 35px rgba(255, 183, 3, 0.6);
}

/* Hero Mascot Showcase */
.home-hero-mascot {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 8px 0;
}

.mascot-podium {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.mascot-avatar {
    width: 130px;
    height: 140px;
    filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.5));
}

.hero-hop {
    animation: heroHopAnim 1.6s infinite ease-in-out;
}

@keyframes heroHopAnim {
    0%, 100% { transform: translateY(0) scale(1, 1); }
    40% { transform: translateY(0) scale(1.15, 0.8); }
    60% { transform: translateY(-28px) scale(0.88, 1.18); }
    80% { transform: translateY(0) scale(1.08, 0.9); }
}

.mascot-shadow {
    width: 90px;
    height: 14px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    margin-top: 2px;
    animation: shadowScale 1.6s infinite ease-in-out;
}

@keyframes shadowScale {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    60% { transform: scale(0.5); opacity: 0.15; }
}

/* Home Action Buttons */
.home-actions {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
}

.jumbo-btn {
    font-family: var(--font-heading);
    font-size: 1.7rem;
    font-weight: 700;
    color: #431407;
    background: linear-gradient(180deg, #FFE44D 0%, #FFB703 60%, #FB8500 100%);
    border: 4px solid #FFFFFF;
    border-radius: 40px;
    padding: 15px 48px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.8);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.jumbo-btn:active {
    transform: scale(0.96) translateY(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.8);
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 700;
    padding: 14px 34px;
    border-radius: 40px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
    transition: all 0.2s ease;
}

.secondary-btn:active {
    transform: scale(0.96);
    background: rgba(255, 255, 255, 0.35);
}

.start-pulse {
    animation: buttonPulse 1.8s infinite ease-in-out;
}

@keyframes buttonPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.home-footer-tag {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    font-weight: 700;
}

/* ==========================================================================
   2. SETUP SCREEN (LOBBY PENGATURAN)
   ========================================================================== */
#screen-setup {
    background: radial-gradient(circle at 50% 30%, #C1121F 0%, #780000 70%, #350000 100%);
    justify-content: center;
    align-items: center;
    padding: 18px 24px;
}

.setup-container {
    width: 100%;
    max-width: 1250px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.setup-top-bar {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.setup-title {
    font-family: var(--font-heading);
    font-size: 2.1rem;
    color: var(--color-gold);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
}

.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    width: 100%;
    margin: 4px 0;
}

.setup-card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 18px;
    padding: 10px 14px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
    border: 3.5px solid var(--color-gold);
}

.card-heading {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--color-primary-dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.player-selector-group, .difficulty-selector-group, .time-selector-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.target-selector-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.select-btn {
    background: var(--ui-gray);
    border: 3px solid var(--ui-border);
    border-radius: 14px;
    padding: 6px 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-height: 76px;
}

.select-btn:active {
    transform: scale(0.96);
}

.select-btn.active {
    background: #FFF7ED;
    border-color: var(--color-gold-dark);
    box-shadow: 0 0 0 3px var(--color-gold), 0 8px 16px rgba(251, 133, 0, 0.25);
    transform: translateY(-2px);
}

.player-avatar, .diff-emoji, .target-emoji, .time-emoji {
    font-size: 1.75rem;
    margin-bottom: 2px;
}

.player-avatar-group {
    display: flex;
    font-size: 1.15rem;
    margin-bottom: 2px;
}

.btn-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ui-dark);
}

.btn-sub {
    font-size: 0.70rem;
    color: #64748B;
    font-weight: 700;
}

.rules-bar {
    display: flex;
    justify-content: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.35);
    padding: 6px 20px;
    border-radius: 30px;
    width: 100%;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-white);
    font-size: 1.0rem;
}

/* ==========================================================================
   3. GAMEPLAY SCREEN LAYOUT (VIEWING + TOUCH ZONE)
   ========================================================================== */
#screen-game {
    background: #02203C;
}

/* TOP VIEWING ZONE (44% Height) */
.viewing-zone {
    height: 44%;
    min-height: 250px;
    background: var(--track-sky);
    display: flex;
    flex-direction: column;
    position: relative;
    border-bottom: 6px solid #0F172A;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
    z-index: 50;
}

.game-top-bar {
    height: 42px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: rgba(15, 23, 42, 0.85);
    color: var(--color-white);
}

.mini-action-btn {
    background: rgba(255, 255, 255, 0.2);
    color: #FFFFFF;
    border: none;
    padding: 6px 16px;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-weight: 700;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.mini-action-btn:active {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.35);
}

.menu-accent-btn {
    background: #D90429 !important;
    border: 2px solid var(--color-white) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    font-size: 1.0rem !important;
    padding: 6px 18px !important;
}

.menu-accent-btn:active {
    background: #8D0801 !important;
}

.race-status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #0284C7;
    padding: 4px 18px;
    border-radius: 20px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.05rem;
    color: #FFFFFF;
}

.pulse-dot {
    width: 10px;
    height: 10px;
    background: #4ADE80;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.2; }
}

.game-timer-badge {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-gold);
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 14px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.game-timer-badge.urgent {
    color: #FFFFFF !important;
    background: #DC2626 !important;
    animation: timerUrgentPulse 0.5s infinite alternate;
}

@keyframes timerUrgentPulse {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(220, 38, 38, 0.4); }
    100% { transform: scale(1.1); box-shadow: 0 0 16px rgba(220, 38, 38, 0.9); }
}

/* ==========================================================================
   RACE ARENA (ACCURATE GRID & CHECKERED FINISH LINE)
   ========================================================================== */
.race-arena {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    background: linear-gradient(180deg, #7DD3FC 0%, #E0F2FE 36%, var(--track-grass) 36%, var(--track-dirt) 58%, var(--track-dirt-dark) 100%);
}

.track-scenery {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.cloud {
    position: absolute;
    background: #FFFFFF;
    border-radius: 50px;
    opacity: 0.85;
}

.cloud.c1 { width: 120px; height: 35px; top: 15px; left: 15%; }
.cloud.c2 { width: 160px; height: 45px; top: 30px; left: 65%; }

/* TRACK PLAY ZONE (Coordinates 0% START to 100% FINISH) */
.track-play-zone {
    position: relative;
    height: 72%;
    margin: 0 48px; /* Offset pasti agar pas dengan skala marker bawah */
    display: flex;
    align-items: center;
}

/* 1. Garis Start Putih Tegas */
.track-start-line {
    position: absolute;
    left: 0%;
    top: 0;
    bottom: 0;
    width: 6px;
    background: #FFFFFF;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.9);
    transform: translateX(-50%);
    z-index: 25;
}

.start-flag {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.2rem;
}

/* 2. Garis Bantu Langkah Vertikal (1 s.d. 9) - Disembunyikan agar tampilan lapangan bersih */
.track-step-grid {
    display: none;
}

/* 3. Garis Finish Papan Catur Hitam Putih (Checkered Finish Line) */
.checkered-finish-line {
    position: absolute;
    left: 100%;
    top: 0;
    bottom: 0;
    width: 32px;
    transform: translateX(-50%);
    z-index: 28;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.checkered-strip {
    width: 100%;
    height: 100%;
    background-image:
        linear-gradient(45deg, #111827 25%, transparent 25%),
        linear-gradient(-45deg, #111827 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #111827 75%),
        linear-gradient(-45deg, transparent 75%, #111827 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
    background-color: #FFFFFF;
    box-shadow: 0 0 14px rgba(0, 0, 0, 0.7);
    border-left: 3px solid #FFFFFF;
    border-right: 3px solid #FFFFFF;
}

.finish-gate-overhead {
    position: absolute;
    top: -26px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 45;
    pointer-events: none;
}

.finish-arch {
    background: #D90429;
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 5px 14px;
    border-radius: 12px;
    border: 3px solid #FFFFFF;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(0,0,0,0.5);
    letter-spacing: 0.5px;
}

/* 4. Jalur Balap Pemain */
.race-lanes {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    z-index: 30;
}

.race-lane {
    display: flex;
    align-items: center;
    position: relative;
    height: 25%;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.35);
}

.lane-label {
    position: absolute;
    left: -38px;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    color: #FFFFFF;
    background: rgba(0, 0, 0, 0.75);
    padding: 2px 6px;
    border-radius: 6px;
    z-index: 35;
}

/* SACK RACER SPRITE (Centering & Exact Pos) */
.sack-racer {
    position: absolute;
    left: 0%; /* Diupdate oleh JS: 0%, 10%, 20%, ..., 100% */
    transform: translateX(-50%); /* TEPAT DI TENGAH MARKER */
    bottom: -2px;
    width: 58px;
    height: 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    transition: left 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 40;
}

.sack-avatar {
    width: 48px;
    height: 52px;
    position: relative;
    transform-origin: bottom center;
}

.sack-racer.hop-forward .sack-avatar {
    animation: sackHopAnim 0.55s ease-out;
}

.sack-racer.hop-backward .sack-avatar {
    animation: sackBackAnim 0.55s ease-out;
}

.sack-racer.idle .sack-avatar {
    animation: sackIdleBreath 2s infinite ease-in-out;
}

@keyframes sackHopAnim {
    0% { transform: scale(1, 1) translateY(0); }
    30% { transform: scale(1.15, 0.75) translateY(0); }
    60% { transform: scale(0.85, 1.25) translateY(-28px) rotate(6deg); }
    85% { transform: scale(1.1, 0.85) translateY(0); }
    100% { transform: scale(1, 1) translateY(0); }
}

@keyframes sackBackAnim {
    0% { transform: scale(1, 1) translateY(0); }
    40% { transform: scale(0.9, 1.1) translateY(-18px) rotate(-12deg); }
    80% { transform: scale(1.15, 0.8) translateY(0); }
    100% { transform: scale(1, 1) translateY(0); }
}

@keyframes sackIdleBreath {
    0%, 100% { transform: scale(1, 1); }
    50% { transform: scale(1.03, 0.96); }
}

/* Dust puff */
.dust-cloud {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 28px;
    height: 14px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
}

.sack-racer.hop-forward .dust-cloud {
    animation: dustPuffAnim 0.5s ease-out;
}

@keyframes dustPuffAnim {
    0% { opacity: 0.9; transform: translateX(-50%) scale(0.4); }
    100% { opacity: 0; transform: translateX(-80%) scale(2.2); }
}

.racer-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.racer-score-tag {
    position: absolute;
    top: -18px;
    background: #0F172A;
    color: var(--color-gold);
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    border: 1.5px solid #FFFFFF;
    white-space: nowrap;
}

/* 5. Skala Poin Jarak Akurat Sejajar (Track Distance Markers) */
.track-distance-markers {
    height: 28px;
    background: rgba(15, 23, 42, 0.95);
    border-top: 2px solid rgba(255, 255, 255, 0.2);
    position: relative;
    width: 100%;
}

.marker-track-inner {
    position: relative;
    height: 100%;
    margin: 0 48px; /* SAMA PERSIS dengan .track-play-zone */
}

.step-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    color: #E2E8F0;
    white-space: nowrap;
}

.step-marker .start-txt {
    color: #4ADE80;
    font-size: 0.85rem;
}

.step-marker .finish-txt {
    color: var(--color-gold);
    font-size: 0.95rem;
}

/* ==========================================================================
   BOTTOM TOUCH ZONE (56% Height - Split-Screen Quiz)
   ========================================================================== */
.touch-zone {
    height: 56%;
    background: #0F172A;
    padding: 8px 12px;
    display: flex;
    overflow: hidden;
}

.split-columns-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    gap: 10px;
}

/* INDIVIDUAL PLAYER COLUMN */
.player-column {
    flex: 1;
    background: #FFFFFF;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 14px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    border: 4px solid var(--ui-border);
    transition: border-color 0.2s ease;
}

.player-column.player-1 { border-color: var(--p1-color); }
.player-column.player-2 { border-color: var(--p2-color); }
.player-column.player-3 { border-color: var(--p3-color); }
.player-column.player-4 { border-color: var(--p4-color); }

.col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--ui-gray);
    margin-bottom: 4px;
}

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

.col-avatar {
    font-size: 1.6rem;
}

.col-player-name {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ui-dark);
}

.col-badges {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-badge {
    background: var(--ui-dark);
    color: var(--color-gold);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 14px;
}

.wrong-badge {
    background: #FEE2E2;
    color: #DC2626;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    border: 1px solid #FCA5A5;
}

/* Question Area */
.question-card {
    background: #F8FAFC;
    border: 2px solid #E2E8F0;
    border-radius: 14px;
    padding: 10px 14px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 80px;
}

.question-text {
    font-size: 1.25rem;
    font-weight: 800;
    color: #1E293B;
    line-height: 1.35;
    flex: 1;
}

.split-3 .question-text { font-size: 1.15rem; }
.split-4 .question-text { font-size: 1.05rem; }

.btn-read-tts {
    background: #E2E8F0;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.btn-read-tts:active {
    transform: scale(0.9);
    background: var(--color-primary-light);
    color: #FFFFFF;
}

/* Multiple Choice Options Grid */
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 8px;
}

.split-4 .options-grid {
    grid-template-columns: 1fr;
    gap: 6px;
}

.option-btn {
    background: #FFFFFF;
    border: 3px solid #CBD5E1;
    border-radius: 14px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    text-align: left;
    min-height: 60px;
    position: relative;
    transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.option-btn:active {
    transform: scale(0.96);
    background: #F1F5F9;
}

.option-key {
    background: var(--ui-dark);
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.option-text {
    font-size: 1.1rem;
    font-weight: 800;
    color: #1E293B;
    line-height: 1.2;
    flex: 1;
}

.split-3 .option-text { font-size: 1.0rem; }
.split-4 .option-text { font-size: 0.95rem; }

.option-btn:nth-child(1) .option-key { background: #E63946; }
.option-btn:nth-child(2) .option-key { background: #0077B6; }
.option-btn:nth-child(3) .option-key { background: #2D6A4F; }
.option-btn:nth-child(4) .option-key { background: #D97706; }

.option-btn.correct {
    background: #DCFCE7 !important;
    border-color: #22C55E !important;
    box-shadow: 0 0 0 3px #86EFAC;
    animation: correctPop 0.4s ease-out;
}

.option-btn.wrong {
    background: #FEE2E2 !important;
    border-color: #EF4444 !important;
    box-shadow: 0 0 0 3px #FCA5A5;
    animation: wrongShake 0.4s ease-in-out;
}

@keyframes correctPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Feedback Overlay Banner inside player column */
.col-feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.col-feedback-overlay.active {
    display: flex;
}

.feedback-icon {
    font-size: 3.5rem;
    margin-bottom: 8px;
    animation: bouncePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feedback-title {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.feedback-title.correct { color: #16A34A; }
.feedback-title.wrong { color: #DC2626; }
.feedback-title.penalty { color: #991B1B; }

.feedback-sub {
    font-size: 1.1rem;
    font-weight: 700;
    color: #475569;
}

@keyframes bouncePop {
    0% { transform: scale(0.3); opacity: 0; }
    70% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==========================================================================
   4. MODAL KONFIRMASI KELUAR
   ========================================================================== */
.confirm-modal-card {
    max-width: 520px;
    padding: 30px 32px;
}

.confirm-icon {
    font-size: 3.5rem;
    margin-bottom: 8px;
}

.confirm-title {
    font-family: var(--font-heading);
    font-size: 2.0rem;
    color: var(--color-primary-dark);
    margin-bottom: 6px;
}

.confirm-subtitle {
    font-size: 1.1rem;
    color: #475569;
    font-weight: 700;
    margin-bottom: 24px;
    line-height: 1.35;
}

.confirm-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.exit-yes-btn {
    background: linear-gradient(180deg, #EF233C 0%, #D90429 100%) !important;
    color: #FFFFFF !important;
    font-size: 1.25rem !important;
    padding: 14px 28px !important;
    border-color: #FFFFFF !important;
    justify-content: center;
}

.exit-no-btn {
    background: #64748B !important;
    border-color: #94A3B8 !important;
    font-size: 1.25rem !important;
    padding: 14px 28px !important;
    color: #FFFFFF !important;
    justify-content: center;
}

/* ==========================================================================
   5. MODAL PETUNJUK / RULES
   ========================================================================== */
.rules-modal-card {
    max-width: 780px;
    text-align: left;
    padding: 28px 36px;
}

.rules-header {
    text-align: center;
    margin-bottom: 18px;
}

.rules-icon {
    font-size: 3rem;
    margin-bottom: 4px;
}

.rules-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    color: var(--color-primary-dark);
}

.rules-subtitle {
    color: #64748B;
    font-size: 1.1rem;
    font-weight: 700;
}

.rules-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.rule-card-item {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: #F8FAFC;
    border: 2px solid #E2E8F0;
    padding: 12px 18px;
    border-radius: 16px;
}

.rule-badge-num {
    background: var(--color-primary);
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.3rem;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.rule-detail h4 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: #1E293B;
    margin-bottom: 2px;
}

.rule-detail p {
    font-size: 1.0rem;
    color: #475569;
    line-height: 1.35;
}

.rules-footer {
    display: flex;
    justify-content: center;
}

/* ==========================================================================
   6. VICTORY MODAL & PODIUM
   ========================================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.modal-backdrop.active {
    display: flex;
}

.modal-content {
    background: #FFFFFF;
    border-radius: 28px;
    width: 100%;
    max-width: 850px;
    padding: 30px 40px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    border: 6px solid var(--color-gold);
    position: relative;
}

.bounce-in {
    animation: modalBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalBounceIn {
    0% { transform: scale(0.6); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.trophy-sparkle {
    font-size: 4rem;
    margin-bottom: 6px;
    animation: starPulse 1.5s infinite alternate ease-in-out;
}

@keyframes starPulse {
    0% { transform: scale(1) rotate(-5deg); }
    100% { transform: scale(1.15) rotate(5deg); }
}

.victory-title {
    font-family: var(--font-heading);
    font-size: 2.4rem;
    color: var(--color-primary-dark);
}

.victory-subtitle {
    font-size: 1.4rem;
    font-weight: 800;
    color: #1E293B;
    margin-top: 4px;
}

/* Podium Display */
.podium-display {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 16px;
    margin: 24px 0 16px 0;
    height: 180px;
}

.podium-step {
    flex: 1;
    max-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.podium-winner-av {
    font-size: 2.4rem;
    margin-bottom: 6px;
    animation: winnerHop 1s infinite alternate;
}

@keyframes winnerHop {
    0% { transform: translateY(0); }
    100% { transform: translateY(-12px); }
}

.podium-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 4px;
}

.podium-block {
    width: 100%;
    border-radius: 14px 14px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-family: var(--font-heading);
    font-weight: 700;
    box-shadow: inset 0 4px 8px rgba(255, 255, 255, 0.4), 0 4px 12px rgba(0,0,0,0.2);
}

.podium-block.first {
    height: 110px;
    background: linear-gradient(180deg, #FFD166 0%, #FFB703 100%);
    color: #431407;
    font-size: 1.8rem;
}

.podium-block.second {
    height: 80px;
    background: linear-gradient(180deg, #E2E8F0 0%, #94A3B8 100%);
    font-size: 1.5rem;
}

.podium-block.third {
    height: 60px;
    background: linear-gradient(180deg, #FDBA74 0%, #EA580C 100%);
    font-size: 1.3rem;
}

.podium-block.fourth {
    height: 45px;
    background: linear-gradient(180deg, #CBD5E1 0%, #64748B 100%);
    font-size: 1.1rem;
}

.victory-stats {
    background: #F8FAFC;
    border-radius: 16px;
    padding: 12px 20px;
    display: flex;
    justify-content: space-around;
    font-size: 1.1rem;
    font-weight: 700;
    color: #334155;
    margin-bottom: 20px;
}

.victory-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.restart-btn {
    background: linear-gradient(180deg, #4ADE80 0%, #16A34A 100%);
    color: #FFFFFF;
    font-size: 1.3rem;
    padding: 12px 36px;
}

.menu-btn {
    background: linear-gradient(180deg, #94A3B8 0%, #475569 100%);
    color: #FFFFFF;
    font-size: 1.3rem;
    padding: 12px 36px;
}
