:root {
    --page: #0f0f12;
    --panel: #1a1a1f;
    --panel-hover: #252530;
    --text: #f0f0f5;
    --dim: #a0a0b0;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #7c2d2d;
    --accent-dark: #991b1b;
    --white: #ffffff;
    --success: #1e9e5a;
    --botch: #e03c3c;
    --fail: #5f6b7a;
    --r: 4px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.22);
    --shadow-heavy: 0 11px 24px rgba(0, 0, 0, 0.32);
}

/* light: clean white */
body.theme-light {
    --page: #f8f9fc;
    --panel: #ffffff;
    --panel-hover: #eef1f7;
    --text: #1a1a24;
    --dim: #5a5a6e;
    --border: rgba(0, 0, 0, 0.1);
    --accent: #b91c1c;
    --accent-dark: #991b1b;
}

/* dark: default */
body.theme-dark {
    --page: #0f0f12;
    --panel: #1a1a1f;
    --panel-hover: #252530;
    --text: #f0f0f5;
    --dim: #a0a0b0;
    --border: rgba(255, 255, 255, 0.12);
    --accent: #dc2626;
    --accent-dark: #b91c1c;
}

/* blood: deep reds, VtM vibes */
body.theme-blood {
    --page: #1a0f0f;
    --panel: #251515;
    --panel-hover: #351a1a;
    --text: #ffe6e6;
    --dim: #d4a4a4;
    --border: rgba(224, 90, 90, 0.2);
    --accent: #e05a5a;
    --accent-dark: #c02828;
    --botch: #c02828;
    --success: #2d8a5a;
}

/* shadow: muted blue-greys */
body.theme-shadow {
    --page: #0d0d10;
    --panel: #15151a;
    --panel-hover: #1e1e28;
    --text: #e8e6ed;
    --dim: #8a8899;
    --border: rgba(138, 153, 172, 0.15);
    --accent: #8a99ac;
    --accent-dark: #5d6c7b;
}

/* parchment: warm tans, old paper feel */
body.theme-parchment {
    --page: #e8e0d4;
    --panel: #f5f0e8;
    --panel-hover: #ebe4d8;
    --text: #2c2419;
    --dim: #6b5d4d;
    --border: rgba(44, 36, 25, 0.15);
    --accent: #6b4423;
    --accent-dark: #4a2f18;
}

/* dreaming: parchment warmth, gold-primary with red accents */
body.theme-dreaming {
    --page: #eadfd6;
    --panel: #f5efe8;
    --panel-hover: #ecdfd4;
    --text: #3a2419;
    --dim: #8b5e42;
    --border: rgba(180, 110, 75, 0.28);
    --accent: #c5a028;
    --accent-dark: #a0522d;
    --botch: #b91c1c;
    --fail: #9e5e5e;
}

/* Scrollbars: themed to match current theme (track = panel, thumb = dim) */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--dim) var(--panel);
}
/* WebKit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--panel);
}
::-webkit-scrollbar-thumb {
    background: var(--dim);
    border-radius: 5px;
    border: 2px solid var(--panel);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text);
}
::-webkit-scrollbar-corner {
    background: var(--panel);
}

* {
    box-sizing: border-box;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Lora', Georgia, serif;
    background: var(--page);
    color: var(--text);
    min-height: 100vh;
}

.main {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    justify-content: safe center;
    padding: 2rem 1rem;
}

.page-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-top: 1.5rem;
}

.header-logo {
    max-height: 6rem;
    width: auto;
    object-fit: contain;
}

/* ── toggle bar ───────────────────────────────────── */
.toggle-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}

.toggle-bar-theme {
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    margin-left: 0.25rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--dim);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.toggle-bar-theme:hover,
.toggle-bar-theme:focus {
    background: var(--panel-hover);
    border-color: var(--accent);
    color: var(--text);
    outline: none;
}

.toggle-bar-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--dim);
    margin-left: 0.25rem;
}

.toggle-bar-label + .toggle-bar-theme {
    margin-left: 0;
}

.toggle-pill {
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel);
    color: var(--dim);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
    position: relative;
    user-select: none;
}

.toggle-pill:hover:not(:disabled) {
    background: var(--panel-hover);
    border-color: var(--accent);
    color: var(--text);
    transform: translateY(-1px);
}

.toggle-pill--active {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.toggle-pill--active:hover:not(:disabled) {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: var(--white);
}

.toggle-pill--disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.toggle-pill-badge {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.15em 0.5em;
    border-radius: 999px;
    background: var(--dim);
    color: var(--page);
    margin-left: 0.25rem;
    position: relative;
    top: -0.5px;
}

/* ── app panels (roller + initiative side-by-side; sheet below) ────────────────────── */
.app-panels {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    width: 100%;
    max-width: 1100px;
    align-items: flex-start;
    justify-content: center;
}

.panel-hidden {
    display: none !important;
}

/* Character sheet panel (VtM V20) — full width so it appears below Initiative Tracker */
.sheets-panel {
    display: flex;
    flex-basis: 100%;
    width: 100%;
    max-width: 1100px;
    min-width: 0;
    min-height: 0;
}

.sheets-panel .floating-panel-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 1.5rem;
    overflow: visible;
}

.sheet-panel-heading-wrap {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.sheet-panel-heading-wrap .sheet-panel-heading {
    margin-bottom: 0;
}

.sheet-panel-logo {
    max-height: 4.5rem;
    max-width: 100%;
    width: auto;
    object-fit: contain;
    display: block;
}

.sheet-panel-heading {
    margin-bottom: 1rem;
}

.sheets-panel iframe {
    flex: 1 1 0;
    min-height: 70vh;
    width: 100%;
    border: none;
    border-radius: 0 0 12px 12px;
}

.legal {
    margin-top: 2rem;
    width: 100%;
    max-width: 600px;
    padding: 0 1rem;
}

.legal-item {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    overflow: hidden;
}

.legal-item:last-child {
    margin-bottom: 0;
}

.legal-item-summary {
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: background 0.15s ease;
}

.legal-item-summary::-webkit-details-marker {
    display: none;
}

.legal-item-summary::after {
    content: "▼";
    font-size: 0.65em;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.legal-item[open] .legal-item-summary::after {
    transform: rotate(180deg);
}

.legal-item-summary:hover {
    background: var(--panel-hover);
}

.legal-item-heading {
    margin: 0;
    padding: 0;
    font: inherit;
    font-weight: 600;
    display: inline;
}

.legal-item-content {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border);
}

.legal-item-content p {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    color: var(--dim);
    line-height: 1.5;
    text-align: left;
}

.legal-item-content p:first-child {
    margin-top: 1rem;
}

.legal-item-content a {
    color: var(--accent);
    text-decoration: none;
}

.legal-item-content a:hover {
    text-decoration: underline;
}

.legal-item-content code {
    padding: 0.15em 0.4em;
    font-size: 0.9em;
    background: var(--panel-hover);
    border-radius: 3px;
}

.credits {
    margin: 2rem 0 0;
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--dim);
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
    opacity: 0.9;
}

.contact {
    margin: 0.75rem 0 0;
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--dim);
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
    opacity: 0.9;
}

.credits a,
.contact a {
    color: var(--accent);
    text-decoration: none;
}

.credits a:hover,
.contact a:hover {
    text-decoration: underline;
}

.kofi {
    margin: 1.5rem 0 1.5rem;
    padding: 0 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.kofi-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: #72a4f2;
    color: #fff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    transition: opacity 0.2s, transform 0.2s;
}

.kofi-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.kofi-button-icon {
    height: 20px;
    width: auto;
}

.roller {
    display: flex;
    width: 100%;
    max-width: 600px;
    flex: 1 1 0;
    min-width: 0;
}

/* ── initiative panel ─────────────────────────────── */
.initiative-panel {
    display: flex;
    width: 100%;
    max-width: 600px;
    flex: 1 1 0;
    min-width: 0;
}

.initiative-panel .floating-panel-content {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.init-heading,
.roller-heading {
    margin: 0 0 0.15rem;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
}

.roller-heading {
    margin-bottom: 1rem;
}

.init-subheading {
    margin: 0 0 1rem;
    font-size: 0.75rem;
    color: var(--dim);
    text-align: center;
    font-style: italic;
}

.init-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.init-form--spaced {
    margin-top: 1rem;
}

.init-form #init-name.init-input--error {
    border-color: var(--botch);
    animation: initInputShake 0.4s ease;
}

@keyframes initInputShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px); }
    40% { transform: translateX(4px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.init-form-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    align-items: flex-end;
}

.init-form-row--stats .field {
    flex: 1;
    min-width: 0;
    width: auto;
}

.init-form-row--stats .field-add {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    padding-bottom: 2px;
}

.init-form-row--stats .field-add .init-btn--add {
    min-width: 5rem;
    padding: 0.5rem 1rem;
}

.init-btn {
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
    white-space: nowrap;
}

.init-btn:hover {
    transform: translateY(-1px);
}

.init-btn--add {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.init-btn--add:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.init-btn--roll,
.init-btn--primary {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.init-actions .init-btn--roll,
.init-actions .init-btn--primary {
    flex: 1;
    min-width: 8rem;
}

.init-btn--roll:hover,
.init-btn--primary:hover {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
}

.init-btn--nav {
    background: var(--panel-hover);
    color: var(--text);
    border-color: var(--border);
    padding: 0.45rem 0.65rem;
    font-size: 0.75rem;
}

.init-btn--nav:hover {
    border-color: var(--accent);
    background: var(--panel);
}

.init-btn--clear {
    background: var(--panel-hover);
    color: var(--dim);
    border-color: var(--border);
}

.init-btn--clear:hover {
    border-color: var(--botch);
    color: var(--botch);
}

.init-btn--danger {
    background: var(--botch);
    color: var(--white);
    border-color: var(--botch);
}

.init-btn--danger:hover {
    background: var(--botch);
    border-color: var(--botch);
    filter: brightness(0.9);
}

.init-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.init-options {
    margin-bottom: 0.5rem;
}

.init-options .field {
    max-width: 12rem;
}

.init-actions .init-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.init-actions .init-btn:disabled:hover {
    background: inherit;
    border-color: var(--border);
    color: inherit;
}

.init-round-label {
    margin: 0 0 0.25rem;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    min-height: 1.25em;
}

.init-turn-label {
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    text-align: center;
    min-height: 1.25em;
}

.init-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-height: 8rem;
    padding: 0.75rem;
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.init-empty {
    text-align: center;
    color: var(--dim);
    font-size: 0.8125rem;
    padding: 1.5rem 0.5rem;
    font-style: italic;
}

.init-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.65rem;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.init-row--active {
    border-color: var(--accent);
    background: rgba(124, 45, 45, 0.12);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    box-shadow: 0 0 0 1px var(--accent), inset 0 0 8px rgba(0, 0, 0, 0.06);
    box-shadow: 0 0 0 1px var(--accent), inset 0 0 8px color-mix(in srgb, var(--accent) 12%, transparent);
    animation: initPulse 2s ease-in-out infinite;
}

@keyframes initPulse {

    0%,
    100% {
        box-shadow: 0 0 0 1px var(--accent), inset 0 0 8px color-mix(in srgb, var(--accent) 12%, transparent);
    }

    50% {
        box-shadow: 0 0 0 2px var(--accent), inset 0 0 14px color-mix(in srgb, var(--accent) 18%, transparent);
    }
}

.init-rank {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--accent);
    min-width: 1.5rem;
    text-align: center;
    flex-shrink: 0;
}

.init-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
    flex: 1 1 auto;
    min-width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.init-stats {
    font-size: 0.75rem;
    color: var(--dim);
    flex-shrink: 0;
    white-space: nowrap;
}

.init-row .init-btn--d10 {
    font-size: 0.7rem;
    padding: 0.3rem 0.5rem;
    flex-shrink: 0;
}

.init-row .init-btn--d10:hover {
    background: var(--accent);
    color: var(--white);
    border-color: var(--accent);
}

.init-stat-label {
    font-weight: 600;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    opacity: 0.7;
}

.init-stat-sep {
    opacity: 0.4;
    margin: 0 0.1rem;
}

.init-d10 {
    color: var(--accent);
    font-weight: 600;
}

.init-total {
    font-weight: 700;
    font-size: 0.875rem;
    color: var(--text);
}

.init-remove {
    font-family: inherit;
    background: none;
    border: none;
    color: var(--dim);
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
    line-height: 1;
}

.init-remove:hover {
    color: var(--botch);
    background: rgba(224, 60, 60, 0.1);
}

.floating-panel-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 18px 28px -4px rgba(0, 0, 0, 0.32);
    padding: 1.5rem;
    overflow: visible;
}

.roller-content {
    width: 100%;
}

.tray-dash {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.tray-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

.tray-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    align-items: center;
}

.field label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text);
    text-align: center;
}

.field input[type="text"],
.field input[type="number"],
.field select {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    margin: 0;
    width: 100%;
    max-width: 100%;
}

.field select {
    text-align: left;
}

.row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.row-formula {
    flex-wrap: wrap;
}

.row-formula .field-flex:first-child {
    flex: 2;
    min-width: 140px;
}

.row-formula .field-flex:not(:first-child) {
    flex: 1;
    min-width: 80px;
}

.row-formula .field-flex-2 {
    flex: 2;
    min-width: 140px;
}

.row-special .field-flex:first-child {
    flex: 1.25;
    min-width: 80px;
}

.row-special .field-flex:not(:first-child) {
    flex: 1.25;
    min-width: 90px;
}

.row-special .field-flex-2 {
    flex: 2.5;
    min-width: 140px;
}

input[type="text"],
input[type="number"] {
    font-family: inherit;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-align: center;
}

select {
    font-family: inherit;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-align: left;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent);
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
}

.checkbox-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
    width: 100%;
}

.checkbox-option:hover {
    border-color: var(--accent);
    background: var(--panel);
}

.checkbox-option input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    accent-color: var(--accent);
}

.checkbox-label {
    font-size: 0.875rem;
    color: var(--text);
}

.field-roll .roll-btn {
    width: 100%;
}

.roll-btn {
    font-family: inherit;
    background: var(--accent);
    color: var(--white);
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
}

.roll-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
    background: var(--accent-dark);
}

.roll-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.roll-intense {
    animation: roll-trigger-shake 0.12s ease-in-out infinite;
}

@keyframes roll-trigger-shake {

    0%,
    100% {
        transform: translateX(0) translateY(0);
    }

    25% {
        transform: translateX(-2px) translateY(-1px);
    }

    50% {
        transform: translateX(2px) translateY(1px);
    }

    75% {
        transform: translateX(-1px) translateY(2px);
    }
}

.roll-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.roll-overlay.roll-overlay--hidden {
    display: none !important;
    pointer-events: none !important;
}

.roll-overlay .roll-3d {
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
}

.roll-overlay .roll-2d {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: none;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    position: relative;
    pointer-events: none;
}

.roll-overlay .roll-2d .dice-result {
    pointer-events: none;
    margin: 0;
}

.roll-overlay .roll-3d canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.roll-overlay.roll-overlay--2d .roll-2d {
    display: flex;
}

.roll-overlay.roll-overlay--2d .roll-3d {
    display: none;
}

.results-popup {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    min-width: 12rem;
    max-width: 90vw;
    padding: 1rem 1.25rem;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 2;
    text-align: center;
}

.roll-overlay.roll-overlay--results-above .results-popup {
    top: 32%;
    transform: translate(-50%, -50%);
}

.rp-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--dim);
    margin-bottom: 0.5rem;
}

.rp-roll-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.rp-values {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.rp-values .dice-result-success {
    color: var(--success);
}

.rp-values .dice-result-failure {
    color: var(--dim);
}

.rp-values .dice-result-botch {
    color: var(--botch);
    font-weight: 700;
}

.rp-successes {
    font-size: 1rem;
    font-weight: 600;
    color: var(--success);
}

.rp-successes.zero {
    color: var(--botch);
}

.rp-successes.popup-botch {
    color: var(--botch);
    font-weight: 700;
}

.diff-warning {
    font-size: 0.75rem;
    color: var(--botch);
    margin: 0.25rem 0 0;
    font-weight: 500;
}

.rp-meta {
    font-size: 0.75rem;
    color: var(--dim);
    margin-top: 0.5rem;
    opacity: 0.9;
}

.rp-timestamp {
    font-size: 0.75rem;
    color: var(--dim);
    margin-top: 0.25rem;
    opacity: 0.9;
}

.roll-overlay .roll-dismiss-hint {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text);
    font-size: 0.875rem;
    border-radius: 4px;
    pointer-events: none;
}

.dice-result {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 0.875rem;
    margin: 0.25rem;
    border-radius: var(--radius-lg);
    font-weight: 700;
    font-size: 1.125rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    text-align: center;
    transition: opacity 0.25s ease;
    animation: dicePop 0.5s ease;
}

.dice-result.d4,
.dice-result.d6,
.dice-result.d8,
.dice-result.d10,
.dice-result.d12,
.dice-result.d20,
.dice-result.d100 {
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    padding: 0;
}

.dice-result.d4 {
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    border-radius: 0;
}

.dice-result.d6 {
    border-radius: 0.25rem;
}

.dice-result.d8 {
    clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
    border-radius: 0;
}

.dice-result.d10 {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border-radius: 0;
}

.dice-result.d12 {
    clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
    border-radius: 0;
}

.dice-result.d20 {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border-radius: 0;
}

.dice-result.d100 {
    border-radius: 50%;
}

.success {
    background: var(--success);
    color: var(--white);
    box-shadow: var(--shadow);
}

.failure {
    background: var(--fail);
    color: var(--white);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.botch {
    background: var(--botch);
    color: var(--white);
    box-shadow: var(--shadow);
}

.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10001;
    padding: 1rem 1.5rem;
    border-radius: var(--r);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 0, 0, 0.2);
    animation: toastFade 0.35s ease-out;
}

@keyframes toastFade {
    from {
        opacity: 0;
        transform: translateX(1.5rem) translateY(-0.5rem);
    }

    to {
        opacity: 1;
        transform: translateX(0) translateY(0);
    }
}

@keyframes dicePop {
    from {
        opacity: 0;
        transform: scale(0.5);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .main {
        padding: 1rem 0.75rem;
    }

    .app-panels {
        flex-direction: column;
        align-items: center;
    }

    .roller {
        max-width: 100%;
    }

    .initiative-panel {
        max-width: 100%;
        flex: 1 1 auto;
    }

    .row-formula .field-flex:first-child {
        flex: 1;
        min-width: 100px;
    }

    .row-formula .field-flex:not(:first-child) {
        min-width: 70px;
    }

    .row-special .checkbox-label {
        font-size: 0.75rem;
    }

    .row-special .field-flex-2 select {
        font-size: 0.875rem;
        padding: 0.45rem 0.5rem;
    }

    .row-special .field-flex:first-child,
    .row-special .field-flex:not(:first-child) {
        min-width: 0;
    }

    .row-special .field-flex-2 {
        min-width: 100px;
    }

    .row-special .checkbox-option {
        padding: 0.4rem 0.5rem;
    }

    .roll-overlay.roll-overlay--results-above .results-popup {
        top: 18%;
    }

    .roll-overlay.roll-overlay--2d .roll-2d {
        margin-top: 0;
        padding-top: 3.5rem;
        overflow-y: auto;
        max-height: 50vh;
    }

    .roll-overlay .roll-2d {
        padding: 1rem 1.5rem;
        gap: 0.5rem;
        max-width: min(24rem, 100%);
    }

    .roll-overlay .roll-2d .dice-result.d4,
    .roll-overlay .roll-2d .dice-result.d6,
    .roll-overlay .roll-2d .dice-result.d8,
    .roll-overlay .roll-2d .dice-result.d10,
    .roll-overlay .roll-2d .dice-result.d12,
    .roll-overlay .roll-2d .dice-result.d20,
    .roll-overlay .roll-2d .dice-result.d100 {
        width: 2.75rem;
        height: 2.75rem;
        min-width: 2.75rem;
        min-height: 2.75rem;
        font-size: 1rem;
    }

    .toggle-pill {
        font-size: 0.8125rem;
        padding: 0.4rem 0.9rem;
    }

    .init-stats {
        display: none;
    }
}

/* ── VtM 20 character sheet (same panel style as Roller / Initiative) ── */
.sheet-root {
    font-family: inherit;
    display: block;
}

.sheet-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.sheet-section {
    padding: 0.75rem 0;
}

.sheet-section-attributes {
    padding-bottom: 1.25rem;
}

.sheet-subheading {
    margin: 0 0 0.5rem;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    letter-spacing: 0.02em;
}

.sheet-section-hr {
    border: none;
    border-top: 2px solid var(--border);
    margin: 0 0 0.75rem;
}

.sheet-header-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.sheet-header-grid-3x3 {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem 1rem;
}

.sheet-clan-custom {
    margin-top: 0.35rem;
}

.sheet-header-grid .field label {
    font-size: 0.8125rem;
    color: var(--dim);
}

.sheet-header-grid input,
.sheet-header-grid select {
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
}

.sheet-cols-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

/* Grid items default to min-width: auto, which blocks shrinking and lets flex rows overflow the column (visible on the last column). */
.sheet-cols-3 > .sheet-col {
    min-width: 0;
}

.sheet-col-title {
    margin: 0 0 0.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--dim);
}

.sheet-trait-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border);
    min-width: 0;
}

.sheet-trait-row label,
.sheet-trait-row > span:first-child {
    flex: 0 0 5.75rem;
    min-width: 0;
    font-size: 0.875rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sheet-trait-spec {
    flex: 1 1 4rem;
    min-width: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
}

.sheet-trait-spec::placeholder {
    color: var(--dim);
    opacity: 0.5;
}

.sheet-virtue-row {
    flex-wrap: wrap;
}

.sheet-virtue-row .sheet-virtue-select {
    flex: 0 0 auto;
    min-width: 6rem;
    padding: 0.35rem 0.5rem;
    font-size: 0.8125rem;
}

.sheet-dot-tracker,
.sheet-square-tracker {
    display: flex;
    gap: 0.2rem;
    flex-wrap: wrap;
}

.sheet-trait-row .sheet-dot-tracker,
.sheet-trait-row .sheet-square-tracker {
    flex: 0 1 auto;
    min-width: 0;
}

.sheet-dot-tracker.sheet-dots-large .sheet-dot {
    width: 1rem;
    height: 1rem;
}

.sheet-dot,
.sheet-square {
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid var(--accent);
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
    transition: border-color 0.15s, background 0.15s;
}

.sheet-dot.filled,
.sheet-square.filled {
    background: var(--accent);
}

.sheet-square {
    border-radius: 2px;
}

.sheet-square.filled::before,
.sheet-square.filled::after {
    content: "";
    position: absolute;
    width: 60%;
    height: 2px;
    background: var(--panel);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
}

.sheet-square.filled::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.sheet-square {
    position: relative;
}

/* Extensible 5+5 trackers (Attributes, Disciplines): second row unlocked when 5th dot is set */
.sheet-tracker-extensible {
    flex-wrap: wrap;
}

.sheet-tracker-dots-row {
    display: flex;
    gap: 0.2rem;
    flex-wrap: nowrap;
}

.sheet-tracker-overflow {
    display: none;
    gap: 0.2rem;
    flex-basis: 100%;
}

.sheet-tracker-overflow-unlocked {
    display: flex;
}

.sheet-tracker-overflow .sheet-square {
    border-style: dashed;
}

.sheet-add-btn {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    padding: 0.45rem 0.75rem;
}

.sheet-cols-3 .sheet-col .sheet-add-btn {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.sheet-ability-row,
.sheet-discipline-row,
.sheet-background-row,
.sheet-repeating-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.35rem 0;
}

.sheet-ability-row .sheet-ability-name,
.sheet-discipline-row .sheet-discipline-name,
.sheet-background-row .sheet-background-name {
    flex: 1 1 6rem;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
}

.sheet-remove-btn {
    flex: 0 0 auto;
    background: none;
    border: none;
    color: var(--dim);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    font-size: 1rem;
    line-height: 1;
    border-radius: var(--r);
}

.sheet-remove-btn:hover {
    color: var(--botch);
    background: rgba(224, 60, 60, 0.1);
}

.sheet-labeled-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sheet-field-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dim);
}

/* Merits & Flaws rows: left column (name, points, type, remove stacked) + right column (description) */
.sheet-merits-flaws-list {
    margin-bottom: 0.25rem;
}
.sheet-merit-row,
.sheet-flaw-row,
.sheet-power-row,
.sheet-combo-row,
.sheet-bond-row,
.sheet-vinculum-row,
.sheet-boon-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.sheet-merit-row:last-child,
.sheet-flaw-row:last-child,
.sheet-power-row:last-child,
.sheet-combo-row:last-child {
    border-bottom: none;
}
.sheet-merit-left,
.sheet-flaw-left,
.sheet-power-left,
.sheet-combo-left,
.sheet-bond-left,
.sheet-vinculum-left,
.sheet-boon-left {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 0 0 14rem;
    max-width: 40%;
    min-width: 0;
}
.sheet-merit-row .sheet-merit-name,
.sheet-merit-row .sheet-merit-type,
.sheet-flaw-row .sheet-flaw-name,
.sheet-flaw-row .sheet-flaw-type,
.sheet-power-row .sheet-power-discipline,
.sheet-power-row .sheet-power-name,
.sheet-combo-row .sheet-combo-name,
.sheet-combo-row .sheet-combo-d1,
.sheet-combo-row .sheet-combo-d2,
.sheet-combo-row .sheet-combo-d3,
.sheet-combo-row .sheet-combo-req1,
.sheet-combo-row .sheet-combo-req2,
.sheet-combo-row .sheet-combo-book {
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.sheet-merit-points-row,
.sheet-flaw-points-row,
.sheet-power-level-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.sheet-merit-points-row,
.sheet-flaw-points-row {
    flex-wrap: wrap;
}
.sheet-merit-row .sheet-merit-points-label,
.sheet-flaw-row .sheet-flaw-points-label,
.sheet-power-row .sheet-power-level-label,
.sheet-combo-row .sheet-combo-level-label {
    font-size: 0.75rem;
    color: var(--dim);
    flex-shrink: 0;
}
.sheet-merit-row .sheet-dot-tracker,
.sheet-flaw-row .sheet-dot-tracker,
.sheet-power-row .sheet-dot-tracker,
.sheet-combo-row .sheet-dot-tracker {
    flex: 0 0 auto;
}
.sheet-merit-row .sheet-merit-desc,
.sheet-flaw-row .sheet-flaw-desc,
.sheet-power-row .sheet-power-desc,
.sheet-combo-row .sheet-combo-desc,
.sheet-bond-row .sheet-bond-desc,
.sheet-vinculum-row .sheet-vinculum-desc,
.sheet-boon-row .sheet-boon-desc {
    flex: 1 1 0;
    min-width: 0;
    min-height: 4rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    resize: vertical;
    box-sizing: border-box;
}
.sheet-merit-row[draggable="true"],
.sheet-flaw-row[draggable="true"],
.sheet-power-row[draggable="true"],
.sheet-combo-row[draggable="true"] {
    cursor: grab;
}
.sheet-merit-row[draggable="true"]:active,
.sheet-flaw-row[draggable="true"]:active,
.sheet-power-row[draggable="true"]:active,
.sheet-combo-row[draggable="true"]:active {
    cursor: grabbing;
}
.sheet-merit-row.sheet-drag-over,
.sheet-flaw-row.sheet-drag-over,
.sheet-power-row.sheet-drag-over,
.sheet-combo-row.sheet-drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: 2px;
}
.sheet-merit-row.sheet-dragging,
.sheet-flaw-row.sheet-dragging,
.sheet-power-row.sheet-dragging,
.sheet-combo-row.sheet-dragging {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    box-shadow: var(--shadow-heavy);
    opacity: 0.95;
}

/* Merits & Flaws tab: section blocks with centered headings and hr */
#vtm-tab-merits .sheet-merits-flaws-block,
#vtm-tab-bonds .sheet-merits-flaws-block,
#ctd-tab-merits .sheet-merits-flaws-block {
    margin-top: 2.75rem;
    padding-top: 0.5rem;
}
#vtm-tab-merits .sheet-merits-flaws-block:first-child,
#vtm-tab-bonds .sheet-merits-flaws-block:first-child,
#ctd-tab-merits .sheet-merits-flaws-block:first-child {
    margin-top: 0;
    padding-top: 0;
}
#vtm-tab-merits .sheet-section-head,
#vtm-tab-bonds .sheet-section-head,
#ctd-tab-merits .sheet-section-head {
    text-align: center;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text, #e8e6e3);
    margin: 0 0 0.5rem;
    letter-spacing: 0.02em;
}
#vtm-tab-merits .sheet-section-hr,
#vtm-tab-bonds .sheet-section-hr,
#ctd-tab-merits .sheet-section-hr {
    margin: 0 0 0.75rem;
}
#vtm-tab-merits .sheet-merits-flaws-block .sheet-add-btn,
#vtm-tab-bonds .sheet-merits-flaws-block .sheet-add-btn,
#ctd-tab-merits .sheet-merits-flaws-block .sheet-add-btn {
    display: block;
    margin: 0.35rem auto 0;
}

/* Powers & Combat tabs use the same section styling as Merits & Flaws */
#vtm-tab-powers .sheet-merits-flaws-block,
#vtm-tab-combat .sheet-merits-flaws-block,
#ctd-tab-combat .sheet-merits-flaws-block {
    margin-top: 2.75rem;
    padding-top: 0.5rem;
}
#vtm-tab-powers .sheet-merits-flaws-block:first-child,
#vtm-tab-combat .sheet-merits-flaws-block:first-child,
#ctd-tab-combat .sheet-merits-flaws-block:first-child {
    margin-top: 0;
    padding-top: 0;
}
#vtm-tab-powers .sheet-section-head,
#vtm-tab-combat .sheet-section-head,
#ctd-tab-combat .sheet-section-head {
    text-align: center;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text, #e8e6e3);
    margin: 0 0 0.5rem;
    letter-spacing: 0.02em;
}
#vtm-tab-powers .sheet-section-hr,
#vtm-tab-combat .sheet-section-hr,
#ctd-tab-combat .sheet-section-hr {
    margin: 0 0 0.75rem;
}
#vtm-tab-powers .sheet-merits-flaws-block .sheet-add-btn,
#vtm-tab-combat .sheet-merits-flaws-block .sheet-add-btn,
#ctd-tab-combat .sheet-merits-flaws-block .sheet-add-btn {
    display: block;
    margin: 0.35rem auto 0;
}

/* Combination disciplines: compact grouping for disciplines + requirements */
.sheet-combo-disciplines {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.sheet-combo-discipline {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.sheet-combo-d1-level,
.sheet-combo-d2-level,
.sheet-combo-d3-level {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.sheet-combo-reqs {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* ── Blood Sorcery tab ── */
#vtm-tab-sorcery .sheet-merits-flaws-block {
    margin-top: 2rem;
}
#vtm-tab-sorcery .sheet-merits-flaws-block:first-child {
    margin-top: 0;
}
#vtm-tab-sorcery .sheet-section-head {
    text-align: center;
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text, #e8e6e3);
    margin: 0 0 0.5rem;
    letter-spacing: 0.02em;
}
#vtm-tab-sorcery .sheet-section-hr {
    margin: 0 0 0.75rem;
}
#vtm-tab-sorcery .sheet-merits-flaws-block .sheet-add-btn {
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.sheet-sorcery-names-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.sheet-sorcery-name-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sheet-sorcery-name-row .sheet-labeled-field {
    flex: 0 0 12rem;
}
.sheet-sorcery-name-row .sheet-dot-tracker {
    flex: 0 0 auto;
}

.sheet-sorcery-paths-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}
.sheet-sorcery-paths-col {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.sheet-sorcery-path-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sheet-sorcery-path-row .sheet-labeled-field {
    flex: 1 1 0;
    min-width: 0;
}
.sheet-sorcery-path-row .sheet-sorcery-path-name {
    width: 100%;
    box-sizing: border-box;
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
}
.sheet-sorcery-path-row .sheet-dot-tracker {
    flex: 0 0 auto;
}

.sheet-sorcery-ritual-row {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.sheet-sorcery-ritual-row:last-child {
    border-bottom: none;
}
.sheet-sorcery-ritual-left {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 0 0 18rem;
    max-width: 45%;
    min-width: 0;
}
.sheet-sorcery-ritual-left .sheet-labeled-field input,
.sheet-sorcery-ritual-left .sheet-labeled-field select {
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.sheet-sorcery-ritual-level-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.sheet-sorcery-ritual-level-label {
    font-size: 0.75rem;
    color: var(--dim);
    flex-shrink: 0;
}
.sheet-sorcery-ritual-row .sheet-dot-tracker {
    flex: 0 0 auto;
}
.sheet-sorcery-ritual-row .sheet-sorc-ritual-desc {
    flex: 1 1 0;
    min-width: 0;
    min-height: 4rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    resize: vertical;
    box-sizing: border-box;
}
.sheet-sorcery-ritual-row[draggable="true"] {
    cursor: grab;
}
.sheet-sorcery-ritual-row[draggable="true"]:active {
    cursor: grabbing;
}
.sheet-sorcery-ritual-row.sheet-drag-over {
    outline: 2px dashed var(--accent);
    outline-offset: 2px;
}
.sheet-sorcery-ritual-row.sheet-dragging {
    outline: 2px solid var(--accent);
    outline-offset: 0;
    box-shadow: var(--shadow-heavy);
    opacity: 0.95;
}
.sheet-sorcery-ritual-row {
    cursor: pointer;
}
.sheet-sorcery-ritual-row:hover {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.sheet-sorcery-ritual-roll-row {
    margin-top: 0.25rem;
}
.sheet-sorc-ritual-roll-btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
}

@media (max-width: 600px) {
    .sheet-sorcery-paths-grid {
        grid-template-columns: 1fr;
    }
    .sheet-sorcery-ritual-row {
        flex-direction: column;
    }
    .sheet-sorcery-ritual-left {
        flex: none;
        max-width: 100%;
    }
}

/* Attribute + Ability roll link (click trait → line follows mouse → click second trait → modal) */
.sheet-roll-line-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
}

.sheet-roll-line-overlay svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.sheet-roll-line-overlay line,
.sheet-roll-line-overlay .sheet-roll-line-loop {
    stroke: var(--accent);
    stroke-width: 2;
    stroke-dasharray: 6 4;
    stroke-linecap: round;
    opacity: 0.9;
}

.sheet-rollable-trait-row {
    cursor: pointer;
}

/* Outline only when hovering the trait name (not dots or specialty), to show it’s clickable */
.sheet-rollable-trait-row > label:hover,
.sheet-rollable-trait-row > .sheet-ability-name:hover,
.sheet-rollable-trait-row > span:first-child:hover {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.sheet-rollable-trait-row.sheet-roll-link-source {
    outline: 2px dashed var(--accent);
    outline-offset: 2px;
}

/* Willpower block: same affordance as rollable trait names (accent outline on the title) */
.sheet-willpower-block {
    cursor: pointer;
}

.sheet-willpower-block > .sheet-col-title {
    width: fit-content;
    cursor: pointer;
}

.sheet-willpower-block > .sheet-col-title:hover {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}

.sheet-roll-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.sheet-roll-modal {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
    min-width: 18rem;
    max-width: 90vw;
    padding: 1.25rem;
}

.sheet-roll-modal h4 {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--text);
}

.sheet-roll-modal .sheet-roll-modal-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.sheet-roll-modal .sheet-roll-modal-row label {
    flex: 0 0 7rem;
    font-size: 0.875rem;
}

.sheet-roll-modal .sheet-roll-modal-row input[type="number"],
.sheet-roll-modal .sheet-roll-modal-row select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.35rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
}

.sheet-roll-modal .sheet-roll-modal-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    margin-bottom: 1rem;
}

.sheet-roll-modal .sheet-roll-modal-checkboxes label {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.sheet-roll-modal .sheet-roll-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.sheet-roll-modal .sheet-roll-modal-actions button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: var(--radius);
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
}

.sheet-roll-modal .sheet-roll-modal-actions .sheet-roll-submit {
    background: var(--accent);
    color: var(--white, #fff);
    border-color: var(--accent);
}

.sheet-roll-modal .sheet-roll-modal-actions .sheet-roll-submit:hover {
    filter: brightness(1.1);
}

.sheet-resources {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
}

.sheet-resources-row--full {
    grid-column: 1 / -1;
    display: flex;
    gap: 1.25rem;
}

.sheet-resources-row--full > .sheet-resource-block {
    flex: 1;
    min-width: 0;
}

.sheet-resource-block {
    padding: 0.75rem 1rem;
    background: var(--panel-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.sheet-resource-block .sheet-col-title {
    margin-bottom: 0.6rem;
}

.sheet-resource-block .sheet-resource-subtitle {
    margin-top: 0.85rem;
}

.sheet-bearing-label {
    display: block;
    font-size: 0.8125rem;
    color: var(--dim);
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

.sheet-resource-block > * + * {
    margin-top: 0.5rem;
}

.sheet-check {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    cursor: pointer;
    margin-bottom: 0.25rem;
}

.sheet-check input {
    accent-color: var(--accent);
}

.sheet-blood-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: flex-end;
}

.sheet-blood-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sheet-movement-fields {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sheet-inline-label {
    font-size: 0.8125rem;
    color: var(--dim);
}

.sheet-blood-field input {
    width: 3.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.sheet-movement-row input[type="number"] {
    width: 3.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.sheet-path-sins {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sheet-path-sin-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: text;
}

.sheet-path-sin-num {
    flex: 0 0 1.25rem;
    font-weight: 600;
    color: var(--dim);
}

.sheet-path-sin-row input {
    flex: 1;
    min-width: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.sheet-movement-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.sheet-movement-row .sheet-inline-label {
    min-width: 6rem;
}

.sheet-unit {
    font-size: 0.75rem;
    color: var(--dim);
}

/* Auto-resize: JS sets height to scrollHeight so content fits without scrolling */
textarea {
    box-sizing: border-box;
}

.sheet-resource-block textarea {
    width: 100%;
    min-height: 4rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel);
    color: var(--text);
}

/* Health track (V20 style: label, penalty, cycle box) */
.sheet-health-rows {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sheet-health-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 0.5rem;
}

.sheet-health-label {
    font-size: 0.875rem;
    color: var(--text);
}

.sheet-health-penalty {
    font-size: 0.8125rem;
    color: var(--dim);
    min-width: 1.5rem;
    text-align: right;
}

.sheet-health-box {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--accent);
    border-radius: 2px;
    background: transparent;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.sheet-health-box:hover {
    border-color: var(--text);
}

.sheet-health-box[data-health-value="x"]::before { content: "×"; }
.sheet-health-box[data-health-value="slash"]::before { content: "/"; }
.sheet-health-box[data-health-value="asterisk"]::before { content: "*"; }
/* Legacy: map old symbols for backward compatibility */
.sheet-health-box[data-health-value="check"]::before { content: "/"; }
.sheet-health-box[data-health-value="hash"]::before { content: "*"; }

.sheet-health-key {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: var(--dim);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
}
.sheet-health-key-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.sheet-health-key-symbol {
    font-weight: bold;
    min-width: 1.25rem;
    text-align: center;
}
.sheet-health-key-note {
    font-style: italic;
}

.sheet-heal-btn {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.sheet-blood-reset-turn {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
}

.sheet-exp {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: flex-end;
}

.sheet-exp-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sheet-exp-field input {
    width: 3.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

.sheet-tabs {
    margin-bottom: 0.75rem;
}

.sheet-tabs .toggle-pill {
    padding: 0.65rem 1.25rem;
    font-size: 0.95rem;
    min-height: 44px;
}

.sheet-tabs .toggle-pill-badge {
    font-size: 0.7rem;
}

.sheet-tab-pane {
    padding: 0.5rem 0;
}

.sheet-tab-pane textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--panel-hover);
    color: var(--text);
    font-family: inherit;
}

.sheet-info-fields {
    margin-top: 0.75rem;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.6rem 0.9rem;
}

.sheet-info-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.sheet-info-field input {
    width: 100%;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
}

@media (max-width: 640px) {
    .sheet-info-fields {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 900px) {
    .sheet-info-fields {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.sheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    padding-top: 1rem;
}

.sheet-actions .init-btn {
    font-size: 0.8125rem;
    padding: 0.45rem 0.75rem;
    min-width: 7rem;
    text-align: center;
}

.sheet-actions #vtm-sheet-select,
.sheet-actions #ctd-sheet-select {
    min-width: 10rem;
}

.sheet-batch-upload {
    flex: 1 1 100%;
    margin-top: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-width: 32rem;
}

.sheet-batch-upload-dropzone {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.sheet-batch-upload-dropzone:hover,
.sheet-batch-upload-dropzone:focus-visible,
.sheet-batch-upload-dropzone.sheet-batch-upload-dropzone--hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-soft);
    background: rgba(0, 0, 0, 0.35);
    outline: none;
}

.sheet-batch-upload-title {
    margin: 0 0 0.15rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.sheet-batch-upload-subtitle {
    margin: 0;
    font-size: 0.8rem;
    color: var(--dim);
}

.sheet-batch-upload-help {
    margin: 0;
    font-size: 0.75rem;
    color: var(--dim);
    text-align: center;
}

.sheet-toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-heavy);
    z-index: 10001;
    animation: toastFade 0.35s ease-out;
}

.sheet-toast--success {
    border-color: var(--success);
    color: var(--success);
}

.sheet-toast--error {
    border-color: var(--botch);
    color: var(--botch);
}

@media (max-width: 900px) {
    .sheet-cols-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .sheet-merit-row,
    .sheet-flaw-row {
        flex-direction: column;
        align-items: stretch;
    }
    .sheet-merit-left,
    .sheet-flaw-left {
        flex: 1 1 auto;
        max-width: 100%;
        width: 100%;
    }
    .sheet-merit-row .sheet-merit-desc,
    .sheet-flaw-row .sheet-flaw-desc {
        width: 100%;
    }
}