:root {
    --primary-color: #4CAF50;
    --secondary-color: #2196F3;
    --background-color: #f0f2f5;
    --text-color: #333;
    --success-color: #4CAF50;
    --error-color: #f44336;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --card-background: #fff;
}

body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--background-color);
    min-height: 100vh;
}

.game-container {
    max-width: 600px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background-color: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 15px;
}

.left-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.level-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.level-badge {
    font-weight: bold;
    color: #333;
    white-space: nowrap;
}

.progress-bar {
    width: 100px;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: #4CAF50;
    transition: width 0.3s ease;
}

.xp-counter {
    color: #666;
    font-size: 0.9em;
    white-space: nowrap;
}

.center-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.hearts {
    display: flex;
    gap: 2px;
}

.heart {
    font-size: 1.2em;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.heart.active {
    opacity: 1;
}

.streak-container {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #ff6b6b;
    font-weight: bold;
}

.right-section {
    display: flex;
    gap: 10px;
}

.icon-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background-color: #e0e0e0;
    color: #333;
}

.icon-btn i {
    font-size: 1.1em;
}

/* Game Area */
.game-area {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    margin: 20px 0;
}

.problem {
    font-size: 2.5em;
    margin: 24px 0;
    color: var(--text-color);
    font-weight: bold;
}

.answer-section {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.answer-input {
    width: 120px;
    font-size: 1.8em;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    text-align: center;
    transition: all 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.submit-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1.2em;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-btn:hover:not(:disabled) {
    background-color: #45a049;
    transform: translateY(-1px);
}

.submit-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Share Button and Dialog */
.icon-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: none;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.icon-button:hover {
    transform: translateY(-2px);
}

.share-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.share-dialog.hidden {
    display: none;
}

.share-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
}

.share-input-group {
    display: flex;
    gap: 8px;
    margin: 16px 0;
}

.share-input-group input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.copy-btn {
    background: var(--secondary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.close-dialog {
    width: 100%;
    padding: 8px;
    background: #f0f0f0;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 16px;
}

/* Level Up Message */
.level-up {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(76, 175, 80, 0.95);
    color: white;
    padding: 30px 40px;
    border-radius: 15px;
    text-align: center;
    animation: levelUp 3s ease-in-out;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    min-width: 300px;
}

.level-up h2 {
    font-size: 2.5em;
    margin: 0 0 15px 0;
}

.level-up .level-number {
    font-size: 1.8em;
    margin: 10px 0;
}

.level-up .level-desc {
    font-size: 1.2em;
    margin: 10px 0;
    opacity: 0.9;
}

/* Analytics Section */
.analytics-container {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.stat-card {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 0.5rem;
    text-align: center;
}

.stat-card i {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.stat-card h3 {
    color: #666;
    font-size: 0.75rem;
    margin: 0.25rem 0;
    font-weight: normal;
}

.stat-card p {
    color: #333;
    font-size: 0.875rem;
    font-weight: 500;
    margin: 0;
}

@media (max-width: 500px) {
    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
}

/* Animations */
@keyframes levelUp {
    0% { 
        transform: translate(-50%, -50%) scale(0.7);
        opacity: 0;
    }
    10% { 
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }
    20% { 
        transform: translate(-50%, -50%) scale(1);
    }
    80% { 
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    100% { 
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.7);
    }
}

@keyframes confettiFall {
    0% { transform: translateY(-100vh) rotate(0deg); }
    100% { transform: translateY(100vh) rotate(360deg); }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    top: -10px;
    border-radius: 50%;
    animation: confettiFall 3s linear forwards;
    z-index: 1000;
}

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

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

.correct {
    animation: correct 0.6s ease;
    color: var(--success-color);
}

.incorrect {
    animation: incorrect 0.4s ease;
    color: var(--error-color);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    body {
        padding: 12px;
    }

    .game-container {
        padding: 16px;
    }

    .problem {
        font-size: 2em;
    }

    .answer-section {
        flex-direction: column;
    }

    .answer-input {
        width: 100%;
        max-width: 200px;
    }

    .submit-btn {
        width: 100%;
    }

    .level-up {
        width: 90%;
        min-width: auto;
        padding: 20px;
    }

    .level-up h2 {
        font-size: 2em;
    }

    .icon-button {
        bottom: 10px;
        right: 10px;
    }
}

.footer {
    text-align: center;
    padding: 20px;
    margin-top: 20px;
    color: #666;
    font-size: 0.9em;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer a:hover {
    color: #45a049;
    text-decoration: underline;
}