/*
 * Build calculator (/builder/).
 *
 * Loaded only on the calculator's pages (Builder\Routes). The skill pane
 * follows the game's structure - the mastery bar on the left, a grid of six
 * columns and seven tier rows, round buttons for passives and modifiers,
 * square ones for actives, brackets from a skill to what hangs on it - but
 * none of its textures: surfaces, rules and frames are the site's own.
 */

/* ============ Page ============ */
.builder-page__head {
    flex-wrap: wrap;
    align-items: center;
}

/* "My builds" sits on the right, beside the language switch. */
.builder-page__mine {
    margin-inline-start: auto;
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

.builder-page__mine:hover,
.builder-page__mine:focus-visible {
    color: var(--color-accent);
}

.builder__message {
    padding: var(--space-l);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-l);
    background: var(--color-surface);
    color: var(--color-text-muted);
    text-align: center;
}

.builder__editor {
    display: grid;
    gap: var(--space-m);
}

/* ============ Class table ============ */
.class-table__intro {
    margin-bottom: var(--space-s);
}

.class-table__title {
    margin: 0;
    color: var(--color-heading);
    font-size: var(--text-xl);
}

.class-table__hint {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

/* ---- Two-step picker: a mastery, then one of its eleven classes ---- */
.class-picker {
    display: grid;
    grid-template-columns: minmax(15rem, 1fr) minmax(0, 2fr);
    gap: var(--space-l);
    /* The corner meander takes ~31px: less padding would lay text on it. */
    padding: var(--space-l);
    border: var(--border-thin) solid var(--color-border);
    background: var(--color-surface);
}

.class-picker__step {
    display: grid;
    align-content: start;
    gap: var(--space-s);
    min-width: 0;
}

.class-picker__step + .class-picker__step {
    padding-inline-start: var(--space-l);
    border-inline-start: var(--border-thin) solid var(--color-border);
}

.class-picker__heading {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    margin: 0;
    color: var(--color-heading);
    font-size: var(--text-s);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.class-picker__number {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 1.5rem;
    height: 1.5rem;
    border: var(--border-thin) solid var(--color-border-accent);
    border-radius: 50%;
    color: var(--color-accent);
    font-size: var(--text-2xs);
}

.class-picker__masteries,
.class-picker__classes {
    display: grid;
    gap: var(--space-3xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Classes in two columns where there is room: eleven rows is a long list. */
.class-picker__classes {
    grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
    gap: var(--space-2xs);
}

.class-picker__crest {
    flex: none;
    border-radius: 50%;
}

/* Both steps' buttons: a row of crest and text, the text free to wrap. */
.class-picker__mastery,
.class-picker__class {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    width: 100%;
    padding: var(--space-2xs) var(--space-xs);
    border: var(--border-thin) solid transparent;
    border-radius: var(--radius-m);
    background: none;
    color: var(--color-text);
    font: inherit;
    text-align: start;
    overflow-wrap: anywhere;
    hyphens: auto;
    cursor: pointer;
}

.class-picker__mastery:hover,
.class-picker__mastery:focus-visible,
.class-picker__class:hover,
.class-picker__class:focus-visible {
    border-color: var(--color-border-strong);
    background: var(--color-surface-sunken);
    color: var(--color-text-strong);
}

.class-picker__mastery--current {
    border-color: var(--color-border-accent);
    background: var(--color-surface-sunken);
    color: var(--color-heading);
}

.class-picker__mastery-name {
    font-family: var(--font-heading);
    font-size: var(--text-s);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.class-picker__class {
    border-color: var(--color-border);
    background: var(--color-canvas-alt);
}

/* The build on screen: its class is marked wherever the list shows it. */
.class-picker__class--current {
    border-color: var(--color-accent);
    box-shadow: inset 0 0 0 var(--border-thin) var(--color-accent);
}

/* The two crests of a pair overlap a little, like a coat of arms. */
.class-picker__pair {
    display: flex;
    flex: none;
    width: 3rem;
}

.class-picker__pair .class-picker__crest + .class-picker__crest {
    margin-inline-start: -0.5rem;
}

.class-picker__class-text {
    display: grid;
    gap: 0.125rem;
    min-width: 0;
}

.class-picker__class-name {
    color: var(--color-text-strong);
    font-family: var(--font-heading);
    font-size: var(--text-m);
    font-weight: 700;
    line-height: 1.2;
}

.class-picker__class-with {
    color: var(--color-text-muted);
    font-size: var(--text-2xs);
    line-height: 1.3;
}

/* Narrow: the steps stack, the masteries become a grid of tiles. */
@media (max-width: 48rem) {
    .class-picker {
        grid-template-columns: minmax(0, 1fr);
    }

    .class-picker__step + .class-picker__step {
        padding-inline-start: 0;
        padding-top: var(--space-l);
        border-inline-start: 0;
        border-top: var(--border-thin) solid var(--color-border);
    }

    .class-picker__masteries {
        grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
    }
}

/* ============ Head: class, budget, actions ============ */
.builder-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--space-s) var(--space-l);
    align-items: center;
    /* Not less on a phone either: the corner meander takes ~31px. */
    padding: var(--space-l);
    border: var(--border-thin) solid var(--color-border);
    background: var(--color-surface);
}

.builder-head__class {
    margin: 0 0 var(--space-3xs);
    color: var(--color-heading);
    font-size: var(--text-xl);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

/*
 * The build's own name: a field that reads as a line of the heading, not a
 * form control, until it is pointed at.
 */
.builder-head__name {
    display: block;
    width: 100%;
    max-width: 28rem;
    margin: 0 0 var(--space-s);
    padding: var(--space-3xs) 0 var(--space-2xs);
    border: 0;
    border-bottom: var(--border-thin) dashed var(--color-border-strong);
    border-radius: 0;
    background: none;
    color: var(--color-text-strong);
    font-size: var(--text-m);
}

.builder-head__name::placeholder {
    color: var(--color-text-muted);
}

.builder-head__name:hover {
    border-bottom-color: var(--color-text-muted);
}

.builder-head__name:focus-visible {
    border-bottom-style: solid;
    border-bottom-color: var(--color-accent);
    outline: none;
}

.builder-head__author {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-2xs);
    margin: var(--space-2xs) 0 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

/* Badge and author, separated by dots that wrap with their part. */
.builder-head__author > * + *::before {
    content: '·';
    margin-inline-end: var(--space-2xs);
}

/* A build an AI assistant assembled: a badge first, no dot after it. */
.builder-head__ai {
    padding: 0 var(--space-2xs);
    border: var(--border-thin) solid var(--color-border-accent);
    border-radius: var(--radius-s);
    color: var(--color-text);
    cursor: help;
}

.builder-head__ai + *::before {
    content: none;
}

/*
 * Created and updated on a line of their own, as label and value: the time
 * carries a dot of its own, so the two are spaced apart rather than dotted.
 */
.builder-head__dates {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3xs) var(--space-m);
    margin: var(--space-3xs) 0 0;
    font-size: var(--text-xs);
}

.builder-head__date {
    display: flex;
    gap: var(--space-2xs);
    margin: 0;
}

.builder-head__date-label {
    color: var(--color-text-muted);
}

.builder-head__date-value {
    margin: 0;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

.builder-head__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
    justify-content: flex-end;
    align-items: center;
}

/*
 * Under saving, on a row of their own: new build, another class, reset.
 * Text buttons, quieter than the save - they change or drop the build.
 */
.builder-tools {
    display: flex;
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: var(--space-3xs) var(--space-s);
    justify-content: flex-end;
}

.builder-tools__button {
    display: inline-flex;
    gap: var(--space-3xs);
    align-items: center;
    padding: var(--space-3xs) 0;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
}

.builder-tools__button:hover,
.builder-tools__button:focus-visible {
    color: var(--color-accent);
}

.builder-tools__button--danger:hover,
.builder-tools__button--danger:focus-visible {
    color: var(--color-danger);
}

.builder-tools__button:disabled {
    cursor: default;
    opacity: 0.5;
}

.builder-tools__icon {
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.builder-head__status {
    display: grid;
    gap: var(--space-2xs);
    grid-column: 1 / -1;
}

.builder-head__problem,
.builder-head__note {
    margin: 0;
    font-size: var(--text-s);
}

.builder-head__problem {
    color: var(--color-danger);
}

.builder-head__note {
    color: var(--color-text-muted);
}

/* ---- Character level stepper ---- */
.builder-level {
    display: inline-flex;
    /* The field is a grid: without this the box stretches to the label, past its buttons. */
    justify-self: start;
    height: 2.25rem;
    border: var(--border-thin) solid var(--color-border-strong);
    border-radius: var(--radius-m);
    overflow: hidden;
}

.builder-level__step {
    width: 2.25rem;
    padding: 0;
    border: 0;
    background: var(--color-surface-sunken);
    color: var(--color-text-strong);
    font-size: var(--text-m);
    cursor: pointer;
}

.builder-level__step:hover,
.builder-level__step:focus-visible {
    background: var(--color-surface-hover);
    color: var(--color-accent-hover);
}

.builder-level__input {
    width: 3.5rem;
    padding: 0;
    border: 0;
    border-inline: var(--border-thin) solid var(--color-border);
    border-radius: 0;
    background: var(--color-canvas-alt);
    color: var(--color-text-strong);
    font-variant-numeric: tabular-nums;
    text-align: center;
    appearance: textfield;
}

/*
 * Focus is shown on the whole box, not the field: the site-wide outline sits
 * 2px outside the field and the box clips it (overflow: hidden, for the
 * rounded corners), which left a lone bright stripe down its left side.
 */
.builder-level__input:focus,
.builder-level__input:focus-visible {
    border-inline-color: var(--color-border);
    outline: none;
}

.builder-level:focus-within {
    border-color: var(--color-accent);
}

.builder-level__input::-webkit-inner-spin-button,
.builder-level__input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

/* ============ Progression: level, skill points, masteries ============ */
/*
 * Below the build's own header: the numbers that decide how far the trees
 * can go. Four cells split by rules; each number carries a line saying what
 * it is, since "spent / available / free" read as a riddle on their own.
 */
.builder-plan {
    display: grid;
    /*
     * The level cell carries the quest toggles, whose three names run long in
     * some languages, and the minimum level under them.
     */
    grid-template-columns: minmax(18rem, 1.3fr) minmax(14rem, 1.4fr) minmax(12rem, 1fr);
    border: var(--border-thin) solid var(--color-border);
    background: var(--color-surface);
}

/*
 * Each cell is two rows of the panel's grid: its numbers, then the block under
 * a rule (minimum level, attack, switches). The subgrid puts the three rules
 * on one line whatever each cell holds above them.
 */
.builder-plan__cell {
    display: grid;
    grid-row: span 2;
    grid-template-rows: subgrid;
    row-gap: 0;
    min-width: 0;
    padding: var(--space-m) var(--space-l);
}

/*
 * The lower row is as tall as the tallest cell's block; the shorter blocks
 * keep their own height instead of spreading their lines over it.
 */
.builder-plan__cell > * {
    align-self: start;
}

/* The masteries keep their switches right under them, not on the others' line. */
.builder-plan__cell--masteries {
    grid-template-rows: none;
    align-content: start;
}

.builder-plan__main {
    display: grid;
    align-content: start;
    gap: var(--space-2xs);
    min-width: 0;
}

.builder-plan__cell + .builder-plan__cell {
    border-inline-start: var(--border-thin) solid var(--color-border);
}

.builder-plan__label {
    margin: 0;
    /* A long word in another language breaks rather than leaves its cell. */
    overflow-wrap: break-word;
    hyphens: auto;
    color: var(--color-text-muted);
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.builder-plan__value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0 var(--space-3xs);
    margin: 0;
    color: var(--color-text-strong);
    font-variant-numeric: tabular-nums;
}

.builder-plan__value strong {
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    line-height: 1;
}

.builder-plan__value--bad strong {
    color: var(--color-danger);
}

.builder-plan__of {
    color: var(--color-text-muted);
    font-size: var(--text-m);
}

.builder-plan__free {
    margin-inline-start: auto;
    color: var(--color-text);
    font-size: var(--text-xs);
}

.builder-plan__free--bad {
    color: var(--color-danger);
}

.builder-plan__hint {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-2xs);
    line-height: var(--leading-normal);
}

/*
 * Under the quest rewards, the minimum level: label and hint on the left, the
 * number beside both, split off by a rule like the switches under the masteries.
 */
.builder-plan__need {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-3xs) var(--space-s);
    margin: var(--space-s) 0 0;
    padding: var(--space-s) 0 0;
    border-top: var(--border-thin) solid var(--color-border);
}

.builder-plan__need-value {
    grid-column: 2;
    grid-row: 1 / span 2;
}

.builder-plan__need-value strong {
    font-size: var(--text-2xl);
}

.builder-plan__need-hint {
    grid-column: 1;
}

/* Under the masteries, the switches of what the numbers count. */
.builder-plan__conditions {
    display: grid;
    gap: var(--space-2xs);
    min-width: 0;
    margin: var(--space-s) 0 0;
    padding: var(--space-s) 0 0;
    border: 0;
    border-top: var(--border-thin) solid var(--color-border);
}

.builder-plan__conditions .builder-plan__label {
    /* A floated legend sits inside the fieldset, under its rule, not on it. */
    float: left;
    width: 100%;
    padding: 0;
    margin-bottom: var(--space-3xs);
}

.builder-plan__condition {
    display: flex;
    clear: left;
    gap: var(--space-xs);
    align-items: center;
    width: fit-content;
    font-size: var(--text-xs);
    cursor: pointer;
}

.builder-plan__masteries {
    display: grid;
    gap: var(--space-2xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

.builder-plan__mastery {
    display: flex;
    justify-content: space-between;
    gap: var(--space-s);
    color: var(--color-text);
    font-size: var(--text-s);
}

.builder-plan__mastery-level {
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.builder-plan__mastery-level strong {
    color: var(--color-text-strong);
}

/* How much of the budget is spent: the same fill as the mastery bar. */
.builder-meter {
    display: block;
    height: 0.375rem;
    border: var(--border-thin) solid var(--color-border-strong);
    border-radius: var(--radius-s);
    background: var(--color-canvas-alt);
    overflow: hidden;
}

.builder-meter__fill {
    display: block;
    height: 100%;
    background: linear-gradient(to right, var(--color-border-accent), var(--color-accent));
    transition: width var(--duration) var(--ease);
}

.builder-meter__fill--bad {
    background: var(--color-danger);
}

/* ---- Life and energy under the skill points ---- */
/* Life and energy side by side, over the two numbers of the attack below. */
.builder-pools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-s);
    margin: var(--space-s) 0 0;
    padding: var(--space-s) 0 0;
    border-top: var(--border-thin) solid var(--color-border);
    list-style: none;
}

.builder-pools__pool {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: var(--space-2xs);
    row-gap: var(--space-3xs);
    align-items: baseline;
    font-size: var(--text-xs);
}

.builder-pools__label {
    color: var(--color-text-muted);
}

.builder-pools__value {
    color: var(--color-text-strong);
    font-family: var(--font-heading);
    font-size: var(--text-s);
    font-variant-numeric: tabular-nums;
}

/*
 * The whole bar is the pool; its darker left part is what the hero has of
 * their own (base and attribute points), the brighter rest is what skills
 * and gear add.
 */
.builder-pools__bar {
    grid-column: 1 / -1;
    display: block;
    height: 0.375rem;
    border: var(--border-thin) solid var(--color-border-strong);
    border-radius: var(--radius-s);
    background: var(--pool);
    overflow: hidden;
}

.builder-pools__own {
    display: block;
    height: 100%;
    background: color-mix(in srgb, var(--pool) 55%, var(--color-canvas));
    transition: width var(--duration) var(--ease);
}

.builder-pools__pool--life { --pool: var(--color-life); }
.builder-pools__pool--mana { --pool: var(--color-energy); }

/*
 * Under the pools, the default attack: average damage and damage per second,
 * in the pools' two columns, split off by a rule.
 */
.builder-offense {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-s);
    margin: var(--space-s) 0 0;
    padding: var(--space-s) 0 0;
    border-top: var(--border-thin) solid var(--color-border);
}

.builder-offense__row {
    display: grid;
    gap: var(--space-3xs);
    min-width: 0;
}

.builder-offense__label {
    overflow-wrap: break-word;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.builder-offense__value {
    margin: 0;
    color: var(--color-text-strong);
    font-family: var(--font-heading);
    font-size: var(--text-xl);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* ---- Saved link ---- */
.builder-link {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
    align-items: center;
}

.builder-link__label {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

/*
 * The private switch beside "Share": a small toggle button in look, a real
 * checkbox underneath (hidden the accessible way), so the keyboard and the
 * screen reader get a checkbox.
 */
.builder-private {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-3xs);
    padding: var(--space-3xs) var(--space-2xs);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-m);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    cursor: pointer;
    user-select: none;
}

.builder-private__input {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
}

.builder-private__icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.builder-private:hover,
.builder-private:has(.builder-private__input:focus-visible) {
    border-color: var(--color-border-strong);
    color: var(--color-text-strong);
}

.builder-private--on {
    border-color: var(--color-border-accent);
    background: var(--color-surface-sunken);
    color: var(--color-text-strong);
}

/* The input with the copy button sitting inside its end. */
.builder-link__field {
    position: relative;
    display: flex;
    flex: 1 1 18rem;
    min-width: 0;
}

.builder-link__input {
    flex: 1;
    min-width: 0;
    padding-inline-end: 2.75rem;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
}

.builder-link__copy {
    position: absolute;
    inset: 0 0 0 auto;
    display: grid;
    place-items: center;
    width: 2.5rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    cursor: pointer;
}

.builder-link__copy:hover,
.builder-link__copy:focus-visible {
    color: var(--color-accent);
}

.builder-link__copy--done {
    color: var(--color-success);
}

.builder-link__copy svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ============ Mastery tabs ============ */
.builder-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
    align-items: flex-end;
    position: relative;
    z-index: 1;
}

.builder-tabs__tab {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: var(--space-2xs) var(--space-s);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-m) var(--radius-m) 0 0;
    /*
     * A tab stands on the board's top rule and has no bottom edge of its own:
     * its side borders end at the rule instead of running over it.
     */
    border-bottom: 0;
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: var(--text-s);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    cursor: pointer;
}

.builder-tabs__tab:hover,
.builder-tabs__tab:focus-visible {
    /* Not the bottom: on the current tab that edge is the board's colour. */
    border-top-color: var(--color-border-accent);
    border-inline-color: var(--color-border-accent);
    color: var(--color-accent-hover);
}

.builder-tabs__tab--current {
    border-color: var(--color-border-accent);
    /*
     * The current tab alone drops over the rule, in the board's own colour:
     * the tab and the board read as one piece.
     */
    margin-bottom: calc(var(--border-thin) * -1);
    border-bottom: var(--border-thin) solid var(--color-surface);
    background: var(--color-surface);
    color: var(--color-heading);
}

/* A tab that is an icon only (the character sheet): square-ish, the name in its title. */
.builder-tabs__tab--icon {
    justify-content: center;
    min-width: 3rem;
    /*
     * As tall as a mastery tab (its 1.75rem crest plus padding): the two
     * blocks stand side by side, and their panels must start on one line.
     */
    min-height: calc(1.75rem + 2 * var(--space-2xs));
}

/* A page's own tab of the sheet (the editor's portals): a game icon. */
.builder-tabs__page-icon {
    width: 1.375rem;
    height: 1.375rem;
}

.builder-tabs__icon {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.builder-tabs__crest {
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
}

.builder-tabs__level {
    min-width: 1.75rem;
    padding: 0 var(--space-3xs);
    border-radius: var(--radius-s);
    background: var(--color-canvas-alt);
    color: var(--color-text-strong);
    font-variant-numeric: tabular-nums;
    text-align: center;
}

/* ============ Workspace: the trees, and the character sheet beside them ============ */
/*
 * Two blocks side by side, each a tab strip standing on its own panel, as the
 * game keeps the skill window and the character window apart.
 */
.builder-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 19rem;
    gap: var(--space-m);
    /* Both blocks as tall as the taller one: the sheet follows the tree down. */
    align-items: stretch;
}

/*
 * A strip and its panel touch: no gap, the tabs stand on the panel's rule.
 * The panel takes whatever height the block has left under its tabs.
 */
.builder-workspace__trees,
.builder-sheet {
    display: grid;
    grid-template-rows: auto 1fr;
    min-width: 0;
}

/* Under the sheet's panel, the key skills: a row of their own height. */
.builder-sheet {
    grid-template-rows: auto 1fr auto;
}

/* The tabs on the left, the difficulty's round buttons on the right. */
.builder-sheet__bar {
    display: flex;
    gap: var(--space-xs);
    justify-content: space-between;
    align-items: flex-end;
}

/* As tall as a tab and on its baseline, so the buttons sit on the tabs' middle. */
.builder-difficulty {
    display: flex;
    flex: none;
    gap: var(--space-2xs);
    align-items: center;
    height: calc(1.75rem + 2 * var(--space-2xs));
}

.builder-difficulty__option {
    display: grid;
    place-items: center;
    width: 1.625rem;
    height: 1.625rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

/*
 * The game's indicator is not centred in its picture: the disc fills pixels
 * 0-20 of 22 and leaves a strip on the right and at the bottom. Drawn at
 * 28px from the top left corner inside a 26px circle, the disc's centre is
 * the button's centre, and the ring round the button sits on its rim.
 */
.builder-difficulty__option:has(.builder-difficulty__icon) {
    position: relative;
    overflow: hidden;
}

.builder-difficulty__icon {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 1.75rem;
    max-width: none;
    height: 1.75rem;
    opacity: 0.4;
    filter: grayscale(0.7);
    transition: opacity 0.15s, filter 0.15s;
}

.builder-difficulty__option:hover .builder-difficulty__icon,
.builder-difficulty__option:focus-visible .builder-difficulty__icon {
    opacity: 0.8;
    filter: none;
}

/* A sheet with tabs of the page's own (the editor's portals): smaller switcher, so the row fits. */
.builder-sheet--pages .builder-tabs__tab--icon {
    min-width: 2.625rem;
}

.builder-sheet--pages .builder-difficulty {
    gap: var(--space-2xs);
}

.builder-sheet--pages .builder-difficulty__option {
    width: 1.25rem;
    height: 1.25rem;
}

.builder-sheet--pages .builder-difficulty__icon {
    width: 1.375rem;
    height: 1.375rem;
}

/* The chosen one: bright, with a thin ring and a soft glow round its rim. */
.builder-difficulty__option--current {
    color: var(--color-heading);
    box-shadow:
        0 0 0 1px var(--color-border-accent),
        0 0 0.5rem color-mix(in srgb, var(--color-accent) 35%, transparent);
}

.builder-difficulty__option--current .builder-difficulty__icon {
    opacity: 1;
    filter: none;
}

/*
 * Side by side, the row is as tall as the tree alone: the sheet's panel
 * reports no height of its own (contain: size) and fills what the row gives
 * it, scrolling if its content is longer. Otherwise a sheet taller than the
 * tree stretched the board and left a band of emptiness under the tree.
 * Stacked, the sheet sizes itself again (the narrow-screen rule below).
 */
@media (min-width: 62.0625rem) {
    .builder-sheet .builder-stats {
        contain: size;
    }

    /*
     * The scroll lives inside the panel, not on it: the corner meander is
     * drawn on the panel, and a scrolling panel carried it away with the text.
     */
    .builder-sheet__scroll {
        min-height: 0;
        overflow-y: auto;
        scrollbar-color: var(--color-border-strong) transparent;
        scrollbar-width: thin;
    }
}

/* ============ Board: the skill tree ============ */
.builder-board {
    padding: var(--space-l);
    /* The same rule as the current tab, which is part of it. */
    border: var(--border-thin) solid var(--color-border-accent);
    background: var(--color-surface);
}

/* ============ Skill pane ============ */
.skill-pane {
    display: grid;
    grid-template-columns: 4rem minmax(34rem, 1fr);
    grid-template-rows: auto auto;
    gap: var(--space-xs) var(--space-s);
    overflow-x: auto;
    /*
     * The top mark ("40") sits on the field's top edge and half of it rises
     * above; a scrolling box clips whatever leaves it, so it gets the room.
     */
    padding-block: var(--space-xs) var(--space-3xs);
    scrollbar-color: var(--color-border-strong) transparent;
    scrollbar-width: thin;
}

/* ---- The mastery bar ---- */
.skill-pane__bar {
    position: relative;
    grid-column: 1;
    grid-row: 1;
}

.skill-pane__track {
    --bar-width: 0.75rem;
    --bar-gap: var(--space-xs);
    position: absolute;
    inset: 0 auto;
    /* Centred in its column, so the bar button below sits right under it. */
    left: 50%;
    width: var(--bar-width);
    transform: translateX(-50%);
    border: var(--border-thin) solid var(--color-border-strong);
    border-radius: var(--radius-s);
    background: var(--color-canvas-alt);
}

.skill-pane__fill {
    position: absolute;
    inset: auto 0 0;
    border-radius: inherit;
    background: linear-gradient(to top, var(--color-border-accent), var(--color-accent));
    transition: height var(--duration) var(--ease);
}

.skill-pane__mark {
    position: absolute;
    right: calc(100% + var(--bar-gap));
    transform: translateY(50%);
    color: var(--color-text-muted);
    font-size: var(--text-2xs);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.skill-pane__mark--reached {
    color: var(--color-heading);
}

/*
 * The tick: a notch across the track only, nothing between it and the
 * number. The mark is positioned against the track's padding box, hence the
 * border taken off its width.
 */
.skill-pane__mark::after {
    content: '';
    position: absolute;
    top: 50%;
    left: calc(100% + var(--bar-gap));
    width: calc(var(--bar-width) - 2 * var(--border-thin));
    height: var(--border-thin);
    background: var(--color-border-strong);
}

.skill-pane__mark--reached::after {
    background: var(--color-canvas);
}

/* The top mark is the track's end: a notch there would only sit on its edge. */
.skill-pane__mark:last-child::after {
    display: none;
}

.skill-pane__foot {
    display: grid;
    justify-items: center;
    gap: var(--space-3xs);
    grid-column: 1;
    grid-row: 2;
}

.skill-pane__bar-button {
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 2px solid var(--color-border-accent);
    border-radius: var(--radius-s);
    background: var(--color-surface-sunken);
    overflow: hidden;
    cursor: pointer;
}

.skill-pane__bar-button:hover,
.skill-pane__bar-button:focus-visible,
.skill-pane__bar-button--focus {
    border-color: var(--color-accent);
}

.skill-pane__bar-button--spent {
    border-color: var(--color-border-strong);
}

.skill-pane__bar-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /*
     * The game's "+" icons are 64x64 with the picture in the middle 48x48 and
     * 8px of transparency round it. Scaled by 64/48 the picture fills the
     * button, and the button (overflow: hidden) cuts the empty margin off.
     */
    transform: scale(1.3334);
}

.skill-pane__bar-level {
    color: var(--color-text-strong);
    font-size: var(--text-2xs);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* The controls hint: beside the bar button, under the field, where the row was empty. */
.skill-pane__note {
    display: grid;
    align-items: center;
    grid-column: 2;
    grid-row: 2;
}

/* ---- The field ---- */
.skill-pane__field {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    aspect-ratio: 600 / 434;
    container-type: inline-size;
}

.skill-pane__lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.skill-pane__rule {
    stroke: var(--color-border);
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
}

.skill-pane__bracket {
    fill: none;
    stroke: var(--color-border-strong);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.skill-pane__bracket--active {
    stroke: var(--color-border-accent);
}

/* ============ Skill button ============ */
.skill-button {
    position: absolute;
    /* BUTTON in SkillTree.js, in the field's 600 units. */
    width: calc(100% * 32 / 600);
    aspect-ratio: 1;
    padding: 0;
    border: 2px solid var(--color-border-strong);
    background: var(--color-surface-sunken);
    cursor: pointer;
    transform: translate(-50%, -50%);
    transition: border-color var(--duration) var(--ease),
                box-shadow var(--duration) var(--ease);
    -webkit-touch-callout: none;
    user-select: none;
}

.skill-button--square {
    border-radius: var(--radius-s);
}

.skill-button--round {
    border-radius: 50%;
}

.skill-button__icon {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    pointer-events: none;
}

.skill-button__level {
    position: absolute;
    top: calc(100% + 0.25rem);
    left: 50%;
    transform: translateX(-50%);
    color: var(--color-text-muted);
    font-size: clamp(0.625rem, 1.9cqi, 0.8125rem);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
}

.skill-button:hover,
.skill-button:focus-visible,
.skill-button--focus {
    border-color: var(--color-accent);
    outline: none;
}

.skill-button--learned {
    border-color: var(--color-border-accent);
}

.skill-button--learned .skill-button__level {
    color: var(--color-text-strong);
}

.skill-button--max {
    border-color: var(--color-highlight);
    box-shadow: var(--shadow-glow);
}

.skill-button--locked .skill-button__icon {
    filter: grayscale(1);
    opacity: 0.45;
}

.skill-button--locked:hover .skill-button__icon {
    opacity: 0.7;
}

/* ============ Skill tooltip ============ */
/*
 * Drawn into <body> with fixed coordinates (SkillTooltip.js): the pane
 * scrolls sideways on a phone and would clip it. Under a mouse it lets the
 * pointer through - it follows the cursor and has nothing to click.
 */
.skill-tip {
    position: fixed;
    z-index: 100;
    display: grid;
    gap: var(--space-2xs);
    width: max-content;
    max-width: min(22rem, calc(100vw - 24px));
    padding: var(--space-s);
    border: var(--border-thin) solid var(--color-border-accent);
    border-radius: var(--radius-m);
    background: var(--color-canvas);
    box-shadow: var(--shadow-m);
    font-size: var(--text-s);
    line-height: var(--leading-snug);
    pointer-events: none;
}

.skill-tip--pinned {
    pointer-events: auto;
}

.skill-tip p {
    margin: 0;
}

.skill-tip__name {
    color: var(--color-heading);
    font-family: var(--font-heading);
    font-size: var(--text-m);
    font-weight: 700;
}

.skill-tip__level {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.skill-tip__description {
    color: var(--color-text-reading);
}

.skill-tip__section {
    display: grid;
    gap: 2px;
}

.skill-tip__caption {
    color: var(--color-accent);
    font-size: var(--text-xs);
    font-weight: 700;
}

.skill-tip__lines {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    color: var(--color-text-strong);
    list-style: none;
}

.skill-tip__lines .skill-tip__lines {
    padding-inline-start: var(--space-s);
}

.skill-tip__section--next .skill-tip__lines {
    color: var(--color-text-muted);
}

.skill-tip__chance {
    color: var(--color-accent);
}

.skill-tip__ref {
    display: flex;
    gap: var(--space-2xs);
    align-items: center;
}

.skill-tip__ref-icon {
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
}

.skill-tip__blocked {
    color: var(--color-danger);
}

.skill-tip__controls {
    display: flex;
    gap: var(--space-2xs);
}

.skill-tip__step {
    min-width: 2.75rem;
    min-height: 2.25rem;
    font-size: var(--text-m);
}

/* A level the worn gear raised: green, as the game prints bonuses. */
/* Doubled class: it must beat `.skill-button--learned .skill-button__level`. */
.skill-button__level.skill-button__level--boosted,
.skill-tip__boosted {
    color: var(--color-success);
}

.skill-tip__items {
    display: grid;
    gap: var(--space-3xs);
}

.skill-tip__step:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Pane and the hint under it. */
.builder-board__main {
    display: grid;
    /* Rows as tall as their content: any spare height stays below, not between. */
    align-content: start;
    gap: var(--space-xs);
    min-width: 0;
}

/* ---- How to spend points: the mouse way or the touch way ---- */
.builder-board__hint {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-align: center;
}

.builder-board__hint-touch {
    display: none;
}

@media (hover: none) {
    .builder-board__hint-mouse {
        display: none;
    }

    .builder-board__hint-touch {
        display: inline;
    }
}

/* ============ Equipment tab ============ */
/* Set apart from the mastery tabs: it is not a tree. */
.builder-tabs__tab--gear {
    margin-inline-start: auto;
}

.builder-gear-pane {
    display: grid;
    gap: var(--space-m);
    padding-block: var(--space-s);
}

/*
 * The game's character window: the figure in the middle, the helmet above it
 * between the two rings; weapon, armour and artifact down the left; shield,
 * bracers, amulet and greaves down the right. The weapon-set switches sit in
 * the top corners, over the hands they switch.
 */
.builder-gear {
    display: grid;
    grid-template-columns: 1fr 3.5rem minmax(4.5rem, 1.2fr) 3.5rem 1fr;
    /* Width of the side slots: one for all, their heights follow the shape. */
    --gear-side: 4.75rem;

    grid-template-rows: repeat(5, auto);
    grid-template-areas:
        "setl     ring1  head   ring2  setr"
        "weapon   figure figure figure shield"
        "torso    figure figure figure arms"
        "torso    figure figure figure amulet"
        "artifact figure figure figure legs";
    gap: var(--space-xs);
    width: 100%;
    max-width: 34rem;
    margin: 0 auto;
}

/* The slots are one list for the screen reader, but cells of the grid above. */
.builder-gear__slots {
    display: contents;
}

.builder-gear__cell {
    display: flex;
    min-width: 0;
}

.builder-gear__cell--ring1 { grid-area: ring1; }
.builder-gear__cell--head { grid-area: head; }
.builder-gear__cell--ring2 { grid-area: ring2; }
.builder-gear__cell--weapon { grid-area: weapon; }
.builder-gear__cell--shield { grid-area: shield; }
.builder-gear__cell--torso { grid-area: torso; }
.builder-gear__cell--arms { grid-area: arms; }
.builder-gear__cell--amulet { grid-area: amulet; }
.builder-gear__cell--artifact { grid-area: artifact; }
.builder-gear__cell--legs { grid-area: legs; }

/* The helmet is a square box; the rings beside it, small ones low in the row. */
.builder-gear__cell--head {
    justify-self: center;
    width: 100%;
    max-width: 5.5rem;
    aspect-ratio: 1;
}

.builder-gear__cell--ring1,
.builder-gear__cell--ring2 {
    align-self: end;
    aspect-ratio: 34 / 29;
}

/*
 * The other slots take the shape of the outline the game engraves for them
 * (the pictures in assets/img/gear-slots), so the frame and the picture
 * meet. The side slots share one width, as in the game (68-69 px each), and
 * their height follows from the shape; the rows take the tallest of them.
 */
.builder-gear__cell--weapon,
.builder-gear__cell--shield,
.builder-gear__cell--torso,
.builder-gear__cell--arms,
.builder-gear__cell--amulet,
.builder-gear__cell--artifact,
.builder-gear__cell--legs {
    align-items: center;
    justify-content: center;
}

.builder-gear__cell--weapon .builder-gear__slot,
.builder-gear__cell--shield .builder-gear__slot,
.builder-gear__cell--torso .builder-gear__slot,
.builder-gear__cell--arms .builder-gear__slot,
.builder-gear__cell--amulet .builder-gear__slot,
.builder-gear__cell--artifact .builder-gear__slot,
.builder-gear__cell--legs .builder-gear__slot {
    flex: none;
    width: var(--gear-side);
    max-width: 100%;
    height: auto;
}

.builder-gear__cell--weapon .builder-gear__slot,
.builder-gear__cell--shield .builder-gear__slot { aspect-ratio: 69 / 126; }
.builder-gear__cell--torso .builder-gear__slot { aspect-ratio: 69 / 103; }
.builder-gear__cell--arms .builder-gear__slot { aspect-ratio: 68 / 70; }
/* The game's own low slot (CharacterEquipNeck: 69 x 33), from the XPack2 window. */
.builder-gear__cell--amulet .builder-gear__slot { aspect-ratio: 69 / 33; }
.builder-gear__cell--artifact .builder-gear__slot { aspect-ratio: 69 / 68; }
.builder-gear__cell--legs .builder-gear__slot { aspect-ratio: 68 / 66; }

.builder-gear__slot {
    position: relative;
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-width: 0;
    padding: var(--space-2xs);
    border: var(--border-thin) dashed var(--color-border-strong);
    border-radius: var(--radius-s);
    background: var(--color-surface-sunken);
    color: inherit;
    text-align: center;
    cursor: pointer;
}

.builder-gear__slot:hover,
.builder-gear__slot:focus-visible {
    border-color: var(--color-border-accent);
}

.builder-gear__slot--worn {
    border-style: solid;
}

/* The selected and the focused item wear the hover's border, not a ring outside. */
.builder-gear__slot--selected {
    border-color: var(--color-border-accent);
}

.builder-gear__slot:focus-visible {
    outline: none;
}

.builder-gear__slot--bad {
    border-color: var(--color-danger);
}

/* A shield slot a two-handed weapon has taken: shut, and it says why on hover. */
.builder-gear__slot--blocked {
    cursor: not-allowed;
    /* Faint hatching: taken, but by the weapon beside it. */
    background-image: repeating-linear-gradient(
        -45deg,
        transparent 0 6px,
        color-mix(in srgb, var(--color-border) 40%, transparent) 6px 7px
    );
}

/* The two-handed weapon seen through the shield's slot it takes. */
.builder-gear__icon--ghost {
    opacity: 0.3;
}

.builder-gear__slot:disabled:not(.builder-gear__slot--blocked) {
    cursor: default;
}

/* Item icons are not square (a spear is 64x256): the box keeps its shape. */
.builder-gear__icon {
    /* Sized from its own pixels once loaded (fitIcon); the slot is the cap. */
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* The socketed relic, in the corner the game marks it in. */
.builder-gear__relic {
    position: absolute;
    right: var(--space-3xs);
    bottom: var(--space-3xs);
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--color-canvas-alt);
    object-fit: contain;
}

/*
 * The game's rarity colours - the same as the knowledge base's cards
 * (.db-card__rarity--*), for names and for the glow behind a worn item.
 */
.builder-rarity--magical { color: var(--color-rarity-magical); }
.builder-rarity--rare { color: var(--color-rarity-rare); }
.builder-rarity--epic { color: var(--color-rarity-epic); }
.builder-rarity--legendary { color: var(--color-rarity-legendary); }
.builder-rarity--lesser,
.builder-rarity--greater,
.builder-rarity--divine { color: var(--color-rarity-artifact); }

/*
 * A worn item's rarity is a glow in two opposite corners, as in the game's
 * inventory: top right and bottom left. The game draws each as a crescent -
 * bright against the corner, with a curved inner edge - which is what lies
 * outside an ellipse centred in the slot. So the ellipse's outside is
 * coloured, and a diagonal mask keeps only those two corners.
 * A plain item has none.
 */
.builder-rarity-frame--magical { --rarity: var(--color-rarity-magical); }
.builder-rarity-frame--rare { --rarity: var(--color-rarity-rare); }
.builder-rarity-frame--epic { --rarity: var(--color-rarity-epic); }
.builder-rarity-frame--legendary { --rarity: var(--color-rarity-legendary); }
.builder-rarity-frame--lesser,
.builder-rarity-frame--greater,
.builder-rarity-frame--divine { --rarity: var(--color-rarity-artifact); }

.builder-gear__slot--worn[class*='builder-rarity-frame--']::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        ellipse 64% 64% at 50% 50%,
        transparent 86%,
        color-mix(in srgb, var(--rarity) 10%, transparent) 97%,
        color-mix(in srgb, var(--rarity) 28%, transparent) 112%
    );
    -webkit-mask-image: linear-gradient(to bottom right, transparent 28%, #000 44%, #000 56%, transparent 72%);
    mask-image: linear-gradient(to bottom right, transparent 28%, #000 44%, #000 56%, transparent 72%);
    pointer-events: none;
}

/* Above the glow. */
.builder-gear__icon {
    position: relative;
}

/*
 * An empty slot's outline, cut from the game's window. It fills the slot to
 * its frame, as in the game, rather than standing as a smaller square inside
 * it; the stone it is engraved in is lighter than our slot, so it is dimmed.
 */
.builder-gear__art {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
    opacity: 0.22;
    filter: grayscale(0.4);
    transition: opacity 0.15s;
}

.builder-gear__slot:hover .builder-gear__art,
.builder-gear__slot:focus-visible .builder-gear__art {
    opacity: 0.45;
}

.builder-gear__label {
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    overflow-wrap: anywhere;
}

/* Which set the hand shows, in the slot's corner. */
.builder-gear__set-mark {
    position: absolute;
    top: var(--space-3xs);
    right: var(--space-2xs);
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: var(--text-xs);
}

.builder-gear__figure {
    grid-area: figure;
    position: relative;
    display: flex;
    min-width: 0;
    /*
     * No height of its own: the side slots set the rows, and a long summary
     * scrolls inside instead of stretching the window and the page.
     */
    contain: size;
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    background: var(--color-canvas-alt);
}

/* ---- The middle of the window: what the worn gear adds up to (GearSummary.js) ---- */
.gear-summary {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-m);
    min-width: 0;
    min-height: 0;
    padding: var(--space-m);
    overflow-y: auto;
    scrollbar-color: var(--color-border-strong) transparent;
    scrollbar-width: thin;
    font-size: var(--text-xs);
    line-height: var(--leading-snug);
}

.gear-summary--empty {
    align-items: center;
    justify-content: center;
}

/* The build's crests behind the text, as a watermark; they stay as it scrolls. */
.gear-summary__crests {
    position: absolute;
    inset: 0;
    overflow: hidden;
    display: flex;
    gap: var(--space-l);
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.gear-summary__crest {
    width: min(9rem, 35%);
    height: auto;
    opacity: 0.07;
    filter: grayscale(1);
}

.gear-summary--empty .gear-summary__crest {
    opacity: 0.18;
}

.gear-summary__start {
    position: relative;
    margin: 0;
    color: var(--color-text-muted);
    text-align: center;
}

.gear-summary__section {
    position: relative;
}

.gear-summary__title {
    display: flex;
    gap: var(--space-xs);
    align-items: baseline;
    justify-content: space-between;
    margin: 0 0 var(--space-2xs);
    padding-bottom: var(--space-3xs);
    border-bottom: var(--border-thin) solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.gear-summary__aside {
    letter-spacing: 0;
    text-transform: none;
}

.gear-summary__list,
.gear-summary__needs,
.gear-summary__chips {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gear-summary__list {
    display: grid;
    gap: var(--space-xs);
}

.gear-summary__row,
.gear-summary__need {
    display: flex;
    gap: var(--space-xs);
    justify-content: space-between;
    margin: 0;
}

.gear-summary__set-name {
    font-weight: 600;
}

.gear-summary__set-name--on {
    color: var(--color-success);
}

.gear-summary__count {
    flex: none;
    color: var(--color-text-strong);
    font-variant-numeric: tabular-nums;
}

.gear-summary__bonus {
    margin: 0;
    color: var(--color-success);
}

.gear-summary__bonus--later {
    color: var(--color-text-muted);
}

/* Requirements in two columns: four short rows. */
.gear-summary__needs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
    gap: var(--space-3xs) var(--space-m);
}

.gear-summary__need-label {
    color: var(--color-text-muted);
}

.gear-summary__need--unmet .gear-summary__count,
.gear-summary__need--unmet .gear-summary__need-label {
    color: var(--color-danger);
}

.gear-summary__chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3xs);
}

.gear-summary__chip {
    padding: 0.125rem var(--space-xs);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    background: var(--color-surface-sunken);
}

.gear-summary__chip--all {
    border-color: var(--color-border-accent);
}

.gear-summary__plus {
    color: var(--color-success);
    font-variant-numeric: tabular-nums;
}

.gear-summary__missing {
    margin: 0;
    color: var(--color-text-muted);
}

/* ---- I / II ---- */
.builder-gear__sets {
    display: flex;
    gap: var(--space-3xs);
    align-self: end;
    /* Centred over the hand's slot below. */
    justify-content: center;
}

.builder-gear__sets--left {
    grid-area: setl;
}

.builder-gear__sets--right {
    grid-area: setr;
}

.builder-gear__set {
    min-width: 2rem;
    height: 2rem;
    padding: 0 var(--space-2xs);
    border: var(--border-thin) solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    cursor: pointer;
}

.builder-gear__set:hover,
.builder-gear__set:focus-visible {
    border-color: var(--color-border-accent);
    color: var(--color-accent-hover);
}

.builder-gear__set--current {
    border-color: var(--color-border-accent);
    background: var(--color-surface-raised);
    color: var(--color-heading);
}

.builder-gear__soon {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-align: center;
}

/* ---- The selected item: its socket, its bonus, its card ---- */
.builder-gear-detail {
    display: grid;
    gap: var(--space-s);
    width: 100%;
    max-width: 34rem;
    margin: 0 auto;
    padding-top: var(--space-s);
    border-top: var(--border-thin) solid var(--color-border);
}

.builder-gear-detail__head {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-s);
    align-items: center;
}

.builder-gear-detail__name {
    display: grid;
    flex: 1;
    min-width: 10rem;
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--text-m);
}

/* The item's name, a link to its page: in its rarity's colour, underlined on hover. */
.builder-gear-detail__link {
    justify-self: start;
    text-decoration: none;
}

.builder-gear-detail__link:hover,
.builder-gear-detail__link:focus-visible {
    text-decoration: underline;
}

.builder-gear-detail__meta {
    display: block;
    color: var(--color-text-muted);
    font-family: var(--font-main);
    font-size: var(--text-xs);
}

.builder-gear-detail__actions,
.builder-socket__actions {
    display: flex;
    gap: var(--space-2xs);
}

/* ---- Tooltip of a worn item (GearTooltip.js): the game's, lines of text ---- */
.gear-tip {
    position: fixed;
    z-index: 100;
    display: grid;
    gap: var(--space-xs);
    width: max-content;
    max-width: min(20rem, calc(100vw - 24px));
    padding: var(--space-xs) var(--space-s);
    border: var(--border-thin) solid var(--color-border-accent);
    border-radius: var(--radius-s);
    background: color-mix(in srgb, var(--color-canvas) 94%, transparent);
    box-shadow: var(--shadow-m);
    font-size: var(--text-xs);
    line-height: var(--leading-snug);
    pointer-events: none;
}

.gear-tip p {
    margin: 0;
}

.gear-tip__name {
    font-family: var(--font-heading);
    font-size: var(--text-s);
    font-weight: 700;
}

/* Name and type read as one head. */
.gear-tip__type {
    margin-top: calc(-1 * var(--space-xs)) !important;
    color: var(--color-text-muted);
}

.gear-tip__lines {
    margin: 0;
    padding: 0;
    list-style: none;
}

.gear-tip__line--base {
    color: var(--color-text-strong);
}

.gear-tip__line--prop,
.gear-tip__line--sub,
.gear-tip__line--skill {
    color: var(--color-info);
}

/* Head of a group ("10% шанс на:", "Бонус всем компаньонам"): not a stat itself. */
.gear-tip__line--chance {
    margin-top: var(--space-3xs);
    color: var(--color-heading);
}

/* Members of a group, marked so they read as its list. */
.gear-tip__line--sub {
    position: relative;
    padding-inline-start: var(--space-s);
}

.gear-tip__line--sub::before {
    content: '•';
    position: absolute;
    inset-inline-start: var(--space-3xs);
    color: var(--color-text-muted);
}

/* The skill an item grants: its icon, name, level and trigger, as the game shows it. */
.gear-tip__skill {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
}

.gear-tip__skill-icon {
    flex: none;
    width: 2rem;
    height: 2rem;
}

.gear-tip__skill-name {
    margin: 0;
    color: var(--color-heading);
}

.gear-tip__skill-meta {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.gear-tip__line--bonus,
.gear-tip__line--set {
    color: var(--color-success);
}

.gear-tip__reqs {
    color: var(--color-text-muted);
}

/* The next step of a set: what one more piece would give. */
.gear-tip__line--later {
    color: var(--color-text-muted);
}

.gear-tip__line--unmet {
    color: var(--color-danger);
}

.builder-socket {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-s);
    align-items: center;
    padding: var(--space-xs) var(--space-s);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    background: var(--color-surface-sunken);
}

.builder-socket__label {
    color: var(--color-text-muted);
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.builder-socket__relic {
    display: flex;
    flex: 1;
    gap: var(--space-xs);
    align-items: center;
    min-width: 10rem;
}

.builder-socket__icon {
    width: 2rem;
    height: 2rem;
    object-fit: contain;
}

.builder-socket__field {
    display: grid;
    gap: var(--space-3xs);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.builder-socket__field--wide {
    flex-basis: 100%;
}

.builder-socket__select {
    max-width: 100%;
}

/* ---- The picker window ---- */
.gear-picker {
    width: min(36rem, calc(100vw - 2rem));
    max-height: min(40rem, calc(100vh - 2rem));
    padding: 0;
    border: var(--border-thin) solid var(--color-border-accent);
    border-radius: var(--radius-m);
    background: var(--color-surface);
    color: var(--color-text);
}

.gear-picker::backdrop {
    background: color-mix(in srgb, var(--color-canvas) 70%, transparent);
}

.gear-picker__inner {
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    gap: var(--space-s);
    max-height: inherit;
    padding: var(--space-m);
}

.gear-picker__head {
    display: flex;
    gap: var(--space-s);
    align-items: center;
    justify-content: space-between;
}

.gear-picker__title {
    margin: 0;
    font-size: var(--text-l);
}

.gear-picker__close {
    width: 2rem;
    height: 2rem;
    border: var(--border-thin) solid var(--color-border);
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-muted);
    font-size: var(--text-l);
    line-height: 1;
    cursor: pointer;
}

.gear-picker__close:hover,
.gear-picker__close:focus-visible {
    border-color: var(--color-border-accent);
    color: var(--color-accent-hover);
}

.gear-picker__search {
    width: 100%;
}

.gear-picker__list {
    min-height: 0;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-strong) transparent;
}

.gear-picker__row {
    display: flex;
    gap: var(--space-s);
    align-items: center;
    width: 100%;
    padding: var(--space-2xs) var(--space-xs);
    border: 0;
    border-radius: var(--radius-s);
    background: transparent;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

.gear-picker__row:hover,
.gear-picker__row:focus-visible {
    background: var(--color-surface-hover);
}

.gear-picker__row--current {
    background: var(--color-surface-raised);
}

/* An item the hero cannot wear: greyed and shut; its failing requirement stays red. */
.gear-picker__row--unmet {
    cursor: not-allowed;
}

.gear-picker__row--unmet:hover {
    background: none;
}

.gear-picker__row--unmet .gear-picker__icon,
.gear-picker__row--unmet .gear-picker__name {
    opacity: 0.45;
    filter: grayscale(1);
}

.gear-picker__icon {
    flex: none;
    width: 2.25rem;
    height: 2.25rem;
    object-fit: contain;
}

.gear-picker__text {
    display: grid;
    min-width: 0;
}

.gear-picker__name {
    font-weight: 600;
}

.gear-picker__meta {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.gear-picker__level--bad {
    color: var(--color-danger);
}

.gear-picker__note {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-align: center;
}

/* ============ Character sheet ============ */
/* The sheet's panel: the board's own look, the tabs above belong to it. */
.builder-stats {
    display: grid;
    /* Both tracks may shrink: a grid item's minimum is its content otherwise. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    /* The corner meander takes ~31px: less padding would lay text on it. */
    padding: var(--space-l);
    border: var(--border-thin) solid var(--color-border-accent);
    background: var(--color-surface);
}

.builder-sheet__scroll {
    display: grid;
    /*
     * One column no wider than the panel: with the default `auto` track a
     * long label or the conditions' select widened it and a sideways scroll
     * appeared.
     */
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-m);
    align-content: start;
    min-width: 0;
    overflow-x: hidden;
}

/* ---- One section of a tab, ruled off from the next, as in the game ---- */
.builder-sheet__section {
    display: grid;
    gap: var(--space-xs);
}

.builder-sheet__section + .builder-sheet__section {
    padding-top: var(--space-s);
    border-top: var(--border-thin) solid var(--color-border-accent);
}

.builder-sheet__heading {
    display: flex;
    gap: var(--space-xs);
    align-items: baseline;
    justify-content: space-between;
    margin: 0;
    color: var(--color-heading);
    font-family: var(--font-heading);
    font-size: var(--text-m);
}

.builder-sheet__points {
    color: var(--color-accent);
    font-family: var(--font-main);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
}

.builder-sheet__points--bad {
    color: var(--color-danger);
}

.builder-sheet__list {
    display: grid;
    gap: var(--space-3xs);
    margin: 0;
}

.builder-sheet-row {
    display: flex;
    gap: var(--space-xs);
    align-items: baseline;
    justify-content: space-between;
}

/* A blank line between groups, where the game leaves one. */
.builder-sheet-row--gap {
    margin-top: var(--space-xs);
}

.builder-sheet-row__label {
    display: flex;
    gap: var(--space-3xs);
    align-items: center;
    min-width: 0;
    color: var(--color-text-muted);
}

.builder-sheet-row__value {
    margin: 0;
    color: var(--color-text-strong);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* The game prints life red and energy blue. */
.builder-sheet-row--life .builder-sheet-row__value {
    color: #e0473f;
}

.builder-sheet-row--mana .builder-sheet-row__value {
    color: #6f7fe8;
}

/* The game's small square +, and a − beside it to take a point back. */
.builder-sheet__step {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 1.125rem;
    height: 1.125rem;
    padding: 0;
    border: var(--border-thin) solid var(--color-border-accent);
    border-radius: var(--radius-s);
    background: var(--color-surface-raised);
    color: var(--color-heading);
    font-size: var(--text-xs);
    line-height: 1;
    cursor: pointer;
}

.builder-sheet__step:hover:not(:disabled),
.builder-sheet__step:focus-visible {
    border-color: var(--color-accent);
    color: var(--color-accent-hover);
}

.builder-sheet__step:disabled {
    opacity: 0.3;
    cursor: default;
}

/* ---- Icon grids: resistances, damage bonuses, races ---- */
.builder-sheet-grid {
    display: grid;
    grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
    gap: var(--space-xs) var(--space-2xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

.builder-sheet-grid__cell {
    display: flex;
    gap: 0.125rem;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

/* Races and damage stand in more columns: the number goes under the icon. */
.builder-sheet-grid--stacked .builder-sheet-grid__cell {
    flex-direction: column;
}

.builder-sheet-grid__icon {
    flex: none;
    /* Small enough that "-100%" fits beside it in a quarter of the panel. */
    width: 1.25rem;
    height: 1.25rem;
    object-fit: contain;
}

.builder-sheet-grid__value {
    color: var(--color-success);
    font-size: var(--text-2xs);
    letter-spacing: -0.01em;
    white-space: nowrap;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.builder-sheet-grid__value--bad {
    color: var(--color-danger);
}

/* ---- What the numbers assume ---- */
.builder-sheet__conditions {
    display: grid;
    gap: var(--space-2xs);
    padding-top: var(--space-s);
    border-top: var(--border-thin) solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.builder-sheet__note {
    margin: 0;
    font-size: var(--text-2xs);
}

/* ---- Quest rewards, beside the character level (QuestRewards.js) ---- */
.builder-quests {
    display: grid;
    gap: var(--space-2xs);
    margin-top: var(--space-xs);
}

.builder-quests__toggles {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3xs);
}

/* One toggle per difficulty: its name, and the skill / attribute points it hands out. */
.builder-quests__toggle {
    display: grid;
    /* Equal while they fit; a long name wraps the row instead of being cut. */
    flex: 1 0 auto;
    gap: 0.125rem;
    justify-items: center;
    padding: var(--space-3xs) var(--space-xs);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    background: var(--color-surface-sunken);
    color: var(--color-text-muted);
    cursor: pointer;
}

.builder-quests__toggle:hover,
.builder-quests__toggle:focus-visible {
    border-color: var(--color-border-accent);
}

.builder-quests__toggle--on {
    border-color: var(--color-border-accent);
    background: var(--color-surface-raised);
    color: var(--color-text-strong);
}

.builder-quests__name {
    font-family: var(--font-heading);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.builder-quests__gain {
    font-size: var(--text-2xs);
    font-variant-numeric: tabular-nums;
}

/* Some of a difficulty's quests counted: framed, not lit. */
.builder-quests__toggle--some {
    border-color: var(--color-border-accent);
    color: var(--color-text);
}

/* ---- The quest picker: the key-skill dialog, wider, with difficulty tabs ---- */
/*
 * A fixed height: with only a maximum the list's 1fr row grew with its
 * content and the dialog scrolled as well as the list. Now only the list does;
 * the title and the tabs stay.
 */
.quest-picker {
    width: min(36rem, calc(100vw - 2rem));
    height: min(44rem, calc(100vh - 2rem));
    max-height: none;
    overflow: hidden;
}

.quest-picker__inner {
    grid-template-rows: auto auto minmax(0, 1fr);
    height: 100%;
    max-height: none;
}

.quest-picker__bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs) var(--space-s);
    align-items: flex-end;
    justify-content: space-between;
}

.quest-picker__all {
    display: flex;
    gap: var(--space-xs);
}

.quest-picker__quests {
    display: grid;
    gap: var(--space-3xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A quest: its checkbox and name, what it gives under them, a passive to pick. */
.quest-picker__quest {
    display: grid;
    gap: var(--space-3xs);
    padding: var(--space-2xs) var(--space-xs);
    border: var(--border-thin) solid transparent;
    border-radius: var(--radius-s);
    color: var(--color-text-muted);
}

.quest-picker__quest--on {
    border-color: var(--color-border);
    background: var(--color-surface-raised);
    color: var(--color-text);
}

.quest-picker__check {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    cursor: pointer;
}

.quest-picker__name {
    color: var(--color-text-strong);
    font-size: var(--text-s);
}

.quest-picker__gains {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-s);
    margin: 0;
    padding: 0 0 0 calc(1em + var(--space-xs));
    font-size: var(--text-xs);
    list-style: none;
}

.quest-picker__choice {
    padding-left: calc(1em + var(--space-xs));
}

.quest-picker__choice select {
    width: auto;
    max-width: 100%;
    padding: 0.125rem var(--space-2xs);
    color: var(--color-text-strong);
    font-size: var(--text-xs);
}

/* ============ Narrow screens ============ */
@media (max-width: 62rem) {
    /* Two by two, the rules between the cells redrawn for the new grid. */
    .builder-plan {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Three cells: the masteries take the whole second row. */
    .builder-plan__cell:nth-child(3) {
        grid-column: 1 / -1;
    }

    .builder-plan__cell + .builder-plan__cell {
        border-inline-start: 0;
    }

    .builder-plan__cell:nth-child(even) {
        border-inline-start: var(--border-thin) solid var(--color-border);
    }

    .builder-plan__cell:nth-child(n + 3) {
        border-top: var(--border-thin) solid var(--color-border);
    }

    .builder-workspace {
        grid-template-columns: minmax(0, 1fr);
    }

    .builder-head {
        grid-template-columns: minmax(0, 1fr);
    }

    .builder-head__actions,
    .builder-tools {
        justify-content: flex-start;
    }

}

@media (max-width: 40rem) {
    .builder-plan {
        grid-template-columns: minmax(0, 1fr);
    }

    .builder-plan__cell:nth-child(even) {
        border-inline-start: 0;
    }

    .builder-plan__cell + .builder-plan__cell {
        border-top: var(--border-thin) solid var(--color-border);
    }
}

/* ============ Key skills: three learned skills on show under the sheet ============ */
.key-skills {
    margin-top: var(--space-m);
    /* The corner meander takes ~31px: less padding would lay text on it. */
    padding: var(--space-l);
    border: var(--border-thin) solid var(--color-border-accent);
    background: var(--color-surface);
}

.key-skills__title {
    margin: 0 0 var(--space-s);
    color: var(--color-text-muted);
    font-size: var(--text-2xs);
    letter-spacing: var(--tracking-wide);
    text-align: center;
    text-transform: uppercase;
}

.key-skills__note {
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-align: center;
}

.key-skills__note + .key-skills__list {
    margin-top: var(--space-s);
}

/* One skill a row: the picture on the left, the name and level beside it. */
.key-skills__list {
    display: grid;
    gap: var(--space-2xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

.key-skills__item {
    display: flex;
}

.key-skills__slot {
    display: flex;
    flex: 1;
    gap: var(--space-s);
    align-items: center;
    min-width: 0;
    padding: var(--space-2xs) var(--space-xs);
    border: var(--border-thin) solid transparent;
    border-radius: var(--radius-s);
    background: var(--color-surface-sunken);
    color: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color var(--duration) var(--ease);
}

.key-skills__slot:hover,
.key-skills__slot:focus-visible {
    border-color: var(--color-accent);
    outline: none;
}

/* An empty place: a dashed row with a "+", as tall as a filled one. */
.key-skills__slot--empty {
    justify-content: center;
    min-height: calc(2.5rem + 2 * var(--space-2xs) + 2px);
    border-color: var(--color-border);
    border-style: dashed;
    background: transparent;
}

.key-skills__plus {
    color: var(--color-text-muted);
    font-size: var(--text-xl);
    line-height: 1;
}

.key-skills__text {
    display: grid;
    min-width: 0;
}

.key-skills__icon,
.key-picker__icon {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid var(--color-border-accent);
    border-radius: var(--radius-s);
    object-fit: cover;
}

.key-skills__icon--round,
.key-picker__icon--round {
    border-radius: 50%;
}

.key-skills__name {
    /* A long name in another language breaks rather than widens the column. */
    overflow-wrap: break-word;
    hyphens: auto;
    font-size: var(--text-s);
    font-weight: 600;
    line-height: 1.25;
}

.key-skills__level,
.key-picker__level {
    color: var(--color-text-muted);
    font-size: var(--text-2xs);
    font-variant-numeric: tabular-nums;
}

.key-skills__level--boosted,
.key-picker__level--boosted {
    color: var(--color-success);
}

/* ---- The window that chooses a slot's skill ---- */
.key-picker {
    width: min(28rem, calc(100vw - 2rem));
    max-height: min(40rem, calc(100vh - 2rem));
    padding: 0;
    border: var(--border-thin) solid var(--color-border-accent);
    border-radius: var(--radius-m);
    background: var(--color-surface);
    color: var(--color-text);
}

.key-picker::backdrop {
    background: color-mix(in srgb, var(--color-canvas) 70%, transparent);
}

.key-picker__inner {
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: var(--space-s);
    max-height: inherit;
    padding: var(--space-m);
}

.key-picker__head {
    display: flex;
    gap: var(--space-s);
    align-items: center;
    justify-content: space-between;
}

.key-picker__title {
    margin: 0;
    font-size: var(--text-l);
}

.key-picker__close {
    width: 2rem;
    height: 2rem;
    border: var(--border-thin) solid var(--color-border);
    border-radius: 50%;
    background: transparent;
    color: var(--color-text-muted);
    font-size: var(--text-l);
    line-height: 1;
    cursor: pointer;
}

.key-picker__close:hover,
.key-picker__close:focus-visible {
    border-color: var(--color-border-accent);
    color: var(--color-accent-hover);
}

.key-picker__list {
    min-height: 0;
    overflow-y: auto;
    scrollbar-color: var(--color-border-strong) transparent;
    scrollbar-width: thin;
}

.key-picker__group + .key-picker__group {
    margin-top: var(--space-s);
}

.key-picker__mastery {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    margin: 0 0 var(--space-2xs);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

.key-picker__crest {
    width: 1.5rem;
    height: 1.5rem;
}

.key-picker__skills {
    margin: 0;
    padding: 0;
    list-style: none;
}

.key-picker__row {
    display: flex;
    gap: var(--space-s);
    align-items: center;
    width: 100%;
    padding: var(--space-2xs) var(--space-xs);
    border: 0;
    border-radius: var(--radius-s);
    background: transparent;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

.key-picker__row:hover,
.key-picker__row:focus-visible {
    background: var(--color-surface-hover);
}

/* On show in another slot: marked, and choosing it swaps the two. */
.key-picker__row--shown {
    background: var(--color-surface-raised);
}

.key-picker__row--current {
    box-shadow: inset 0 0 0 1px var(--color-border-accent);
}

.key-picker__name {
    flex: 1;
    min-width: 0;
    font-weight: 600;
}

.key-picker__remove {
    justify-self: center;
    padding: var(--space-2xs) var(--space-m);
    border: var(--border-thin) solid var(--color-border);
    border-radius: var(--radius-s);
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
}

.key-picker__remove:hover,
.key-picker__remove:focus-visible {
    border-color: var(--color-danger);
    color: var(--color-danger);
}

/* ============ Character editor (/editor/) ============ */

/* The start screen: what it does, the file picker (also a drop target), where the file is. */
.save-open {
    display: grid;
    gap: var(--space-m);
    justify-items: start;
    /* Not less on a phone either: the corner meander takes ~31px. */
    padding: var(--space-l);
    border: var(--border-thin) solid var(--color-border);
    background: var(--color-surface);
    transition: border-color var(--duration) var(--ease);
}

.save-open--over {
    border-color: var(--color-accent);
    background: var(--color-surface-raised);
}

.save-open__intro {
    max-width: 44rem;
    margin: 0;
    color: var(--color-text-reading);
    line-height: var(--leading-reading);
}

.save-open__pick {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-s);
    align-items: center;
}

.save-open__drop {
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

.save-open__problem {
    margin: 0;
    color: var(--color-danger);
}

.save-open__steps {
    display: grid;
    gap: var(--space-2xs);
    margin: 0;
    padding-left: var(--space-l);
    color: var(--color-text);
}

.save-open__label {
    margin: 0 0 calc(var(--space-s) * -1);
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

/* A Windows path: long and without spaces to break at. */
.save-open__path {
    max-width: 100%;
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--radius-s);
    background: var(--color-surface-sunken);
    color: var(--color-text-strong);
    font-family: var(--font-mono);
    font-size: var(--text-s);
    overflow-wrap: anywhere;
}

.save-open__note {
    max-width: 44rem;
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

/* The hero's name in the editor's header: the file's, not editable. */
.save-head__name {
    margin: 0 0 var(--space-s);
    color: var(--color-text-strong);
    font-size: var(--text-m);
}

/* Portals (PortalPanel.js): an icon tab of the sheet, the acts' shrines as checkboxes. */
.save-portals {
    display: grid;
    gap: var(--space-m);
}

.save-portals__note {
    max-width: 44rem;
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

.save-portals__acts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr));
    gap: var(--space-m) var(--space-l);
}

/* A difficulty the hero has not reached: shown, not editable. */
.save-portals__act {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.save-portals__act:disabled {
    opacity: 0.5;
}

/* The act's name and its count, which also opens or closes the whole act. */
.save-portals__legend {
    display: flex;
    gap: var(--space-xs);
    justify-content: space-between;
    align-items: baseline;
    width: 100%;
    margin-bottom: var(--space-2xs);
    padding: 0 0 var(--space-3xs);
    border-bottom: var(--border-thin) solid var(--color-border);
    color: var(--color-heading);
    font-family: var(--font-heading);
    font-size: var(--text-s);
    font-weight: 700;
}

.save-portals__toggle-act {
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}

.save-portals__toggle-act:hover:enabled,
.save-portals__toggle-act:focus-visible {
    color: var(--color-accent);
}

.save-portals__list {
    display: grid;
    gap: var(--space-3xs);
    margin: 0;
    padding: 0;
    list-style: none;
}

.save-portals__label {
    display: flex;
    gap: var(--space-2xs);
    align-items: center;
    color: var(--color-text);
    font-size: var(--text-s);
    cursor: pointer;
}

.save-portals__label:hover {
    color: var(--color-text-strong);
}

.save-portals__check {
    flex: none;
    margin: 0;
}

/* Statistics (StatisticsPanel.js): sections of the sheet's third tab - the editable counters, then what the game counted. */
.save-stats {
    gap: var(--space-s);
}

.save-stats__note {
    max-width: 44rem;
    margin: 0;
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

.save-stats__group {
    display: grid;
    gap: var(--space-2xs);
    margin: 0;
}

.save-stats__list {
    display: grid;
    gap: var(--space-3xs);
    margin: 0;
}

.save-stats__row {
    display: flex;
    gap: var(--space-s);
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--space-3xs);
    border-bottom: var(--border-thin) solid var(--color-border);
}

.save-stats__label {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.save-stats__value {
    margin: 0;
    color: var(--color-text-strong);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    text-align: right;
}

/* A compact field, as tall as a row of the sheet; its number as plain as the values beside it. */
.save-stats__input {
    width: 7rem;
    padding: 0.125rem var(--space-2xs);
    color: var(--color-text-strong);
    font-size: var(--text-xs);
    line-height: 1.4;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* The greatest monster: a long name, on its own line under the heading. */
.save-stats__value--left {
    text-align: left;
}

/* Equipment tab of the editor: the file's gear in the calculator's panel, read only. */
.save-gear__note {
    max-width: 44rem;
    margin: 0 0 var(--space-s);
    color: var(--color-text-muted);
    font-size: var(--text-s);
}

.save-gear__note--bad {
    color: var(--color-danger);
}

.save-gear__extras {
    display: grid;
    gap: var(--space-3xs);
    margin: 0;
    font-size: var(--text-s);
}

.save-gear__extra {
    display: flex;
    gap: var(--space-xs);
}

.save-gear__extra dt {
    color: var(--color-text-muted);
}

.save-gear__extra dd {
    margin: 0;
    color: var(--color-text-strong);
}

/* A reward's quest, under the reward. */
.save-stats__quest {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

/*
 * The quest rewards under the sheet: a long list would take the height the
 * sheet stretches to and squeeze it, so the block is capped and its list scrolls.
 */
.save-rewards {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    max-height: 18rem;
}

.save-rewards .save-stats__rewards {
    padding-right: var(--space-2xs);
    overflow-y: auto;
    scrollbar-color: var(--color-border-strong) transparent;
    scrollbar-width: thin;
}

.save-stats__rewards {
    display: grid;
    gap: var(--space-3xs);
    margin: 0;
    padding-left: var(--space-m);
    color: var(--color-text);
    font-size: var(--text-s);
}
