html, body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

h1:focus {
    outline: none;
}

/* Shown until the WebAssembly app renders its shell. */
.vtt-loading {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--bs-secondary-color);
}

body:has(.vtt-shell) .vtt-loading {
    display: none;
}

.avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    display: inline-grid;
    place-items: center;
    vertical-align: middle;
}

.avatar-initial {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    font-size: 0.8rem;
    font-weight: 600;
}

.presence-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    flex: none;
    background: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
}

    .presence-dot.online {
        background: var(--bs-success);
        border-color: var(--bs-success);
    }

.role-badge {
    font-weight: 600;
}

.role-dm {
    background: #7c3aed;
    color: #fff;
}

.role-codm {
    background: #4f46e5;
    color: #fff;
}

.role-player {
    background: #0f766e;
    color: #fff;
}

.role-observer {
    background: var(--bs-secondary-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
}

.live-status {
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
    align-self: center;
}

    .live-status.connected {
        color: var(--bs-success);
    }

.btn-discord {
    background: #5865f2;
    border-color: #5865f2;
    color: #fff;
}

    .btn-discord:hover, .btn-discord:focus-visible {
        background: #4752c4;
        border-color: #4752c4;
        color: #fff;
    }

.login-card {
    max-width: 28rem;
}

.campaign-description {
    white-space: pre-line;
}

.editor-sidebar {
    position: sticky;
    top: 1rem;
}

.editor-row {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.5rem;
}

.grants-section {
    border-top: 1px solid var(--bs-border-color-translucent);
    padding: 0.6rem 0;
}

    .grants-section > summary {
        font-weight: 600;
        cursor: pointer;
    }

    .grants-section[open] > summary {
        margin-bottom: 0.4rem;
    }

.element-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.15rem 0.35rem 0.15rem 0.6rem;
    border-radius: 1rem;
    background: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    font-size: 0.85rem;
}

.btn-close-sm {
    width: 0.5rem;
    height: 0.5rem;
    background-size: 0.5rem;
}

.history li + li {
    border-top: 1px solid var(--bs-border-color-translucent);
}

.sheet-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr));
    gap: 0.5rem;
}

    .sheet-stats.compact {
        grid-template-columns: repeat(4, 1fr);
    }

.sheet-stat {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.35rem 0.5rem;
    text-align: center;
    cursor: help;
}

    .sheet-stat .label {
        font-size: 0.72rem;
        color: var(--bs-secondary-color);
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }

    .sheet-stat .value {
        font-size: 1.25rem;
        font-weight: 600;
        font-variant-numeric: tabular-nums;
    }

.sheet table tr[title], .sheet [title] {
    cursor: help;
}

.power-card {
    border: 1px solid var(--bs-border-color);
    border-left: 4px solid var(--bs-secondary-color);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem 0.65rem;
    height: 100%;
}

    .power-card.usage-atwill {
        border-left-color: #198754;
    }

    .power-card.usage-encounter {
        border-left-color: #b02a37;
    }

    .power-card.usage-daily {
        border-left-color: #6c757d;
    }

    .power-card .power-title {
        font-weight: 600;
    }

.score-input {
    width: 5rem;
}

.quantity-input {
    width: 4.5rem;
}

/* ---- Table ---- */

.vtt-full {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.vtt-full-main {
    flex: 1;
    min-height: 0;
}

.table-page {
    display: flex;
    height: 100%;
}

.table-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--bs-border-color);
    flex-wrap: wrap;
}

.table-map {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #16191c;
    touch-action: none;
    user-select: none;
    outline: none;
}

    .table-map.cursor-grab { cursor: grab; }
    .table-map.cursor-grabbing { cursor: grabbing; }
    .table-map.cursor-crosshair { cursor: crosshair; }
    .table-map.cursor-pointer { cursor: pointer; }

.map-svg {
    display: block;
}

.map-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: var(--bs-secondary-color);
}

.table-sidebar {
    width: 22rem;
    flex: none;
    border-left: 1px solid var(--bs-border-color);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Five tabs have to fit across the sidebar. */
.table-sidebar .nav-tabs .nav-link {
    padding: 0.5rem 0.6rem;
    font-size: 0.875rem;
}

.sidebar-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
}

.token circle {
    stroke: rgba(255, 255, 255, 0.85);
}

.token.controllable {
    cursor: move;
}

.token.selected circle {
    stroke: #ffd43b;
    stroke-width: 4px;
}

.token circle.bloodied {
    stroke: #fa5252;
}

.token.hidden-token {
    opacity: 0.5;
}

/* Party view: creatures the party can't see right now. */
.token.unseen {
    opacity: 0.45;
}

    .token.unseen circle {
        stroke-dasharray: 4 3;
    }

.token-initials {
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: 700;
    pointer-events: none;
}

.token-name {
    fill: #fff;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.85);
    stroke-width: 3px;
    pointer-events: none;
}

.hp-back { fill: rgba(0, 0, 0, 0.6); }
.hp-fill { fill: #40c057; }
.hp-bloodied { fill: #fa5252; }

.wall { stroke-linecap: round; pointer-events: none; }
.wall-wall { stroke: #ff6b6b; }
.wall-door { stroke: #ffd43b; }
.wall-window { stroke: #74c0fc; }
.wall-secretdoor { stroke: #da77f2; }
.wall.open { stroke-dasharray: 6 6; opacity: 0.7; }

.wall-preview {
    stroke: #ffd43b;
    stroke-width: 3px;
    stroke-dasharray: 8 6;
    pointer-events: none;
}

.corner-marker {
    fill: #ffd43b;
    pointer-events: none;
}

.measure-line {
    stroke: #4dabf7;
    stroke-width: 3px;
    stroke-dasharray: 10 6;
    pointer-events: none;
}

.measure-label, .ping-label {
    fill: #fff;
    text-anchor: middle;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.9);
    stroke-width: 4px;
    font-weight: 700;
    pointer-events: none;
}

.ping {
    fill: none;
    stroke: #fcc419;
    stroke-width: 4px;
    pointer-events: none;
    transform-box: fill-box;
    transform-origin: center;
    animation: ping 1.2s ease-out infinite;
}

@keyframes ping {
    from { transform: scale(0.3); opacity: 1; }
    to { transform: scale(1.4); opacity: 0; }
}

.chat-panel {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-log {
    flex: 1;
    min-height: 8rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.4rem;
}

.chat-message {
    border-left: 3px solid var(--bs-border-color);
    padding: 0.15rem 0.5rem;
}

    .chat-message.private {
        border-left-color: #845ef7;
        background: rgba(132, 94, 247, 0.08);
    }

.chat-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.roll-dice {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

.chat-to {
    max-width: 7.5rem;
}

.physical-values {
    width: 9rem;
}

.token-swatch {
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    flex: none;
}

.attack-card,
.attack-form {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem;
}

    .attack-card.applied {
        opacity: 0.7;
    }

    .attack-card .table {
        --bs-table-bg: transparent;
    }

.target-list {
    max-height: 9rem;
    overflow-y: auto;
}

.undo-button {
    max-width: 16rem;
}

.attack-notes {
    font-size: 0.85em;
}

.dice-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.drawing {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.draw-swatch span {
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    border-radius: 50%;
    vertical-align: middle;
}

.move-path {
    fill: none;
    stroke: #ffd43b;
    stroke-width: 3px;
    stroke-dasharray: 8 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.measure-label.blocked {
    fill: #ff8787;
}

.template-square {
    fill: rgba(255, 107, 53, 0.3);
    stroke: rgba(255, 107, 53, 0.75);
    stroke-width: 1px;
}

    .template-square.out-of-range {
        fill: rgba(134, 142, 150, 0.3);
        stroke: rgba(134, 142, 150, 0.8);
    }

/* Combat log lines written by the table itself. */
.chat-event {
    font-size: 0.85em;
    font-style: italic;
    color: var(--bs-secondary-color);
    padding: 0.1rem 0.5rem;
    border-left: 3px solid transparent;
}

    .chat-event.private {
        border-left-color: #845ef7;
        background: rgba(132, 94, 247, 0.08);
    }

.initiative-list .list-group-item.current-turn {
    background: rgba(255, 212, 59, 0.14);
    border-left: 3px solid #ffd43b;
}

.init-value {
    width: 3.5rem;
    flex: none;
    text-align: center;
    font-weight: 600;
}

.init-input {
    width: 4rem;
    flex: none;
}

.turn-box {
    border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    padding: 0.5rem;
}

.turn-item-top {
    border-left: 3px solid var(--bs-primary);
}

.feature-kind {
    max-width: 8.5rem;
}

.token .turn-ring {
    fill: none;
    stroke: #ffd43b;
    stroke-dasharray: 6 4;
}

.effect-badge circle {
    fill: #f08c00;
    stroke: #fff;
    stroke-width: 1.5px;
}

.effect-badge text {
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: central;
    font-weight: 700;
    pointer-events: none;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }
