:root {
    color-scheme: dark;
    --background: #090a0d;
    --surface: rgba(19, 21, 27, 0.92);
    --border: rgba(215, 176, 92, 0.22);
    --gold: #d7b05c;
    --gold-light: #f5dd9a;
    --text: #f4f0e8;
    --muted: #9b9da5;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 12% 15%, rgba(133, 26, 24, 0.22), transparent 32rem),
        radial-gradient(circle at 82% 82%, rgba(215, 176, 92, 0.10), transparent 26rem),
        var(--background);
}

body::before {
    position: fixed;
    inset: 0;
    pointer-events: none;
    content: "";
    opacity: 0.16;
    background-image: linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
    background-size: 44px 44px;
}

.page {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 520px);
    gap: clamp(3rem, 8vw, 8rem);
    align-items: center;
    width: min(1180px, calc(100% - 40px));
    min-height: 100vh;
    margin: auto;
    padding: 60px 0;
}

.hero h1 {
    max-width: 700px;
    margin: 12px 0 20px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(3rem, 7vw, 6.5rem);
    font-weight: 500;
    line-height: .93;
    letter-spacing: -.055em;
}

.hero > p:not(.eyebrow) {
    max-width: 560px;
    color: var(--muted);
    font-size: 1.15rem;
}

.eyebrow {
    margin: 0;
    color: var(--gold);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .24em;
    text-transform: uppercase;
}

.status {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    margin-top: 26px;
    color: #c6c7cc;
    font-size: .88rem;
}

.status span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d89942;
    box-shadow: 0 0 16px #d89942;
}

.download {
    display: inline-block;
    margin-top: 24px;
    padding: 13px 20px;
    border: 1px solid var(--gold);
    border-radius: 3px;
    color: var(--gold-light);
    font-size: .86rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-decoration: none;
    text-transform: uppercase;
}

.download:hover { background: rgba(215, 176, 92, .1); }
.download-disabled {
    cursor: not-allowed;
    border-color: #555861;
    color: #9699a2;
}
.download-disabled:hover { background: transparent; }

.account-link {
    display: inline-block;
    margin-left: 12px;
    color: #d8d8dc;
    font-size: .86rem;
    font-weight: 700;
    text-decoration: none;
}

.account-link:hover { color: var(--gold-light); }

.checksum {
    max-width: 620px;
    color: #777a82;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: .68rem;
    overflow-wrap: anywhere;
}

.card {
    padding: clamp(26px, 5vw, 44px);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    box-shadow: 0 36px 90px rgba(0,0,0,.42);
    backdrop-filter: blur(16px);
}

.card h2 {
    margin: 8px 0 6px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 2.1rem;
    font-weight: 500;
}

.muted {
    margin-top: 0;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1.55;
}

form { margin-top: 28px; }

label {
    display: block;
    margin-bottom: 16px;
    color: #d9d7d1;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
}

input {
    display: block;
    width: 100%;
    margin-top: 7px;
    padding: 13px 14px;
    border: 1px solid #30333a;
    border-radius: 3px;
    outline: none;
    color: var(--text);
    background: #0d0f13;
    font: inherit;
    transition: border-color .2s, box-shadow .2s;
}

input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(215, 176, 92, .11);
}

.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

button {
    width: 100%;
    margin-top: 8px;
    padding: 15px;
    border: 1px solid #e1c273;
    border-radius: 3px;
    color: #15120b;
    background: linear-gradient(135deg, var(--gold-light), var(--gold));
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

button:hover { filter: brightness(1.08); }
button:disabled {
    cursor: not-allowed;
    filter: grayscale(.55);
    opacity: .62;
}

.notice {
    margin: 20px 0;
    padding: 12px 14px;
    border: 1px solid;
    border-radius: 3px;
    font-size: .86rem;
}

.notice p { margin: 3px 0; }
.success { border-color: #386c4b; color: #b8e0c4; background: #102419; }
.error { border-color: #743b3b; color: #f0bbbb; background: #291313; }
.waiting { border-color: #66552d; color: #e8d49c; background: #241e10; }

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.auth-card { width: min(440px, 100%); }
.auth-card h1 { margin: 8px 0; font-family: Georgia, serif; font-size: 2.6rem; }

.form-links {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.form-links a, .topbar a, .small-action {
    color: var(--gold-light);
    text-decoration: none;
}

.topbar {
    position: sticky;
    z-index: 10;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 64px;
    padding: 0 max(24px, calc((100vw - 1180px) / 2));
    border-bottom: 1px solid var(--border);
    background: rgba(9, 10, 13, .92);
    backdrop-filter: blur(14px);
}

.topbar .brand {
    color: var(--text);
    font-family: Georgia, serif;
    font-size: 1.2rem;
}

.topbar nav {
    display: flex;
    gap: 22px;
    align-items: center;
}

.topbar nav form { margin: 0; }

.link-button {
    width: auto;
    margin: 0;
    padding: 0;
    border: 0;
    color: var(--gold-light);
    background: none;
    font-weight: 600;
}

.panel-shell, .admin-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 54px 0 80px;
}

.panel-heading { margin-bottom: 32px; }
.panel-heading h1 { margin: 8px 0; font-family: Georgia, serif; font-size: clamp(2.2rem, 5vw, 4rem); }

.character-grid, .equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
    gap: 18px;
}

.character-card, .admin-card, .equipment-card, .empty-state {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface);
}

.character-card h2, .admin-card h2, .equipment-card h3 { margin: 8px 0 18px; }

.character-card dl {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 0;
}

.character-card dl div {
    padding: 10px;
    border: 1px solid #282b31;
    background: #0d0f13;
}

.character-card dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.character-card dd { margin: 4px 0 0; font-size: 1.25rem; }

.admin-grid { display: grid; gap: 22px; }
.admin-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid #292c32; text-align: left; font-size: .84rem; }
th { color: var(--gold); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }

.inline-form, .create-character, .stats-form {
    display: flex;
    gap: 10px;
    align-items: end;
}

.inline-form { margin: 0 0 20px; }
.inline-form input { margin: 0; }
.inline-form button, .create-character button, .stats-form button { width: auto; white-space: nowrap; }
.create-character { min-width: 470px; margin: 0; }
.create-character input, .create-character select { margin: 0; }

select {
    display: block;
    width: 100%;
    margin-top: 7px;
    padding: 13px 14px;
    border: 1px solid #30333a;
    border-radius: 3px;
    color: var(--text);
    background: #0d0f13;
    font: inherit;
}

.stats-form { flex-wrap: wrap; }
.stats-form label { flex: 1 1 160px; margin: 0; }
.equipment-grid { margin-top: 22px; }
.equipment-card { margin: 0; }

.check-row { display: flex; gap: 20px; margin: 4px 0 16px; }
.check-row label { display: flex; gap: 8px; align-items: center; margin: 0; }
.check-row input { display: inline; width: auto; margin: 0; }
.small-action { white-space: nowrap; font-weight: 700; }

@media (max-width: 840px) {
    .page { grid-template-columns: 1fr; gap: 44px; }
    .hero h1 { font-size: clamp(3rem, 14vw, 5rem); }
    .topbar { padding: 0 16px; }
    .create-character { min-width: 650px; }
}

@media (max-width: 500px) {
    .page { width: min(100% - 24px, 1180px); padding: 34px 0; }
    .two-columns { grid-template-columns: 1fr; gap: 0; }
}
