:root {
    --bg: #14161a;
    --surface: #1e2229;
    --surface-2: #272c35;
    --text: #e8eaed;
    --muted: #9aa3af;
    --accent: #6ea8fe;
    --ok: #5cb85c;
    --warn: #e0a800;
    --error: #e35d6a;
    --radius: 10px;

    /* Meldet dem Browser das dunkle Layout an, damit alles, was er selbst
       zeichnet, dazu passt: die Auswahlraeder der select-Felder, der
       Datumswaehler, Bildlaufleisten. Ohne diese Zeile kommen die hell. */
    color-scheme: dark;
}

* { box-sizing: border-box; }

/* Elemente mit display-Regel (etwa button) ignorieren sonst das hidden-Attribut. */
[hidden] { display: none !important; }

body {
    margin: 0;
    padding: 1rem;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

a { color: var(--accent); }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }

.topbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.topbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
}

.status { font-size: .9rem; color: var(--muted); }
.status--ok::before { content: "● "; color: var(--ok); }
.status--warn::before { content: "● "; color: var(--warn); }

.message {
    padding: .6rem .8rem;
    border-radius: var(--radius);
    margin: 0 0 1rem;
}
.message--ok    { background: #1d3b25; color: #b7e4c7; }
.message--warn  { background: #3d3418; color: #ffe8a3; }
.message--error { background: #40232a; color: #ffc9d0; }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1rem;
}
.filters a {
    padding: .3rem .7rem;
    border-radius: 999px;
    background: var(--surface);
    text-decoration: none;
    font-size: .85rem;
}
.filters a.is-active { background: var(--accent); color: #10131a; }

.games { display: grid; gap: .6rem; }

.game {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: .8rem;
    align-items: center;
    padding: .7rem;
    background: var(--surface);
    border-radius: var(--radius);
}
.game--error { outline: 1px solid var(--error); }

.game__cover {
    width: 48px;
    height: 64px;
    object-fit: cover;
    border-radius: 6px;
    background: var(--surface-2);
}
.game__cover--empty { display: block; }

.game__info { min-width: 0; }
.game__title { font-weight: 600; overflow-wrap: anywhere; }
.game__meta { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }

.badge {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    background: var(--surface-2);
    color: var(--muted);
}
.badge--exact { background: #22384f; color: #cbe3ff; }
.badge--cancelled { text-decoration: line-through; }
.badge--bought { background: #1f3d2b; color: #c6f0d4; }

.game__right { text-align: right; display: grid; gap: .3rem; justify-items: end; }

.empty { color: var(--muted); padding: 2rem 0; text-align: center; }

button, .button {
    display: inline-flex;
    align-items: center;
    font: inherit;
    padding: .45rem .9rem;
    border: 0;
    border-radius: var(--radius);
    background: var(--accent);
    color: #10131a;
    cursor: pointer;
    text-decoration: none;
}
.button--quiet { background: var(--surface-2); color: var(--text); }
.button--danger { background: #40232a; color: #ffc9d0; }
button:disabled { opacity: .5; cursor: not-allowed; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-form {
    display: grid;
    gap: .6rem;
    width: min(320px, 90vw);
    padding: 1.5rem;
    background: var(--surface);
    border-radius: var(--radius);
}
.login-form__password { display: grid; gap: .6rem; }
.login-divider {
    margin: .4rem 0 0;
    text-align: center;
    font-size: .9rem;
    color: var(--muted);
}
.login-hint { margin: 0; font-size: .9rem; color: var(--muted); }
.login-form input {
    font: inherit;
    padding: .5rem;
    border-radius: var(--radius);
    border: 1px solid var(--surface-2);
    background: var(--bg);
    color: var(--text);
}

.passkey-offer {
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
}
.passkey-offer h2 { font-size: 1.1rem; margin: 0 0 .4rem; }
.passkey-offer p { margin: 0 0 .8rem; color: var(--muted); }
.passkey-offer__actions { display: flex; flex-wrap: wrap; gap: .5rem; }

.passkey-intro { color: var(--muted); max-width: 60ch; }
.passkey-list { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.passkey {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
}
.passkey form { margin: 0; }
.passkey__name { font-weight: 600; }
.passkey__meta { font-size: .85rem; color: var(--muted); }

@media (max-width: 480px) {
    .game { grid-template-columns: 40px 1fr; }
    .game__right { grid-column: 1 / -1; justify-items: start; text-align: left; }

    .topbar {
        flex-direction: column;
        align-items: stretch;
        gap: .5rem;
    }

    /* Statuszeile steht über den Buttons statt daneben. */
    .topbar__actions .status { flex-basis: 100%; }
}

.form {
    display: grid;
    gap: .8rem;
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}
.form__grid {
    display: grid;
    gap: .8rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.form label { display: grid; gap: .25rem; font-size: .85rem; color: var(--muted); }
.form label[hidden] { display: none; }
.form input, .form select, .form textarea {
    font: inherit;
    padding: .45rem;
    border-radius: var(--radius);
    border: 1px solid var(--surface-2);
    background: var(--bg);
    color: var(--text);
    width: 100%;
}

.form textarea { min-height: 4.5rem; resize: vertical; }
.form__actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.field-error { color: var(--error); font-size: .8rem; }
.history { font-size: .8rem; color: var(--muted); }
.history li { margin-bottom: .2rem; }
.inline-form { display: inline; }
.link-button {
    background: none;
    border: 0;
    color: var(--accent);
    font: inherit;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
}

.form-panel {
    background: var(--surface);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.form-panel__summary {
    padding: .8rem 1rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius);
    /* Eigenes Dreieck statt des Browser-Markers, damit die Zeile in beiden
       Zustaenden gleich aussieht. */
    list-style: none;
}

.form-panel__summary::-webkit-details-marker { display: none; }

.form-panel__summary::before {
    content: "＋ ";
    color: var(--muted);
}

.form-panel[open] .form-panel__summary::before { content: "－ "; }

.form-panel[open] .form-panel__summary {
    border-bottom: 1px solid var(--surface-2);
    border-radius: var(--radius) var(--radius) 0 0;
}

.form-panel .form {
    background: transparent;
    margin-bottom: 0;
    border-radius: 0 0 var(--radius) var(--radius);
}

.igdb {
    display: grid;
    gap: .35rem;
    padding: .8rem;
    background: var(--surface-2);
    border-radius: var(--radius);
}

.igdb label { font-size: .85rem; color: var(--muted); }

.igdb input {
    font: inherit;
    padding: .45rem;
    border-radius: var(--radius);
    border: 1px solid var(--surface);
    background: var(--bg);
    color: var(--text);
    width: 100%;
}

.igdb__hint { margin: 0; font-size: .8rem; color: var(--muted); }

.igdb__results { display: grid; gap: .35rem; }

.igdb__hit {
    display: flex;
    gap: .6rem;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: .4rem;
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius);
    cursor: pointer;
}

.igdb__hit:hover { background: var(--bg); }

.igdb__hit img {
    width: 34px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    flex: none;
}

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

.igdb__wahl {
    display: flex;
    flex-wrap: wrap;
    gap: .3rem;
    padding: 0 .4rem .2rem 3.1rem;
}

.igdb__fassung {
    font: inherit;
    font-size: .8rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--accent);
    cursor: pointer;
}

.igdb__fassung:hover { background: var(--bg); }

@media (max-width: 480px) {
    .igdb__wahl { padding-left: .4rem; }
}
