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

/* ------------------------------------------- */
/* 2. BASE CONTAINER & TYPOGRAPHY */
/* ------------------------------------------- */
#cadet-command-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); /* Soft shadow with Navy hint */
    color: var(--cc-dark-text);
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

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

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

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

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

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

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

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

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

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

/* Setup Button Styling */
.cc-setup-btn {
    cursor: pointer;
    padding: clamp(15px, 2vw, 25px);
    margin: 10px;
    border: 3px solid var(--cc-blue-navy);
    border-radius: 12px;
    background-color: white;
    color: var(--cc-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);
}

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

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

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

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

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

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

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

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

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

.cc-quiz-answer:hover, .cc-salute-button:hover, #cc-seniority-submit:hover:not(:disabled) {
    background-color: var(--cc-blue-navy);
    color: white;
    box-shadow: 0 4px 10px rgba(0, 51, 102, 0.3);
}

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

/* Ready Area and Start Button */
.cc-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(--cc-gold-brass);
}

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

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

.cc-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(--cc-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;
}

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

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

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

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

/* ------------------------------------------- */
/* 4. IMAGE DISPLAY (FIXED FOR HIGH-RES!) */
/* ------------------------------------------- */
#cc-rank-image-container, #cc-salute-image-container {
    position: relative;
    max-height: 50vh; /* Use viewport height for better screen fit */
    width: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px auto;
    overflow: hidden;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    border: 3px solid var(--cc-gold-brass); /* A nice gold frame */
}

#cc-rank-image, #cc-salute-image {
    max-width: 100%;
    max-height: 50vh; /* Matches container max-height */
    height: auto;
    display: block;
    object-fit: contain;
}

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

/* Countdown Timer */
#cc-countdown-timer {
    position: absolute;
    top: 20px;
    right: 20px;
    background-color: var(--cc-gold-brass);
    color: var(--cc-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;
}

#cc-countdown-timer.final-seconds {
    background-color: var(--cc-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);
    }
}

/* Salute buttons are wider */
.cc-salute-button {
    min-width: 300px;
    background-color: var(--cc-teal-accent);
    color: white;
    border-color: var(--cc-teal-accent);
    font-weight: bold;
}
.cc-salute-button:hover {
    background-color: var(--cc-blue-navy);
}

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

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

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

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

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

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

#cc-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;
    }
}

/* ------------------------------------------- */
/* 8. SENIORITY QUIZ (DRAG & DROP) */
/* ------------------------------------------- */
#cc-fleet-sort-area {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.cc-fleet-drop-target {
    flex: 1;
    min-height: 400px;
    background-color: var(--cc-light-bg);
    border: 3px dashed var(--cc-blue-navy);
    border-radius: 8px;
    padding: 15px;
    transition: background-color 0.2s;
}

.cc-fleet-drop-target h4 {
    margin-top: 0;
    border-bottom: 2px solid var(--cc-teal-accent);
    padding-bottom: 10px;
}

.cc-fleet-drop-target.drag-over {
    background-color: rgba(0, 163, 163, 0.1); /* Lightened accent color */
    border-style: solid;
}

.cc-rank-card {
    cursor: grab;
    padding: 12px;
    margin-bottom: 10px;
    background-color: white;
    border: 1px solid var(--cc-blue-navy);
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    font-weight: 600;
    transition: transform 0.1s;
}

.cc-rank-card.dragging {
    opacity: 0.4;
    border: 2px dashed var(--cc-gold-brass);
}

#cc-seniority-submit {
    display: block;
    margin: 20px auto 0;
}

/* ------------------------------------------- */
/* 9. END GAME SCREEN */
/* ------------------------------------------- */
#cc-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;
}

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

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

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

#cc-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;
}

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

#cc-final-scores th {
    background-color: var(--cc-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;
}

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

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

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

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

/* New Challenge button */
#cc-game-over .cc-new-challenge-btn,
#cc-game-over button.cc-new-challenge-btn,
button.cc-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;
}

#cc-game-over .cc-new-challenge-btn:hover,
#cc-game-over button.cc-new-challenge-btn:hover,
button.cc-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-command-game {
        padding: 10px;
        margin: 0;
        min-height: 100vh;
    }
    .cc-setup-header {
        padding: 20px 15px;
        margin-bottom: 25px;
    }
    .cc-setup-header h2 {
        font-size: clamp(1.8em, 8vw, 2.5em);
    }
    .cc-control-group {
        margin-bottom: 30px;
    }
    .cc-control-group h3 {
        font-size: clamp(1.2em, 5vw, 1.6em);
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    .cc-step-number {
        width: 40px;
        height: 40px;
    }
    .cc-setup-group {
        padding: 15px;
    }
    .cc-setup-btn {
        min-width: 100%;
        margin: 8px 0;
        padding: 20px;
    }
    .cc-ready-area {
        padding: 20px;
        margin-top: 30px;
    }
    .cc-start-btn {
        font-size: clamp(1.2em, 5vw, 1.8em) !important;
        padding: 15px 30px !important;
    }
    .cc-answer-buttons, #cc-salute-area, #cc-fleet-sort-area {
        flex-direction: column;
        align-items: stretch;
    }
    .cc-quiz-answer, .cc-salute-button {
        min-width: 100%;
        margin: 5px 0;
    }
    #cc-fleet-sort-area {
        gap: 10px;
    }
    .cc-fleet-drop-target {
        min-height: 200px;
    }
    #cc-rank-image-container, #cc-salute-image-container {
        max-height: 40vh;
    }
    #cc-rank-image, #cc-salute-image {
        max-height: 40vh;
    }
    #cc-countdown-timer {
        width: 60px;
        height: 60px;
        font-size: 2em;
        top: 10px;
        right: 10px;
    }
    h3, h4 {
        font-size: 1.2em;
        margin-bottom: 10px;
    }
    #cc-game-over {
        padding: 20px;
        min-height: 100vh;
    }
    #cc-game-over h2 {
        font-size: clamp(2em, 10vw, 4em);
        margin-bottom: 20px;
    }
    #cc-final-scores table {
        font-size: clamp(1.2em, 5vw, 2em);
    }
    #cc-final-scores th {
        font-size: clamp(1.4em, 6vw, 2.5em);
    }
    #cc-final-scores th, #cc-final-scores td {
        padding: 15px 10px;
    }
    #cc-game-over button {
        font-size: clamp(1.2em, 5vw, 1.8em);
        padding: 15px 30px;
        margin-top: 30px;
    }
}