/* WAR STARS Leaderboard styles
 *
 * NOTE: Copy your font files into:
 *   netlify_site/fonts/m5x7.ttf
 *   netlify_site/fonts/workbench.ttf
 */

@font-face {
    font-family: "m5x7";
    src: url("fonts/m5x7.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: "workbench";
    src: url("fonts/workbench.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg-color: #03030a;
    --text-color: #f0f0f0;
    --accent-blue: #00c8ff; /* matches game accent */
    --gold: #ffd54a;
    --row-alt-bg: #11111a;
    --row-hover-bg: #1a1a26;
    
    /* 
       SCALING GUIDE:
       Adjust the pixel value in clamp() below to change the global zoom.
       Current: 24px (This sets the base font size).
    */
    --base-scale: clamp(16px, 2dvw, 30px);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg-color);
    color: var(--text-color);
    font-family: "m5x7", monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* This makes 1em equal to our base scale variable */
    font-size: var(--base-scale);
}

/* Layout */

.container {
    width: 75dvw; /* Request: 75% of screen width */
    max-width: none;
    padding: 1em;
}

.header {
    text-align: center;
    margin-bottom: 0.5em;
}

.title {
    font-family: "workbench", cursive;
    font-size: 2.5em; /* relative to body font size */
    color: var(--gold);
    display: flex;
    justify-content: center;
    align-items: center;
    letter-spacing: 0.05em;
}

.title .star {
    font-size: 0.8em;
    margin: 0 0.25em;
}

.subtitle {
    margin-top: 0.1em;
    font-size: 1em;
    color: var(--accent-blue);
}

.status {
    margin: 0.5em 0;
    font-size: 0.9em;
    color: var(--accent-blue);
}

.footer {
    margin-top: 0.8em;
    text-align: center;
    font-size: 0.8em;
    color: #888ca0;
}

/* Leaderboard table */

.leaderboard-wrapper {
    height: 60dvh; /* Request: 60% of screen height */
    overflow-y: auto;
    border-radius: 0.25em;
    background: rgba(0, 0, 0, 0.15);
}

.leaderboard {
    width: 100%;
    border-collapse: collapse;
    font-size: 1em;
    table-layout: fixed;
}

.leaderboard thead {
    background: #131320;
}

.leaderboard th,
.leaderboard td {
    padding: 0.3em 0.5em;
    text-align: left;
}

.leaderboard th {
    font-weight: normal;
    color: var(--accent-blue);
    border-bottom: 1px solid #202034;
    position: sticky; /* Keeps header visible while scrolling */
    top: 0;
    z-index: 1;
    background: #131320; /* Prevents rows from showing through the header */
}

.col-rank {
    width: 10%;
    text-align: right;
}

.col-name {
    width: 30%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Truncates long names with "..." */
}

.col-score {
    width: 25%;
    text-align: right;
}

.col-time {
    width: 35%;
    text-align: right;
}

.leaderboard tbody tr:nth-child(odd) {
    background: var(--row-alt-bg);
}

.leaderboard tbody tr:nth-child(even) {
    background: transparent;
}

.leaderboard tbody tr:hover {
    background: var(--row-hover-bg);
}

.leaderboard tbody tr.top-row {
    color: var(--gold);
}

/* Responsive tweaks */

@media (max-width: 480px) {
    /* Since we use viewport units, manual font resizing here is less necessary,
       but we still hide the time column on narrow devices. */
    
    .col-time {
        display: none; 
    }
    
    .leaderboard th,
    .leaderboard td {
        padding: 0.2em;
    }
}