/* ===== RESET AND BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ===== CONTAINER LAYOUT ===== */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

/* Detect if opened in new tab (full screen) */
@media (min-height: 600px) {
    .container {
        height: 90vh;
    }
}

/* ===== GAME AREA ===== */
.game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
    gap: 10px;
}

/* ===== STATUS BAR ===== */
.status-bar {
    display: flex;
    justify-content: space-around;
    gap: 8px;
    flex-wrap: wrap;
}

.status-item {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 70px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    cursor: help;
    transition: transform 0.2s, box-shadow 0.2s;
}

.status-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.status-label {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 500;
}

.status-value {
    font-size: 18px;
    font-weight: bold;
    margin-top: 2px;
}

/* ===== QUESTION CONTAINER ===== */
.question-container {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
    margin: 8px 0;
}

.question-text {
    font-size: 32px;
    font-weight: bold;
    color: white;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-indicator {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    margin-top: 12px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: white;
    border-radius: 3px;
    transition: width 0.3s ease;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

/* ===== ANSWER GRID ===== */
.answer-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin: 8px 0;
}

.answer-btn {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    padding: 18px;
    border-radius: 12px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    min-height: 60px;
    touch-action: manipulation;
}

.answer-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.answer-btn:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.answer-btn.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    animation: correctPulse 0.5s ease;
}

.answer-btn.incorrect {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    animation: incorrectShake 0.5s ease;
}

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

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

/* ===== FEEDBACK MESSAGE ===== */
.feedback-message {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.feedback-message.show {
    animation: fadeInOut 1.5s ease;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    20%, 80% { opacity: 1; }
}

/* ===== CONTROL BUTTONS ===== */
.control-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
    min-height: 44px;
    touch-action: manipulation;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-large {
    padding: 16px 32px;
    font-size: 18px;
    min-height: 54px;
}

/* ===== ANALYTICS PANEL ===== */
.analytics-panel {
    background: #f8f9fa;
    border-top: 2px solid #dee2e6;
    max-height: 40%;
    display: flex;
    flex-direction: column;
}

.analytics-header {
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    min-height: 44px;
}

.analytics-header:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
}

.toggle-icon {
    transition: transform 0.3s;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.analytics-content {
    overflow-y: auto;
    max-height: 0;
    transition: max-height 0.3s ease;
}

.analytics-content.expanded {
    max-height: 300px;
}

.analytics-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
    background: white;
    border-bottom: 1px solid #dee2e6;
}

.summary-item {
    display: flex;
    flex-direction: column;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

.summary-label {
    font-size: 11px;
    color: #6c757d;
    font-weight: 500;
}

.summary-value {
    font-size: 18px;
    font-weight: bold;
    color: #495057;
    margin-top: 2px;
}

.action-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #e9ecef;
    font-weight: bold;
    font-size: 13px;
}

.btn-clear {
    padding: 4px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
    min-height: 28px;
}

.btn-clear:hover {
    background: #c82333;
}

.action-log {
    padding: 8px 12px;
    max-height: 150px;
    overflow-y: auto;
}

.log-entry {
    display: flex;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: white;
    border-radius: 4px;
    font-size: 12px;
    border-left: 3px solid #667eea;
    align-items: center;
}

.log-time {
    color: #6c757d;
    font-weight: bold;
    min-width: 45px;
}

.log-icon {
    font-size: 14px;
}

.log-text {
    color: #495057;
    flex: 1;
}

/* ===== MODAL STYLES ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    margin-bottom: 12px;
    line-height: 1.6;
    color: #495057;
}

.modal-body ul {
    margin-left: 20px;
    margin-bottom: 12px;
}

.modal-body li {
    margin-bottom: 6px;
    color: #495057;
}

/* ===== CELEBRATION OVERLAY ===== */
.celebration-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
    align-items: center;
    justify-content: center;
}

.celebration-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.celebration-content {
    text-align: center;
    animation: celebrationBounce 0.6s ease;
}

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

.celebration-emoji {
    font-size: 80px;
    margin-bottom: 16px;
    animation: rotate 0.6s ease;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.celebration-text {
    font-size: 36px;
    font-weight: bold;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 480px) {
    .game-area {
        padding: 8px;
        gap: 8px;
    }
    
    .question-text {
        font-size: 28px;
    }
    
    .answer-btn {
        font-size: 20px;
        padding: 14px;
        min-height: 54px;
    }
    
    .status-value {
        font-size: 16px;
    }
    
    .status-label {
        font-size: 10px;
    }
    
    .btn {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* ===== ACCESSIBILITY ===== */
.btn:focus,
.answer-btn:focus {
    outline: 3px solid #ffc107;
    outline-offset: 2px;
}

/* ===== SCROLLBAR STYLING ===== */
.action-log::-webkit-scrollbar,
.analytics-content::-webkit-scrollbar {
    width: 6px;
}

.action-log::-webkit-scrollbar-track,
.analytics-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.action-log::-webkit-scrollbar-thumb,
.analytics-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.action-log::-webkit-scrollbar-thumb:hover,
.analytics-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}