@import url('../font/quicksand.css');

body {
    font-family: "Segoe UI", sans-serif;
    margin: 0;
    overflow: hidden;
    text-align: center;
    background: linear-gradient(180deg, #0ea5e9 0%, #0284c7 25%, #0369a1 50%, #075985 100%);
    position: relative;
}
body::before {
    content: '';
    position: fixed;
    top: 0; left: -100%;
    width: 300%; height: 100%;
    background:
        repeating-linear-gradient(90deg,
            transparent 0px, transparent 80px,
            rgba(255,255,255,0.03) 80px, rgba(255,255,255,0.03) 82px
        ),
        repeating-linear-gradient(0deg,
            transparent 0px, transparent 60px,
            rgba(255,255,255,0.02) 60px, rgba(255,255,255,0.02) 62px
        );
    animation: waterDrift 25s linear infinite;
    pointer-events: none;
    z-index: 0;
}
@keyframes waterDrift {
    0% { transform: translateX(0) translateY(0); }
    50% { transform: translateX(-15%) translateY(3px); }
    100% { transform: translateX(-33.33%) translateY(0); }
}
h1 { color: white; margin-top:10px; }
* {
    box-sizing: border-box;
}
body.vehicle #bo:before,
body.motogp #bo:before,
body.bicycle #bo:before,
body.ct1 #bo:before {
    content: '';
    display: block;
    position: absolute;
    width: 100%;
    height: 41px;
    background: repeating-linear-gradient(90deg,
        #ef4444 0px, #ef4444 20px, #fff 20px, #fff 40px
    );
    border-top: 3px solid #991b1b;
    border-bottom: 2px solid #b91c1c;
    top: 30px;
}
body.vehicle #boduoi,
body.motogp #boduoi,
body.bicycle #boduoi,
body.ct1 #boduoi {
    display: block;
    position: absolute;
    width: 13000px;
    left: -1000px;
    height: 17px;
    background: repeating-linear-gradient(90deg,
        #ef4444 0px, #ef4444 15px, #fff 15px, #fff 30px
    );
    border-top: 2px solid #991b1b;
    z-index: 6;
    bottom: 0;
}
body.vehicle #bg_road,
body.motogp #bg_road,
body.bicycle #bg_road,
body.ct1 #bg_road {
    background: linear-gradient(180deg, #4a4d54 0%, #3f3f46 50%, #374151 100%);
    position: absolute;
    z-index: 5;
    bottom: 0;
    top: 195px;
    left: 0;
    width: 1000%;
}
body.vehicle #bg_road::after,
body.motogp #bg_road::after,
body.bicycle #bg_road::after,
body.ct1 #bg_road::after {
    content: '';
    position: absolute;
    top: 48%;
    left: 0;
    width: 100%;
    height: 3px;
    background: repeating-linear-gradient(90deg,
        rgba(255,255,255,0.5) 0px, rgba(255,255,255,0.5) 40px,
        transparent 40px, transparent 80px
    );
}
body.vehicle .name {
    top: 15px;
}
body.motogp .name,
body.bicycle .name {
    top: 10px;
    right: 45px;
}
body.ct1 .name {
    top: 30px;
    right: 60px;
}
#controls { position: fixed; top: 0px; right: 0px; margin:0px; z-index: 900; font-family: 'Quicksand', sans-serif; }
#pond-container { overflow:hidden; width:100vw; height:100vh; border-bottom:6px solid #004080; position:relative; }
#pond { position: absolute; top: 200px; left: 0; width: 13000px; height: calc(100% - 200px); transition: transform 0.1s linear; z-index: 11; }
#pond .duck { position:absolute; left:0; width:170px; height:170px; z-index: 1 }
#pond .duck img { width:170px; height:170px; transform: scaleX(1)}
#pond .duck .index {
    position: absolute;
    bottom: 53px;
    right: 61px;
    z-index: 1;
    text-align: center;
    display: block;
    width: 39px;
    color: #000;
    font-weight: bold;
    font-size: 14px;
}
.name {
    color: #1e293b;
    font-weight: 700;
    font-size: 13px;
    position: absolute;
    top: 40px;
    right: 40px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: 5px 12px;
    text-align: center;
    border-radius: 10px;
    transform: translate(-45px, 5px);
    box-shadow: 0 3px 12px rgba(0,0,0,0.12);
    border: 1px solid rgba(255,255,255,0.7);
    font-family: 'Quicksand', sans-serif;
    white-space: nowrap;
    transition: transform 0.2s ease;
}
.name::after {
    content: '';
    position: absolute;
    display: block;
    width: 0;
    z-index: 1;
    border-style: solid;
    border-color: rgba(255,255,255,0.92) transparent;
    border-width: 8px 8px 0;
    bottom: -7px;
    right: 4px;
    margin-left: -14px;
}

#countdown { font-size:160px; position:absolute; top:50%; width:100%; display:none; z-index:9; font-family: 'Quicksand', sans-serif; font-weight: 800; text-align: center; background: linear-gradient(90deg, #f472b6, #fb923c, #facc15, #4ade80, #60a5fa, #a78bfa, #f472b6); background-size: 300% 100%; -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.35)); animation: countdownRainbow 1.2s linear infinite; }
@keyframes countdownRainbow {
    0%   { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}
#raceTimer { position: fixed; top:210px; right:10px; font-size:48px; color:#fff; text-shadow:0 2px 8px rgba(0,0,0,0.2); z-index:5; background: linear-gradient(135deg, #f59e0b, #ef4444); border-radius: 16px; padding: 10px 20px; box-shadow: 0 8px 25px rgba(245,158,11,0.35); font-family: 'Quicksand', sans-serif; font-weight: 800; min-width: 70px; text-align: center; border: 2px solid rgba(255,255,255,0.3); }
#result { display: none !important; }
.bubble { position:absolute; width:10px; height:10px; background:rgba(255,255,255,0.7); border-radius:50%; animation:bubbleUp 2s linear forwards; z-index:1; }
.splash { position:absolute; width:15px; height:15px; border-radius:50%; background:rgba(255,255,255,0.8); animation:splashUp 0.6s ease-out forwards; }
.confetti { position:absolute; width:8px; height:8px; border-radius:2px; animation:confettiFall 1s linear forwards; }
.water-ring { position: absolute; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,0.6); border-radius: 50%; opacity: 1; animation: ringExpand 1.5s ease-out forwards; pointer-events: none; z-index: 1; }
@keyframes bubbleUp { 0% { transform:translateY(0); opacity:1; } 100% { transform:translateY(-80px); opacity:0; } }
@keyframes splashUp { 0%{ transform:scale(1) translateY(0); opacity:1; } 100%{ transform:scale(2) translateY(-40px); opacity:0; } }
@keyframes confettiFall { 0%{ opacity:1; transform:translateY(0) rotate(0deg);} 100%{opacity:0; transform:translateY(-80px) rotate(360deg);} }
@keyframes ringExpand { 0% { transform: scale(1); opacity: 0.9; } 100% { transform: scale(6); opacity: 0; } }
.winner-glow { box-shadow: 0 0 30px 10px gold; border-radius: 50%; animation: glowRotate 2s linear infinite; }
#bank {
    position: absolute; top: 0; left: -1000px; width: 13000px; height: 180px;
    background: linear-gradient(180deg,
        #4ade80 0%, #22c55e 25%, #16a34a 55%,
        #a16207 75%, #92400e 90%, #78350f 100%
    );
    z-index: 5;
}
#bank::before {
    content: '';
    position: absolute;
    bottom: 0; left: 0;
    width: 100%; height: 30px;
    background: linear-gradient(180deg, transparent, rgba(120,53,15,0.4));
}
.tree { position: absolute; bottom: 0; pointer-events: none; z-index: 6; }
.bo {
    position: absolute; top: 160px; left: -1000px; width: 13000px; height: 50px;
    z-index: 8;
    background: linear-gradient(180deg,
        #92400e 0%, #78350f 30%, #5b3010 60%,
        rgba(14,165,233,0.3) 100%
    );
    border-top: 2px solid #a16207;
}
.bo::after {
    content: '';
    position: absolute;
    top: -8px; left: 0;
    width: 100%; height: 10px;
    background: repeating-linear-gradient(90deg,
        transparent 0px, transparent 15px,
        rgba(34,197,94,0.4) 15px, rgba(34,197,94,0.4) 18px
    );
}
.xuatphat {
    position: absolute; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 210; transition: opacity 0.8s ease-out;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.xuatphat::before {
    content: '🏁 XUẤT PHÁT';
    font-size: 42px; font-weight: 900;
    font-family: 'Quicksand', sans-serif;
    color: #fff;
    text-shadow: 0 4px 15px rgba(0,0,0,0.4), 0 0 30px rgba(6,182,212,0.5);
    background: linear-gradient(135deg, #06b6d4, #8b5cf6);
    padding: 20px 48px;
    border-radius: 20px;
    border: 3px solid rgba(255,255,255,0.4);
    box-shadow: 0 15px 40px rgba(6,182,212,0.3);
    animation: bannerPulse 1.5s ease-in-out infinite alternate;
}
.vedich {
    display: none !important;
    position: absolute; top: 50%; left: 50%;
    width: 400px; height: 300px;
    transform: translate(-50%, -50%);
    z-index: 10; transition: opacity 0.8s ease-out;
    align-items: center; justify-content: center;
}
.vedich::before {
    content: '🏆 VỀ ĐÍCH';
    font-size: 42px; font-weight: 900;
    font-family: 'Quicksand', sans-serif;
    color: #1e293b;
    text-shadow: 0 2px 8px rgba(0,0,0,0.15);
    background: linear-gradient(135deg, #fde68a, #fbbf24, #f59e0b);
    padding: 20px 48px;
    border-radius: 20px;
    border: 3px solid rgba(255,255,255,0.5);
    box-shadow: 0 15px 40px rgba(245,158,11,0.3);
}
@keyframes bannerPulse {
    from { transform: scale(1); box-shadow: 0 15px 40px rgba(6,182,212,0.3); }
    to { transform: scale(1.05); box-shadow: 0 20px 50px rgba(6,182,212,0.5), 0 0 40px rgba(139,92,246,0.2); }
}
.hidden { opacity: 0; pointer-events: none; }
.menu-container {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    width: min(95vw, 960px);
    height: auto;
    max-height: 85vh;
    box-sizing: border-box;
    padding: 28px 32px 80px;
    border-radius: 24px;
    flex-direction: column;
    display: flex;
    transition: transform 0.35s cubic-bezier(.4,0,.2,1), opacity 0.35s ease;
    z-index: 1000;
    text-align: left;
    box-shadow: 0 25px 60px rgba(0,0,0,0.18), 0 0 0 1px rgba(0,0,0,0.05);
    position: relative;
    font-family: 'Quicksand', sans-serif;
    color: #1e293b;
}

.menu-container * {
    box-sizing: border-box;
}
.menu-container .wrapper {
    width: 100%;
    height: auto;
    max-height: calc(85vh - 130px);
    overflow-y: auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    box-shadow: none;
    padding: 0;
    gap: 16px;
}

.menu-container .danhsach {
    padding: 16px;
    width: calc(50% - 8px);
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    border-radius: 16px;
    border: 1px solid rgba(16,185,129,0.15);
}

.menu-container .setup {
    width: calc(50% - 8px);
    padding: 16px;
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    border-radius: 16px;
    border: 1px solid rgba(139,92,246,0.15);
}
.menu-container .setup .col {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(139,92,246,0.1);
}
.menu-container .setup .col:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.menu-container .btn-actions {
    position: absolute;
    bottom: 20px;
    right: 32px;
    justify-content: flex-end;
    width: auto;
    display: flex;
    gap: 12px;
}

.winner-menu { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; justify-content: center; align-items: center; opacity: 0; pointer-events: none; transition: opacity 0.35s ease; z-index: 1000; }
.winner-menu.show { opacity: 1; pointer-events: all; }
.winner-menu.show .menu-container { transform: scale(1); }
.close-btn { margin-top: 10px; background: linear-gradient(135deg, #ef4444, #dc2626); border: none; color: white; padding: 8px 16px; border-radius: 10px; cursor: pointer; font-weight: 700; }
.clear-btn { background: linear-gradient(135deg, #f59e0b, #d97706); border: none; color: white; padding: 8px 16px; border-radius: 10px; cursor: pointer; margin-right: 8px; font-weight: 700; }
.buton_dk{ position: fixed; bottom:10px; right: 10px; z-index: 900; }
#winnerList { padding-right: 5px; max-height: 280px; overflow-y: auto; }
.danhsach h3, .setup h3 {
    border-bottom: none;
    padding-bottom: 8px;
    color: #1e293b;
    font-size: 17px;
    margin: 8px 0 12px;
    font-weight: 800;
    letter-spacing: -0.3px;
}
.setup h3 { color: #6d28d9; }
.danhsach h3 { color: #059669; }
input[type="checkbox"], input[type="radio"] { font-size: 18px !important; width: 18px; height: 18px; accent-color: #8b5cf6; cursor: pointer; }
input[type="number"] { font-size: 16px !important; width: 60px; height: 32px; border: 2px solid #e2e8f0; border-radius: 8px; padding: 2px 8px; text-align: center; outline: none; transition: border-color 0.2s; }
input[type="number"]:focus { border-color: #8b5cf6; }
.question-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 200; }
.qbox { background: rgba(255,255,255,0.97); backdrop-filter: blur(20px); padding: 28px; border-radius: 20px; max-width: 500px; text-align: left; color: #1e293b; box-shadow: 0 25px 60px rgba(0,0,0,0.15); border: 1px solid rgba(0,0,0,0.06); }
.qbox .highlight { color: #8b5cf6; font-weight: bold; }
#questionArea h3 { font-size: 24px !important; color: #1e293b; font-weight: 700; line-height: 1.4; margin-bottom: 16px; }
#questionArea button { font-size: 16px !important; margin: 4px 8px; font-family: 'Quicksand', sans-serif; transition: all 0.25s cubic-bezier(0.4,0,0.2,1); }
#questionArea { z-index: 900; font-family: 'Quicksand', sans-serif; }
.traloicauhoi { display: none !important; }
.traloicauhoi span { color: #fff !important; font-weight: 700; }
button#traloi { padding: 16px 36px; font-size: 20px; color: #fff; border: none; border-radius: 14px; background: linear-gradient(135deg, #06b6d4, #8b5cf6); box-shadow: 0 8px 25px rgba(6,182,212,0.35); cursor: pointer; transition: all 0.3s ease; display: none; font-weight: 700; font-family: 'Quicksand', sans-serif; }
button#traloi:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 12px 30px rgba(6,182,212,0.45); }
button:hover { transform: scale(1.05); }
#questionCountdown { font-size: 36px; font-weight: bold; }
.btn-overlay { position: relative; border: none; padding: 12px 28px !important; background: linear-gradient(135deg, #06b6d4, #8b5cf6); cursor: pointer; border-radius: 12px; color: #fff; font-family: 'Quicksand', sans-serif; font-weight: 700; font-size: 16px; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(6,182,212,0.3); display: inline-flex; align-items: center; justify-content: center; }
.btn-overlay img { display: none; }
.btn-overlay span {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    width: auto;
}
.btn-overlay:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 25px rgba(6,182,212,0.4); }
.btn-overlay:hover span { color: #fff; }
button { padding: 8px 16px; font-size: 16px; background: linear-gradient(135deg, #fbbf24, #f59e0b); border: none; cursor: pointer; transition: all 0.25s ease; border-radius: 10px; font-family: 'Quicksand', sans-serif; font-weight: 700; color: #1e293b; }
.btn_boqua { background: linear-gradient(135deg, #ef4444, #dc2626); color: white; border-radius: 10px; }
#closeMenu { background: linear-gradient(135deg, #10b981, #059669); }
#closeMenu:hover { box-shadow: 0 6px 20px rgba(16,185,129,0.35); }
#resetGame { background: linear-gradient(135deg, #f59e0b, #d97706); }
#resetGame:hover { box-shadow: 0 6px 20px rgba(245,158,11,0.35); }
.menu { position: fixed; top: 0; right: 0; background: linear-gradient(135deg, rgba(15,23,42,0.85), rgba(30,58,138,0.8)); backdrop-filter: blur(10px); color: white; display: flex; align-items: center; gap: 10px; padding: 8px 16px; border-bottom-left-radius: 14px; z-index: 100; width: auto; max-width: 100vw; box-shadow: 0 4px 15px rgba(0,0,0,0.2); border: 1px solid rgba(255,255,255,0.1); }
#lopname { font-size: 16px; font-weight: 700; margin: 0; white-space: nowrap; font-family: 'Quicksand', sans-serif; }

.start-line,
.finish-line {
    position: absolute;
    top: 260px;
    bottom: 40px;
    z-index: 9;
    width: 80px;
    background-color: white;
    /* Tạo họa tiết caro đen trắng */
    background-image:
            linear-gradient(45deg, #8b1419 25%, transparent 25%, transparent 75%, #8b1419 75%, #8b1419),
            linear-gradient(45deg, #8b1419 25%, transparent 25%, transparent 75%, #8b1419 75%, #8b1419);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}
.start-line {
    left: 100px;
}

.finish-line {
    left: -100%;
}



/*
    start welcome screen
*/
#welcomeScreen {
    font-family: 'Quicksand', sans-serif !important;
    background-color: #090a0f;
    color: #ffffff;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 99999;
}

#welcomeScreen.fade-out {
    pointer-events: none;
    opacity: 0;
    transform: scale(1.1);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

/* Stars Background */
#welcomeScreen .stars {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 40px 70px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 50px 160px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 90px 40px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 130px 80px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(2px 2px at 160px 120px, #ffffff, rgba(0,0,0,0));
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: moveStars 150s linear infinite;
    z-index: 0;
}
#welcomeScreen .stars1 { animation-duration: 50s; opacity: 0.3; }
#welcomeScreen .stars2 { animation-duration: 100s; opacity: 0.2; transform: scale(1.5); }
#welcomeScreen .stars3 { animation-duration: 150s; opacity: 0.1; transform: scale(2); }

@keyframes moveStars {
    0% { transform: translateY(0); }
    100% { transform: translateY(-200px); }
}

#welcomeScreen::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at center, rgba(66, 153, 225, 0.15) 0%, rgba(0, 0, 0, 0) 60%);
    z-index: 0;
    pointer-events: none;
}

/* Header */
.ws-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.ws-logo-container {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    margin-left: 15px;
}
.ws-logo-container::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(66, 153, 225, 0.4) 0%, rgba(159, 122, 234, 0.2) 40%, rgba(0, 0, 0, 0) 70%);
    border-radius: 50%;
    z-index: -1;
    filter: blur(15px);
    animation: pulseNebula 4s ease-in-out infinite alternate;
}
@keyframes pulseNebula {
    0% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.5; }
    100% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
}

.ws-logo {
    max-width: 120px;
    height: auto;
    filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.5));
    animation: floatLogo 6s ease-in-out infinite;
}
@keyframes floatLogo {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Main */
.ws-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    position: relative;
    z-index: 1;
}

.ws-content-wrapper {
    text-align: center;
    padding: 2rem;
    width: 100%;
    max-width: 900px;
    animation: fadeInScale 1s ease-out forwards;
}
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.ws-game-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    line-height: 1.2;
    color: #fff;
    margin: 0;
    background: linear-gradient(to right, #4fd1c5, #f687b3, #4fd1c5);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientText 5s linear infinite;
    filter: drop-shadow(0 0 10px rgba(246, 135, 179, 0.5));
    font-weight: 800;
}
@keyframes gradientText {
    0% { background-position: 0% center; }
    100% { background-position: 200% center; }
}

.ws-game-subtitle {
    font-size: clamp(1rem, 3vw, 1.25rem);
    color: #e2e8f0;
    font-weight: 600;
    margin-top: 1rem;
    margin-bottom: 0;
    opacity: 0;
    letter-spacing: 0.5px;
    animation: fadeIn 2s ease-out 0.5s forwards;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 0.9; transform: translateY(0); }
}

.ws-button-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 3rem;
}

/* Cosmic Button Styling */
.ws-btn-primary-cosmic {
    position: relative;
    padding: 1rem 3.5rem;
    font-size: 1.5rem;
    font-family: 'Quicksand', sans-serif;
    font-weight: 700;
    color: #fff;
    background: #0f172a;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    overflow: hidden;
    z-index: 1;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 0.5rem;
    text-decoration: none;
    display: inline-block;
}
.ws-btn-primary-cosmic::before {
    content: '';
    position: absolute;
    top: -3px; left: -3px; right: -3px; bottom: -3px;
    z-index: -1;
    background: linear-gradient(45deg, #4299e1, #9f7aea, #ed64a6, #4299e1);
    background-size: 400%;
    border-radius: 52px;
    animation: animateBorder 4s linear infinite;
    opacity: 0.8;
    transition: opacity 0.3s;
}
.ws-btn-primary-cosmic::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px; right: 3px; bottom: 3px;
    background: #0f172a;
    border-radius: 48px;
    z-index: -1;
    transition: background 0.3s;
}
.ws-btn-primary-cosmic:hover::after {
    background: #1e3a8a;
}
.ws-btn-primary-cosmic span {
    position: relative;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    display: inline-block;
    transition: transform 0.2s;
}
.ws-btn-primary-cosmic:hover span {
    transform: scale(1.05);
}
.ws-btn-primary-cosmic:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}
.ws-btn-primary-cosmic:hover::before {
    opacity: 1;
}
.ws-btn-primary-cosmic:active {
    transform: translateY(1px);
}
@keyframes animateBorder {
    0% { background-position: 0 0; }
    50% { background-position: 300% 0; }
    100% { background-position: 0 0; }
}

.ws-more-games-link {
    color: #a0aec0;
    font-size: 1.1rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    display: inline-block;
}
.ws-more-games-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    transform: translateY(-1px);
}

.ws-credit {
    position: absolute;
    bottom: 1rem;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 1px;
    z-index: 10;
}
.ws-credit a {
    color: #9f7aea;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.3s, text-shadow 0.3s;
}
.ws-credit a:hover {
    color: #fff;
    text-shadow: 0 0 8px rgba(159, 122, 234, 0.8);
}

/* Language switcher */
.ws-language-switcher {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0.25rem 0.5rem;
    backdrop-filter: blur(5px);
}
.ws-lang-btn {
    color: #a0aec0;
    font-weight: 700;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: color 0.3s, text-shadow 0.3s;
}
.ws-lang-btn:hover {
    color: #e2e8f0;
}
.ws-lang-btn.active {
    color: #4299e1;
    text-shadow: 0 0 8px rgba(66, 153, 225, 0.6);
}
.ws-lang-separator {
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.8rem;
    user-select: none;
}

/* Game Screen hiding style */
#gameScreen {
    position: relative;
    width: 100vw;
    height: 100vh;
}
/*
    end welcome screen
*/

#closeSetting {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.2);
    color: #ef4444;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    line-height: 1;
}
#closeSetting:hover {
    background: #ef4444;
    color: #fff;
    transform: rotate(90deg);
}

/* ====== Race Type Card Grid ====== */
.setup .option {
    display: inline-block;
    margin: 3px;
}
.setup .option label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(255,255,255,0.7);
    font-size: 14px;
    font-weight: 600;
}
.setup .option label:hover {
    border-color: #8b5cf6;
    background: rgba(139,92,246,0.06);
    transform: translateY(-1px);
}
.setup .option input[type="radio"]:checked + span {
    color: #6d28d9;
    font-weight: 800;
}
.setup .option:has(input[type="radio"]:checked) label {
    border-color: #8b5cf6;
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    box-shadow: 0 2px 10px rgba(139,92,246,0.15);
}

/* ====== Question Area Modern Styles ====== */
#questionArea {
    background: rgba(255,255,255,0.97) !important;
    backdrop-filter: blur(24px) !important;
    -webkit-backdrop-filter: blur(24px) !important;
    border-radius: 24px !important;
    box-shadow: 0 25px 60px rgba(0,0,0,0.2) !important;
    border: 1px solid rgba(0,0,0,0.06) !important;
    color: #1e293b !important;
    animation: questionScaleIn 0.3s cubic-bezier(.4,0,.2,1) !important;
    padding: 30px !important;
    font-family: 'Quicksand', sans-serif !important;
}
#questionArea .optBtn {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9) !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 14px !important;
    padding: 14px 24px !important;
    font-size: 18px !important;
    cursor: pointer;
    transition: all 0.25s ease !important;
    color: #1e293b !important;
    font-weight: 600 !important;
    font-family: 'Quicksand', sans-serif !important;
    text-align: left !important;
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
}
#questionArea .optBtn:hover {
    border-color: #8b5cf6 !important;
    background: linear-gradient(135deg, #f5f3ff, #ede9fe) !important;
    transform: translateX(6px) !important;
    box-shadow: 0 4px 15px rgba(139,92,246,0.15) !important;
}
#questionArea .optBtn:disabled {
    cursor: default;
    opacity: 0.85;
}



/* ====== Winner List Item Styles ====== */
.winner-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.8);
    border-radius: 10px;
    border-left: 3px solid #10b981;
    transition: all 0.2s ease;
    animation: winnerSlideIn 0.3s ease-out backwards;
}
.winner-item:hover {
    background: rgba(255,255,255,1);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.winner-item.top-1 { border-left-color: #f59e0b; background: linear-gradient(90deg, rgba(251,191,36,0.1), transparent); }
.winner-item.top-2 { border-left-color: #94a3b8; background: linear-gradient(90deg, rgba(148,163,184,0.1), transparent); }
.winner-item.top-3 { border-left-color: #c2884c; background: linear-gradient(90deg, rgba(194,136,76,0.08), transparent); }
.winner-item .remove-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(239,68,68,0.1);
    color: #ef4444;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}
.winner-item .remove-btn:hover {
    background: #ef4444;
    color: #fff;
}

/* ====== Menu Button ====== */
.menu-btn {
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05)) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
    color: #fff !important;
    padding: 6px 14px !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Quicksand', sans-serif;
}
.menu-btn:hover {
    background: rgba(255,255,255,0.2) !important;
    transform: scale(1.05);
}

/* ====== Custom Scrollbar ====== */
.menu-container .wrapper::-webkit-scrollbar,
#winnerList::-webkit-scrollbar {
    width: 6px;
}
.menu-container .wrapper::-webkit-scrollbar-track,
#winnerList::-webkit-scrollbar-track {
    background: transparent;
}
.menu-container .wrapper::-webkit-scrollbar-thumb,
#winnerList::-webkit-scrollbar-thumb {
    background: rgba(139,92,246,0.25);
    border-radius: 10px;
}
.menu-container .wrapper::-webkit-scrollbar-thumb:hover,
#winnerList::-webkit-scrollbar-thumb:hover {
    background: rgba(139,92,246,0.45);
}

/* ====== New Animations ====== */
@keyframes resultPulse {
    0%, 100% { box-shadow: 0 8px 30px rgba(245,158,11,0.35); }
    50% { box-shadow: 0 8px 40px rgba(245,158,11,0.55), 0 0 20px rgba(245,158,11,0.2); }
}
@keyframes questionScaleIn {
    from { opacity: 0; transform: translate(-50%,-50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}
@keyframes winnerSlideIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ====== Labels in menu ====== */
.menu-container label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    line-height: 1.4;
}
.menu-container label span {
    font-weight: 600;
}

/* ====== Student count ====== */
#soluonghs {
    margin-top: 10px;
    padding: 8px 12px;
    background: rgba(16,185,129,0.08);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #059669;
}

/* ====== Mode-specific Backgrounds (CSS-only, no images) ====== */
body.bird {
    background: linear-gradient(180deg, #e0f2fe 0%, #bae6fd 20%, #7dd3fc 50%, #38bdf8 80%, #0ea5e9 100%) !important;
}
body.bird::before {
    background:
        radial-gradient(circle at 20% 30%, rgba(255,255,255,0.3) 0%, transparent 40%),
        radial-gradient(circle at 70% 60%, rgba(255,255,255,0.2) 0%, transparent 35%),
        radial-gradient(circle at 50% 80%, rgba(255,255,255,0.15) 0%, transparent 30%) !important;
    animation: none !important;
}
body.bird #bank {
    background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 30%, #bae6fd 60%, #94a3b8 80%, #64748b 100%) !important;
}
body.bird .bo {
    background: linear-gradient(180deg, #94a3b8 0%, #64748b 50%, rgba(56,189,248,0.4) 100%) !important;
    border-top-color: #cbd5e1 !important;
}
body.bird #pond-container {
    border-bottom-color: #7dd3fc !important;
}

body.animal {
    background: linear-gradient(180deg, #86efac 0%, #4ade80 20%, #22c55e 50%, #16a34a 80%, #15803d 100%) !important;
}
body.animal::before {
    background:
        repeating-linear-gradient(85deg,
            transparent 0px, transparent 12px,
            rgba(255,255,255,0.04) 12px, rgba(255,255,255,0.04) 14px
        ),
        repeating-linear-gradient(95deg,
            transparent 0px, transparent 18px,
            rgba(0,100,0,0.04) 18px, rgba(0,100,0,0.04) 20px
        ) !important;
    animation: grassSway 4s ease-in-out infinite !important;
}
@keyframes grassSway {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(-2%); }
}
body.animal #bank {
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 40%, #16a34a 70%, #15803d 100%) !important;
}
body.animal .bo {
    background: linear-gradient(180deg, #15803d 0%, #166534 50%, rgba(34,197,94,0.5) 100%) !important;
    border-top-color: #16a34a !important;
}
body.animal #pond-container {
    border-bottom-color: #16a34a !important;
}

/* ====== SVG Environment Overlay ====== */
.svg-env-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

/* ============================================================
   QUESTION MODAL — Redesigned for students
   ============================================================ */
#questionOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(6px);
    z-index: 899;
}
#questionArea {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90vw; height: 90vh;
    max-width: none;
    z-index: 900;
    border-radius: 28px;
    background: linear-gradient(145deg, #ffffff 0%, #f0f4ff 50%, #fdf2f8 100%);
    color: #1e293b;
    box-shadow: 0 30px 80px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.5) inset;
    font-family: 'Quicksand', sans-serif;
    overflow: hidden;
    display: none;
    flex-direction: column;
    animation: modalPopIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalPopIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.85); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Timer */
#qTimerDisplay {
    position: absolute;
    top: 14px; right: 16px;
    font-size: 22px;
    font-weight: 900;
    font-family: 'Quicksand', sans-serif;
    color: #fff;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    padding: 6px 18px;
    border-radius: 50px;
    min-width: 72px;
    text-align: center;
    z-index: 5;
    box-shadow: 0 4px 14px rgba(239,68,68,0.35);
    animation: timerPulse 1s ease-in-out infinite;
    letter-spacing: 1px;
}
#qTimerDisplay:empty { display: none; }
@keyframes timerPulse {
    0%, 100% { box-shadow: 0 4px 14px rgba(239,68,68,0.35); transform: scale(1); }
    50%       { box-shadow: 0 6px 20px rgba(239,68,68,0.55); transform: scale(1.04); }
}

/* Badge */
.q-badge {
    padding: 6px 18px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-align: center;
    text-transform: uppercase;
    position: absolute;
    top: 20px;
    left: 30px;
}
.badge-mc { background: linear-gradient(135deg, #6366f1, #8b5cf6); color: #fff; }
.badge-sa { background: linear-gradient(135deg, #06b6d4, #22d3ee); color: #fff; }
.badge-es { background: linear-gradient(135deg, #f59e0b, #fbbf24); color: #fff; }
.badge-fb { background: linear-gradient(135deg, #10b981, #34d399); color: #fff; }
.badge-tf { background: linear-gradient(135deg, #14b8a6, #2dd4bf); color: #fff; }
.badge-ma { background: linear-gradient(135deg, #f43f5e, #fb7185); color: #fff; }

/* Header row: type badge + progress badge */
.q-header-row {
    display: flex;
    gap: 10px;
    position: absolute;
    top: 20px;
    left: 30px;
    right: 30px;
}
/* Override q-badge positioning when inside header row */
.q-header-row .q-badge {
    position: static;
}
.q-progress-badge {
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(99, 102, 241, 0.12);
    color: #6366f1;
    border: 1.5px solid rgba(99, 102, 241, 0.3);
}

/* Question title */
.q-title {
    font-size: clamp(36px, 3vw, 48px);
    font-weight: 700;
    line-height: 1.5;
    padding: 10px 0;
    margin-top: 30px;
    color: #1e293b;
    text-align: center;
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-content: center;
    align-items: center;
    margin-left: auto;
    margin-right: auto;
    max-width: 900px;
}
.q-title img { vertical-align: middle; }

mjx-container {
    margin-left: 10px;
    margin-right: 10px;
}

/* Question image */
.q-img {
    text-align: center;
    padding: 0 32px 12px;
    position: relative;
}
.q-img img {
    max-width: 100%;
    max-height: 30vh;
    border-radius: 16px;
    position: absolute;
    top: 0;
    left: 0;
}

/* === 2-column layout khi câu hỏi có ảnh === */
.q-content-with-img {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
    padding: 30px 8px 0;
    flex-grow: 1;
}
.q-content-with-img .q-title {
    flex: 1 1 50%;
    min-width: 0;
    margin: 0;
    text-align: left;
    justify-content: flex-start;
    height: 100%;
}
.q-content-with-img .q-img {
    flex: 0 0 50%;
    max-width: 50%;
    padding: 0;
    height: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    align-content: center;
    justify-content: center;
    position: relative;
}
.q-content-with-img .q-img img {
    height: auto;
    width: auto;
    object-fit: contain;
    max-height: 100%;
    max-width: 100%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Body — scrollable */
.q-body {
    overflow-y: auto;
    padding: 30px 10px;
    text-align: center;
}

/* ---- Multiple Choice ---- */
.q-opts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    text-align: left;
    margin: 0 auto;
}
.optBtn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Quicksand', sans-serif;
    color: #334155;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
}
.optBtn:hover {
    border-color: #818cf8;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.15);
}
.opt-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 15px;
    font-weight: 800;
    flex-shrink: 0;
    margin-right: 10px;
}
.opt-text { flex: 1; }
/* Đáp án đúng (reveal) */
#questionArea .optBtn.opt-correct {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0) !important;
    border-color: #10b981 !important;
    border-width: 2px !important;
    color: #065f46 !important;
    animation: pulseCorrect 0.5s ease;
}
#questionArea .optBtn.opt-correct .opt-letter {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: #fff !important;
}
/* Đáp án đã chọn sai */
#questionArea .optBtn.opt-wrong {
    background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
    border-color: #ef4444 !important;
    border-width: 2px !important;
    color: #7f1d1d !important;
    animation: shakeWrong 0.4s ease;
}
#questionArea .optBtn.opt-wrong .opt-letter {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #fff !important;
}
@keyframes pulseCorrect {
    0%,100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}
@keyframes shakeWrong {
    0%,100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* ============================================================
   QUESTION MODAL — ACTION BUTTONS (Unified Pill Style)
   ============================================================ */

/* --- BASE: tất cả action button dùng chung --- */
.q-btn-show,
.q-btn-correct,
.q-btn-wrong,
.q-btn-confirm,
.q-btn-next,
#questionArea .btn_boqua,
#questionArea .markBtn,
#questionArea #showAnsBtn,
#questionArea #skipQBtn,
#questionArea #closeQBtn,
#qNextBtn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 13px 32px !important;
    border-radius: 50px !important;
    border: none !important;
    color: #fff !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    font-family: 'Quicksand', sans-serif !important;
    cursor: pointer !important;
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,0.18), 0 2px 0 rgba(0,0,0,0.07) !important;
    text-decoration: none !important;
    line-height: 1 !important;
}
.q-btn-show:hover,
.q-btn-correct:hover,
.q-btn-wrong:hover,
.q-btn-confirm:hover,
.q-btn-next:hover,
#questionArea .btn_boqua:hover,
#questionArea .markBtn:hover,
#questionArea #showAnsBtn:hover,
#questionArea #skipQBtn:hover,
#questionArea #closeQBtn:hover,
#qNextBtn:hover {
    transform: translateY(-2px) scale(1.04) !important;
    filter: brightness(1.08);
}
.q-btn-show:active,
.q-btn-correct:active,
.q-btn-wrong:active,
.q-btn-confirm:active,
.q-btn-next:active,
#questionArea .btn_boqua:active,
#questionArea .markBtn:active,
#questionArea #showAnsBtn:active,
#questionArea #skipQBtn:active,
#questionArea #closeQBtn:active,
#qNextBtn:active {
    transform: translateY(0) scale(0.97) !important;
    filter: brightness(0.95);
}
.q-btn-confirm:disabled {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* --- BACKGROUND theo từng loại --- */
/* Hiện đáp án */
.q-btn-show,
#questionArea #showAnsBtn           { background: linear-gradient(135deg, #6366f1, #8b5cf6) !important; }
/* Đúng */
.q-btn-correct,
#questionArea .markBtn[data-correct="true"]  { background: linear-gradient(135deg, #10b981, #34d399) !important; }
/* Sai */
.q-btn-wrong,
#questionArea .markBtn[data-correct="false"] { background: linear-gradient(135deg, #ef4444, #f87171) !important; }
/* Xác nhận */
.q-btn-confirm                       { background: linear-gradient(135deg, #6366f1, #8b5cf6) !important; }
/* Tiếp theo */
.q-btn-next,
#qNextBtn                            { background: linear-gradient(135deg, #10b981, #06b6d4) !important; }
/* Bỏ qua */
#questionArea .btn_boqua,
#questionArea #skipQBtn              { background: linear-gradient(135deg, #f59e0b, #fb923c) !important; }
/* Đóng */
#questionArea #closeQBtn             { background: linear-gradient(135deg, #06b6d4, #8b5cf6) !important; }

/* Animation cho nút Tiếp theo */
#qNextBtn { animation: nextBtnSlideIn 0.35s ease both; }
@keyframes nextBtnSlideIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
.q-ans-container {
    display: none;
    margin-top: 16px;
}
.q-ans-box {
    background: linear-gradient(135deg, #f0fdf4, #ecfdf5);
    padding: 20px 24px;
    border-radius: 16px;
    border: 1px solid #10b981;
    font-size: clamp(24px, 3vw, 36px);
    font-weight: 700;
    color: #065f46;
    text-align: center;
    line-height: 1.6;
}
.q-mark-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}


/* ---- True/False ---- */
.tf-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    text-align: left;
    margin: 0 auto;
}
.tf-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: #fff;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    transition: all 0.3s ease;
}
.tf-text {
    flex: 1;
    font-size: clamp(18px, 3vw, 24px);
    font-weight: 600;
    color: #334155;
    text-align: left;
    line-height: 1.5;
}
.tf-btns {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.tf-btn {
    width: 44px; height: 44px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: 'Quicksand', sans-serif;
}
.tf-btn:hover { transform: scale(1.1); }
.tf-true { color: #10b981; }
.tf-false { color: #ef4444; }
.tf-btn.selected {
    color: #fff;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.tf-true.selected {
    background: linear-gradient(135deg, #10b981, #34d399);
    border-color: #10b981;
}
.tf-false.selected {
    background: linear-gradient(135deg, #ef4444, #f87171);
    border-color: #ef4444;
}
.tf-row.tf-correct {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-color: #10b981;
}
.tf-row.tf-wrong {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    border-color: #ef4444;
    animation: shakeWrong 0.4s ease;
}

/* ---- Matching (SVG line UI) ---- */
.match-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 72px;   /* row-gap col-gap — the col gap is the "channel" for lines */
    position: relative;
    margin: 0 auto;
}
.match-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 5;
    overflow: visible;
}
.match-item {
    padding: 12px 16px;
    border-radius: 14px;
    border: 2px solid #e2e8f0;
    background: #fff;
    font-size: clamp(18px, 3vw, 24px);
    font-weight: 600;
    color: #334155;
    transition: all 0.2s ease;
    position: relative;
    line-height: 1.4;
    display: flex;
    align-items: center;
    min-height: 52px;
    cursor: pointer;
    user-select: none;
}
.match-l {
    padding-right: 28px; /* space for right dot */
}
.match-r {
    padding-left: 28px;  /* space for left dot */
}
.match-item.selected {
    border-color: #6366f1;
    background: linear-gradient(135deg, #eef2ff, #f5f3ff);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}
.match-item.paired {
    border-color: #3b82f6;
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
}
/* Dots */
.match-dot {
    width: 14px; height: 14px;
    border-radius: 50%;
    background: #6366f1;
    border: 2.5px solid #fff;
    box-shadow: 0 0 0 2px #6366f1;
    position: absolute;
    z-index: 10;
    transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
    pointer-events: none; /* clicks pass through to the item */
}
.match-dot:hover {
    transform: translateY(-50%) scale(1.25);
    background: #4f46e5;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.4);
}
.match-dot-r {
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
}
.match-dot-l {
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
}
.match-dot.dot-selected {
    background: #f59e0b !important;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.4) !important;
    transform: translateY(-50%) scale(1.3);
}
.match-item.paired .match-dot {
    background: #3b82f6;
    box-shadow: 0 0 0 2px #3b82f6;
}
.match-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    margin-right: 10px;
    flex-shrink: 0;
}
.match-num-r {
    margin-right: 0;
    margin-left: 10px;
    background: linear-gradient(135deg, #0ea5e9, #06b6d4);
}
.match-text {
    flex: 1;
}
.match-item.match-correct {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0) !important;
    border-color: #10b981 !important;
}
.match-item.match-wrong {
    background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
    border-color: #ef4444 !important;
    animation: shakeWrong 0.4s ease;
}

/* ---- Bottom bar (sticky) ---- */
.q-bottom-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    position: sticky;
    bottom: 0;
    z-index: 2;
}
.q-action-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
    padding-bottom: 10px;
    border-bottom: 1px dashed #e2e8f0;
}
.q-nav-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    width: 100%;
}
/* Utility: ẩn button kể cả khi có display:inline-flex !important */
.q-btn-hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 640px) {
    #questionArea {
        width: 96vw;
        height: 96vh;
        border-radius: 18px;
    }
    .match-container { flex-direction: column; gap: 16px; }
    .tf-row { flex-direction: column; align-items: flex-start; }
    .tf-btns { align-self: flex-end; }
}

/* ============================================================
   CONGRATULATIONS MODAL — Candy Sweet Light Theme
   ============================================================ */
#questionArea.congrats-mode {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    padding: 0 !important;
}

.congrats-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 480px;
    max-width: 90vw;
    background: #ffffff;
    border-radius: 28px;
    padding: 44px 40px 36px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 0 0 4px #f9a8d4,
        0 0 0 8px #fde68a,
        0 0 0 12px #86efac,
        0 30px 80px rgba(0,0,0,0.18);
    animation: congratsPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes congratsPop {
    0% { transform: scale(0.7) translateY(40px); opacity: 0; }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* Top rainbow stripe */
.congrats-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 6px;
    background: linear-gradient(90deg, #f472b6, #fb923c, #facc15, #4ade80, #60a5fa, #a78bfa, #f472b6);
    background-size: 200% 100%;
    animation: rainbowSlide 3s linear infinite;
}

@keyframes rainbowSlide {
    0% { background-position: 0% 0%; }
    100% { background-position: 200% 0%; }
}

.congrats-close-x {
    position: absolute;
    top: 14px;
    right: 16px;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
    width: 32px;
    height: 32px;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Quicksand', sans-serif;
}
.congrats-close-x:hover {
    background: #fee2e2;
    color: #ef4444;
    transform: rotate(90deg) scale(1.1);
}

/* Corner decorations */
.congrats-deco {
    position: absolute;
    font-size: 26px;
    opacity: 0.65;
    animation: decoFloat 3s ease-in-out infinite;
}
.congrats-deco-tl { top: 14px; left: 18px; animation-delay: 0s; }
.congrats-deco-tr { top: 14px; right: 18px; animation-delay: 0.7s; }
.congrats-deco-bl { bottom: 14px; left: 18px; animation-delay: 1.4s; }
.congrats-deco-br { bottom: 14px; right: 18px; animation-delay: 2.1s; }

@keyframes decoFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-6px) rotate(8deg); }
}

.congrats-trophy {
    font-size: 68px;
    margin-bottom: 4px;
    filter: drop-shadow(0 6px 16px rgba(251,191,36,0.45));
    animation: trophyBounce 1.8s ease-in-out infinite;
}

@keyframes trophyBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    45% { transform: translateY(-10px) scale(1.06); }
    60% { transform: translateY(-4px) scale(1.03); }
}

.congrats-stars {
    display: flex;
    gap: 8px;
    font-size: 20px;
    margin-bottom: 10px;
    animation: starPulse 2s ease-in-out infinite;
}
.congrats-stars span:nth-child(2) { animation-delay: 0.3s; font-size: 26px; }
@keyframes starPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.congrats-sub {
    color: #7c3aed;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0 0 12px 0;
    text-transform: uppercase;
    background: linear-gradient(135deg, #a855f7, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.congrats-name-wrap {
    background: linear-gradient(135deg, #fef3c7, #fde68a, #fecaca);
    border-radius: 16px;
    padding: 12px 28px;
    margin-bottom: 24px;
    border: 2px solid #fbbf24;
    box-shadow: 0 4px 16px rgba(251,191,36,0.25);
}

.congrats-name {
    font-size: 36px;
    font-weight: 900;
    margin: 0;
    color: #92400e;
    text-shadow: 0 2px 6px rgba(180,83,9,0.15);
    line-height: 1.2;
    text-align: center;
    word-break: break-word;
}

.congrats-actions {
    pointer-events: auto;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.congrats-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: 50px;
    border: none;
    background: linear-gradient(135deg, #f472b6 0%, #fb923c 100%);
    color: #ffffff;
    font-size: 17px;
    font-weight: 800;
    font-family: 'Quicksand', sans-serif;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 20px rgba(244,114,182,0.4), 0 2px 0 rgba(0,0,0,0.08);
    letter-spacing: 0.3px;
}
.congrats-btn:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 10px 28px rgba(244,114,182,0.5), 0 2px 0 rgba(0,0,0,0.08);
}
.congrats-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 3px 10px rgba(244,114,182,0.35);
}
.congrats-btn-close {
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 100%);
    box-shadow: 0 6px 20px rgba(96,165,250,0.35), 0 2px 0 rgba(0,0,0,0.08);
}
.congrats-btn-close:hover {
    box-shadow: 0 10px 28px rgba(96,165,250,0.45), 0 2px 0 rgba(0,0,0,0.08);
}

/* ============================================================
   TIMEOUT HIGHLIGHT — Hiển thị đáp án đúng khi hết giờ
   ============================================================ */

/* Trắc nghiệm: opt-correct đã có animation, dùng thêm glow */
#questionArea .optBtn.opt-correct {
    animation: pulseCorrect 0.5s ease, glowCorrect 1.2s ease-in-out 0.5s infinite alternate;
}
@keyframes glowCorrect {
    from { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.3); }
    to   { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

/* Đúng/Sai: button đáp án đúng khi hết giờ */
.tf-btn.tf-timeout-correct {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-color: #86efac;
    animation: pulseCorrect 0.5s ease, glowCorrect 1.2s ease-in-out 0.5s infinite alternate;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.35);
}

/* Ghép đôi: item đáp án đúng khi hết giờ */
.match-item.match-timeout-correct {
    background: linear-gradient(135deg, #d1fae5, #6ee7b7) !important;
    border-color: #10b981 !important;
    border-width: 3px !important;
    animation: glowCorrect 1.2s ease-in-out infinite alternate;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3) !important;
}

/* Đúng/Sai: button đáp án SAI khi hết giờ */
.tf-btn.tf-timeout-wrong {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    color: #fff !important;
    border-color: #b91c1c !important;
    opacity: 0.75;
}

/* Ghép đôi: item SAI khi hết giờ */
.match-item.match-timeout-wrong {
    background: linear-gradient(135deg, #fee2e2, #fecaca) !important;
    border-color: #ef4444 !important;
    border-width: 2px !important;
    opacity: 0.75;
}