/* Add Orbitron font for timer & Font Awesome */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;700&family=Orbitron:wght@500;700&display=swap');

body {
    font-family: 'Roboto', sans-serif; line-height: 1.6; margin: 0; padding: 20px 0;
    background-image: linear-gradient(135deg, #1a1a1a 0%, #121212 80%);
    background-color: #121212; /* Fallback */
    background-size: cover, auto;
    background-position: center center, 0 0;
    background-attachment: fixed;
    color: #e0e0e0;
    display: flex; justify-content: center; align-items: flex-start; min-height: 100vh;
    animation: fadeInPage 0.8s ease-out;
    position: relative;
    overflow-x: hidden;
}

body::after { /* Subtle Glow/Flicker Overlay */
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(ellipse at center,
                                rgba(255, 100, 0, 0.12) 0%,
                                rgba(200, 50, 0, 0.04) 40%,
                                transparent 70%);
    opacity: 0.6;
    animation: subtleGlowFlicker 7s infinite alternate ease-in-out;
    z-index: -1;
    pointer-events: none;
}

@keyframes fadeInPage { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes subtleGlowFlicker {
    0% { opacity: 0.5; transform: scale(1.05) translate(1px, -1px); }
    20% { opacity: 0.7; }
    40% { opacity: 0.4; transform: scale(1.07) translate(-1px, 1px); }
    60% { opacity: 0.8; }
    80% { opacity: 0.5; transform: scale(1.03) translate(0px, 0px); }
    100% { opacity: 0.6; transform: scale(1.05) translate(1px, -1px); }
}

.container {
    width: 90%; max-width: 1200px; background: rgba(30, 30, 30, 0.95);
    padding: 25px 30px; box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    border-radius: 15px; border: 1px solid #383838; backdrop-filter: blur(5px);
}
header {
    text-align: center; margin-bottom: 30px; padding-bottom: 20px;
    border-bottom: 1px solid #444; position: relative;
}
.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.server-logo {
    max-width: 150px; max-height: 75px;
    border-radius: 8px; background-color: rgba(255,255,255,0.08); padding: 5px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.4); transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.server-logo:hover { transform: scale(1.08); box-shadow: 0 5px 10px rgba(0,0,0,0.5); }

.auto-refresh-controls { display: flex; align-items: center; }
.auto-refresh-label { margin-left: 10px; font-size: 0.9em; color: #b0bec5; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #444; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: #00aeff; }
input:focus + .slider { box-shadow: 0 0 1px #00aeff; }
input:checked + .slider:before { transform: translateX(22px); }
.slider.round { border-radius: 28px; }
.slider.round:before { border-radius: 50%; }

header h1 { color: #00aeff; margin-bottom: 8px; font-weight: 700; font-size: 2.3em; text-shadow: 0 0 10px rgba(0, 174, 255, 0.3); }
header h2.server-name-display { color: #c5cae9; font-weight: 300; font-size: 1.7em; margin-top: 0; animation: subtlePulse 2.5s infinite ease-in-out; }
@keyframes subtlePulse {
    0%, 100% { text-shadow: 0 0 5px rgba(197, 202, 233, 0.4); opacity: 0.95; }
    50% { text-shadow: 0 0 12px rgba(197, 202, 233, 0.8); opacity: 1; }
}
.card {
    background: linear-gradient(145deg, #2f2f2f, #2a2a2a); padding: 22px;
    border-radius: 10px; margin-bottom: 28px; box-shadow: 0 5px 15px rgba(0,0,0,0.35);
    border: 1px solid #484848;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-left-color 0.3s ease;
    border-left: 4px solid transparent;
}
.card:hover { transform: translateY(-5px) scale(1.015); box-shadow: 0 8px 25px rgba(0,0,0,0.5); border-left-color: #00aeff; }
.card > h3, .card > h4:not(.team-player-table h4) { /* Exclude team table h4 from this general rule */
    color: #00aeff; margin-top: 0; margin-bottom: 18px; border-bottom: 1px solid #505050; padding-bottom: 12px; font-weight: 500;
}
.card > h3 .icon, .card > h4:not(.team-player-table h4) .icon { margin-right: 10px; font-size: 1.1em; }
.card > h4:not(.team-player-table h4) { font-size: 1.25em; color: #81d4fa; }

.error-message { background-color: #6f2020; color: #ffcdd2; padding: 18px 22px; border: 1px solid #a13030; border-radius: 10px; margin-bottom: 28px; box-shadow: 0 3px 8px rgba(111, 32, 32, 0.5); }
.error-message .icon { margin-right: 8px; font-size: 1.2em; }

.server-highlights { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 25px; padding: 10px 0; text-align: center; margin-bottom: 28px; }
.highlight-item { background-color: #383838; padding: 20px; border-radius: 10px; box-shadow: inset 0 0 15px rgba(0,0,0,0.3), 0 3px 8px rgba(0,0,0,0.3); display: flex; flex-direction: column; align-items: center; justify-content: center; transition: transform 0.25s ease-out, background-color 0.25s, box-shadow 0.25s; position: relative; overflow: hidden; min-height: 120px; }
.highlight-item:hover { transform: translateY(-4px) scale(1.02); background-color: #404040; box-shadow: inset 0 0 10px rgba(0,0,0,0.2), 0 5px 12px rgba(0,0,0,0.4); }
.highlight-label { font-size: 0.95em; color: #b0bec5; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.8px; z-index: 2; }
.highlight-value { font-size: 1.7em; font-weight: bold; color: #f5f5f5; z-index: 2; }
.server-online-status .highlight-value.status-text .icon { margin-right: 8px; }
.server-online-status.online .highlight-value.status-text { color: #4caf50; }
.server-online-status.offline .highlight-value.status-text { color: #f44336; }
.map-highlight { background-size: cover; background-position: center center; color: #fff; justify-content: flex-end; padding: 0; background-color: #222; }
.map-highlight-overlay { background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.65) 60%, rgba(0,0,0,0.0) 100%); padding: 15px 20px; width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; box-sizing: border-box; }
.map-highlight .highlight-label { color: #cfd8dc; }
.map-highlight .map-name-value { color: #00aeff; font-size: 1.8em; line-height: 1.1; }
.map-timer-display { font-family: 'Orbitron', sans-serif; font-size: 2.4em; color: #ff9800; font-weight: 700; letter-spacing: 1.5px; line-height: 1; text-shadow: 0 0 8px rgba(255, 152, 0, 0.5); }
#map-timer-countdown.low-time { color: #f44336; text-shadow: 0 0 8px rgba(244, 67, 54, 0.6); animation: pulseLowTime 1s infinite; }
@keyframes pulseLowTime { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
#map-timer-total-static { font-size: 0.45em; color: #b0bec5; font-family: 'Roboto', sans-serif; font-weight: normal; vertical-align: text-bottom; margin-left: 5px; }

.details-grid.minimal-details { grid-template-columns: 1fr; }
.details-grid p { margin: 0; font-size: 1em; color: #ced4da; background-color: rgba(50, 50, 50, 0.7); padding: 12px 15px; border-radius: 6px; border-left: 3px solid #555; transition: border-left-color 0.3s ease, background-color 0.3s ease; }
.details-grid p:hover { border-left-color: #00aeff; background-color: rgba(60, 60, 60, 0.8); }
.details-grid p strong { color: #f5f5f5; min-width: 120px; display: inline-block; }
.details-grid p .icon { margin-right: 8px; color: #00aeff; font-size: 1.1em; vertical-align: middle; width: 20px; text-align:center; }

.player-list-section h3 { text-align: center; }
.team-tables-wrapper { display: flex; flex-wrap: wrap; gap: 25px; align-items: flex-start; }
.unassigned-players-section { margin-top: 30px; width:100%; }
.unassigned-players-section .team-player-table { flex-basis: 100%; min-width: unset; }
.team-player-table { flex-grow: 1; flex-basis: 0; min-width: 400px; margin-bottom: 22px; background-color: transparent; /* Let children handle background */ border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.2); overflow: hidden; }
.team-player-table .no-players-message { text-align: center; color: #999; font-style: italic; padding: 12px 15px; background-color: rgba(40,40,40,0.7); border-radius: 0 0 8px 8px;}

.team-player-table h4 { /* Team Header Row Styling */
    font-size: 1.2em;
    color: #e0e0e0; 
    margin-bottom: 0;
    padding: 10px 15px;
    border-bottom: 2px solid #006ba5; /* Darker accent for the border */
    text-align: left;
    display: flex;
    align-items: center;
    background: linear-gradient(to bottom, #3c3c3c, #282828); /* Dark metallic gradient */
    border-radius: 8px 8px 0 0;
    text-shadow: 0 1px 1px rgba(0,0,0,0.3);
}
.team-player-table h4 .team-name-highlight {
    color: #00aeff; /* Keep team name blue */
}
.team-player-table h4 .team-flag-icon { box-shadow: 0 1px 2px rgba(0,0,0,0.5); }

.table-content-wrapper { padding: 0 15px 15px 15px; overflow-x: auto; background-color: rgba(40,40,40,0.7); border-radius: 0 0 8px 8px; /* Match bottom radius if h4 has top */ }

table.sortable-table { width: 100%; border-collapse: separate; border-spacing: 0; animation: fadeInTable 0.6s ease-out forwards; opacity: 0; }
@keyframes fadeInTable { from { opacity: 0; transform: translateY(15px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
th, td { border-bottom: 1px solid #4a4a4a; padding: 8px 10px; text-align: center; font-size: 0.88em; word-break: break-word; vertical-align: middle; }
th:first-child, td:first-child { text-align: left; padding-left: 12px; min-width: 140px; }
td:first-child, th:first-child { border-left: none; }
td:last-child, th:last-child { border-right: none; }
tr:last-child td { border-bottom: none; }
th[data-sort-key] { cursor: pointer; user-select: none; }
th[data-sort-key]:hover { background: linear-gradient(to bottom, #0099e0, #007bb5) !important; }
th .sort-arrow { font-family: "Font Awesome 6 Free"; font-weight: 900; display: inline-block; margin-left: 6px; opacity: 0.4; transition: opacity 0.2s, transform 0.2s; font-size: 0.8em; width: 1em; text-align: center; }
th.sorted-asc .sort-arrow::before { content: "\f0de"; }
th.sorted-desc .sort-arrow::before { content: "\f0dd"; }
th.sorted-asc .sort-arrow, th.sorted-desc .sort-arrow { opacity: 1; transform: scale(1.15); }
th { background: linear-gradient(to bottom, #00aeff, #008fcc); color: #ffffff; font-weight: bold; text-transform: uppercase; letter-spacing: 0.5px; white-space: normal; word-break: break-word; transition: background 0.3s ease; position: sticky; top: 0; z-index: 1; }
th .icon-header { margin-right: 5px; font-size: 1em; vertical-align: middle; }
tbody tr { background-color: #303030; transition: background-color 0.25s ease, transform 0.2s ease-out; }
tbody tr.clickable-row { cursor: pointer; }
tbody tr.clickable-row:hover { background-color: #484848; transform: scale(1.008) translateX(3px); box-shadow: 0 2px 5px rgba(0,0,0,0.3); }
tbody tr:nth-child(even) { background-color: #2b2b2b; }
tbody tr.clickable-row:nth-child(even):hover { background-color: #484848; }

footer { text-align: center; margin-top: 35px; padding-top: 22px; border-top: 1px solid #444; font-size: 0.9em; color: #90a4ae; }
.refresh-status-text { color: #00aeff; font-weight: bold; text-shadow: 0 0 5px rgba(0,174,255,0.3); }
#scrollToTopBtn { display: none; position: fixed; bottom: 28px; right: 28px; z-index: 100; border: none; outline: none; background: linear-gradient(135deg, #00aeff, #007fcc); color: white; cursor: pointer; padding: 0; width: 55px; height: 55px; border-radius: 50%; font-size: 26px; box-shadow: 0 6px 18px rgba(0,174,255,0.4); transition: background 0.3s, opacity 0.3s, transform 0.3s, box-shadow 0.3s; line-height: 55px; text-align: center; }
#scrollToTopBtn span { display: inline-block; transition: transform 0.2s ease-out; }
#scrollToTopBtn.show { display: block; animation: zoomInButton 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes zoomInButton { from { opacity: 0; transform: scale(0.3); } to { opacity: 1; transform: scale(1); } }
#scrollToTopBtn:hover { background: linear-gradient(135deg, #0099e0, #006ba5); transform: scale(1.12) rotate(10deg); box-shadow: 0 8px 22px rgba(0,174,255,0.6); }
#scrollToTopBtn:hover span { transform: translateY(-4px) scale(1.15); }

@media (max-width: 1024px) { .header-top-row { flex-direction: column; align-items: center; } .server-logo { margin-bottom: 10px; } .auto-refresh-controls { margin-top: 10px; } }
@media (max-width: 992px) { .server-highlights { grid-template-columns: 1fr; gap: 20px; } .highlight-item { min-width: 90%; width: auto;} .map-timer-display { font-size: 2em; } .team-player-table { flex-basis: 100%; min-width: 100%;} .team-tables-wrapper { gap: 0; } }
@media (max-width: 768px) {
    body { padding: 10px 0; }
    .container { width: 95%; padding: 20px 15px; max-width: 100%; border-radius: 10px; }
    header h1 { font-size: 1.9em; }
    header h2.server-name-display { font-size: 1.4em; animation: none; }
    .server-logo { max-width: 110px; max-height: 55px; }
    .details-grid.minimal-details p { font-size: 0.95em; }
    .card { border-radius: 8px; }
    .team-player-table h4 { font-size: 1.1em; padding: 8px 12px; border-radius: 6px 6px 0 0; }
    .team-flag-icon { width: 24px; height: auto; margin-right: 6px; }
    .team-flag-icon.placeholder { height: 16px; }
    .table-content-wrapper { padding: 0 10px 10px 10px; border-radius: 0 0 6px 6px; }
    .player-list-section table thead { display: none; }
    .player-list-section table tr { display: block; margin-bottom: 0; border: none; border-radius: 0; box-shadow: none; background-color: transparent; padding: 0; }
    .player-list-section table tr:nth-child(even) { background-color: transparent; } /* No alternating color for TRs now */
    .player-list-section table td {
        display: flex; 
        align-items: center; 
        text-align: left; 
        padding: 7px 8px; /* Adjusted padding */
        position: relative;
        border: none;
        border-bottom: 1px dashed #555; /* Softer separator */
        font-size: 0.88em; /* Consistent font size */
        min-height: auto; /* Let content define height */
        background-color: #383838; /* Slightly lighter than card for contrast */
    }
    .player-list-section table tr:last-child td:last-of-type { border-bottom: 0; } /* Last cell of last TR in a player block */
    .player-list-section table tr td:first-of-type { border-top-left-radius: 0px; border-top-right-radius: 0px;} /* If TDs are stacked */
    .player-list-section table tr td:last-of-type { border-bottom-left-radius: 0px; border-bottom-right-radius: 0px;}
    /* Alternating TD backgrounds for clarity */
    .player-list-section table tr td:nth-child(odd) { background-color: #353535; }
    .player-list-section table tr td:nth-child(even) { background-color: #303030; }


    .player-list-section table td::before { /* Icon styling */
        font-family: "Font Awesome 6 Free";
        font-weight: 900;
        font-size: 0.9em; 
        color: #00aeff;
        margin-right: 6px;
        min-width: 18px; 
        text-align: center;
        display: inline-block;
    }
    
    .player-list-section table td[data-icon-class="fas fa-user"]::before { content: "\f007"; }
    .player-list-section table td[data-icon-class="fas fa-trophy"]::before { content: "\f091"; }
    .player-list-section table td[data-icon-class="fas fa-crosshairs"]::before { content: "\f05b"; }
    .player-list-section table td[data-icon-class="fas fa-skull"]::before { content: "\f54c"; }
    .player-list-section table td[data-icon-class="fas fa-signal"]::before { content: "\f012"; }
        
    .player-list-section table td span.data-label-mobile-text {
        color: #b0bec5;
        font-weight: bold;
        margin-right: 5px; 
        white-space: nowrap;
    }
        
    .player-list-section table td span.data-value-mobile-text {
        color: #e0e0e0; 
        flex-grow: 1; 
        text-align: right; 
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .player-list-section table td[data-label="Name"] span.data-value-mobile-text {
        text-align: left; 
        white-space: normal; /* Allow name to wrap */
    }
    .player-list-section table td[data-label="Name"] span.data-label-mobile-text {
        min-width: 40px; 
    }
    #scrollToTopBtn { width: 45px; height: 45px; font-size: 22px; line-height: 45px; right: 20px; bottom: 20px; }
}
@media (max-width: 480px) {
    header h1 { font-size: 1.7em; }
    .card { padding: 18px; }
    th, td { padding: 6px 8px; font-size:0.85em; }
    .highlight-value { font-size: 1.5em; }
    .map-timer-display { font-size: 1.8em; }
    .header-top-row { flex-direction: column; align-items: center; }
    .auto-refresh-controls { margin-top: 10px; }
}