:root {
    --bg: #1c1814;
    --fg: #f4efe6;
    --card: #29241e;
    --muted: #c3b8a6;
    --line: rgba(196, 164, 112, 0.35);
    --gold: #e2c07a;
    --gold-ink: #2a2116;
    --damage: #e08a55;
    --heal: #7dcaa8;
    --taken: #e07a72;
    --shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
    font-family: Manrope, ui-sans-serif, system-ui, sans-serif;
    background: var(--bg);
    color: var(--fg);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(900px 420px at 8% -10%, rgba(180, 130, 60, 0.22), transparent 60%),
        radial-gradient(700px 380px at 110% 0%, rgba(140, 60, 30, 0.16), transparent 55%),
        var(--bg);
}

h1, h2, h3, .run-name, .drop-title {
    font-family: Literata, Georgia, serif;
    font-weight: 560;
}

a { color: inherit; }

.shell {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 4rem;
}

.topbar, .report-head, .actions, .meter-head, .events li, .death {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.topbar {
    font-size: 0.75rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--gold);
}
.topbar .button { letter-spacing: 0; text-transform: none; font-size: 0.9rem; }
.topbar-links { display: flex; align-items: center; gap: 1.75rem; }

.hero {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 2.5rem;
    align-items: start;
    margin-top: 2.5rem;
}
.hero-side { display: grid; gap: 1rem; align-content: start; }
.hero-side > .drop + .drop { margin-top: 0; }

.eyebrow {
    margin: 0;
    color: var(--gold);
    letter-spacing: 0.22em;
    text-transform: uppercase;
    font-family: Literata, Georgia, serif;
    font-size: 0.9rem;
}

.eyebrow.tight { letter-spacing: 0.18em; font-size: 0.75rem; }

h1 {
    margin: 0.6rem 0 0;
    font-size: clamp(3.2rem, 8vw, 5.4rem);
    line-height: 0.9;
}

.home-title {
    max-width: 11em;
    font-size: clamp(2.5rem, 6vw, 4.4rem);
    line-height: 0.98;
    text-wrap: balance;
}

.file-name { font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.15; }

.lead, .muted { color: var(--muted); line-height: 1.55; }

.steps, .facts {
    display: grid;
    gap: 1rem;
}

.steps { grid-template-columns: repeat(3, 1fr); margin: 2rem 0 0; padding: 0; list-style: none; }
.facts { grid-template-columns: repeat(3, 1fr); margin-top: 3.5rem; border: 1px solid var(--line); background: var(--line); }
.archive { margin-top: 3rem; }
.archive h2, .dungeon-head h2 { margin: 0; font-size: clamp(2rem, 4vw, 2.8rem); }
.dungeon-list, .log-list { display: grid; gap: 0.35rem; margin-top: 1rem; }
.dungeon-link, .log-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    color: inherit;
    text-decoration: none;
}
.dungeon-link:hover, .log-link:hover { border-color: var(--gold); }
.log-open { color: inherit; text-decoration: none; flex: 1 1 auto; min-width: 0; }
.log-link form { margin: 0; }
.rank-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-top: 1.6rem; }
.rank-grid article { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem 1rem 1rem; }
.rank-grid h3 { margin: 0; font-size: 1.35rem; }
.rank-grid ol { list-style: none; margin: 0.7rem 0 0; padding: 0; }
.rank-grid li { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.4rem 0; border-top: 1px solid var(--line); }
.dungeon-head { margin-top: 2rem; }
.dungeon-head > h1 { line-height: 1.15; margin-bottom: 0.9rem; }
.facts article { background: var(--card); padding: 1rem 1rem 1.2rem; }
.facts h2 { margin: 0; font-size: 1.25rem; }
.facts p, .steps p { margin: 0.5rem 0 0; font-size: 0.92rem; line-height: 1.5; }

.step-n { color: var(--gold); letter-spacing: 0.16em; font-size: 0.75rem; }
.steps li { border-top: 1px solid var(--line); padding-top: 0.75rem; }

.drop + .drop { margin-top: 1rem; }
.cabinet-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
    margin-top: 2rem;
}
.cabinet-pair > .drop { margin-top: 0; }
.cabinet-pair:has(> .drop:only-child) { grid-template-columns: 1fr; }
.cabinet-logs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    align-items: start;
    margin-top: 2rem;
}
.cabinet-logs > .dungeon-head { margin-top: 0; min-width: 0; }
.cabinet-logs h2 { font-size: clamp(1.55rem, 2.4vw, 2.1rem); }
.nick-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.nick-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.nick-actions { display: flex; align-items: center; gap: 0.35rem; }
.nick-actions form { margin: 0; }
.nick-actions .button { min-height: 2.1rem; padding: 0 0.7rem; }
.drop, .empty, dialog {
    background: rgba(41, 36, 30, 0.86);
    border: 1px dashed rgba(226, 192, 122, 0.45);
    border-radius: 14px;
    padding: 1.4rem 1.25rem 1.5rem;
}

.drop.is-hot, .drop.is-busy { border-color: var(--gold); background: rgba(226, 192, 122, 0.08); }
.drop.is-busy { border-style: solid; }
.drop.is-busy .button { opacity: 0.45; pointer-events: none; }
.upload-status {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--gold);
    border-radius: 8px;
    background: rgba(28, 24, 20, 0.45);
}
.spinner {
    width: 1.15rem;
    height: 1.15rem;
    flex: 0 0 auto;
    border: 2px solid rgba(226, 192, 122, 0.35);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.drop-title { margin: 0; font-size: 1.7rem; }
.empty { border-style: solid; margin-top: 2rem; }
.empty h2 { margin: 0; font-size: 2rem; }

.actions { margin-top: 1.2rem; flex-wrap: wrap; justify-content: flex-start; }
.hint { margin: 0.8rem 0 0; color: var(--muted); font-size: 0.8rem; }
.hint.event-link { margin-bottom: 1.5rem; }
.stack { display: grid; gap: 0.75rem; margin-top: 1rem; }
.field {
    width: 100%;
    box-sizing: border-box;
    min-height: 2.75rem;
    padding: 0 0.8rem;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #1c1814;
    color: var(--fg);
    font: inherit;
}
select.field {
    cursor: pointer;
    appearance: none;
    padding-right: 2.2rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='none' stroke='%23e2c07a' stroke-width='1.6' d='M1 1.2 6 6.2 11 1.2'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
}
textarea.field { min-height: 7rem; padding: 0.7rem 0.8rem; resize: vertical; }
.field-label { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.8rem; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.choice { display: flex; flex-wrap: wrap; gap: 1rem; }
.check { display: inline-flex; align-items: center; gap: 0.45rem; }
.event-cover {
    display: block;
    width: 100%;
    max-height: 320px;
    margin-top: 1.4rem;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--line);
}
.signup-list { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.35rem; }
.signup-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}
.signup-row form { margin: 0 0 0 auto; }
.signup-row .button { min-height: 2.1rem; padding: 0 0.7rem; }
.signup-row.is-cancelled {
    background: rgba(224, 122, 114, 0.18);
    border-color: var(--taken);
    color: var(--taken);
}
.signup-row.is-cancelled .badge,
.signup-row.is-cancelled .muted { color: var(--taken); }
.avatar { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.75rem;
    padding: 0 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: var(--gold);
    color: var(--gold-ink);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.button-ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.button-ghost.is-on { border-color: var(--gold); color: var(--gold); }
.file { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
label.button { position: relative; }

.alert { color: var(--taken); }
.status { color: var(--heal); margin: 0.8rem 0 0; }

.report-head { align-items: flex-end; flex-wrap: wrap; }
.topbar + .report-head { margin-top: 2rem; }
.create-event { margin-top: 2rem; }
.report-head > .actions { margin-left: auto; }
.report-head > form { margin: 0; }
.report-head.cabinet-head {
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    margin-top: 2rem;
}
.report-head.cabinet-head .avatar {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    flex: 0 0 80px;
}
.run-name { margin: 1.2rem 0 0; font-size: clamp(2.2rem, 5vw, 3.4rem); line-height: 1; }

.chips, .tabs { display: flex; gap: 0.5rem; overflow-x: auto; padding-bottom: 0.35rem; }
.chips { margin-top: 1.4rem; }
.pull-filter { margin-top: 0.85rem; }

.chip, .tab, .pull {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--fg);
    font: inherit;
    cursor: pointer;
    text-align: left;
}

.chip, .tab { flex: 0 0 auto; border-radius: 8px; min-height: 2.25rem; padding: 0 0.8rem; }
.chip.is-active, .tab.is-active, .pull.is-active { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); }

.pull {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-left-width: 4px;
    border-radius: 8px;
    padding: 0.4rem 0.7rem;
    white-space: normal;
}
.pull-portrait {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    object-fit: cover;
    background: #1c1814;
    border: 1px solid rgba(196, 164, 112, 0.45);
}
.pull-copy { flex: 1 1 auto; min-width: 0; }
.pull-name { display: block; overflow-wrap: anywhere; }
.pull-times {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.12rem;
    font-variant-numeric: tabular-nums;
}
.pull.is-active .muted { color: #4a3b24; }
.pull.outcome-kill { border-left-color: var(--heal); }
.pull.outcome-wipe { border-left-color: var(--taken); }
.pull.outcome-trash, .pull.outcome-reset { border-left-color: rgba(226, 192, 122, 0.55); }
.pull[hidden] { display: none; }
.pulls {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.35rem;
    width: 100%;
    max-width: 100%;
    margin-top: 1rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1px;
    margin: 1rem 0 0;
    padding: 0;
    background: var(--line);
    border: 1px solid var(--line);
    overflow: hidden;
}
.stats div { background: var(--card); padding: 0.75rem; }
.stats dt { margin: 0; color: var(--muted); font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; }
.stats dd { margin: 0.25rem 0 0; font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.tabs { margin-top: 1rem; }
.note, .stack, .meter, .events { margin-top: 0.8rem; }

.meter, .events {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
}
.meter details + details, .events li + li { border-top: 1px solid rgba(196, 164, 112, 0.22); }
.meter summary, .events li, .death {
    padding: 0.8rem 1rem;
    background: transparent;
}
.meter summary { cursor: pointer; list-style: none; }
.meter summary::-webkit-details-marker { display: none; }
.meter summary:hover, .death:hover { background: rgba(255, 255, 255, 0.03); }
.meter-name, .badge, .player-name { display: inline-flex; align-items: center; gap: 0.45rem; }
.player-name { vertical-align: middle; }
.class-icon {
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 3px;
    object-fit: cover;
    flex: 0 0 auto;
}
#death-title { display: flex; align-items: center; gap: 0.45rem; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.72rem; color: var(--muted); }
.bar { display: block; height: 0.4rem; margin-top: 0.45rem; background: #3a342c; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; }
.bar-damage { background: var(--damage); }
.bar-heal { background: var(--heal); }
.bar-taken { background: var(--taken); }
.meter-body { padding: 0.2rem 1rem 1rem; border-top: 1px solid rgba(196, 164, 112, 0.2); }

.events { list-style: none; margin-left: 0; padding: 0; }
.events li { align-items: flex-start; }
.death { width: 100%; border: 0; color: inherit; font: inherit; cursor: pointer; }
.block { display: block; }
.small { font-size: 0.78rem; }
.nums { font-variant-numeric: tabular-nums; }
.heal { color: var(--heal); }
.taken { color: var(--taken); }
.foot { margin-top: 1.5rem; }

.table-title { margin: 0.4rem 0; color: var(--muted); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem; font-family: Manrope, sans-serif; }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 32rem; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; color: var(--muted); font-weight: 400; font-size: 0.75rem; }
td, th { padding: 0.35rem 0.4rem; }
tbody tr { border-top: 1px solid rgba(196, 164, 112, 0.2); }
.num { text-align: right; }
.dot { display: inline-block; width: 0.45rem; height: 0.45rem; border-radius: 999px; margin-right: 0.35rem; vertical-align: middle; }
.tone-fire { background: var(--damage); }
.tone-frost { background: #9fd4ef; }
.tone-nature { background: var(--heal); }
.tone-shadow { background: #c4b3ef; }
.tone-arcane { background: var(--gold); }
.tone-holy { background: #f3e2b0; }
.tone-physical { background: rgba(232, 224, 212, 0.8); }

dialog {
    width: min(34rem, calc(100% - 2rem));
    border-style: solid;
    color: var(--fg);
    box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h3 { margin: 0; font-size: 1.7rem; }
#death-events { list-style: none; padding: 0; margin: 1rem 0; max-height: 20rem; overflow: auto; }
#death-events li { display: grid; grid-template-columns: 4.5rem 1fr auto; gap: 0.75rem; margin-bottom: 0.55rem; }

[hidden] { display: none !important; }

@media (max-width: 860px) {
    .hero, .steps, .facts, .stats, .rank-grid, .cabinet-pair, .cabinet-logs, .field-row { grid-template-columns: 1fr; }
    .stats { grid-template-columns: 1fr 1fr; }
    .wide { display: none; }
    .shell { width: min(1120px, calc(100% - 1.25rem)); }
}
