/* UNIVERSAL DESKTOP LAYOUT */
html,
body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* Prevent scrolling */
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
}

/* HEADER: Fixed Height */
header {
    background-color: #2c3e50;
    color: white;
    padding: 0 20px;
    height: 40px;
    flex-shrink: 0;
    /* Prevents shrinking */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    position: relative;
}

h1 {
    font-size: 1.1rem;
    margin: 0;
    font-weight: 600;
}

/* MAIN CONTAINER: Flex 1 to take all remaining space */
.main-container {
    display: flex;
    flex: 1;
    /* Takes all height between Header and Footer */
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* SIDEBAR: Fixed Width */
#sidebar {
    width: 380px;
    flex-shrink: 0;
    /* Fixed width */
    background-color: #ffffff;
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
    z-index: 900;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    height: 100%;
}

/* ACTIVE PANEL (Top of Sidebar) */
#active-panel {
    padding: 15px;
    background-color: #fdfefe;
    flex-grow: 1;
    /* Takes all space above stats */
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

#active-header-box {
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 5px;
}

.label {
    display: block;
    font-size: 0.75rem;
    color: #95a5a6;
    text-transform: uppercase;
    margin-bottom: 2px;
}

#active-team-display {
    margin: 0;
    font-size: 1.5rem;
    color: #2c3e50;
    letter-spacing: -0.5px;
}

.mission-box {
    background: #e8f8f5;
    border: 1px solid #d1f2eb;
    border-radius: 6px;
    padding: 8px;
    border-left: 5px solid #1abc9c;
}

.mission-label {
    display: block;
    font-size: 0.7rem;
    color: #16a085;
    font-weight: bold;
}

.mission-box p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.3;
    color: #34495e;
}

/* QUIZ AREA */
#quiz-area {
    margin-top: 5px;
    background-color: #f7f9f9;
    border-radius: 8px;
    padding: 10px;
    border: 1px solid #ecf0f1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.action-btn {
    width: 100%;
    padding: 10px;
    background: #8e44ad;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 3px 0 #71368a;
    transition: transform 0.1s;
}

.action-btn:active {
    transform: translateY(3px);
    box-shadow: none;
}

.hidden {
    display: none !important;
}

#question-text {
    font-size: 0.95rem;
    font-weight: 700;
    color: #2c3e50;
    text-align: center;
    margin: 0 0 10px 0;
    line-height: 1.3;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.progress-bg {
    flex-grow: 1;
    height: 12px;
    background: #ddd;
    border-radius: 6px;
    overflow: hidden;
}

#progress-bar {
    height: 100%;
    background: #27ae60;
    width: 100%;
    transition: width 0.1s linear;
}

#timer-text {
    font-weight: bold;
    color: #2c3e50;
    min-width: 100px;
    font-size: 0.9rem;
    text-align: right;
    white-space: nowrap;
}

.options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.options-container button {
    width: 100%;
    padding: 6px 4px;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.8rem;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.options-container button:hover {
    border-color: #3498db;
    background: #ebf5fb;
}

#notification-area {
    background: white;
    border-radius: 4px;
    padding: 6px 10px;
    border-left: 4px solid #3498db;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 5px;
    min-height: 20px;
}

#last-message {
    margin: 0;
    font-size: 0.85rem;
    color: #34495e;
}

/* BOTTOM STATS (Sidebar Footer) */
#bottom-section {
    background-color: #f4f6f7;
    border-top: 1px solid #dcdcdc;
    padding: 10px;
}

#bottom-section h3 {
    font-size: 0.75rem;
    color: #95a5a6;
    margin: 0 0 5px 0;
    text-transform: uppercase;
}

#stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: white;
}

#stats-table th {
    text-align: left;
    padding: 5px;
    border-bottom: 2px solid #ddd;
    color: #7f8c8d;
    font-size: 0.8rem;
}

#stats-table td {
    padding: 5px;
    border-bottom: 1px solid #eee;
}

.row-active {
    background-color: #eafaf1;
    border-left: 3px solid #2ecc71;
    font-weight: bold;
}

/* MAP: Flex Grow */
#map {
    flex-grow: 1;
    /* Takes all remaining width */
    height: 100%;
    background: #aad3df;
    z-index: 1;
}

.leaflet-control-container .leaflet-routing-container-hide {
    display: none;
}

/* FOOTER: Fixed Height */
#footer-panel {
    height: 60px;
    flex-shrink: 0;
    /* Fixed height */
    background: #2c3e50;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    width: 100%;
    box-sizing: border-box;
}

.footer-group {
    display: flex;
    align-items: center;
    gap: 15px;
}

.footer-label {
    font-size: 0.9rem;
    color: #bdc3c7;
    font-weight: bold;
}

.team-controls {
    display: flex;
    gap: 10px;
}

.team-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    font-weight: bold;
    cursor: pointer;
    background: #34495e;
    color: #bdc3c7;
    border: 2px solid #7f8c8d;
    transition: all 0.2s;
    font-size: 1rem;
}

.team-btn:hover {
    border-color: white;
    color: white;
}

.team-btn.active {
    transform: scale(1.1);
    color: white;
    border-color: white;
    box-shadow: 0 0 5px white;
}

#btn-team-1.active {
    background: #e74c3c;
    border-color: #e74c3c;
}

#btn-team-2.active {
    background: #3498db;
    border-color: #3498db;
}

.tool-btn {
    background: transparent;
    border: 1px solid #95a5a6;
    color: #ecf0f1;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.tool-btn:hover {
    background: #e67e22;
    border-color: #e67e22;
}

/* MARKERS */
.team-icon {
    border: 2px solid white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

.team-1-marker {
    background: #e74c3c;
}

.team-2-marker {
    background: #3498db;
}

.target-marker-icon {
    border-radius: 50%;
    border: 2px solid white;
    background: #95a5a6;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.target-marker-icon.correct {
    background: #27ae60 !important;
    border-color: #2ecc71;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(46, 204, 113, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

/* VICTORY MODAL */
.victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.5s ease-out;
}

.event-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    animation: fadeIn 0.3s ease-out;
}

.event-modal {
    background: linear-gradient(135deg, #f39c12, #d35400);
    padding: 30px;
    border-radius: 12px;
    color: white;
    text-align: center;
    font-size: 1.2rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 3px solid #fff;
    max-width: 500px;
    animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.event-modal h2 {
    margin: 0 0 15px 0;
    text-transform: uppercase;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.event-modal button {
    margin-top: 20px;
    padding: 10px 25px;
    font-size: 1.1rem;
    cursor: pointer;
    background: white;
    color: #d35400;
    border: none;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 4px 0 #e67e22;
    text-transform: uppercase;
    transition: all 0.2s;
}

.event-modal button:hover {
    background: #fdfefe;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #e67e22;
}

.event-modal button:active {
    transform: translateY(4px);
    box-shadow: none;
}

.victory-modal {
    background: white;
    width: 600px;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    overflow: hidden;
    animation: scaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.victory-modal h2 {
    font-size: 2.5rem;
    color: #f1c40f;
    margin: 0 0 20px 0;
    text-shadow: 2px 2px 0 #d35400;
}

.rank-list {
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.rank-item {
    background: #f8f9fa;
    margin-bottom: 15px;
    padding: 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    border: 2px solid transparent;
    transition: transform 0.2s;
}

.rank-item:hover {
    transform: scale(1.02);
}

.rank-item.gold {
    background: #fff9c4;
    border-color: #f1c40f;
}

.rank-item.silver {
    background: #f5f5f5;
    border-color: #bdc3c7;
}

.rank-item.bronze {
    background: #ffe0b2;
    border-color: #d35400;
}

.rank-pos {
    font-size: 2rem;
    margin-right: 20px;
    min-width: 40px;
}

.rank-info {
    text-align: left;
    flex-grow: 1;
}

.rank-name {
    font-size: 1.3rem;
    font-weight: bold;
    color: #2c3e50;
    display: block;
}

.rank-stats {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-top: 4px;
}

.restart-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 4px 0 #219150;
    transition: all 0.2s;
    margin-top: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.restart-btn:hover {
    background: #2ecc71;
    transform: translateY(2px);
    box-shadow: 0 2px 0 #219150;
}

.restart-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}