:root {
    --bg: #0f1115;
    --card: #171a21;
    --line: #262b36;
    --text: #e8eaf0;
    --muted: #8b93a7;
    --accent: #4ea1ff;
    --good: #3ddc97;
    --warn: #ffb454;
    --bad: #ff6b6b;
}

* {
    box-sizing: border-box;
}

/* author display rules (e.g. .row { display: flex }) otherwise beat [hidden] */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font:
        15px/1.45 system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
}

header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    background: #12151c;
    position: sticky;
    top: 0;
    z-index: 10;
}

/* left title and right controls take equal space, so the join button sits centered */
.header-left {
    flex: 1 1 0;
    min-width: 0;
}

.header-join {
    flex: 0 0 auto;
    white-space: nowrap;
}

h1 {
    margin: 0;
    font-size: 22px;
    letter-spacing: 0.5px;
}
h2 {
    margin: 0 0 10px;
    font-size: 17px;
}
h3 {
    margin: 20px 0 8px;
    font-size: 14px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

#subtitle {
    color: var(--muted);
    font-size: 13px;
}

.header-right {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.header-right a.button {
    white-space: nowrap;
}

#mod-pw {
    min-width: 150px;
    padding: 6px 8px;
}

main {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 16px 60px;
    display: grid;
    gap: 14px;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
}

.row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.row.space {
    justify-content: space-between;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}
.live-time {
    font-variant-numeric: tabular-nums;
    font-weight: 650;
}

.mod-actions {
    margin-top: 10px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 13px;
    background: #232938;
    border: 1px solid var(--line);
}
.badge.warmup {
    color: var(--warn);
}
.badge.scored {
    color: var(--good);
}
.badge.paused {
    color: var(--accent);
}
.badge.finished {
    color: var(--muted);
}

button {
    font: inherit;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #202634;
    color: var(--text);
    cursor: pointer;
}
button:hover {
    border-color: #3a4256;
}
button.primary {
    background: #1f5fbf;
    border-color: #2f76e0;
}
button.primary:hover {
    background: #2470d8;
}
button.danger {
    background: #4a1f24;
    border-color: #6d2c33;
}
button.ghost {
    background: transparent;
}
button.big-btn {
    padding: 12px 22px;
    font-size: 17px;
    font-weight: 650;
}

input {
    font: inherit;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #10131a;
    color: var(--text);
    min-width: 180px;
}

.alert {
    background: #3a1d1d;
    border: 1px solid #6d2c33;
    color: #ffb3b3;
    padding: 10px 14px;
    border-radius: 10px;
}

.round {
    margin-top: 18px;
}
.round:first-child {
    margin-top: 0;
}
.round-title {
    font-weight: 650;
    margin-bottom: 6px;
    color: var(--accent);
}
tr.dnf td {
    color: var(--muted);
}

.ranking {
    display: grid;
    gap: 6px;
}
.rank-row {
    display: grid;
    grid-template-columns: 44px 1fr auto;
    gap: 10px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--line);
}
.rank-row:last-child {
    border-bottom: 0;
}
.rank-pos {
    color: var(--muted);
}
.rank-time {
    font-variant-numeric: tabular-nums;
}

table {
    width: 100%;
    border-collapse: collapse;
}
th,
td {
    padding: 7px 9px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
th {
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
td.num,
th.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
tr.leader td {
    color: var(--good);
}
.scroll {
    overflow-x: auto;
}

a.button {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #202634;
    color: var(--text);
    text-decoration: none;
}
a.button:hover {
    border-color: #3a4256;
}
a.button.primary {
    background: #1f5fbf;
    border-color: #2f76e0;
}
a.button.primary:hover {
    background: #2470d8;
}
a.button.big-btn {
    padding: 12px 22px;
    font-size: 17px;
    font-weight: 650;
}

@media (max-width: 640px) {
    a.button.big-btn {
        width: 100%;
        text-align: center;
    }
    header {
        padding: 14px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .header-left,
    .header-right {
        flex: 1 1 100%;
    }
    .header-right {
        justify-content: center;
    }
    .header-join {
        flex: 1 1 100%;
        text-align: center;
    }
    .rank-row {
        grid-template-columns: 34px 1fr auto;
    }
}
