:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --dark: #1e293b;
    --light: #f8fafc;
    --gray: #cbd5e1;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 50%, #ec4899 100%);
    color: var(--dark);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.app-container {
    width: 100%;
    max-width: 900px;
}

.screen {
    display: none;
    animation: fadeIn 0.35s ease-in-out forwards;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    background: #ffffff;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.hero-header {
    text-align: center;
    color: white;
    margin-bottom: 20px;
}

.trophy-icon {
    font-size: 3.2rem;
    color: #fde047;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

.hero-header h1 {
    font-size: 2.1rem;
    font-weight: 800;
}

.hero-header p {
    font-size: 1.05rem;
    opacity: 0.9;
}

/* Mode Selector Tabs */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 15px 0 25px 0;
}

@media (max-width: 600px) {
    .mode-selector {
        grid-template-columns: 1fr;
    }
}

.mode-btn {
    padding: 14px 10px;
    border: 2px solid var(--gray);
    background: #f8fafc;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #64748b;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    text-align: center;
}

.mode-btn i {
    font-size: 1.4rem;
}

.mode-btn.active {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

/* Room Box & QR */
.room-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0f9ff;
    border: 2px solid #bae6fd;
    padding: 18px;
    border-radius: 16px;
    margin-bottom: 20px;
    gap: 15px;
}

@media (max-width: 550px) {
    .room-box {
        flex-direction: column;
        text-align: center;
    }
}

.room-label {
    font-size: 0.85rem;
    font-weight: 800;
    color: #0284c7;
    letter-spacing: 1px;
}

.room-code {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: 4px;
    margin: 4px 0;
}

.room-hint {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.4;
}

.qr-container {
    background: white;
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

.setup-section h4 {
    color: var(--primary);
    font-size: 1.15rem;
    margin-bottom: 4px;
}

.subtitle {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 15px;
}

.team-inputs-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.team-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 12px;
    border: 1px solid var(--gray);
}

.device-tag {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
}

.device-tag.hp {
    background: #dcfce7;
    color: #15803d;
}

.device-tag.manual {
    background: #e2e8f0;
    color: #475569;
}

.team-name-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid var(--gray);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s;
}

.team-input-row .team-name-input {
    border: none;
    background: transparent;
    padding: 6px;
    font-weight: 600;
}

.uppercase-input {
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.status-msg {
    margin-top: 12px;
    text-align: center;
    font-weight: 600;
    color: var(--primary);
}

/* Buttons */
.btn {
    width: 100%;
    padding: 14px 20px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 8px 16px rgba(79, 70, 229, 0.3);
    margin-top: 10px;
}

.primary-btn:hover {
    transform: translateY(-2px);
}

.secondary-btn {
    background: #f1f5f9;
    color: var(--primary);
    border: 2px dashed var(--primary);
    margin-bottom: 10px;
}

.btn-icon {
    background: #fee2e2;
    color: var(--danger);
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
}

/* Mobile Controller Screen (HP) */
.mobile-card {
    text-align: center;
    padding: 30px 20px;
}

.mobile-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.mobile-team-title {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.mobile-status-text {
    font-size: 1.05rem;
    color: #475569;
    margin-bottom: 30px;
    min-height: 28px;
}

.big-buzzer-btn {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 8px solid #fef3c7;
    background: linear-gradient(145deg, #f59e0b, #d97706);
    color: white;
    font-size: 1.3rem;
    font-weight: 900;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 0 auto;
    cursor: pointer;
    box-shadow: 0 15px 30px rgba(217, 119, 6, 0.45);
    transition: transform 0.1s, background 0.3s;
    user-select: none;
}

.big-buzzer-btn i {
    font-size: 3.5rem;
}

.big-buzzer-btn:active:not(:disabled) {
    transform: scale(0.93);
}

.big-buzzer-btn.locked {
    background: #94a3b8;
    border-color: #e2e8f0;
    box-shadow: none;
    cursor: not-allowed;
}

.big-buzzer-btn.winner {
    background: linear-gradient(145deg, #10b981, #059669);
    border-color: #d1fae5;
    box-shadow: 0 15px 30px rgba(16, 185, 129, 0.5);
}

/* Scoreboard & Game Main */
.top-scoreboard {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    margin-bottom: 20px;
    padding-bottom: 5px;
}

.score-card {
    background: white;
    padding: 12px 18px;
    border-radius: 14px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.1);
    min-width: 130px;
    text-align: center;
    border-bottom: 4px solid var(--primary);
    flex: 1;
}

.score-card.active-turn {
    background: #eef2ff;
    border-color: var(--accent);
    transform: scale(1.03);
}

.score-card .t-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--dark);
    margin-bottom: 4px;
}

.score-card .t-score {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
}

.game-main-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.quiz-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

.category-badge { background: #e0e7ff; color: var(--primary); }
.progress-badge { background: #f1f5f9; color: #475569; }

.timer-box {
    width: 100%;
    height: 12px;
    background: #f1f5f9;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.timer-fill {
    height: 100%;
    width: 100%;
    background: var(--success);
    transition: width 1s linear, background-color 0.3s;
}

.timer-label {
    text-align: right;
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 20px;
}

.question-container {
    background: #f8fafc;
    border-left: 6px solid var(--primary);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.question-container h2 {
    font-size: 1.25rem;
    line-height: 1.6;
}

.buzzer-stage {
    background: #fffbeb;
    border: 2px dashed #fcd34d;
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    margin-bottom: 20px;
}

.buzzer-instruction {
    color: #92400e;
    margin-bottom: 15px;
    font-size: 1.05rem;
}

.buzzer-buttons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.buzzer-btn {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 14px;
    font-size: 1rem;
    font-weight: 800;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

.active-player-banner {
    background: #dbeafe;
    color: #1e40af;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 20px;
    text-align: center;
    border: 2px solid #bfdbfe;
}

.answer-inputs-area {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    text-align: left;
    padding: 15px 20px;
    background: #f8fafc;
    border: 2px solid var(--gray);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover:not(:disabled) {
    background: #eef2ff;
    border-color: var(--primary);
    color: var(--primary);
}

.option-btn.correct { background: #d1fae5 !important; border-color: var(--success) !important; color: #065f46 !important; }
.option-btn.wrong { background: #fee2e2 !important; border-color: var(--danger) !important; color: #991b1b !important; }
.option-btn:disabled { cursor: not-allowed; }

.short-answer-wrapper { display: flex; gap: 10px; }
.matching-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media(max-width: 600px) { .matching-grid { grid-template-columns: 1fr; } }

.feedback-alert {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    font-weight: 700;
    text-align: center;
    font-size: 1.1rem;
}
.feedback-alert.success { background: #d1fae5; color: #065f46; }
.feedback-alert.error { background: #fee2e2; color: #991b1b; }

.hidden { display: none !important; }

.result-card { text-align: center; }
.winner-icon { font-size: 4rem; color: var(--accent); margin-bottom: 15px; }
.podium-container { display: flex; flex-direction: column; gap: 12px; margin: 25px 0; }
.podium-item {
    background: #f8fafc;
    padding: 16px 20px;
    border-radius: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 2px solid var(--gray);
    font-size: 1.1rem;
    font-weight: 700;
}
.podium-item.rank-1 {
    background: linear-gradient(135deg, #fef08a, #fde047);
    border-color: #ca8a04;
    color: #713f12;
    font-size: 1.25rem;
}