/* ===== Design tokens ===== */
:root {
    --bg: #0a0a0b;
    --surface: #161618;
    --surface-2: #1d1d20;
    --border: rgba(255, 255, 255, 0.08);
    --text: #f3f3ef;
    --text-muted: #9a9a9f;
    --accent: #e32311;
    --accent-soft: rgba(227, 35, 17, 0.16);
    /* Textton des Akzents, kein zweiter Akzent: Stufe 7 der Level-10-
       Tonleiter, gleiche Farbe, nur heller. Der volle Akzent erreicht als
       Text auf diesen dunklen Flächen nur 4,25:1 und fällt damit unter AA;
       dieser Ton trägt 5,3 bis 6,3:1. Flächen bleiben --accent. */
    --accent-text: #f0644f;

    --font-display: 'Press Start 2P', cursive;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Consolas, monospace;

    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: dark;
    /* Die Teile, die der Browser stellt, gehören auch zum Entwurf: ohne das
       bringt jede Seite hier Systemvorgaben mit, die zu keinem Designsystem
       gehören. Scrollleiste, Markierung, Cursor und Formularhaken laufen
       deshalb über die Palette. */
    scrollbar-color: var(--surface-2) var(--bg);
    accent-color: var(--accent);
}

::selection {
    background: var(--accent-soft);
    color: var(--text);
}

::-webkit-scrollbar {
    width: 11px;
    height: 11px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-2);
    border-radius: 999px;
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
    background: #34343a;
}

html, body {
    max-width: 100%;
    color: var(--text);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* body (not html) carries the base color: on mobile, overscroll/rubber-band
   bounce past the top or bottom of the page paints in the *canvas* color,
   which the spec takes from html if it has one, else propagates up from
   body. Giving html its own background-color promotes IT to canvas — which
   paints below *everything*, hiding a z-index:-1 fixed child of body no
   matter the opacity (confirmed live) — so html deliberately has none here.
   Leaving body with a color lets its background propagate to canvas for the
   overscroll case, without the hide-my-own-sibling problem html caused. */
body {
    background-color: var(--bg);
}

/* Ambient glow, same colors as the static version before it — just drifting
   very slowly so it reads as alive without pulling attention from the page. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    contain: strict;
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 15% 0%, rgba(227, 35, 17, 0.16), transparent 45%),
        radial-gradient(circle at 85% 20%, rgba(255, 100, 7, 0.11), transparent 40%);
    animation: ambient-drift 26s ease-in-out infinite alternate;
    will-change: transform;
}

@keyframes ambient-drift {
    /* scale stays constant (not animated) so it always provides a fixed
       overscan margin comfortably larger than the translate distance below —
       otherwise the moving box can briefly expose a real edge outside the
       viewport (seen live as a white strip, since html/body have no
       background-color of their own to show through instead). */
    from {
        transform: scale(1.08) translate(0, 0);
    }
    to {
        transform: scale(1.08) translate(1%, 1.5%);
    }
}

@media (prefers-reduced-motion: reduce) {
    body::before,
    .skeleton-row td::before {
        animation: none;
    }
}

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 20px 60px;
}

/* ===== Header ===== */
.back-link {
    display: inline-block;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 0;
    transition: color 0.2s ease, transform 0.2s ease;
}

.back-link:hover,
.back-link:focus-visible {
    color: var(--text);
    transform: translateX(-3px);
}

.page-header {
    margin: 18px 0 28px;
}

.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 4vw, 2.2rem);
    line-height: 1.5;
    letter-spacing: 1px;
    margin: 0 0 12px;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.6);
}

.page-sub {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
    max-width: 60ch;
}

/* ===== Top player banner ===== */
.top-player {
    display: flex;
    align-items: center;
    gap: 16px;
    background: linear-gradient(135deg, var(--surface-2), var(--surface));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    margin-bottom: 24px;
    box-shadow: 0 8px 24px rgba(227, 35, 17, 0.08);
}

.top-player-crown {
    width: 26px;
    height: 26px;
    color: #ffcc33;
    filter: drop-shadow(0 0 8px rgba(255, 204, 51, 0.45));
    flex-shrink: 0;
}

.top-player-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.top-player-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
}

.top-player-name {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
    font-size: 1.05rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-player-name:hover,
.top-player-name:focus-visible {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.top-player-elo {
    font-family: var(--font-display);
    font-size: clamp(1.1rem, 3vw, 1.6rem);
    color: var(--accent-text);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

/* ===== Error banner ===== */
.error-banner[hidden] {
    display: none;
}

.error-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(227, 35, 17, 0.12);
    border: 1px solid rgba(227, 35, 17, 0.4);
    color: #ffb4a8;
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: 24px;
    font-size: 0.9rem;
}

.error-banner button {
    flex-shrink: 0;
}

/* ===== Cards ===== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    margin-bottom: 20px;
}

.card h2 {
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin: 0 0 14px;
    color: var(--text);
}

.card-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: -8px 0 16px;
}

.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.card-header h2 {
    margin: 0;
}

.grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 20px;
    align-items: start;
}

.grid > section,
.card {
    /* Grid/flex items default to min-width: auto, which lets wide content
       (like the table) force this card wider than its track and break the
       page layout. min-width: 0 lets it shrink and scroll internally instead. */
    min-width: 0;
}

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

/* ===== Buttons ===== */
button {
    font-family: var(--font-mono);
    display: inline-block;
    padding: 8px 14px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
}

button:hover {
    border-color: var(--accent);
    background-color: var(--accent-soft);
}

button:active {
    transform: scale(0.97);
}

button:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 3px;
    gap: 3px;
}

.segmented button {
    border: none;
    border-radius: 6px;
    padding: 7px 12px;
}

.segmented button:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

.segmented button.active {
    background-color: var(--accent);
    color: #fff;
}

.segmented button.active:hover {
    background-color: var(--accent);
}

.metric-toggle {
    margin-bottom: 16px;
}

/* ===== Chart ===== */
.chart-wrap {
    position: relative;
    height: min(50vh, 420px);
}

.chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 0 20px;
}

.chart-empty[hidden] {
    display: none;
}

/* ===== Table / leaderboard ===== */
.table-wrap {
    overflow-x: auto;
}

#maxelotable {
    width: 100%;
    min-width: 320px;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 0.88rem;
}

#maxelotable th:nth-child(1),
#maxelotable td:nth-child(1) {
    width: 32px;
}

#maxelotable th:nth-child(3),
#maxelotable td:nth-child(3) {
    width: 62px;
}

#maxelotable th:nth-child(4),
#maxelotable td:nth-child(4) {
    width: 56px;
}

#maxelotable th:nth-child(5),
#maxelotable td:nth-child(5) {
    width: 60px;
}

#maxelotable th:nth-child(6),
#maxelotable td:nth-child(6) {
    width: 66px;
}

#maxelotable th,
#maxelotable td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

#maxelotable td:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
}

#maxelotable th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    touch-action: manipulation;
}

#maxelotable th[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

#maxelotable th:hover {
    color: var(--text);
}

#maxelotable td.col-elo,
#maxelotable td.col-peak,
#maxelotable td.col-premier {
    font-variant-numeric: tabular-nums;
}

#maxelotable tbody tr {
    transition: background-color 0.15s ease;
}

#maxelotable tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

#maxelotable tbody tr.rank-1 { background-color: rgba(255, 204, 51, 0.06); }
#maxelotable tbody tr.rank-last { background-color: rgba(227, 35, 17, 0.05); }

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    color: var(--text-muted);
    font-size: 0.82rem;
}

.player-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.player-link:hover,
.player-link:focus-visible {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.level-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    /* Rückfall, falls das Skript nicht läuft. Im Normalfall setzt
       readableOn() in charts.js die Farbe passend zur Rangstufe. */
    color: var(--bg);
}

.col-peak {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.col-premier {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.sorted-asc::after {
    content: " ▲";
    color: var(--accent-text);
}

.sorted-desc::after {
    content: " ▼";
    color: var(--accent-text);
}

.skeleton-row td {
    height: 38px;
    padding: 6px 12px;
}

.skeleton-row td::before {
    content: "";
    display: block;
    height: 14px;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--surface-2) 25%, rgba(255, 255, 255, 0.06) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* ===== Prey / hunt section ===== */
.prey-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 10px;
    margin-bottom: 14px;
}

.prey-controls label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

#prey-select {
    padding: 8px 10px;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    border: 1px solid var(--border);
    background-color: var(--surface-2);
    color: var(--text);
    border-radius: 8px;
    min-width: 200px;
}

/* Only the border reacts to plain :focus (mouse click); the outline ring
   itself is intentionally left to the shared select:focus-visible rule
   above so keyboard focus still gets a visible ring instead of none. */
#prey-select:focus {
    border-color: var(--accent);
}

.hunt-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hunt-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 8px 10px;
    background: var(--surface-2);
    border-radius: 8px;
}

/* Gezeichnetes Fadenkreuz statt des Emojis, das vorher hier stand: ein
   Emoji rendert je nach System anders und gehört zu keinem Icon-Satz.
   Als Maske, damit die Farbe aus der Palette kommt. */
.hunt-list li::before {
    content: "";
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    background-color: var(--accent-text);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 1v3M12 20v3M1 12h3M20 12h3'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 1v3M12 20v3M1 12h3M20 12h3'/%3E%3C/svg%3E") center / contain no-repeat;
}

.hunt-list .empty {
    color: var(--text-muted);
    background: transparent;
    padding: 8px 10px 0;
}

.hunt-list .empty::before {
    content: "";
}

/* ===== Footer note ===== */
.support-note {
    margin-top: 32px;
    font-size: 0.8rem;
}

.support-note + .support-note {
    margin-top: 6px;
}

.support-note a {
    color: var(--text-muted);
}

.support-note a:hover {
    color: var(--accent-text);
}

/* Override the light footer from main.html so it stays readable on this dark page */
body .footer-links ul li a {
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

body .footer-links ul li a:hover {
    color: var(--accent-text);
}

/* Die Jagd-Karte ist im Ruhezustand rund ein Fünftel so hoch wie die
   Tabelle daneben. Sticky hält sie im Blick, während man die Tabelle
   durchscrollt, statt sie oben allein stehen zu lassen. */
@media (min-width: 801px) {
    .grid > section:last-child {
        position: sticky;
        top: 20px;
    }
}

/* Auf dem Handy - laut PRODUCT.md der Normalfall - sind die Schalter sonst
   30px hoch. Nur für grobe Zeiger, damit die Dichte am Desktop bleibt. */
@media (pointer: coarse) {
    .segmented button {
        min-height: 44px;
    }

    .back-link {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }
}

@media (max-width: 767px) {
    .top-player {
        flex-wrap: wrap;
    }

    .top-player-elo {
        flex-basis: 100%;
        text-align: right;
    }

    .card-header {
        align-items: stretch;
    }

    .segmented {
        width: 100%;
    }

    .segmented button {
        flex: 1;
    }

    .prey-controls {
        align-items: stretch;
    }

    .prey-controls > label {
        width: 100%;
    }

    #prey-select {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .page {
        padding: 16px 14px 48px;
    }

    .card {
        padding: 16px;
    }

    .top-player {
        padding: 14px 16px;
    }

    .page-title {
        line-height: 1.6;
    }

    .segmented button {
        padding: 8px 6px;
        font-size: 0.68rem;
    }

    #maxelotable {
        font-size: 0.8rem;
    }

    #maxelotable th,
    #maxelotable td {
        padding: 9px 6px;
    }

    #maxelotable th {
        font-size: 0.64rem;
    }

    #maxelotable {
        min-width: 0;
    }

    #maxelotable th:nth-child(1),
    #maxelotable td:nth-child(1) {
        width: 22px;
    }

    #maxelotable th:nth-child(3),
    #maxelotable td:nth-child(3) {
        width: 46px;
    }

    #maxelotable th:nth-child(4),
    #maxelotable td:nth-child(4) {
        width: 38px;
    }

    #maxelotable th:nth-child(5),
    #maxelotable td:nth-child(5) {
        width: 38px;
    }

    #maxelotable th:nth-child(6),
    #maxelotable td:nth-child(6) {
        width: 48px;
    }

    .level-badge {
        min-width: 20px;
        height: 20px;
        padding: 0 4px;
        font-size: 0.68rem;
    }
}
