/* ================= BASE STYLES ================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --success-gradient: linear-gradient(135deg, #4CAF50, #2E7D32);
    --danger-gradient: linear-gradient(135deg, #f44336, #c62828);
    --warning-gradient: linear-gradient(90deg, #ff9800, #ffc107);
    --x-color: #000000;
    --facebook-color: #4267B2;
    --whatsapp-color: #25D366;
    --viber-color: #7360F2;
    --instagram-color: #E1306C;
}

html, body {
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    font-family: 'Poppins', 'Arial', sans-serif;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body {
    background: var(--primary-gradient);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    touch-action: manipulation;
}

/* ================= CONTAINER ================= */
.container {
    width: 100%;
    max-width: 800px;
    max-height: 95vh;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    transition: all 0.3s ease;
}

/* ================= SCREENS ================= */
.screen {
    display: none;
    flex-direction: column;
    padding: 20px;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
    z-index: 2;
    position: relative;
}

/* ================= AD SCREEN ================= */
#ad-screen {
    background: linear-gradient(135deg, #2c3e50, #4a6491);
    color: white;
}

.ad-container {
    text-align: center;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.ad-container h2 {
    margin-bottom: 20px;
    color: white;
    font-size: clamp(1.5rem, 4vw, 1.8rem);
}

.ad-content {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 30px;
    margin: 20px 0;
    width: 90%;
    max-width: 500px;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.ad-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    color: white;
}

.ad-placeholder i {
    color: #ffd700;
    margin-bottom: 10px;
}

.ad-placeholder h3 {
    font-size: 1.3rem;
    margin-bottom: 5px;
}

.ad-placeholder p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.ad-timer {
    margin: 20px 0;
    font-size: 1rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 20px;
    border-radius: 20px;
    display: inline-block;
}

#ad-countdown {
    font-weight: 700;
    color: #ffd700;
    font-size: 1.2rem;
}

.btn-continue {
    background: linear-gradient(135deg, #4CAF50, #2E7D32);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    min-height: 50px;
    margin-top: 20px;
    width: 90%;
    max-width: 300px;
}

.btn-continue:hover, .btn-continue:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(76, 175, 80, 0.3);
}

/* ================= MAIN MENU ================= */
.logo {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 10px;
    flex-shrink: 0;
}

.logo .logo-image {
    max-width: 80%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.subtitle {
    color: #666;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 400;
}

.menu-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    justify-content: center;
}

.btn-menu {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: clamp(15px, 4vw, 18px) clamp(20px, 5vw, 25px);
    font-size: clamp(1rem, 3vw, 1.1rem);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-weight: 600;
    min-height: 60px;
    width: 100%;
}

.btn-menu:hover, .btn-menu:active {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

/* ================= CATEGORY SELECTION ================= */
#category-select h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: clamp(1.3rem, 4vw, 1.6rem);
    flex-shrink: 0;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    margin: 20px 0;
    flex: 1;
    overflow-y: auto;
    padding: 5px;
}

.category-card {
    background: var(--primary-gradient);
    border-radius: 15px;
    padding: 15px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 100px;
    justify-content: center;
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.category-card:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.category-card:hover:before, .category-card:active:before {
    opacity: 1;
}

.category-card i {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #ffd700;
    z-index: 1;
}

.category-card h3 {
    font-size: 1.1rem;
    margin-bottom: 5px;
    z-index: 1;
}

.category-card p {
    font-size: 0.85rem;
    opacity: 0.9;
    z-index: 1;
}

.btn-back {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #dee2e6;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    align-self: flex-start;
    transition: all 0.3s ease;
    min-height: 50px;
    flex-shrink: 0;
}

.btn-back:hover, .btn-back:active {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* ================= GAME SCREEN ================= */
#game-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: nowrap;
    gap: 10px;
    flex-shrink: 0;
    width: 100%;
    min-height: 60px;
}

.game-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
}

.score {
    background: var(--success-gradient);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 80px;
    white-space: nowrap;
    flex-shrink: 0;
}

.category-badge {
    background: var(--primary-gradient);
    color: white;
    padding: 6px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
    flex-shrink: 1;
}

.timer-container {
    text-align: center;
    min-width: 100px;
    flex-shrink: 0;
}

.timer {
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
    font-family: 'Courier New', monospace;
    line-height: 1;
}

.timer-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.timer-progress {
    height: 100%;
    width: 100%;
    transition: width 1s linear;
    background: linear-gradient(90deg, #4CAF50, #FFC107);
}

.question-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
    border-left: 5px solid #667eea;
    flex-shrink: 0;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.question-number {
    color: #667eea;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.question-text {
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    line-height: 1.5;
    color: #333;
    font-weight: 500;
    word-wrap: break-word;
}

.answers-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    flex: 1;
    overflow-y: auto;
    padding: 5px;
    max-height: 50vh;
    min-height: 200px;
}

.answer-btn {
    background: white;
    border: 2px solid #dee2e6;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-height: 50px;
    display: flex;
    align-items: center;
    word-wrap: break-word;
    width: 100%;
    flex-shrink: 0;
}

.answer-btn:hover, .answer-btn:active {
    border-color: #667eea;
    transform: translateX(3px);
}

.answer-btn.correct {
    background: var(--success-gradient);
    color: white;
    border-color: #4CAF50;
    animation: pulseCorrect 1.5s ease;
}

.answer-btn.wrong {
    background: var(--danger-gradient);
    color: white;
    border-color: #f44336;
    animation: pulseWrong 1.5s ease;
}

@keyframes pulseCorrect {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes pulseWrong {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(0.98); }
}

.game-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 15px;
    border-top: 2px solid #f0f0f0;
    flex-shrink: 0;
}

.lives {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.1rem;
    color: #e91e63;
}

.lives i {
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.btn-quit {
    background: #f44336;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.3s ease;
    min-height: 45px;
}

.btn-quit:hover, .btn-quit:active {
    background: #d32f2f;
}

/* ================= GAME OVER ================= */
.result-container {
    text-align: center;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.result-container h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: clamp(1.5rem, 4vw, 1.8rem);
}

.final-score {
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: 700;
    color: #667eea;
    margin: 20px 0;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

.result-message {
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: #666;
    margin-bottom: 30px;
    line-height: 1.5;
    padding: 0 10px;
}

.share-section {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin: 20px 0;
}

.share-section h3 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.1rem;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 15px 0;
}

.btn-share-small {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.3s ease;
    min-height: 40px;
    min-width: 80px;
    justify-content: center;
    flex: 1;
}

.btn-share-small:hover, .btn-share-small:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.save-score {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

#player-name {
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    width: 100%;
}

.btn-save {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 45px;
    width: 100%;
}

.game-over-actions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 25px;
}

.btn-restart {
    background: var(--success-gradient);
    color: white;
    border: none;
    padding: 14px 25px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: transform 0.3s ease;
    min-height: 50px;
    width: 100%;
}

.btn-restart:hover, .btn-restart:active {
    transform: translateY(-2px);
}

/* ================= HIGH SCORES ================= */
.high-scores-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
    margin: 20px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.score-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 15px;
    justify-content: center;
}

.filter-btn {
    background: white;
    border: 2px solid #dee2e6;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.filter-btn.active,
.filter-btn:hover,
.filter-btn:active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.scores-table {
    flex: 1;
    overflow-y: auto;
    min-height: 300px;
}

.score-row {
    display: grid;
    grid-template-columns: 50px 1fr 80px;
    gap: 15px;
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    align-items: center;
    font-size: 0.9rem;
}

.score-row:first-child {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.score-row:nth-child(2) {
    background: linear-gradient(135deg, #c0c0c0, #e0e0e0);
}

.score-row:nth-child(3) {
    background: linear-gradient(135deg, #cd7f32, #e09c5c);
}

.score-header {
    font-weight: 600;
    color: #667eea;
    background: #f1f3f9;
    position: sticky;
    top: 0;
}

.score-rank {
    text-align: center;
    font-weight: 600;
}

.score-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-value {
    text-align: center;
    font-weight: 600;
    color: #4CAF50;
}

.score-date {
    display: none;
}

/* ================= INSTRUCTIONS ================= */
.instructions-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin: 20px 0;
    flex: 1;
}

.instruction-card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.instruction-card:hover {
    transform: translateY(-3px);
}

.instruction-icon {
    width: 60px;
    height: 60px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    color: white;
    font-size: 1.5rem;
}

.instruction-card h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    color: #333;
}

.instruction-card p {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* ================= UTILITY CLASSES ================= */
.no-scores, .error-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.no-scores i, .error-message i {
    font-size: 3rem;
    margin-bottom: 20px;
    color: #ffc107;
}

.error-message i {
    color: #f44336;
}

.btn-retry {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    margin-top: 20px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #667eea;
    font-size: 1.1rem;
}

.loading:after {
    content: '...';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* ================= RESPONSIVE DESIGN ================= */
@media (min-width: 768px) {
    .container {
        padding: 25px;
    }
    
    .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 20px;
    }
    
    .category-card {
        min-height: 180px;
        padding: 25px;
    }
    
    .score-row {
        grid-template-columns: 50px 1fr 100px 120px;
    }
    
    .score-date {
        display: block;
        text-align: right;
        color: #666;
        font-size: 0.85rem;
    }
    
    .instructions-content {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .game-over-actions {
        flex-direction: row;
    }
    
    .save-score {
        flex-direction: row;
    }
    
    #player-name {
        flex: 1;
    }
    
    .btn-save {
        width: auto;
    }
    
    .share-buttons {
        flex-direction: row;
    }
    
    .btn-share-small {
        flex: 0 0 calc(25% - 10px);
    }
}

@media (max-width: 768px) {
    .game-header {
        padding: 5px 0;
    }
    
    .score {
        min-width: 70px;
        padding: 5px 10px;
        font-size: 0.85rem;
    }
    
    .category-badge {
        max-width: 100px;
        font-size: 0.75rem;
        padding: 5px 8px;
    }
    
    .timer-container {
        min-width: 90px;
    }
    
    .timer {
        font-size: 1.8rem;
    }
    
    .timer-bar {
        height: 6px;
    }
    
    .answers-container {
        max-height: 45vh;
    }
}

@media (max-width: 480px) {
    .container {
        border-radius: 15px;
        max-height: 98vh;
    }
    
    .screen {
        padding: 15px;
    }
    
    .game-header {
        min-height: 50px;
    }
    
    .score {
        min-width: 60px;
        padding: 4px 8px;
        font-size: 0.8rem