/* Basic CSS Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #023042;
    font-family: 'Russo One', sans-serif;
}

/* Canvas styling */
canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#lobby {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(2, 48, 66, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.lobby-content {
    background-color: #5689E5;
    padding: 2rem;
    border-radius: 1rem;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 4px solid #98c0f8;
}

.lobby-content h1 {
    color: white;
    margin-bottom: 2rem;
    font-size: 3rem;
    text-shadow: 2px 2px 0px #000;
}



.hidden {
    display: none !important;
}

@font-face {
    font-family: 'GameFont';
    src: url('../fonts/mem5YaGs126MiZpBA-UN7rgOUuhp.ttf') format('truetype');
    font-style: normal;
}


/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    /* Ensure UI is above canvas */
}

.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    pointer-events: auto;
}

.panel {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    padding: 35px;
    border-radius: 12px;
    text-align: center;
    color: white;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.room-panel {
    width: 800px;
    max-width: 95%;
}

.hidden {
    display: none !important;
}

/* Main Menu & Room List */
.create-room-section {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.player-controls {
    display: flex;
    gap: 5px;
}

.mini-btn {
    border: none;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.8;
}

.mini-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.red-btn {
    background: #E56E56;
}

.blue-btn {
    background: #5689E5;
}

.spec-btn {
    background: #95a5a6;
}

.status-bar {
    margin-top: 20px;
}

#newRoomName {
    padding: 12px;
    border-radius: 6px;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    width: 250px;
}

#createRoomBtn {
    padding: 12px 24px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

#createRoomBtn:hover {
    background: #2ecc71;
}

.room-list-container {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 20px;
    min-height: 250px;
}

.room-list-header {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    font-weight: bold;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    margin-bottom: 10px;
    text-transform: uppercase;
    font-size: 0.9em;
    letter-spacing: 0.05em;
}

#room-list {
    list-style: none;
    padding: 0;
    max-height: 350px;
    overflow-y: auto;
}

/* Scrollbar styling */
#room-list::-webkit-scrollbar {
    width: 8px;
}

#room-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

#room-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.room-item {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.room-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.join-room-btn {
    background: #3498db;
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.join-room-btn:hover {
    background: #2980b9;
}

.secondary-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white;
    padding: 10px 20px;
    margin-top: 15px;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: white;
}

.no-rooms {
    padding: 40px;
    color: #bdc3c7;
    font-style: italic;
    font-size: 1.1em;
}

/* Room Lobby Styling */
.room-header h2 {
    font-size: 2rem;
    color: #ecf0f1;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 5px;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}


/* Modal Styling */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    /* Higher than screen */
    pointer-events: auto;
    /* Ensure clickable */
}

.modal-content {
    background: #34495e;
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 300px;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #ecf0f1;
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 4px;
    border: none;
    font-family: inherit;
    font-size: 1.1rem;
    text-align: center;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.primary-btn {
    background: #27ae60;
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    flex: 1;
}

.primary-btn:hover {
    background: #2ecc71;
}

.secondary-btn {
    background: #7f8c8d;
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    flex: 1;
    margin-top: 0;
    /* Reset previous margin */
}

.secondary-btn:hover {
    background: #95a5a6;
}


#nicknameInput.error,
#newRoomName.error {
    border: 2px solid #e74c3c !important;
    animation: shake 0.3s;
    color: #e74c3c;
}

.error::placeholder {
    color: #e74c3c;
    opacity: 1;
}

@keyframes shake {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }

    100% {
        transform: translateX(0);
    }
}

.teams-container {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 10px;
    display: flex;
    flex-direction: row;
    /* Force horizontal */
    gap: 15px;
    justify-content: space-between;
    align-items: stretch;
}

.action-btn {
    padding: 12px 24px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    margin: 5px;
}

.action-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
}

#startGameBtn {
    background-color: #27ae60;
}

#startGameBtn:hover {
    background-color: #2ecc71;
}

#stopGameBtn {
    background-color: #e67e22;
}

#stopGameBtn:hover {
    background-color: #d35400;
}

#leaveRoomBtn:hover {
    background-color: rgba(231, 76, 60, 0.1);
    border-color: #c0392b !important;
    color: #c0392b !important;
}

.team-col {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.red-team {
    border-top: 4px solid #E56E56;
    background: linear-gradient(to bottom, rgba(229, 110, 86, 0.1), rgba(0, 0, 0, 0.2));
}

.blue-team {
    border-top: 4px solid #5689E5;
    background: linear-gradient(to bottom, rgba(86, 137, 229, 0.1), rgba(0, 0, 0, 0.2));
}

.spec-team {
    border-top: 4px solid #95a5a6;
}

.spec-team button {
    background: #7f8c8d;
}

#status-message {
    margin-top: 20px;
    font-size: 1.2rem;
    color: #f1c40f;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.5);
    min-height: 1.5em;
    /* Prevent jump */
}

/* Admin Controls & Sliders */
.admin-controls {
    background: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 15px;
    border-radius: 6px;
}

.setting-row label {
    font-weight: bold;
    color: #ecf0f1;
    min-width: 150px;
    text-align: left;
}

/* Custom Range Slider */
input[type=range] {
    -webkit-appearance: none;
    width: 60%;
    margin: 5px 0;
    background: transparent;
}

input[type=range]:focus {
    outline: none;
}

/* Slider Track */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    cursor: pointer;
    animate: 0.2s;
    background: #34495e;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Slider Thumb */
input[type=range]::-webkit-slider-thumb {
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    -webkit-appearance: none;
    margin-top: -7px;
    /* Center thumb on track */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    border: 2px solid #fff;
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #2980b9;
}

/* Leave Room Button Polish */
#leaveRoomBtn {
    margin-top: 25px !important;
    background: transparent;
    border: 2px solid #c0392b;
    color: #c0392b;
    font-size: 0.9rem;
    padding: 8px 16px;
    opacity: 0.7;
    transition: all 0.2s;
}

#leaveRoomBtn:hover {
    background: #c0392b;
    color: white !important;
    opacity: 1;
    box-shadow: 0 0 10px rgba(192, 57, 43, 0.4);
}