/* 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;
    user-select: none;
}

/* Responsive container - adapts to iframe vs full browser */
.game-container {
    width: 100%;
    height: 450px; /* Default iframe height */
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

/* Detect if running in full browser tab */
@media (min-height: 500px) {
    .game-container {
        height: 90vh;
    }
}

/* Game header with statistics */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: help;
    transition: transform 0.2s ease;
}

.stat-item:hover {
    transform: scale(1.05);
}

.stat-label {
    font-size: 14px;
    opacity: 0.9;
}

.stat-value {
    font-size: 18px;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 8px;
    border-radius: 6px;
}

.timer {
    background: #ff6b6b !important;
    animation: pulse 1s infinite;
}

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

.hearts-container {
    display: flex;
    gap: 4px;
}

.heart {
    font-size: 18px;
    transition: all 0.3s ease;
}

.heart.lost {
    opacity: 0.3;
    filter: grayscale(100%);
    transform: scale(0.8);
}

/* Main game area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow: hidden;
}

/* Diagram display area */
.diagram-container {
    flex: 1;
    min-height: 180px;
    background: #f8f9fa;
    border: 3px solid #e9ecef;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: help;
    transition: all 0.3s ease;
}

.diagram-container:hover {
    border-color: #4facfe;
    box-shadow: 0 4px 16px rgba(79, 172, 254, 0.2);
}

.diagram-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diagram-content {
    text-align: center;
    font-size: 48px;
    color: #6c757d;
    transition: all 0.3s ease;
}

.loading-text {
    font-size: 18px;
    color: #6c757d;
    font-weight: 500;
}

/* Answer buttons grid */
.answers-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    flex-shrink: 0;
}

.answer-btn {
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-height: 44px; /* Touch-friendly minimum */
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #5a67d8 0%, #667eea 100%);
}

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

.answer-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.answer-btn.correct {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    animation: correctAnswer 0.6s ease;
}

.answer-btn.incorrect {
    background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
    animation: incorrectAnswer 0.6s ease;
}

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

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

/* Game controls */
.game-controls {
    padding: 16px 20px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-shrink: 0;
}

.control-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-height: 44px;
}

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

.restart-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

/* Feedback overlay */
.feedback-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.feedback-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: feedbackPop 0.3s ease;
}

@keyframes feedbackPop {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.feedback-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.feedback-text {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
}

/* Game over screen */
.game-over-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.game-over-content {
    background: white;
    padding: 32px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    animation: gameOverSlide 0.5s ease;
}

@keyframes gameOverSlide {
    0% { transform: translateY(-50px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.game-over-content h2 {
    color: #2d3748;
    margin-bottom: 16px;
    font-size: 24px;
}

.game-over-content p {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 16px;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1002;
    max-width: 200px;
    text-align: center;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .game-header {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .stat-value {
        font-size: 14px;
        padding: 2px 6px;
    }
    
    .game-main {
        padding: 12px;
        gap: 12px;
    }
    
    .answers-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .answer-btn {
        font-size: 12px;
        padding: 10px 12px;
        min-height: 40px;
    }
    
    .diagram-content {
        font-size: 36px;
    }
    
    .loading-text {
        font-size: 14px;
    }
}