@import url('https://fonts.googleapis.com/css2?family=Pirata+One&family=Poppins:wght@400;600;700;900&display=swap');

/**
 * Treasure Coin Counter - Pirate/Treasure Theme
 *
 * A fun pirate-themed coin counting game for 2nd graders
 *
 * Color Palette:
 * - Gold: #FFD700 (treasure, highlights)
 * - Treasure Brown: #8B4513 (treasure chest, accents)
 * - Ocean Blue: #1E90FF (water, backgrounds)
 * - Pirate Black: #2C2C2C (text, dark elements)
 * - Silver: #C0C0C0 (nickels, dimes)
 * - Copper: #CD853F (pennies)
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #1E3A8A 0%, #0F766E 25%, #8B4513 50%, #CD853F 75%, #FFD700 100%);
    background-size: 400% 400%;
    animation: treasureShift 20s ease infinite;
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

@keyframes treasureShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.game-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    flex: 1 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-family: 'Pirata One', cursive;
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: 20px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.5);
    animation: treasureBounce 2s ease-in-out infinite;
    letter-spacing: 2px;
}

@keyframes treasureBounce {
    0%, 100% { transform: translateY(0) rotate(-2deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}

.score-display {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.score, .accuracy {
    background: rgba(139, 69, 19, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid #FFD700;
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

/* Screens */
.screen {
    display: block;
    animation: fadeIn 0.5s ease;
}

.screen.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Setup Panel */
.setup-panel, .results-panel {
    background: rgba(255, 215, 0, 0.15);
    backdrop-filter: blur(20px);
    border: 3px solid #FFD700;
    border-radius: 25px;
    padding: 40px 30px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.treasure-mascot {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: spin 3s ease-in-out infinite;
}

.treasure-mascot.excited {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: bounce 1s ease infinite;
}

@keyframes spin {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(10deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

.setup-panel h2 {
    font-family: 'Pirata One', cursive;
    font-size: 2rem;
    margin-bottom: 10px;
    font-weight: 400;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: 1.1rem;
    margin-bottom: 30px;
    opacity: 0.95;
}

/* Difficulty Selector */
.difficulty-selector {
    margin: 30px 0;
}

.difficulty-selector h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #FFD700;
}

.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.difficulty-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 215, 0, 0.5);
    border-radius: 20px;
    padding: 20px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.difficulty-btn:hover {
    transform: translateY(-5px);
    background: rgba(255, 215, 0, 0.25);
    border-color: #FFD700;
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.3);
}

.difficulty-btn.selected {
    background: rgba(255, 215, 0, 0.3);
    border-color: #FFD700;
    border-width: 4px;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

.diff-emoji {
    font-size: 2.5rem;
}

.diff-name {
    font-size: 1.2rem;
    font-weight: 700;
}

.diff-desc {
    font-size: 0.9rem;
    opacity: 0.9;
}

.question-count {
    font-size: 0.85rem;
    opacity: 0.8;
    font-style: italic;
}

/* Coin Values Toggle */
.coin-values-toggle {
    margin: 30px 0;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.3);
    border-radius: 20px;
}

.coin-values-toggle h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #FFD700;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: center;
    margin-bottom: 10px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(139, 69, 19, 0.6);
    border: 2px solid rgba(255, 215, 0, 0.5);
    transition: all 0.4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background-color: #C0C0C0;
    transition: all 0.4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(255, 215, 0, 0.6);
    border-color: #FFD700;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
    background-color: #FFD700;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.6);
}

.toggle-label {
    font-size: 1rem;
    font-weight: 600;
}

.toggle-hint {
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
    text-align: center;
    margin-top: 10px;
}

/* Buttons */
.main-btn, .secondary-btn, .next-btn {
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 10px;
}

.main-btn {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #2C2C2C;
    box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4);
}

.main-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.6);
}

.main-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid #FFD700;
}

.secondary-btn:hover {
    background: rgba(255, 215, 0, 0.3);
    transform: translateY(-2px);
}

.next-btn {
    background: linear-gradient(135deg, #1E90FF 0%, #0F766E 100%);
    color: white;
    margin-top: 20px;
}

.next-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(30, 144, 255, 0.4);
}

/* Progress Bar */
.progress-bar {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid #FFD700;
    border-radius: 50px;
    height: 40px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #FFD700, #FFA500, #FFD700);
    background-size: 200% 100%;
    animation: shimmer 2s linear infinite;
    height: 100%;
    border-radius: 50px;
    transition: width 0.5s ease;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 700;
    font-size: 1rem;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 1;
}

/* Question Panel */
.question-panel {
    background: rgba(255, 215, 0, 0.15);
    backdrop-filter: blur(15px);
    border: 3px solid #FFD700;
    border-radius: 25px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.treasure-chest-display h3 {
    font-family: 'Pirata One', cursive;
    font-size: 1.5rem;
    margin-bottom: 20px;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.coins-display {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
}

.coin-item {
    background: rgba(139, 69, 19, 0.4);
    border: 2px solid #FFD700;
    border-radius: 15px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 80px;
    transition: transform 0.3s ease;
}

.coin-item:hover {
    transform: scale(1.1);
}

.coin-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.coin-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.coin-value {
    font-size: 0.85rem;
    opacity: 0.9;
}

.question {
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    margin-top: 20px;
    color: #FFD700;
}

/* Answers Container */
.answers-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.answer-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 215, 0, 0.5);
    border-radius: 20px;
    padding: 20px;
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.answer-btn:hover:not(:disabled) {
    transform: translateY(-5px);
    background: rgba(255, 215, 0, 0.25);
    border-color: #FFD700;
    box-shadow: 0 8px 20px rgba(255, 215, 0, 0.3);
}

.answer-btn:disabled {
    cursor: not-allowed;
}

.answer-btn.correct {
    background: rgba(34, 197, 94, 0.4);
    border-color: #22c55e;
    animation: correctPulse 0.5s ease;
}

.answer-btn.incorrect {
    background: rgba(239, 68, 68, 0.4);
    border-color: #ef4444;
    animation: shake 0.5s ease;
}

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

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

/* Feedback */
.feedback {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 15px;
    border-radius: 15px;
    margin-top: 20px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback.correct {
    background: rgba(34, 197, 94, 0.3);
    border: 2px solid #22c55e;
    color: #22c55e;
}

.feedback.incorrect {
    background: rgba(239, 68, 68, 0.3);
    border: 2px solid #ef4444;
    color: #ef4444;
}

/* Results */
.results-panel h2 {
    font-family: 'Pirata One', cursive;
    font-size: 2rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat {
    background: rgba(139, 69, 19, 0.4);
    border: 2px solid #FFD700;
    border-radius: 20px;
    padding: 20px;
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 10px;
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 900;
    color: #FFD700;
}

/* Missed Problems */
.missed-section {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-radius: 20px;
    padding: 20px;
    margin: 20px 0;
}

.missed-section h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #FFD700;
}

.missed-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.missed-item {
    background: rgba(139, 69, 19, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 10px;
    padding: 12px;
    font-size: 0.95rem;
}

.results-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 2rem;
    }

    .treasure-mascot {
        font-size: 4rem;
    }

    .difficulty-buttons {
        grid-template-columns: 1fr;
    }

    .answers-container {
        grid-template-columns: 1fr;
    }

    .coins-display {
        gap: 10px;
    }

    .coin-item {
        min-width: 70px;
        padding: 10px;
    }

    .final-stats {
        grid-template-columns: 1fr;
    }

    .toggle-container {
        flex-direction: column;
        gap: 10px;
    }

    .toggle-label {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 10px;
    }

    .setup-panel, .results-panel, .question-panel {
        padding: 20px 15px;
    }

    .main-btn, .secondary-btn, .next-btn {
        padding: 12px 30px;
        font-size: 1rem;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .difficulty-btn:hover,
    .answer-btn:hover,
    .main-btn:hover {
        transform: none !important;
    }
}
