/* Interactive boss death counter + printable A4/Letter tally sheets. */
.boss-death-counter-page {
    --bdc-ink: #c8323c;
    --bdc-ink-deep: #9c1f27;
    --bdc-tint: #fcdede;
    --tool-peek-bg: #c8323c;
}

.bdc-container { max-width: 820px; margin: auto; padding: 64px 24px; }
.bdc-title { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.12; text-wrap: balance; margin: 0 0 20px; }
.bdc-lede { font-size: 1.1rem; line-height: 1.7; max-width: 690px; margin-bottom: 30px; text-wrap: pretty; }

.bdc-form { display: grid; gap: 22px; padding-block: 12px 20px; }
.bdc-field { border: 0; padding: 0; margin: 0; min-width: 0; }
.bdc-field[hidden] { display: none; }
.bdc-field legend { font-weight: 700; margin-bottom: 12px; }
.bdc-options { display: flex; flex-wrap: wrap; gap: 10px; }
.bdc-options input { position: absolute; opacity: 0; }
.bdc-options label {
    display: flex; align-items: center; gap: 8px; min-height: 44px;
    padding: 10px 16px; border-radius: 12px; background: #fff;
    box-shadow: 0 1px 4px rgb(0 0 0 / .08); cursor: pointer;
}
.bdc-options input:checked + label { background: var(--bdc-ink); color: #fff; }
.bdc-options input:focus-visible + label { outline: 2px solid var(--bdc-ink); outline-offset: 3px; }

.bdc-details { display: grid; grid-template-columns: 1.25fr 1fr; gap: 14px; }
.bdc-detail { display: grid; gap: 7px; min-width: 0; }
.bdc-detail label { font-size: .85rem; }
.bdc-detail input {
    box-sizing: border-box; width: 100%; min-width: 0; min-height: 44px;
    padding: 10px 12px; border: 1px solid #ccc; border-radius: 10px;
    background: #fff; color: #222; font: inherit;
}
.bdc-detail input:focus-visible { outline: 2px solid var(--bdc-ink); outline-offset: 2px; }

/* Prevent toolkit's fieldset label counter from repeating inside text-input groups. */
.boss-death-counter-page .tk-app .tk-q .bdc-detail label::before {
    content: none !important;
    counter-increment: none;
}

.bdc-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.bdc-presets[hidden] { display: none; }
.bdc-preset-label { font-size: .78rem; color: #666; margin-right: 4px; }
.bdc-preset-btn {
    min-height: 34px; padding: 5px 11px; border: 1px solid #e3bcbc;
    border-radius: 999px; background: #fff; color: #222;
    font: inherit; font-size: .8rem; cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.bdc-preset-btn:hover { background: #fff4f4; border-color: var(--bdc-ink); }
.bdc-preset-btn.is-active { background: var(--bdc-tint); border-color: var(--bdc-ink); font-weight: 700; color: var(--bdc-ink-deep); }
.bdc-preset-btn:focus-visible { outline: 2px solid var(--bdc-ink); outline-offset: 2px; }

.bdc-result-label { text-transform: uppercase; font-size: .75rem; letter-spacing: .1em; }
.bdc-result-headline { font-size: 1.8rem; font-weight: 700; margin: 8px 0 10px; overflow-wrap: anywhere; }
.bdc-result-body { line-height: 1.6; margin: 0 0 18px; }

/* ----------------------------------------------------------- live deck UI */
.bdc-deck {
    background: #fff;
    border: 1px solid #ead8d8;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 24px rgb(0 0 0 / .04);
}
.bdc-deck-top {
    display: flex;
    flex-wrap: wrap;
    gap: 18px 24px;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 18px;
    border-bottom: 1px solid #f0e4e4;
}
.bdc-score {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}
.bdc-count {
    font-size: clamp(2.8rem, 6vw, 4rem);
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--bdc-ink);
}
.bdc-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: #fff1f1;
    color: var(--bdc-ink-deep);
    border: 1px solid #f0c2c4;
}
.bdc-status.is-victory {
    background: #eaf7ee;
    color: #1f6b3a;
    border-color: #b7dfc4;
}
.bdc-gates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: center;
    min-height: 34px;
}
.bdc-gates-empty { font-size: .84rem; color: #666; font-style: italic; }
.bdc-gates-more {
    font-size: .78rem; font-weight: 700; color: var(--bdc-ink-deep);
    padding: 3px 8px; border-radius: 999px; background: #fff4f4;
}

.bdc-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}
.bdc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 10px 18px;
    border-radius: 12px;
    border: 1px solid #d7d7dc;
    background: #fff;
    color: #222;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.bdc-btn:hover:not(:disabled) { background: #f8f8fa; border-color: #b8b8c0; }
.bdc-btn:active:not(:disabled) { transform: scale(.97); }
.bdc-btn:disabled { opacity: .45; cursor: not-allowed; }
.bdc-btn:focus-visible { outline: 2px solid var(--bdc-ink); outline-offset: 2px; }

.bdc-btn-death {
    flex: 1 1 180px;
    min-height: 52px;
    border: 0;
    background: var(--bdc-ink);
    color: #fff;
    font-size: 1.05rem;
}
.bdc-btn-death:hover:not(:disabled) { background: var(--bdc-ink-deep); }
.bdc-btn-death kbd {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 6px;
    background: rgb(255 255 255 / .22);
    font: 700 .8rem/1.4 monospace;
}

.bdc-btn-victory {
    border-color: #b7dfc4;
    background: #f3fbf5;
    color: #1f6b3a;
}
.bdc-btn-victory:hover:not(:disabled) { background: #e5f6ea; border-color: #84c598; }

.bdc-deck-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    align-items: center;
    justify-content: space-between;
    margin-top: 14px;
    font-size: .83rem;
    color: #555;
}
.bdc-sub-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bdc-mini-btn {
    min-height: 36px;
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid #dcdce0;
    background: #fafafa;
    color: #222;
    font: inherit;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
}
.bdc-mini-btn:hover { background: #f1f1f4; }
.bdc-mini-btn:focus-visible { outline: 2px solid var(--bdc-ink); outline-offset: 2px; }
.bdc-copy-status { font-size: .8rem; font-weight: 600; color: #1f6b3a; }

/* ----------------------------------------------------- saved boss roster */
.bdc-roster {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #f0e4e4;
}
.bdc-roster-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: .84rem;
    font-weight: 700;
}
.bdc-roster-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}
.bdc-roster-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid #e6dada;
    background: #fffafa;
}
.bdc-roster-item.is-current {
    border-color: var(--bdc-ink);
    background: #fff2f2;
}
.bdc-roster-pick {
    flex: 1;
    min-width: 0;
    border: 0;
    background: transparent;
    padding: 0;
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    display: grid;
    gap: 2px;
}
.bdc-roster-pick strong {
    font-size: .88rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bdc-roster-pick small { font-size: .75rem; color: #555; }
.bdc-roster-count {
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    font-size: .95rem;
    color: var(--bdc-ink-deep);
}
.bdc-roster-count.is-victory { color: #1f6b3a; }
.bdc-roster-del {
    border: 0;
    background: transparent;
    color: #777;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    font: 700 1rem/1 sans-serif;
    cursor: pointer;
}
.bdc-roster-del:hover { background: #f2dede; color: #222; }

/* ----------------------------------------------------- printable sheet UI */
.bdc-print-actions { display: flex; gap: 18px; align-items: center; margin: 16px 0 24px; }
.bdc-print-actions button {
    flex-shrink: 0; min-height: 48px; padding: 12px 20px; border: 0;
    border-radius: 14px; background: var(--bdc-ink); color: #fff;
    font: inherit; font-weight: 700; cursor: pointer; transition: transform .15s ease;
}
.bdc-print-actions button:active { transform: scale(.96); }
.bdc-print-actions button:focus-visible { outline: 2px solid var(--bdc-ink); outline-offset: 3px; }
.bdc-print-actions p { font-size: .8rem; line-height: 1.5; margin: 0; }

.bdc-sheet {
    --sheet-content: 840px;
    box-sizing: border-box;
    padding: 26px;
    background: #fff;
    color: #222;
    border: 1px solid #ddd;
    box-shadow: 0 8px 24px rgb(0 0 0 / .06);
    font-variant-numeric: tabular-nums;
}
.bdc-sheet[data-paper="letter"] { --sheet-content: 770px; }
.bdc-sheet .bdc-sheet-kicker { font-size: .65rem; letter-spacing: .12em; margin: 0; color: #555; }
.bdc-sheet h2 {
    font: 700 clamp(1.15rem, 3vw, 1.75rem)/1.25 var(--font-ui);
    overflow-wrap: anywhere; margin: 5px 0 14px;
}
.bdc-sheet-meta { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 8px 16px; margin-bottom: 14px; }
.bdc-sheet .bdc-write { display: flex; align-items: baseline; gap: 8px; margin: 0; font-size: .72rem; min-width: 0; }
.bdc-write span { flex-shrink: 0; }
.bdc-write b {
    font-weight: 400; min-width: 0; flex: 1; min-height: 1.45em;
    border-bottom: 1px solid #999; overflow-wrap: anywhere;
}
.bdc-sheet-content { min-height: var(--sheet-content); display: flex; flex-direction: column; gap: 12px; }
.bdc-sheet-rule {
    margin: 0; padding: 7px 10px; background: #fafafa; border: 1px solid #bbb;
    font-size: .68rem; line-height: 1.45; color: #222;
}

.bdc-tally-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}
.bdc-tally-box {
    border: 1px solid #999;
    padding: 5px 7px;
    min-height: 54px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #fff;
}
.bdc-tally-box span {
    font-size: .58rem;
    color: #666;
    font-weight: 700;
}

.bdc-log-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: .65rem; }
.bdc-log-table th, .bdc-log-table td { border: 1px solid #999; padding: 5px 7px; text-align: left; }
.bdc-log-table th { font-size: .6rem; background: #f5f5f5; }
.bdc-log-table td { height: 34px; }

.bdc-run-stack { display: flex; flex-direction: column; gap: 10px; flex: 1; }
body.page-sketch .bdc-run-card, .bdc-run-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    margin: 0;
    padding: 9px 11px;
    background: #fff;
    border: 1px solid #999;
    font-size: .66rem;
    gap: 7px;
}
.bdc-run-head {
    display: grid;
    grid-template-columns: auto 1.4fr 1fr auto;
    gap: 8px 14px;
    align-items: baseline;
    border-bottom: 1px solid #ccc;
    padding-bottom: 5px;
    font-size: .7rem;
}
.bdc-run-tag {
    display: inline-block; padding: 1px 6px; border: 1px solid #333;
    font-size: .6rem; font-weight: 700;
}
.bdc-run-boxes {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 5px;
}
.bdc-run-box {
    border: 1px solid #bbb;
    height: 30px;
}

body.page-sketch .bdc-foot-box, .bdc-foot-box {
    margin: 0; padding: 8px 11px; background: #fafafa; border: 1.5px solid #333;
    font-size: .65rem; line-height: 1.45; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px 16px;
}

.bdc-sheet-footer {
    display: flex; justify-content: space-between; gap: 10px;
    border-top: 1px solid #999; padding-top: 10px; margin-top: 14px; font-size: .64rem;
}

.bdc-prose { margin-top: 44px; line-height: 1.8; }
.bdc-prose h2 { margin-top: 30px; text-wrap: balance; }
.bdc-prose code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .88em; padding: 2px 6px; border-radius: 6px; background: #f4eeee;
}

@media (max-width: 720px) {
    .bdc-details, .bdc-foot-box { grid-template-columns: 1fr; }
    .bdc-run-head { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .bdc-container { padding: 40px 16px; }
    .bdc-options { flex-direction: column; }
    .bdc-options label { width: 100%; box-sizing: border-box; }
    .bdc-print-actions { flex-direction: column; align-items: stretch; }
    .bdc-sheet { padding: 12px; --sheet-content: 520px; }
    .bdc-sheet[data-paper="letter"] { --sheet-content: 480px; }
    .bdc-sheet-meta { grid-template-columns: 1fr; }
    .bdc-tally-grid { grid-template-columns: repeat(3, 1fr); }
    .bdc-run-boxes { grid-template-columns: repeat(5, 1fr); }
    .bdc-sheet-footer { font-size: .56rem; flex-direction: column; gap: 4px; }
}

@media print {
    html, body { margin: 0 !important; padding: 0 !important; background: #fff !important; }
    body.boss-death-counter-page > :not(main),
    main > :not(.bdc-container),
    .bdc-container > :not(.boss-death-counter),
    .boss-death-counter .tk-app > :not(.tk-r),
    .boss-death-counter .tk-r > :not(.bdc-result),
    .bdc-result:has(.bdc-sheet) > :not(.bdc-sheet),
    .bdc-controls, .bdc-deck-sub, .bdc-roster { display: none !important; }
    main, .bdc-container, .boss-death-counter, .boss-death-counter .tk-app,
    .boss-death-counter .tk-r, .bdc-result {
        display: block !important; position: static !important;
        margin: 0 !important; padding: 0 !important;
        width: 100% !important; max-width: none !important;
        height: auto !important; max-height: none !important;
        overflow: visible !important; border: 0 !important; box-shadow: none !important;
        background: #fff !important; transform: none !important; opacity: 1 !important;
    }
    .bdc-result *, .bdc-result *::before, .bdc-result *::after {
        animation: none !important; transition: none !important;
        opacity: 1 !important; transform: none !important;
    }
    .bdc-sheet {
        display: flex; flex-direction: column;
        height: 252mm; padding: 0; margin: 0; border: 0; box-shadow: none;
        font-family: Arial, sans-serif; break-inside: avoid;
    }
    .bdc-sheet[data-paper="letter"] { height: 234mm; }
    .bdc-sheet-head { flex-shrink: 0; }
    .bdc-sheet h2 { font: 700 15pt/1.18 Arial, sans-serif; margin: 1mm 0 2mm; }
    .bdc-sheet .bdc-sheet-kicker { font-size: 7pt; }
    .bdc-sheet-meta { grid-template-columns: 1fr 1fr 1.2fr; margin-bottom: 2.2mm; gap: 1.5mm 4mm; }
    .bdc-sheet .bdc-write { font-size: 7.8pt; }
    .bdc-sheet-content { min-height: 0; flex: 1; gap: 2mm; }
    .bdc-sheet-rule { padding: 1.5mm 2.2mm; font-size: 7.2pt; }
    .bdc-tally-grid { grid-template-columns: repeat(5, 1fr); gap: 1.8mm; flex: 1; }
    .bdc-tally-box { min-height: 18mm; padding: 1.2mm 1.8mm; }
    .bdc-sheet[data-paper="letter"] .bdc-tally-box { min-height: 15.5mm; }
    .bdc-log-table { font-size: 7.1pt; }
    .bdc-log-table th { font-size: 6.6pt; padding: 1mm 1.5mm; }
    .bdc-log-table td { height: 7mm; padding: 1mm 1.5mm; }
    .bdc-run-stack { gap: 1.8mm; }
    .bdc-run-card { padding: 1.8mm 2.4mm; font-size: 7pt; gap: 1.4mm; }
    .bdc-run-head { grid-template-columns: auto 1.4fr 1fr auto; gap: 1.2mm 3.5mm; font-size: 7.4pt; }
    .bdc-run-boxes { grid-template-columns: repeat(10, 1fr); gap: 1.2mm; }
    .bdc-run-box { height: 7.5mm; }
    .bdc-sheet[data-paper="letter"] .bdc-run-box { height: 6.4mm; }
    .bdc-foot-box { grid-template-columns: 1fr 1fr 1fr; padding: 1.8mm 2.2mm; font-size: 7.1pt; gap: 1.2mm 3.5mm; }
    .bdc-sheet-footer { flex-direction: row; font-size: 7pt; margin-top: 2mm; padding-top: 1.6mm; }
}

@media (prefers-reduced-motion: reduce) {
    .bdc-btn, .bdc-preset-btn, .bdc-print-actions button { transition: none; }
}
