/* ============================================
   KÉO CO KIẾN THỨC - GAME STYLE
   Tone: Cute + Professional (Clash-of-Clans inspired)
   Colors: Warm Gold/Orange/Red/Green/Blue
   ============================================ */

/* --- CSS Variables (Design Tokens) --- */
:root {
    /* Primary Warm Palette */
    --gold: #F5A623;
    --gold-dark: #D4891A;
    --gold-light: #FCEAC5;
    --orange: #FF7A2F;
    --orange-dark: #E06520;
    --brown: #5C3D2E;
    --brown-dark: #3B2518;
    --brown-light: #8B6F5E;
    --cream: #FFF8E7;
    --cream-dark: #F5ECD4;

    /* Team Colors */
    --blue: #3B82F6;
    --blue-dark: #1D4ED8;
    --blue-light: #93C5FD;
    --blue-bg: #EFF6FF;
    --blue-glow: rgba(59, 130, 246, 0.4);

    --red: #EF4444;
    --red-dark: #B91C1C;
    --red-light: #FCA5A5;
    --red-bg: #FEF2F2;
    --red-glow: rgba(239, 68, 68, 0.4);

    /* Feedback */
    --green: #22C55E;
    --green-dark: #16A34A;
    --ice-blue: #A5F3FC;
    --ice-dark: #67E8F9;

    /* UI */
    --shadow-color: rgba(0, 0, 0, 0.25);
    --text-dark: #2D1B0E;
    --text-light: #FFFFFF;
    --border-radius: 16px;
    --border-radius-sm: 10px;
    --border-radius-lg: 24px;

    /* Fonts */
    --font-display: 'Baloo 2', cursive;
    --font-body: 'Nunito', sans-serif;

    /* Sizing */
    --topbar-height: 70px;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: var(--cream);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
}

/* --- Screen System --- */
.screen {
    display: none;
    width: 100%;
    height: 100%;
}
.screen.active {
    display: flex;
}

/* ============================================
   SETUP SCREEN
   ============================================ */
#setup-screen {
    background: linear-gradient(145deg, #FFF8E7 0%, #FCEAC5 50%, #FFE4B5 100%);
    justify-content: center;
    align-items: center;
    padding: 20px 20px;
    position: relative;
    overflow: hidden;
}

/* Mascot decorations */
.mascot {
    position: absolute;
    bottom: 0;
    width: 140px;
    height: auto;
    z-index: 1;
    pointer-events: none;
    opacity: 0.85;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
}
.mascot-left {
    left: 20px;
}
.mascot-right {
    right: 20px;
    transform: scaleX(-1);
}

.setup-container {
    max-width: 1320px;
    width: 100%;
    margin: 0 auto;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 2;
    position: relative;
}

/* Header - horizontal layout */
.setup-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

/* Zalo CTA Button */
.zalo-cta {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 50px;
    background: linear-gradient(135deg, #FF6B35 0%, #FF3E6C 50%, #E8175D 100%);
    color: white;
    text-decoration: none;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    box-shadow:
        0 4px 0 #c22048,
        0 6px 20px rgba(255,62,108,0.35);
    transition: all 0.2s;
    position: relative;
    white-space: nowrap;
    flex-shrink: 0;
}
.zalo-cta:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow:
        0 6px 0 #c22048,
        0 10px 28px rgba(255,62,108,0.45);
}
.zalo-cta:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #c22048;
}
.zalo-cta-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}
.zalo-cta-text {
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.zalo-cta-badge {
    background: white;
    color: #0068FF;
    font-size: 0.68rem;
    font-weight: 900;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Shake animation - subtle attention grabber */
@keyframes shake {
    0%, 86% { transform: translateX(0); }
    88% { transform: translateX(-3px) rotate(-1deg); }
    90% { transform: translateX(3px) rotate(1deg); }
    92% { transform: translateX(-3px) rotate(-0.5deg); }
    94% { transform: translateX(3px) rotate(0.5deg); }
    96% { transform: translateX(-2px); }
    98% { transform: translateX(2px); }
    100% { transform: translateX(0); }
}
.shake-animation {
    animation: shake 3s ease-in-out infinite;
}
.shake-animation:hover {
    animation: none;
}
.setup-header-mascot {
    width: 80px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.12));
    animation: float 3s ease-in-out infinite;
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}
.setup-logo {
    width: 90px;
    height: auto;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.15));
}
.setup-header-text {
    flex: 1;
}
.game-title {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--brown-dark);
    text-shadow:
        2px 2px 0 var(--gold),
        3px 3px 0 var(--gold-dark);
    letter-spacing: 1px;
    line-height: 1.1;
}
.game-subtitle {
    font-size: 1rem;
    font-weight: 700;
    color: var(--brown-light);
    margin-top: 3px;
}

/* 2-Column Grid */
.setup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    min-height: 0;
}
.setup-col-left {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.setup-col-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Section */
.setup-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 16px 20px;
    box-shadow:
        0 3px 0 var(--cream-dark),
        0 4px 12px rgba(0,0,0,0.06);
    border: 2px solid var(--cream-dark);
}
.setup-section-grow {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brown-dark);
    margin-bottom: 12px;
}

.question-count-badge {
    display: inline-block;
    background: var(--gold);
    color: white;
    font-size: 0.72rem;
    padding: 1px 10px;
    border-radius: 20px;
    font-family: var(--font-body);
    font-weight: 800;
    vertical-align: middle;
    margin-left: 6px;
}

/* Mode Selector */
.mode-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 10px;
    border: 3px solid var(--cream-dark);
    border-radius: var(--border-radius);
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-body);
}
.mode-btn:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245,166,35,0.2);
}
.mode-btn.active {
    border-color: var(--orange);
    background: linear-gradient(135deg, #FFF5E6 0%, #FFECD2 100%);
    box-shadow:
        0 3px 0 var(--orange-dark),
        0 4px 12px rgba(255,122,47,0.2);
}
.mode-icon { font-size: 1.8rem; }
.mode-name { font-weight: 800; font-size: 1.05rem; color: var(--brown-dark); }
.mode-desc { font-size: 0.8rem; color: var(--brown-light); font-weight: 600; }

/* Team Names */
.team-names-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.team-name-input label {
    display: block;
    font-weight: 800;
    margin-bottom: 5px;
    font-size: 0.95rem;
}
.team-name-input input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--border-radius-sm);
    border: 2px solid var(--cream-dark);
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 700;
    transition: border-color 0.2s;
    outline: none;
}
.blue-team-input input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}
.red-team-input input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px var(--red-glow);
}

/* Timer Selector */
.timer-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.timer-btn {
    padding: 9px 16px;
    border: 2px solid var(--cream-dark);
    border-radius: var(--border-radius-sm);
    background: white;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--brown-dark);
}
.timer-btn:hover {
    border-color: var(--gold);
    transform: translateY(-1px);
}
.timer-btn.active {
    border-color: var(--orange);
    background: var(--orange);
    color: white;
    box-shadow: 0 3px 0 var(--orange-dark);
}

/* Image Picker */
.image-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.img-pick-btn {
    border: 3px solid var(--cream-dark);
    border-radius: var(--border-radius-sm);
    background: white;
    padding: 4px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
}
.img-pick-btn img {
    width: 100%;
    height: 55px;
    object-fit: contain;
    display: block;
}
.img-pick-btn:hover {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245,166,35,0.2);
}
.img-pick-btn.active {
    border-color: var(--orange);
    background: linear-gradient(135deg, #FFF5E6 0%, #FFECD2 100%);
    box-shadow: 0 3px 0 var(--orange-dark), 0 4px 12px rgba(255,122,47,0.2);
}

/* Question Actions */
.question-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.action-btn {
    padding: 8px 14px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s;
}
.add-btn {
    background: var(--green);
    color: white;
    box-shadow: 0 3px 0 var(--green-dark);
}
.add-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--green-dark);
}
.add-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--green-dark);
}
.import-btn {
    background: var(--blue);
    color: white;
    box-shadow: 0 3px 0 var(--blue-dark);
}
.import-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--blue-dark);
}
.import-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--blue-dark);
}
.export-btn {
    background: var(--gold);
    color: white;
    box-shadow: 0 3px 0 var(--gold-dark);
}
.export-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--gold-dark);
}
.export-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.bank-btn {
    background: linear-gradient(135deg, #FF7A2F 0%, #F5A623 100%);
    color: white;
    box-shadow: 0 3px 0 #D4891A;
}
.bank-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 #D4891A;
}
.bank-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #D4891A;
}

/* Bank Modal */
.bank-modal-content {
    max-width: 750px;
}
.bank-modal-header {
    background: linear-gradient(135deg, #FF7A2F 0%, #F5A623 100%) !important;
}
.bank-modal-header h2 {
    color: white !important;
    text-shadow: 1px 2px 0 rgba(0,0,0,0.15);
}
.bank-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}
.bank-filter-group {
    flex: 1;
}
.bank-filter-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: var(--brown-dark);
}
.bank-filter-group select {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--cream-dark);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    outline: none;
    cursor: pointer;
    background: white;
    color: var(--brown-dark);
    transition: border-color 0.2s;
    appearance: auto;
}
.bank-filter-group select:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(255,122,47,0.2);
}
.bank-select-all {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--cream);
    border-radius: 8px;
    margin-bottom: 10px;
    border: 1px solid var(--cream-dark);
}
.bank-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--brown-dark);
}
.bank-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--orange);
    cursor: pointer;
}
.bank-selected-count {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--orange);
}
.bank-question-list {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 4px;
}
.bank-question-list::-webkit-scrollbar {
    width: 6px;
}
.bank-question-list::-webkit-scrollbar-thumb {
    background: var(--orange);
    border-radius: 3px;
}
.bank-q-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 2px solid var(--cream-dark);
    cursor: pointer;
    transition: all 0.15s;
}
.bank-q-item:hover {
    border-color: var(--orange);
    background: #FFF9F0;
}
.bank-q-item.selected {
    border-color: var(--orange);
    background: linear-gradient(135deg, #FFF5E6 0%, #FFECD2 100%);
}
.bank-q-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--orange);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}
.bank-q-details {
    flex: 1;
    min-width: 0;
}
.bank-q-text {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--brown-dark);
    margin-bottom: 4px;
    line-height: 1.4;
}
.bank-q-answers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.bank-q-answer-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    background: var(--cream-dark);
    color: var(--brown-dark);
}
.bank-q-answer-tag.correct-tag {
    background: var(--green);
    color: white;
}

/* Question List */
.question-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
    min-height: 0;
}
.question-list::-webkit-scrollbar {
    width: 6px;
}
.question-list::-webkit-scrollbar-thumb {
    background: var(--gold);
    border-radius: 3px;
}

.empty-state {
    text-align: center;
    padding: 20px;
    color: var(--brown-light);
}
.empty-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 6px;
}

.question-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--cream);
    border-radius: var(--border-radius-sm);
    margin-bottom: 6px;
    border: 1px solid var(--cream-dark);
    transition: all 0.2s;
}
.question-item:hover {
    border-color: var(--gold);
}
.question-number {
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gold);
    color: white;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.82rem;
    flex-shrink: 0;
}
.question-preview {
    flex: 1;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.question-item-actions {
    display: flex;
    gap: 6px;
}
.qi-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.qi-edit {
    background: var(--blue-light);
    color: var(--blue-dark);
}
.qi-delete {
    background: var(--red-light);
    color: var(--red-dark);
}
.qi-btn:hover {
    transform: scale(1.1);
}

/* Start Button */
.start-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--border-radius);
    background: linear-gradient(135deg, var(--orange) 0%, var(--gold) 100%);
    color: white;
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow:
        0 4px 0 var(--orange-dark),
        0 6px 16px rgba(255,122,47,0.3);
    transition: all 0.2s;
    text-shadow: 1px 2px 0 rgba(0,0,0,0.2);
    letter-spacing: 1px;
    flex-shrink: 0;
}
.start-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow:
        0 6px 0 var(--orange-dark),
        0 8px 24px rgba(255,122,47,0.4);
}
.start-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 0 var(--orange-dark);
}
.start-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.4);
}
.start-icon {
    font-size: 1.5rem;
}

/* Hotkey Guide */
.hotkey-guide {
    text-align: center;
    padding: 12px;
    background: white;
    border-radius: var(--border-radius);
    border: 2px dashed var(--cream-dark);
}
.hotkey-guide h3 {
    font-family: var(--font-display);
    color: var(--brown-dark);
    margin-bottom: 8px;
    font-size: 0.95rem;
}
.hotkey-row {
    display: flex;
    justify-content: center;
    gap: 28px;
    flex-wrap: wrap;
}
.hotkey-team {
    font-weight: 700;
    font-size: 0.88rem;
}
kbd {
    display: inline-block;
    padding: 3px 7px;
    background: var(--cream-dark);
    border-radius: 5px;
    font-weight: 800;
    font-family: var(--font-body);
    font-size: 0.82rem;
    box-shadow: 0 2px 0 #ccc;
    margin: 0 2px;
    min-width: 24px;
    text-align: center;
}

/* ============================================
   QUESTION MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay.active {
    display: flex;
}
.modal-content {
    background: white;
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 650px;
    box-shadow:
        0 8px 0 var(--cream-dark),
        0 20px 60px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease;
}
@keyframes modalSlideIn {
    from { transform: translateY(40px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--cream) 100%);
    border-bottom: 2px solid var(--cream-dark);
}
.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    color: var(--brown-dark);
}
.modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--red-light);
    color: var(--red-dark);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 800;
    transition: all 0.15s;
}
.modal-close:hover {
    background: var(--red);
    color: white;
    transform: scale(1.1);
}
.modal-body {
    padding: 24px;
}
.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 0.95rem;
    color: var(--brown-dark);
}
.form-group textarea,
.form-group input[type="text"] {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--cream-dark);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    outline: none;
    transition: border-color 0.2s;
    resize: vertical;
}
.form-group textarea:focus,
.form-group input[type="text"]:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(245,166,35,0.2);
}
.answers-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.answer-group {
    background: var(--cream);
    padding: 12px;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--cream-dark);
}
.answer-label {
    display: inline-block;
    width: 26px;
    height: 26px;
    line-height: 26px;
    text-align: center;
    border-radius: 6px;
    font-weight: 800;
    font-size: 0.8rem;
    color: white;
    margin-right: 6px;
    vertical-align: middle;
}
.a-label { background: var(--blue); }
.b-label { background: var(--orange); }
.c-label { background: var(--green); }
.d-label { background: var(--red); }

.correct-radio {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--green-dark);
}
.correct-radio input {
    accent-color: var(--green);
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    background: var(--cream);
    border-top: 2px solid var(--cream-dark);
}
.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}
.cancel-btn {
    background: white;
    color: var(--brown-dark);
    border: 2px solid var(--cream-dark);
}
.cancel-btn:hover {
    background: var(--cream-dark);
}
.save-btn {
    background: var(--green);
    color: white;
    box-shadow: 0 3px 0 var(--green-dark);
}
.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 var(--green-dark);
}
.save-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--green-dark);
}

/* ============================================
   GAME SCREEN
   ============================================ */
#game-screen {
    flex-direction: column;
    background: linear-gradient(180deg, #2D1B0E 0%, #5C3D2E 10%, #8B6F5E 100%);
    position: relative;
    overflow: hidden;
}

/* Topbar */
.game-topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.1) 100%);
    z-index: 10;
    flex-shrink: 0;
}
.topbar-team {
    display: flex;
    align-items: center;
    gap: 12px;
}
.team-label {
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: 800;
    text-shadow: 1px 2px 0 rgba(0,0,0,0.3);
}
.blue-topbar .team-label { color: var(--blue-light); }
.red-topbar .team-label { color: var(--red-light); }

.team-score {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow:
        2px 2px 0 var(--brown-dark),
        0 0 20px rgba(245,166,35,0.5);
    min-width: 50px;
    text-align: center;
}

.topbar-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.question-progress {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold-light);
    background: rgba(0,0,0,0.3);
    padding: 4px 16px;
    border-radius: 20px;
}
.game-mode-badge {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--cream);
    opacity: 0.7;
}

/* Arena */
.arena {
    flex: 1;
    display: flex;
    align-items: stretch;
    padding: 6px;
    gap: 0;
    position: relative;
    min-height: 0;
}

/* Team Panels */
.team-panel {
    flex: 0 0 22%;
    max-width: 22%;
    display: flex;
    flex-direction: column;
    border-radius: var(--border-radius);
    padding: 10px;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.blue-panel {
    background: linear-gradient(135deg, rgba(59,130,246,0.15) 0%, rgba(59,130,246,0.08) 100%);
    border: 2px solid rgba(59,130,246,0.3);
    margin-right: 5px;
}
.red-panel {
    background: linear-gradient(135deg, rgba(239,68,68,0.08) 0%, rgba(239,68,68,0.15) 100%);
    border: 2px solid rgba(239,68,68,0.3);
    margin-left: 5px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}
.panel-team-name {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 800;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}
.blue-header .panel-team-name { color: var(--blue-light); }
.red-header .panel-team-name { color: var(--red-light); }

.panel-status {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(0,0,0,0.2);
    color: white;
}

/* Question Box */
.question-box {
    background: rgba(0,0,0,0.3);
    border-radius: 8px;
    padding: 8px 10px;
    margin-bottom: 6px;
    flex-shrink: 0;
    min-height: 44px;
    display: flex;
    align-items: center;
}
.question-text {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    color: white;
    line-height: 1.4;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}

/* Answer Buttons */
.answers-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 5px;
    flex: 1;
    align-content: center;
}
.answer-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 2px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    position: relative;
    overflow: hidden;
}
.answer-btn:hover:not(:disabled):not(.selected):not(.correct):not(.wrong) {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    transform: translateY(-2px);
}
.answer-btn:active:not(:disabled) {
    transform: translateY(1px);
}
.key-hint {
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    flex-shrink: 0;
}
.answer-text {
    flex: 1;
    word-break: break-word;
}

/* Answer States */
.answer-btn.selected {
    border-color: var(--gold);
    background: rgba(245,166,35,0.3);
}
.answer-btn.correct {
    border-color: var(--green);
    background: rgba(34,197,94,0.35) !important;
    animation: correctPulse 0.5s ease;
}
.answer-btn.wrong {
    border-color: var(--red);
    background: rgba(239,68,68,0.35) !important;
    animation: wrongShake 0.4s ease;
}
.answer-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes correctPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
@keyframes wrongShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* Freeze Overlay */
.freeze-overlay {
    position: absolute;
    inset: 0;
    background: rgba(103, 232, 249, 0.35);
    backdrop-filter: blur(3px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    border-radius: var(--border-radius);
    animation: freezeIn 0.3s ease;
}
.freeze-overlay.active {
    display: flex;
}
.freeze-icon {
    font-size: 3.5rem;
    animation: freezeShiver 0.3s ease infinite alternate;
}
.freeze-text {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    color: white;
    text-shadow: 2px 2px 0 rgba(0,100,150,0.5);
    margin-top: 4px;
}
@keyframes freezeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes freezeShiver {
    from { transform: rotate(-3deg); }
    to { transform: rotate(3deg); }
}

/* --- Rope Area (Center) --- */
.rope-area {
    flex: 1;
    flex-shrink: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.center-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 4px;
    background: repeating-linear-gradient(
        to bottom,
        var(--gold) 0px,
        var(--gold) 10px,
        transparent 10px,
        transparent 20px
    );
    transform: translateX(-50%);
    opacity: 0.6;
    z-index: 1;
}

/* Timer Ring */
.timer-display {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
    z-index: 5;
}
.timer-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.timer-bg {
    fill: none;
    stroke: rgba(255,255,255,0.15);
    stroke-width: 6;
}
.timer-progress {
    fill: none;
    stroke: var(--gold);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 283;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear, stroke 0.3s ease;
}
.timer-progress.warning {
    stroke: var(--orange);
}
.timer-progress.danger {
    stroke: var(--red);
    animation: timerPulse 0.5s ease infinite alternate;
}
@keyframes timerPulse {
    from { opacity: 1; }
    to { opacity: 0.5; }
}
.timer-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(245,166,35,0.5);
}
.timer-display.hidden {
    display: none;
}

/* Rope Container */
.rope-container {
    position: relative;
    z-index: 5;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.rope-image {
    width: 600px;
    max-width: 100%;
    height: auto;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.5));
    transition: transform 0.3s ease;
}

/* Pull Indicators */
.pull-indicator {
    position: absolute;
    font-size: 2rem;
    opacity: 0;
    z-index: 4;
    transition: all 0.3s ease;
}
.left-pull {
    left: 10px;
    top: 50%;
    transform: translateY(-50%) scaleX(-1);
}
.right-pull {
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
}
.pull-indicator.show {
    opacity: 1;
    animation: pullBounce 0.4s ease;
}
@keyframes pullBounce {
    0% { transform: translateY(-50%) scale(0.5); opacity: 0; }
    50% { transform: translateY(-50%) scale(1.3); }
    100% { transform: translateY(-50%) scale(1); opacity: 1; }
}

/* Combo Display */
.combo-display {
    position: fixed;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 2px 2px 0 var(--brown-dark), 0 0 20px rgba(245,166,35,0.6);
    z-index: 30;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#blue-combo {
    left: 30px;
    bottom: 20px;
}
#red-combo {
    right: 30px;
    bottom: 20px;
}
.combo-display.show {
    opacity: 1;
    animation: comboReveal 0.5s ease;
}
@keyframes comboReveal {
    0% { transform: scale(0.5) rotate(-10deg); opacity: 0; }
    60% { transform: scale(1.3) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* ============================================
   RESULT SCREEN
   ============================================ */
#result-screen {
    background: linear-gradient(145deg, #2D1B0E 0%, #5C3D2E 100%);
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

#confetti-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.result-container {
    text-align: center;
    z-index: 10;
    animation: resultZoomIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes resultZoomIn {
    0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.result-crown {
    font-size: 5rem;
    animation: crownBounce 1s ease infinite alternate;
    filter: drop-shadow(0 0 20px rgba(245,166,35,0.6));
}
@keyframes crownBounce {
    from { transform: translateY(0) rotate(-5deg); }
    to { transform: translateY(-10px) rotate(5deg); }
}

.result-mascot {
    width: 100px;
    height: auto;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.15));
    animation: float 3s ease-in-out infinite;
    margin: -10px 0;
}

.result-title {
    font-family: var(--font-display);
    font-size: 3rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow:
        3px 3px 0 var(--brown-dark),
        0 0 30px rgba(245,166,35,0.4);
    margin: 10px 0 30px;
}

.result-scores {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 30px;
    margin-bottom: 30px;
}
.result-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 30px;
    border-radius: var(--border-radius);
}
.blue-result {
    background: rgba(59,130,246,0.2);
    border: 2px solid rgba(59,130,246,0.4);
}
.red-result {
    background: rgba(239,68,68,0.2);
    border: 2px solid rgba(239,68,68,0.4);
}
.result-team-name {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 800;
    color: white;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.3);
}
.result-team-score {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 2px 2px 0 var(--brown-dark);
}
.result-vs {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--brown-light);
}

.result-stats {
    color: var(--cream);
    font-weight: 700;
    margin-bottom: 30px;
    font-size: 0.95rem;
    line-height: 1.8;
}

.result-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
}
.result-btn {
    padding: 14px 30px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
}
.replay-btn {
    background: var(--green);
    color: white;
    box-shadow: 0 4px 0 var(--green-dark);
}
.replay-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--green-dark);
}
.home-btn {
    background: var(--gold);
    color: white;
    box-shadow: 0 4px 0 var(--gold-dark);
}
.home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--gold-dark);
}

/* ============================================
   ANIMATIONS (Global)
   ============================================ */
.bounce-animation {
    animation: bounce 2s ease infinite;
}
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* Camera shake */
.shake {
    animation: cameraShake 0.3s ease;
}
@keyframes cameraShake {
    0%, 100% { transform: translate(0); }
    10% { transform: translate(-3px, -2px); }
    30% { transform: translate(3px, 2px); }
    50% { transform: translate(-2px, 1px); }
    70% { transform: translate(2px, -1px); }
    90% { transform: translate(-1px, 2px); }
}

/* Screen transition */
.screen-transition {
    animation: screenFade 0.4s ease;
}
@keyframes screenFade {
    from { opacity: 0; transform: scale(0.98); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .rope-image { width: 450px; }
    .team-panel { flex: 0 0 25%; max-width: 25%; }
}

@media (max-width: 900px) {
    .rope-image { width: 300px; }
    .team-panel { flex: 0 0 28%; max-width: 28%; }
    .team-label { font-size: 1rem; }
    .team-score { font-size: 1.6rem; }
    .panel-team-name { font-size: 0.9rem; }
}

/* ============================================
   SOUND TOGGLE BUTTON
   ============================================ */
.sound-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gold);
    color: white;
    border: 3px solid var(--gold-dark);
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 0 var(--gold-dark), 0 6px 16px rgba(0,0,0,0.2);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sound-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--gold-dark), 0 8px 20px rgba(0,0,0,0.25);
}
.sound-toggle.muted {
    background: var(--brown-light);
    border-color: var(--brown-dark);
    box-shadow: 0 4px 0 var(--brown-dark);
}

/* Fullscreen Toggle */
.fullscreen-toggle {
    position: fixed;
    bottom: 20px;
    right: 80px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--blue);
    color: white;
    border: 3px solid var(--blue-dark);
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 0 var(--blue-dark), 0 6px 16px rgba(0,0,0,0.2);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.fullscreen-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--blue-dark), 0 8px 20px rgba(0,0,0,0.25);
}
.fullscreen-toggle.active {
    background: var(--green);
    border-color: var(--green-dark);
    box-shadow: 0 4px 0 var(--green-dark);
}

/* ============================================
   BGM TOGGLE BUTTON
   ============================================ */
.bgm-toggle {
    position: fixed;
    bottom: 20px;
    right: 140px;
    height: 50px;
    padding: 0 16px;
    border-radius: 25px;
    background: linear-gradient(135deg, #FF6B35 0%, #E8175D 100%);
    color: white;
    border: 3px solid #c22048;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 800;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 0 #9e1a3a, 0 6px 16px rgba(232,23,93,0.3);
    transition: all 0.25s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.bgm-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #9e1a3a, 0 8px 20px rgba(232,23,93,0.4);
}
.bgm-toggle:active {
    transform: translateY(1px);
    box-shadow: 0 2px 0 #9e1a3a;
}
.bgm-toggle .bgm-icon {
    font-size: 1.3rem;
    display: inline-block;
    animation: bgmBounce 1s ease-in-out infinite;
}
.bgm-toggle .bgm-label {
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}

/* When BGM is off */
.bgm-toggle.bgm-off {
    background: linear-gradient(135deg, #6B7280 0%, #4B5563 100%);
    border-color: #374151;
    box-shadow: 0 4px 0 #374151, 0 6px 16px rgba(75,85,99,0.3);
}
.bgm-toggle.bgm-off:hover {
    box-shadow: 0 6px 0 #374151, 0 8px 20px rgba(75,85,99,0.4);
}
.bgm-toggle.bgm-off .bgm-icon {
    animation: none;
}

@keyframes bgmBounce {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-10deg); }
    50% { transform: scale(1) rotate(0deg); }
    75% { transform: scale(1.2) rotate(10deg); }
}
/* ============================================
   HALL OF FAME
   ============================================ */
.hall-of-fame-btn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    padding: 10px 18px;
    border-radius: var(--border-radius-sm);
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: white;
    border: 3px solid #CC8400;
    font-family: var(--font-body);
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 0 #CC8400, 0 6px 16px rgba(0,0,0,0.2);
    transition: all 0.2s;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
}
.hall-of-fame-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #CC8400, 0 8px 20px rgba(0,0,0,0.25);
}

/* HoF Modal */
.hof-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.hof-overlay.active {
    display: flex;
}
.hof-content {
    background: linear-gradient(145deg, #FFF8E7 0%, #FCEAC5 100%);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 0 var(--gold-dark), 0 20px 60px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}
.hof-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}
.hof-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    color: white;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
}
.hof-close {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255,255,255,0.3);
    color: white;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 800;
    transition: all 0.15s;
}
.hof-close:hover {
    background: rgba(255,255,255,0.5);
    transform: scale(1.1);
}
.hof-body {
    padding: 20px 24px;
}
.hof-empty {
    text-align: center;
    padding: 40px;
    color: var(--brown-light);
    font-weight: 700;
}
.hof-empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

/* Match History Item */
.hof-match {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--border-radius-sm);
    margin-bottom: 10px;
    border: 2px solid var(--cream-dark);
    transition: all 0.2s;
}
.hof-match:hover {
    border-color: var(--gold);
    transform: translateX(4px);
}
.hof-rank {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 800;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.hof-rank.gold { background: #FFD700; color: white; }
.hof-rank.silver { background: #C0C0C0; color: white; }
.hof-rank.bronze { background: #CD7F32; color: white; }
.hof-rank.normal { background: var(--cream-dark); color: var(--brown-dark); }

.hof-details {
    flex: 1;
    min-width: 0;
}
.hof-winner {
    font-weight: 800;
    font-size: 1rem;
    color: var(--brown-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hof-score-line {
    font-size: 0.82rem;
    color: var(--brown-light);
    font-weight: 700;
    margin-top: 2px;
}
.hof-date {
    font-size: 0.75rem;
    color: var(--brown-light);
    font-weight: 600;
    flex-shrink: 0;
    text-align: right;
}
.hof-mode-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    color: white;
    margin-left: 6px;
}
.hof-mode-tag.speed { background: var(--orange); }
.hof-mode-tag.endurance { background: var(--blue); }

.hof-footer {
    padding: 12px 24px 20px;
    text-align: center;
}
.hof-clear-btn {
    padding: 8px 20px;
    border: 2px solid var(--red-light);
    border-radius: 8px;
    background: white;
    color: var(--red-dark);
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}
.hof-clear-btn:hover {
    background: var(--red);
    color: white;
    border-color: var(--red);
}
