:root {
    --bg: #110a1a;
    --deep: #0a0510;
    --panel: #211232;
    --panel2: #2a183e;
    --row: #261638;
    --line: #3b2755;
    --gold: #d8ae4e;
    --goldlit: #f7dd93;
    --text: #f1eafb;
    --muted: #a391c1;
    --warn: #e89a5a;
    --bad: #e8564a;
    --good: #9fd8a2;
}

* {
    box-sizing: border-box;
    border-radius: 0;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 "Segoe UI", Inter, system-ui, sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 22px;
    background: linear-gradient(180deg, #33194f, #140b1f);
    border-bottom: 2px solid var(--gold);
    flex: 0 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mark {
    width: 18px;
    height: 18px;
    background: var(--gold);
    transform: rotate(45deg);
    display: block;
}

h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: .04em;
    color: var(--goldlit);
}

header p {
    margin: 2px 0 0;
    font-size: 10px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--gold);
}

.head-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status {
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}

.status.live {
    color: var(--good);
}

.status.dead {
    color: var(--bad);
}

main {
    display: grid;
    grid-template-columns: 320px 1fr;
    flex: 1 1 auto;
    min-height: 0;
}

aside {
    border-right: 1px solid var(--line);
    background: var(--deep);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.aside-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 16px 8px;
}

.overline {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--gold);
}

.muted {
    color: var(--muted);
}

.list {
    list-style: none;
    margin: 0;
    padding: 0 8px 16px;
    overflow-y: auto;
}

.list li {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 8px;
    margin-bottom: 4px;
    border: 1px solid transparent;
    cursor: pointer;
}

.list li:nth-child(odd) {
    background: var(--row);
}

.list li:hover {
    background: #351f4d;
    border-color: var(--line);
}

.list li.active {
    background: #3e275a;
    border-color: var(--gold);
    border-left-width: 3px;
}

.thumb {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    background: var(--panel2);
    object-fit: cover;
    border: 1px solid var(--line);
    image-rendering: auto;
}

.list .name {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list .sub {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: .06em;
}

.detail {
    overflow-y: auto;
    padding: 20px 24px 48px;
    min-height: 0;
}

.empty {
    border: 1px dashed var(--line);
    padding: 24px;
    max-width: 560px;
}

.empty p {
    margin: 0 0 8px;
}

.detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

.detail-head h2 {
    margin: 0;
    font-size: 22px;
}

.detail-head .id {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    word-break: break-all;
}

.banner {
    margin: 14px 0 0;
    padding: 10px 12px;
    background: #4a1e10;
    border: 1px solid var(--warn);
    color: #ffd9bc;
    font-size: 12px;
}

.top {
    display: grid;
    grid-template-columns: minmax(240px, 380px) 1fr;
    gap: 18px;
    margin-top: 16px;
}

.shot {
    border: 1px solid var(--line);
    background: var(--deep);
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    cursor: zoom-in;
}

.no-shot {
    border: 1px dashed var(--line);
    aspect-ratio: 4 / 3;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 12px;
}

.ranks {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
}

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

.card .label {
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--muted);
}

.card .value {
    font-size: 22px;
    font-weight: 700;
    margin-top: 2px;
}

.card .hint {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.meta div {
    border-left: 2px solid var(--gold);
    padding-left: 8px;
}

.meta .k {
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
}

.meta .v {
    font-size: 13px;
    font-family: ui-monospace, Consolas, monospace;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 13px;
}

thead th {
    text-align: right;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 6px 8px;
    border-bottom: 1px solid var(--line);
    font-weight: 700;
}

thead th:first-child {
    text-align: left;
}

tbody td {
    padding: 5px 8px;
    text-align: right;
    font-family: ui-monospace, Consolas, monospace;
    border-bottom: 1px solid #2a183e;
}

tbody td:first-child {
    text-align: left;
    font-family: inherit;
}

tbody tr:nth-child(odd) {
    background: var(--row);
}

tbody tr:hover {
    background: #351f4d;
}

td .note {
    display: block;
    font-family: inherit;
    font-size: 10px;
    color: var(--muted);
}

.rank {
    font-weight: 700;
    letter-spacing: .04em;
    font-family: inherit;
}

.rank.excellent { color: var(--goldlit); }
.rank.good { color: var(--gold); }
.rank.medium { color: var(--text); }
.rank.poor { color: var(--warn); }
.rank.verypoor { color: var(--bad); }
.rank.na { color: #5b4a72; }

h3 {
    font-size: 11px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--gold);
    margin: 26px 0 6px;
}

.history {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 12px;
}

.history li {
    display: flex;
    gap: 14px;
    padding: 5px 8px;
    border-bottom: 1px solid #2a183e;
    font-family: ui-monospace, Consolas, monospace;
}

.history li:nth-child(odd) {
    background: var(--row);
}

/* One entry per earlier push: a collapsed line that opens into that version's full stat table. */
.versions {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
    font-size: 12px;
}

.version {
    border-bottom: 1px solid #2a183e;
}

.version summary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 7px 8px;
    cursor: pointer;
    font-family: ui-monospace, Consolas, monospace;
    color: var(--text);
}

.version summary:hover {
    background: var(--row);
}

.version summary::-webkit-details-marker {
    color: var(--gold);
}

.version[open] summary {
    background: var(--row);
    border-left: 2px solid var(--gold);
}

.version .when {
    color: var(--gold);
    white-space: nowrap;
}

.version .marks {
    display: flex;
    gap: 6px;
}

.version .mini {
    margin-left: auto;
    height: 34px;
    width: auto;
    object-fit: cover;
    border: 1px solid #2a183e;
}

.version-body {
    padding: 4px 8px 12px;
}

.gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 10px 0 0;
}

.gallery figure {
    margin: 0;
}

.gallery img {
    display: block;
    height: 104px;
    width: auto;
    border: 1px solid var(--line);
    cursor: zoom-in;
}

.gallery img:hover {
    border-color: var(--gold);
}

.gallery figcaption {
    margin-top: 4px;
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--muted);
}

.version-body table {
    margin-top: 4px;
}

button {
    font: inherit;
    cursor: pointer;
    border: 1px solid var(--gold);
    background: transparent;
    color: var(--gold);
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

button:hover {
    background: var(--gold);
    color: var(--deep);
}

button.danger {
    border-color: var(--bad);
    color: var(--bad);
}

button.danger:hover {
    background: var(--bad);
    color: var(--deep);
}

/* While the key is missing there is nothing on screen but the lock: no header, no empty panels. */
body.locked header,
body.locked main {
    display: none;
}

.lang {
    display: flex;
    gap: 2px;
    border: 1px solid var(--line);
}

.lang button {
    font-size: 10px;
    letter-spacing: .1em;
    padding: 3px 7px;
    border: none;
    background: transparent;
    color: var(--muted);
}

.lang button:hover {
    background: var(--panel2);
    color: var(--gold);
}

.lang button.active {
    background: var(--gold);
    color: var(--deep);
}

.gate {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    z-index: 50;
}

.gate.open {
    display: flex;
}

.gate-box {
    width: min(360px, calc(100vw - 40px));
    border: 2px solid var(--gold);
    background: var(--panel);
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.gate-box .mark {
    width: 14px;
    height: 14px;
}

.gate-box h2 {
    margin: 4px 0 0;
    font-size: 18px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--goldlit);
}

.gate-box p {
    margin: 0;
    font-size: 12px;
}

.gate-box input {
    font: inherit;
    font-family: ui-monospace, Consolas, monospace;
    background: var(--deep);
    border: 1px solid var(--line);
    color: var(--text);
    padding: 8px 10px;
}

.gate-box input:focus {
    outline: none;
    border-color: var(--gold);
}

.gate-box button {
    align-self: flex-start;
}

.gate-error {
    color: var(--bad);
    min-height: 15px;
}

.gate-hint {
    font-size: 10px;
    letter-spacing: .1em;
    text-transform: uppercase;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }

    aside {
        max-height: 38vh;
        border-right: none;
        border-bottom: 1px solid var(--line);
    }

    .top {
        grid-template-columns: 1fr;
    }
}
