/* ------------------------------------------- */
/* 1. COLOR PALETTE & GLOBAL VARIABLES (PHONETICS THEME) */
/* ------------------------------------------- */
:root {
    --cp-blue-navy: #003366;           /* Deep Navy Blue (Primary) */
    --cp-gold-brass: #FFCC00;          /* Gold/Brass (Highlight) */
    --cp-teal-accent: #00A3A3;         /* Bright Teal/Sea Blue (Accent for Action) */
    --cp-light-bg: #f4f4f9;            /* Light Grey/Off-White (Background) */
    --cp-dark-text: #333333;           /* Dark Text */
    --cp-green-success: #3CB371;       /* Medium Sea Green (Correct Answer) */
    --cp-red-error: #DC143C;           /* Crimson Red (Incorrect Answer) */
    --cp-purple-accent: #6A5ACD;       /* Slate Blue (Secondary Accent for Phonetics) */
}

/* ------------------------------------------- */
/* 2. BASE CONTAINER & TYPOGRAPHY */
/* ------------------------------------------- */
#cadet-phonetics-game {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    max-width: 100%;
    min-height: 100vh;
    margin: 0 auto;
    padding: 10px;
    background-color: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 51, 102, 0.1);
    color: var(--cp-dark-text);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

#cp-main-game, #cp-setup-screen, #cp-game-over {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px 0;
}

#cp-quiz-area {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

h3, h4 {
    color: var(--cp-blue-navy);
    text-align: center;
    margin-bottom: 20px;
}

/* ------------------------------------------- */
/* 3. SETUP SCREEN STYLING */
/* ------------------------------------------- */
.cp-setup-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--cp-blue-navy) 0%, var(--cp-teal-accent) 100%);
    border-radius: 15px;
    color: white;
}

.cp-setup-header h2 {
    font-size: clamp(2em, 5vw, 3.5em);
    margin: 0 0 15px 0;
    color: white;
}

.cp-setup-subtitle {
    font-size: clamp(1em, 2.5vw, 1.5em);
    margin: 0;
    opacity: 0.95;
}

.cp-control-group {
    margin-bottom: 40px;
}

.cp-control-group h3 {
    font-size: clamp(1.3em, 3vw, 2em);
    color: var(--cp-blue-navy);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.cp-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: clamp(35px, 5vw, 50px);
    height: clamp(35px, 5vw, 50px);
    background-color: var(--cp-gold-brass);
    color: var(--cp-blue-navy);
    border-radius: 50%;
    font-weight: bold;
    font-size: clamp(1em, 2.5vw, 1.5em);
}

/* Setup Button Styling */
.cp-setup-btn {
    cursor: pointer;
    padding: clamp(15px, 2vw, 25px);
    margin: 10px;
    border: 3px solid var(--cp-blue-navy);
    border-radius: 12px;
    background-color: white;
    color: var(--cp-blue-navy);
    transition: all 0.3s ease;
    min-width: clamp(150px, 20vw, 200px);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.cp-btn-icon {
    font-size: clamp(1.8em, 3vw, 2.5em);
}

.cp-btn-label {
    font-size: clamp(1em, 2vw, 1.3em);
    font-weight: bold;
}

.cp-btn-desc {
    font-size: clamp(0.8em, 1.5vw, 1em);
    opacity: 0.7;
}

.cp-setup-btn:hover {
    background-color: var(--cp-blue-navy);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 51, 102, 0.3);
}

.cp-setup-btn:hover .cp-btn-desc {
    opacity: 0.9;
}

/* Active State for Setup Buttons */
.cp-setup-btn.active {
    background-color: var(--cp-teal-accent);
    border-color: var(--cp-teal-accent);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 153, 153, 0.4);
}

.cp-setup-btn.active .cp-btn-desc {
    opacity: 1;
}

/* Setup Button Group Layout */
.cp-setup-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    background-color: var(--cp-light-bg);
    border-radius: 12px;
}

/* Game Mode Group - Stacked vertically */
.cp-mode-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cp-mode-btn {
    width: 100%;
    min-width: 100%;
    flex: none;
    margin: 0;
}

/* Quiz Answer Buttons */
.cp-quiz-answer {
    cursor: pointer;
    font-size: 1.1em;
    padding: 12px 25px;
    margin: 8px;
    border: 2px solid var(--cp-blue-navy);
    border-radius: 8px;
    background-color: var(--cp-light-bg);
    color: var(--cp-blue-navy);
    transition: all 0.2s ease-in-out;
    min-width: 200px;
    flex-grow: 1;
}

.cp-quiz-answer:hover {
    background-color: var(--cp-blue-navy);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 51, 102, 0.3);
}

/* Disabled State */
.cp-setup-btn:disabled, .cp-quiz-answer:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Learn Section */
.cp-learn-section {
    text-align: center;
    margin: 40px 0;
}

.cp-learn-divider {
    position: relative;
    margin: 30px 0;
    text-align: center;
}

.cp-learn-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--cp-blue-navy), transparent);
    opacity: 0.2;
}

.cp-learn-divider span {
    position: relative;
    display: inline-block;
    padding: 0 20px;
    background: white;
    color: var(--cp-blue-navy);
    font-weight: bold;
    font-size: clamp(1em, 2vw, 1.2em);
    z-index: 1;
}

.cp-learn-btn {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 25px 40px;
    background: linear-gradient(135deg, var(--cp-purple-accent) 0%, var(--cp-blue-navy) 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(106, 90, 205, 0.3);
    min-width: 300px;
}

.cp-learn-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(106, 90, 205, 0.5);
}

.cp-learn-btn .cp-btn-icon {
    font-size: clamp(2em, 4vw, 3em);
    margin-bottom: 10px;
}

.cp-learn-btn .cp-btn-label {
    font-size: clamp(1.2em, 2.5vw, 1.8em);
    font-weight: bold;
    margin-bottom: 8px;
}

.cp-learn-btn .cp-btn-desc {
    font-size: clamp(0.9em, 1.5vw, 1.1em);
    opacity: 0.9;
    font-weight: normal;
}

/* Ready Area and Start Button */
.cp-ready-area {
    text-align: center;
    margin-top: 50px;
    padding: 30px;
    background: linear-gradient(135deg, rgba(0, 51, 102, 0.05) 0%, rgba(0, 153, 153, 0.05) 100%);
    border-radius: 15px;
    border: 2px solid var(--cp-gold-brass);
}

.cp-settings-display {
    font-size: clamp(1em, 2vw, 1.3em);
    color: var(--cp-blue-navy);
    margin-bottom: 20px;
    font-weight: 500;
}

#cp-display-settings {
    font-weight: bold;
    color: var(--cp-teal-accent);
}

.cp-start-btn {
    font-size: clamp(1.5em, 3vw, 2.2em) !important;
    padding: clamp(18px, 3vw, 25px) clamp(40px, 6vw, 60px) !important;
    background: linear-gradient(135deg, var(--cp-teal-accent) 0%, #00B8A0 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 15px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 8px 25px rgba(0, 153, 153, 0.3) !important;
    display: inline-flex;
    align-items: center;
    gap: 15px;
}

.cp-start-icon {
    font-size: 1.2em;
    animation: bounce 2s infinite;
}

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

.cp-start-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #00B8A0 0%, var(--cp-teal-accent) 100%) !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 35px rgba(0, 153, 153, 0.4) !important;
}

.cp-start-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background: #cccccc !important;
    box-shadow: none !important;
}

/* ------------------------------------------- */
/* 4. LETTER & PHONETIC DISPLAY */
/* ------------------------------------------- */
#cp-letter-display, #cp-phonetic-display {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
    padding: 40px;
    background: linear-gradient(135deg, var(--cp-purple-accent) 0%, var(--cp-teal-accent) 100%);
    border-radius: 15px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    min-height: 200px;
}

.cp-big-letter {
    font-size: clamp(5em, 15vw, 12em);
    font-weight: bold;
    color: white;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.1em;
}

.cp-big-phonetic {
    font-size: clamp(3em, 10vw, 8em);
    font-weight: bold;
    color: white;
    text-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
}

/* ------------------------------------------- */
/* 5. FLAG IMAGE DISPLAY */
/* ------------------------------------------- */
#cp-flag-image-container {
    position: relative;
    max-height: 70vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    border: 1px solid #555555;
    background-color: #e0e0e0;
    padding: 40px;
}

#cp-flag-image {
    max-width: 100%;
    max-height: 70vh;
    width: auto;
    height: auto;
    min-width: 400px;
    min-height: 400px;
    display: block;
    object-fit: contain;
}

/* ------------------------------------------- */
/* 6. QUIZ AREA LAYOUT */
/* ------------------------------------------- */
.cp-answer-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
    padding: 10px;
    background-color: var(--cp-light-bg);
    border-radius: 8px;
}

/* Countdown Timer */
#cp-countdown-timer {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: var(--cp-gold-brass);
    color: var(--cp-blue-navy);
    font-size: 2.5em;
    font-weight: bold;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: pulse 1s ease-in-out infinite;
    z-index: 100;
}

#cp-countdown-timer.final-seconds {
    background-color: var(--cp-red-error);
    color: white;
    animation: urgentPulse 0.5s ease-in-out infinite;
}

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

@keyframes urgentPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(220, 20, 60, 0.6);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 6px 20px rgba(220, 20, 60, 0.9);
    }
}

/* ------------------------------------------- */
/* 7. SCOREBOARD & ROUND INFO */
/* ------------------------------------------- */
#cp-scoreboard {
    display: flex;
    justify-content: space-around;
    border-bottom: 2px solid var(--cp-gold-brass);
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 1.1em;
}

.cp-team-score {
    padding: 5px 15px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.cp-team-score.active {
    background-color: var(--cp-gold-brass);
    color: var(--cp-blue-navy);
}

#cp-round-info {
    margin-bottom: 15px;
}

#cp-round-info h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5em;
    color: var(--cp-teal-accent);
}

/* ------------------------------------------- */
/* 8. FEEDBACK OVERLAY */
/* ------------------------------------------- */
#cp-feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

#cp-feedback-message {
    padding: clamp(20px, 4vw, 40px) clamp(40px, 8vw, 80px);
    font-size: clamp(1.5em, 4vw, 2.5em);
    font-weight: bold;
    color: white;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    max-width: 90vw;
    animation: popIn 0.3s ease-out;
}

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

/* ------------------------------------------- */
/* 9. END GAME SCREEN */
/* ------------------------------------------- */
#cp-game-over {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    padding: 30px 20px 60px;
    overflow-y: auto;
    box-sizing: border-box;
}

#cp-game-over h2 {
    font-size: clamp(2.5em, 6vw, 5em);
    color: var(--cp-blue-navy);
    margin: 20px 0 30px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

#cp-game-over h3 {
    font-size: clamp(2em, 5vw, 4em);
    color: var(--cp-teal-accent);
    margin-bottom: 30px;
}

#cp-final-scores {
    width: 100%;
    max-width: 1200px;
}

#cp-final-scores table {
    width: 100%;
    margin: 0 auto 20px;
    border-collapse: collapse;
    font-size: clamp(1.5em, 3.5vw, 2.8em);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-radius: 15px;
    overflow: hidden;
}

#cp-final-scores th, #cp-final-scores td {
    padding: clamp(15px, 2.5vw, 30px);
    border-bottom: 3px solid #ddd;
    text-align: center;
}

#cp-final-scores th {
    background-color: var(--cp-blue-navy);
    color: white;
    font-weight: bold;
    font-size: clamp(1em, 2vw, 1.5em);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    word-break: break-word;
}

#cp-final-scores tr:nth-child(even) {
    background-color: var(--cp-light-bg);
}

#cp-final-scores tr:first-child td {
    font-weight: bold;
    background-color: var(--cp-gold-brass);
    color: var(--cp-blue-navy);
    font-size: clamp(1.8em, 4.5vw, 3.5em);
    border-bottom: 5px solid var(--cp-blue-navy);
}

#cp-final-scores tr:first-child td:first-child {
    padding-left: 40px;
}

#cp-final-scores tr:first-child td:first-child::before {
    content: "🏆 ";
    font-size: 1.2em;
}

/* New Challenge button */
#cp-game-over .cp-new-challenge-btn,
#cp-game-over button.cp-new-challenge-btn,
button.cp-new-challenge-btn {
    margin-top: 30px !important;
    font-size: clamp(1.3em, 2.5vw, 2em) !important;
    padding: clamp(15px, 2.5vw, 25px) clamp(30px, 5vw, 50px) !important;
    background-color: #DC143C !important;
    background: #DC143C !important;
    color: #FFFFFF !important;
    border: none !important;
    border-radius: 12px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 8px 20px rgba(220, 20, 60, 0.3) !important;
    flex-shrink: 0;
    text-decoration: none !important;
}

#cp-game-over .cp-new-challenge-btn:hover,
#cp-game-over button.cp-new-challenge-btn:hover,
button.cp-new-challenge-btn:hover {
    background-color: #B01030 !important;
    background: #B01030 !important;
    color: #FFFFFF !important;
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(220, 20, 60, 0.4) !important;
}

/* ------------------------------------------- */
/* 10. MEDIA QUERIES (Responsiveness) */
/* ------------------------------------------- */
@media (max-width: 768px) {
    #cadet-phonetics-game {
        padding: 10px;
        margin: 0;
        min-height: 100vh;
    }
    .cp-setup-header {
        padding: 20px 15px;
        margin-bottom: 25px;
    }
    .cp-setup-header h2 {
        font-size: clamp(1.8em, 8vw, 2.5em);
    }
    .cp-control-group {
        margin-bottom: 30px;
    }
    .cp-control-group h3 {
        font-size: clamp(1.2em, 5vw, 1.6em);
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .cp-step-number {
        width: 40px;
        height: 40px;
    }
    .cp-setup-group {
        padding: 15px;
    }
    .cp-setup-btn {
        min-width: 100%;
        margin: 8px 0;
        padding: 20px;
    }
    .cp-ready-area {
        padding: 20px;
        margin-top: 30px;
    }
    .cp-start-btn {
        font-size: clamp(1.2em, 5vw, 1.8em) !important;
        padding: 15px 30px !important;
    }
    .cp-answer-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    .cp-quiz-answer {
        min-width: 100%;
        margin: 5px 0;
    }
    #cp-flag-image-container {
        max-height: 40vh;
    }
    #cp-flag-image {
        max-height: 40vh;
    }
    #cp-countdown-timer {
        width: 60px;
        height: 60px;
        font-size: 2em;
        top: 10px;
        right: 10px;
    }
    .cp-big-letter {
        font-size: clamp(4em, 12vw, 8em);
    }
    .cp-big-phonetic {
        font-size: clamp(2em, 8vw, 5em);
    }
    h3, h4 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    #cp-game-over {
        padding: 20px;
        min-height: 100vh;
    }
    #cp-game-over h2 {
        font-size: clamp(2em, 10vw, 4em);
        margin-bottom: 20px;
    }
    #cp-final-scores table {
        font-size: clamp(1.2em, 5vw, 2em);
    }
    #cp-final-scores th {
        font-size: clamp(1.4em, 6vw, 2.5em);
    }
    #cp-final-scores th, #cp-final-scores td {
        padding: 15px 10px;
    }
    #cp-game-over button {
        font-size: clamp(1.2em, 5vw, 1.8em);
        padding: 15px 30px;
        margin-top: 30px;
    }
}
