/* ============================
 * BRASS PITT specific
 * ============================ */

:root {
    --player-0-color: #7340CC;
    --player-1-color: #D1B200;
    --player-2-color: #86442F;
    --player-3-color: #BCBFC0;
}

/* ── Gameplay area: hand above map, full width ─────────────────── */
#gameplay-area {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* On wide screens, hand sits in a slim strip above the map */
#player-hand {
    border-top: 1px solid var(--line);
    padding-top: 0.5rem;
}

/* Phase description shown to non-active players */
.phase-observer {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0;
    padding: 0.4rem 0;
}

/* .btn-undo moved to application.css — the single action panel's Undo
   button is generic now, not Brass-Pitt-only. .brass-pitt__undo (the old
   wrapper div around it) is dropped entirely: Undo now sits inline inside
   .mode-buttons instead of its own boxed-off row. */

.brass-pitt__map {
    position: relative;  /* anchors the absolute-positioned detail panel */
    margin-bottom: 1rem;
}

/* Built, non-legal spaces are clickable for tile details */
.city__space.space--detail {
    cursor: pointer;
}
.city__space.space--detail:hover .city__space-frame {
    stroke: rgba(0, 0, 0, 0.35);
    stroke-width: 0.25;
}
.city__space.entity-info--active .city__space-frame {
    stroke: var(--player-color, #555);
    stroke-width: 0.35;
}


.brass-pitt .game-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.game--brass-pitt {
    --brass-pitt-player-panel-width: 340px;
}

.game--brass-pitt .game-grid {
    grid-template-columns: minmax(0, 1fr) var(--brass-pitt-player-panel-width);
    gap: 0.5rem;
    align-items: start;
}

.game--brass-pitt .board-area {
    --bp-map-tab-width: clamp(6.5rem, 28%, 10rem);
    min-width: 0;
}

/* Keep the action context and hand together. The generic #actions-control
   remains sticky for other games; Brass Pitt moves that responsibility to
   this shared wrapper so the hand follows it without overlap. */
.game--brass-pitt > .game-controls {
    position: sticky;
    z-index: 30;
    top: 0.5rem;
    min-width: 0;
    max-width: 100%;
    margin-bottom: 0.5rem;
}

.game--brass-pitt > .game-controls #actions-control {
    position: static;
    min-width: 0;
    max-height: calc(100dvh - 5rem);
    margin-bottom: 0;
}

.bp-game-workspace-tabs {
    min-width: 0;
    margin-bottom: 0.5rem;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.bp-game-workspace-tabs__list {
    display: flex;
    min-width: 0;
    gap: 0.25rem;
    padding: 0.3rem;
}

.bp-game-workspace-tab {
    display: inline-flex;
    flex: 1 1 0;
    min-width: 0;
    min-height: 2.75rem;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    cursor: pointer;
}

.bp-game-workspace-tab[data-game-workspace-map-tab] {
    flex: 0 0 var(--bp-map-tab-width);
}

.bp-game-workspace-tabs__players {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    gap: 0.25rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

.bp-game-workspace-tabs__players[hidden],
.bp-game-workspace-tab[hidden] {
    display: none;
}

.bp-game-workspace-tab--player {
    flex: 1 0 8rem;
}

.bp-game-workspace-tab--player.is-active {
    border-color: color-mix(in srgb, var(--player-color) 55%, var(--line));
    background: color-mix(in srgb, var(--player-color) 8%, white);
    color: color-mix(in srgb, var(--player-color) 58%, #1f2937);
}

.bp-game-workspace-tab__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bp-game-workspace-tab:hover {
    background: #f3f6f9;
    color: var(--fg);
}

.bp-game-workspace-tab.is-active {
    border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
    background: color-mix(in srgb, var(--accent) 10%, white);
    color: var(--accent);
}

.bp-game-workspace-tab:focus-visible,
.bp-game-workspace-tab--player:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 1px;
}

/* The hand belongs to the same sticky gameplay context as the current
   action. Keep it to one horizontally scrollable row so stickiness does not
   consume a second large block of the viewport. */
.game--brass-pitt > .game-controls #player-hand {
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0.3rem;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.game--brass-pitt > .game-controls #actions-control + #player-hand {
    border-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.game--brass-pitt > .game-controls:has(#player-hand) #actions-control {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
    box-shadow: none;
}

.game--brass-pitt > .game-controls #player-hand .brass-pitt__cards {
    min-width: 0;
    width: 100%;
    flex-wrap: nowrap;
    gap: 0.35rem;
    margin: 0;
    padding: 0 0 0.15rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
}

.game--brass-pitt > .game-controls #player-hand .brass-pitt__card {
    flex: 0 0 auto;
}

/* Players as a compact top bar */
.game--brass-pitt .players-area h2,
.brass-pitt .players-area h2 {
    display: none;
}

.game--brass-pitt .players-area,
.brass-pitt .player-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: flex-start;
    align-content: flex-start;
    width: var(--brass-pitt-player-panel-width);
}

.game--brass-pitt .brass-pitt__player-area {
    flex: 0 0 100%;
    width: 100%;
    border: 2px solid color-mix(in srgb, var(--player-color, var(--line)) 62%, var(--line));
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: clip;
    align-self: flex-start;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.game--brass-pitt .brass-pitt__player-area:has(.player.is-current) {
    border-color: var(--accent);
    background: #f0f6ff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent),
                0 3px 10px rgba(31, 111, 235, 0.18);
}

.game--brass-pitt .player.brass-pitt__player-card,
.brass-pitt .player-list .player {
    margin-bottom: 0;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    border: 0;
    background: transparent;
}

.game--brass-pitt .brass-pitt__player-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    line-height: 1.2;
}

.game--brass-pitt .brass-pitt__player-header .name {
    color: color-mix(in srgb, var(--player-color, var(--fg)) 46%, var(--fg));
    font-weight: 800;
}

.game--brass-pitt .brass-pitt__player-area:has(.player.is-current) .brass-pitt__player-header .name {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.game--brass-pitt .brass-pitt__player-area:has(.player.is-current) .badge:not(.badge-you) {
    background: var(--accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent);
}

.game--brass-pitt .brass-pitt__player-summary {
    margin-top: 0.45rem;
    line-height: 1.25;
}

.game--brass-pitt .brass-pitt__changing-property {
    display: inline-block;
    min-width: 1.25em;
    margin-inline: -0.12em;
    padding-inline: 0.12em;
    border-radius: 0.3em;
    text-align: center;
}

.game--brass-pitt .brass-pitt__changing-property.is-property-highlighted {
    animation: bp-property-highlight 2.4s ease-out 1;
}

.game--brass-pitt .brass-pitt__changing-property[data-property-highlight-direction="up"] {
    --bp-property-highlight-color: 39, 174, 96;
}

.game--brass-pitt .brass-pitt__changing-property[data-property-highlight-direction="down"] {
    --bp-property-highlight-color: 214, 65, 65;
}

.game--brass-pitt .brass-pitt__income-trigger {
    cursor: pointer;
    text-decoration: underline dotted;
    text-underline-offset: 0.18em;
}

.game--brass-pitt .brass-pitt__income-trigger:hover,
.game--brass-pitt .brass-pitt__income-trigger:focus-visible,
.game--brass-pitt .brass-pitt__income-trigger.entity-info--active {
    color: var(--accent);
    outline: none;
    text-decoration-style: solid;
}

@keyframes bp-property-highlight {
    0% {
        background-color: rgba(var(--bp-property-highlight-color), 0.72);
        box-shadow: 0 0 0 0 rgba(var(--bp-property-highlight-color), 0.55);
        transform: scale(1.18);
    }
    30% {
        background-color: rgba(var(--bp-property-highlight-color), 0.38);
        box-shadow: 0 0 0.65rem 0.18rem rgba(var(--bp-property-highlight-color), 0.32);
        transform: scale(1.08);
    }
    100% {
        background-color: transparent;
        box-shadow: 0 0 0 0 rgba(var(--bp-property-highlight-color), 0);
        transform: scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .game--brass-pitt .brass-pitt__changing-property.is-property-highlighted {
        animation-duration: 0.01ms;
    }
}

.game--brass-pitt .brass-pitt__player-details {
    padding: 0 0.5rem 0.35rem;
}

.game--brass-pitt .brass-pitt__player-details:empty {
    display: none;
}

.game--brass-pitt .brass-pitt__meta {
    flex: 0 0 100%;
}

.game--brass-pitt [data-controller~="match-viewers"],
.game--brass-pitt .viewer-list {
    flex: 0 0 100%;
    width: 100%;
}

.game--brass-pitt .viewer-list {
    margin-top: 0;
}

@media (max-width: 620px) {
    .game--brass-pitt .game-grid {
        grid-template-columns: 1fr;
    }

    .game--brass-pitt .players-area {
        width: 100%;
    }

    .game--brass-pitt .brass-pitt__player-area {
        flex-basis: 100%;
        width: 100%;
    }
}

/* Let the map fill the viewport */
main:has(.brass-pitt) {
    max-width: 100%;
    padding: 0.5rem;
}

.brass-pitt__map h3 {
    margin: 0 0 0.5rem;
}

.brass-pitt__map-canvas {
    --bp-map-aspect-width: 1;
    --bp-map-aspect-height: 1;
    position: relative;
    width: 100%;
    aspect-ratio: var(--bp-map-aspect-width) / var(--bp-map-aspect-height);
    background: #e8ecf0;
    border: 1px solid var(--line);
    border-radius: 4px;
    overflow: hidden;
    overscroll-behavior: contain;
}

.brass-pitt__map-canvas:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

.brass-pitt__map-canvas.is-zoomed {
    cursor: grab;
}

.brass-pitt__map-canvas.is-dragging {
    cursor: grabbing;
    user-select: none;
}

@media (min-width: 1200px) {
    .brass-pitt__map-canvas {
        /* Fit the map in a desktop viewport without changing the aspect
           ratio supplied by the active MapLayout. */
        width: min(
            100%,
            calc(80dvh * var(--bp-map-aspect-width) / var(--bp-map-aspect-height))
        );
        margin-inline: auto;
    }
}

@media (max-width: 620px) {
    .game--brass-pitt .board-area {
        --bp-map-tab-width: 6.25rem;
    }
}

.brass-pitt__edges {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.edge-line {
    stroke: #ccc;
    stroke-linecap: round;
}

.edge--built {
    stroke-width: 0.4 !important;
}

.edge-line--heavy.edge--built {
    stroke-width: 0.75 !important;
}

/* Preview overlay: the acting player has chosen this edge (in
   NetworkChooseEdgeSubPhase) but hasn't finished paying for it yet — see
   NetworkSubPhase#do_link!/#view_context. Dashed + slightly thinner than
   --built and at reduced opacity, so it reads as "in progress" rather than
   as an actually-owned link, even though it's drawn in the acting player's
   color. */
.edge--pending {
    stroke-width: 0.5 !important;
    stroke-dasharray: 1.2, 0.8;
    opacity: 0.6;
}

.edge--legal {
    filter: drop-shadow(0 0 2px #04f);
    cursor: pointer;
}

/* .edge-line sets its own stroke (and, via the template, its own
   stroke-width attribute) unconditionally, so the highlight has to target
   the descendant directly — setting stroke on .edge--legal itself has no
   effect, since a child's own declared value always wins over anything it
   would otherwise inherit from an ancestor. stroke-width lives here (not
   as a per-render inline attribute keyed off e[:legal_edge] like it used
   to be) for the same reason .edge--legal itself is now JS-managed: a CSS
   class toggled by legal_entities_controller.js can never go stale between
   full redraws, whereas a value baked into the template only updates when
   the whole edge re-renders. */
.edge--legal .edge-line {
    stroke: #04f !important;
    stroke-width: 0.8 !important;
}

@media (hover: hover) {
    .edge--legal:hover {
        filter: drop-shadow(0 0 2px red);
    }
    .edge--legal:hover .edge-line {
        stroke: red !important;
    }
}

/* Train icon shown at edge midpoint */
.edge-train-icon {
    font-weight: bold;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 0.15px;
    pointer-events: none;
}

/* Resource icon shown at edge midpoint (below train icon) */
.edge-res-icon {
    font-size: 0.8px;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 0.1px;
    pointer-events: none;
}

.edge-hitarea, .pipeline-hitarea {
    cursor: pointer;
    pointer-events: stroke;
}

/* Hitarea is now always rendered (see _edge.html.erb /
   _pipeline_edge.html.erb) so that a phase change can toggle legality
   via a targeted class update instead of a full board re-render. When not
   legal, it must not intercept clicks/hover. */
.edge-hitarea:not(.is-legal),
.pipeline-hitarea:not(.is-legal) {
    pointer-events: none;
    cursor: default;
}

/* Bonus icons (whiskey, develop, income) — PNG branch of resource_token.
   Value text (e.g. +2 for income) needs to stay readable on any background. */
.resource-bonus { pointer-events: none; }

.resource-bonus__value {
    fill: black;
    paint-order: stroke;
    stroke: #000;
    stroke-width: 0.18;
    font-weight: 700;
}

/* Pipeline lines */
.pipeline-line {
    stroke: #aaa;
    stroke-linecap: round;
}

.pipeline--built {
    stroke-width: 0.4 !important;
}

/* Mirrors .edge--pending above — see that comment and
   NetworkSubPhase#do_link!/#view_context. */
.pipeline--pending {
    stroke-width: 0.4 !important;
    opacity: 0.6;
}

.pipeline--legal {
    filter: drop-shadow(0 0 2px #04f);
    cursor: pointer;
}

/* !important needed to beat both the inline default stroke-width on
   .pipeline-line (see _pipeline_edge.html.erb) and .pipeline--built's
   own !important — same staleness-defensiveness as edge-line: this class
   is JS-managed (legal_entities_controller.js), so it must always win
   regardless of what else is going on, the instant legality changes,
   without waiting for a full redraw. */
.pipeline--legal .pipeline-line {
    stroke: #04f;
    stroke-width: 1.0 !important;
}

@media (hover: hover) {
    .pipeline--legal:hover {
        filter: drop-shadow(0 0 2px red);
    }
    .pipeline--legal:hover .pipeline-line {
        stroke: red;
    }
}


/* City positioned on map */
.brass-pitt__city {
    position: absolute;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    z-index: 2;
    pointer-events: auto;
}


/* Touch devices: enlarge invisible hit-areas for edges and pipelines so
   they're tappable with a finger. CSS overrides the inline stroke-width
   on the SVG elements. */
@media (pointer: coarse) {
    .edge-hitarea { stroke-width: 5; }
    .pipeline-hitarea { stroke-width: 5; }
}

/* ── Prototype: city rendered entirely in SVG ─────────────────────────── */
.city__space-bg {
    fill: rgba(255, 255, 255, 0.85);
    stroke: #777;
    stroke-width: 0.08;
}

.city__space.is-built .city__space-bg {
    stroke: rgba(0, 0, 0, 0.3);
}

.city__space.space--legal .city__space-bg {
    stroke: #1f6feb;
    stroke-width: 0.25;
    filter: drop-shadow(0 0 0.4px rgba(31, 111, 235, 0.7));
    cursor: pointer;
}

/* The frame rect sits on top of the tile to draw the legal/hover outline
   over a built industry tile (which has its own fill). */
.city__space-frame { stroke: transparent; stroke-width: 0.05; }

.city__space.space--legal .city__space-frame {
    stroke: #1f6feb;
    stroke-width: 0.3;
    filter: drop-shadow(0 0 0.4px rgba(31, 111, 235, 0.7));
    cursor: pointer;
}

@media (hover: hover) {
    .city__space.space--legal:hover .city__space-bg,
    .city__space.space--legal:hover .city__space-frame {
        stroke: #0d5fd4;
        stroke-width: 0.4;
    }
}

.city__space.space--legal:active .city__space-bg,
.city__space.space--legal:active .city__space-frame {
    stroke: #c63333;
}

/* Industry tile rendered inside a city space */
.industry-tile__level {
    fill: #fff;
    font-weight: 700;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.5);
    stroke-width: 0.06;
}

.industry-tile__conn-cluster,
.industry-tile__conn-hex,
.industry-tile__conn-bar {
    pointer-events: none;
}

/* ── Pick-tile section in the board (above cards) ──────────────── */
.brass-pitt__step--tile-pick { margin: 0.5rem 0; }
.brass-pitt__tile-pick-row {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.brass-pitt__tile-pick__icon {
    display: block;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    line-height: 0;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.brass-pitt__tile-pick__icon * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.brass-pitt__tile-pick__icon > svg {
    display: block;
}
/* The picker renders only tiles with a current legal pick_tile action.
   .is-legal is still applied client-side when the action region reconnects,
   and gates the clickable affordance/hover effect just like .bp-token below.
   __icon (not bare .brass-pitt__tile-pick) is the button that receives the
   legal action; the plain class belongs to its <li> wrapper. */
.brass-pitt__tile-pick__icon.is-legal {
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 4px;
    transition: transform 0.08s ease;
}
.brass-pitt__tile-pick__icon.entity-info--active {
    outline: 2px solid #1f6feb;
    outline-offset: 2px;
    filter: drop-shadow(0 0 4px rgba(31, 111, 235, 0.55));
}
@media (hover: hover) {
    .brass-pitt__tile-pick__icon.is-legal:hover {
        transform: scale(1.06);
        filter: drop-shadow(0 0 4px rgba(31, 111, 235, 0.7));
    }
}

/* ── Heavy-train & pipeline tokens (player area + pick sub-phases) ── */
.bp-token-row {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 0.3rem;
}
.bp-token {
    display: inline-block;
    vertical-align: middle;
}
.bp-token__body {
    fill: var(--player-color, #888);
    stroke: rgba(0, 0, 0, 0.45);
    stroke-width: 0.18;
}
.bp-token__glyph {
    fill: #fff;
    font-weight: 700;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.5);
    stroke-width: 0.12;
}
.bp-token__train-icon {
    fill: #fff;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 0.08;
}
.bp-token.is-legal {
    cursor: pointer;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    transition: transform 0.08s ease;
}
@media (hover: hover) {
    .bp-token.is-legal:hover {
        transform: scale(1.08);
        filter: drop-shadow(0 0 4px rgba(31, 111, 235, 0.7));
    }
}
.bp-token.is-legal:active {
    transform: scale(0.97);
}
.bp-token[data-entity-info-key] {
    cursor: pointer;
    border-radius: 4px;
}
@media (hover: hover) {
    .bp-token[data-entity-info-key]:hover,
    .bp-token.entity-info--active {
        filter: drop-shadow(0 0 4px rgba(31, 111, 235, 0.45));
    }
}
.bp-token.entity-info--active {
    outline: 1.5px solid rgba(31, 111, 235, 0.75);
    outline-offset: 1px;
}

/* ── Developable tiles row in each player area ─────────────────── */
.brass-pitt__developable-row {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-top: 0.3rem;
}
.brass-pitt__developable-tile {
    display: inline-block;
    vertical-align: middle;
    cursor: pointer;
    border-radius: 4px;
    transition: opacity 0.1s;
}
.brass-pitt__developable-tile:hover {
    opacity: 0.8;
}
.brass-pitt__developable-tile.entity-info--active {
    outline: 2px solid var(--player-color, #888);
    outline-offset: 1px;
}

/* ── Player industry boards ──────────────────────────────────────── */
.bp-player-board-section {
    width: 100%;
}

.bp-player-board-selector__color {
    flex: 0 0 0.75rem;
    width: 0.75rem;
    height: 0.75rem;
    border: 1px solid color-mix(in srgb, var(--player-color) 65%, #1f2937);
    border-radius: 50%;
    background: var(--player-color);
}

.bp-player-board-section__panels,
.bp-player-board-section__panel {
    width: 100%;
}

.bp-player-board-section__item {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    border: 1px solid rgba(31, 41, 55, 0.16);
    border-radius: 6px;
    padding: 0.65rem;
    background: #ffffff;
}

.bp-player-board-section__item .bp-player-board-frame {
    width: 100%;
    max-width: none;
}

.bp-player-board-section__header {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
    color: #263241;
    font-size: 0.86rem;
    line-height: 1.2;
}

.bp-player-board-section__seat {
    color: var(--player-color, #6b7280);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

@media (max-width: 620px) {
    .bp-game-workspace-tab--player {
        flex-basis: 7.25rem;
    }

    .bp-player-board-section__header {
        display: none;
    }

    .game--brass-pitt > .game-controls #player-hand .btn-card {
        min-width: 62px;
        padding: 0.25rem 0.4rem;
    }
}

.bp-player-board-shell {
    margin: 0;
}

.bp-player-board__unlock-token.is-spent {
    opacity: 0.22;
    filter: grayscale(0.85);
}

.bp-player-board__unlock-token.is-locked,
.bp-player-board__unlock-token.is-available {
    opacity: 1;
    filter: none;
}

.bp-player-board-frame {
    position: relative;
    max-width: 780px;
    margin-inline: auto;
    overflow: hidden;
    overscroll-behavior: contain;
    border-radius: 5px;
    container-type: inline-size;
    container-name: player-board;
}

.bp-player-board-frame:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
    outline-offset: 2px;
}

.bp-player-board-frame.is-zoomed {
    cursor: grab;
}

.bp-player-board-frame.is-dragging {
    cursor: grabbing;
    user-select: none;
}

@media (min-width: 1200px) {
    .bp-player-board-section__item .bp-player-board-frame {
        width: min(
            100%,
            var(--bp-player-board-viewport-width)
        );
        height: 80dvh;
    }

    .bp-player-board-section__item .bp-player-board-frame > .bp-player-board {
        height: 100%;
    }
}

.bp-player-board {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    border: 1px solid rgba(31, 41, 55, 0.18);
    border-radius: 5px;
    background:
        linear-gradient(180deg, #fbfcfd 0%, #f4f7f8 100%);
}

.bp-player-board__column-label {
    fill: #263241;
    font-size: 11px;
    font-weight: 800;
}

.bp-player-board__column-line {
    stroke: rgba(31, 41, 55, 0.12);
    stroke-width: 1;
}

.bp-player-board__level-label {
    fill: #6b7280;
    font-size: 10px;
    font-weight: 800;
}

.bp-player-board__arrow {
    fill: none;
    stroke: #9aa5b1;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: none;
    opacity: 0.42;
}

.bp-player-board__arrow.is-accessible {
    stroke: #8f9ba8;
    opacity: 0.48;
}

.bp-player-board__arrow.is-live {
    stroke: #4b5563;
    stroke-width: 2;
    stroke-dasharray: 1 5;
    opacity: 0.9;
}

.bp-player-board__arrow-head {
    fill: #7a8794;
}

.bp-player-board__slot-frame {
    fill: rgba(255, 255, 255, 0.72);
    stroke: rgba(31, 41, 55, 0.16);
    stroke-width: 1;
}

.bp-player-board__slot.is-accessible .bp-player-board__slot-frame {
    stroke: rgba(31, 111, 235, 0.5);
    stroke-width: 1.35;
}

.bp-player-board__slot.is-complete .industry-tile {
    opacity: 0.42;
}

.bp-player-board__tile {
    cursor: pointer;
}

.bp-player-board__tile-hit {
    stroke: transparent;
    stroke-width: 1.6;
}

.bp-player-board__tile:hover .bp-player-board__tile-hit,
.bp-player-board__tile.entity-info--active .bp-player-board__tile-hit {
    stroke: #1f6feb;
}

.bp-player-board__unlock-token {
    pointer-events: none;
}

.bp-player-board__unlock-token.has-entity-info {
    pointer-events: auto;
}

.bp-player-board__unlock-token .bp-token {
    overflow: visible;
}

.bp-player-board__spent-line {
    stroke: rgba(31, 41, 55, 0.68);
    stroke-width: 1.4;
    stroke-linecap: round;
}

/* ── Tile detail content ───────────────────────────────────────── */
/* The framework entity-info panel owns the Popover shell; Brass Pitt only
   styles the richer tile/oilfield content rendered inside it. */
.entity-info-panel:has(.bp-income-track-detail) {
    width: min(42rem, calc(100vw - 16px));
}

.bp-income-track-detail {
    display: flex;
    box-sizing: border-box;
    width: 100%;
    padding: 10px;
    flex-direction: column;
    gap: 8px;
}

.bp-income-track-detail__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
}

.bp-income-track-detail__header span {
    color: var(--muted);
    font-size: 0.8rem;
}

.bp-income-track-detail__row {
    display: flex;
    max-width: calc(100vw - 3.5rem);
    gap: 3px;
    overflow-x: auto;
    padding: 7px 3px;
}

.bp-income-track-detail__space {
    display: grid;
    flex: 0 0 2.4rem;
    overflow: hidden;
    border: 1px solid rgba(31, 41, 55, 0.2);
    border-radius: 5px;
    background: #f6f8fa;
    text-align: center;
}

.bp-income-track-detail__level {
    padding: 2px 3px;
    background: rgba(31, 111, 235, 0.1);
    color: #35516f;
    font-size: 0.68rem;
    font-weight: 700;
}

.bp-income-track-detail__number {
    padding: 4px 3px;
    font-size: 0.82rem;
    font-weight: 800;
}

.bp-income-track-detail__space.is-current {
    border-color: var(--accent);
    background: #fff4b8;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
    transform: translateY(-2px);
}

.bp-income-track-detail__space.is-current .bp-income-track-detail__level {
    background: var(--accent);
    color: #fff;
}

.bp-income-track-detail__axis-label {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.bp-income-track-detail__axis-label--space {
    margin-top: -5px;
}

.bp-tile-detail__card {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.bp-tile-detail__header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.bp-tile-detail__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.bp-tile-detail__name {
    font-weight: 700;
    font-size: 0.9rem;
}
.bp-tile-detail__vp {
    color: #555;
    font-size: 0.75rem;
}
.bp-tile-detail__section {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}
.bp-tile-detail__label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #888;
    font-weight: 600;
    white-space: nowrap;
    min-width: 52px;
}
.bp-tile-detail__row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.bp-tile-detail__cost-item {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(0,0,0,0.05);
    border-radius: 3px;
    padding: 1px 4px;
}
.bp-tile-detail__upgrade {
    background: rgba(180,120,0,0.12);
    color: #7a5000;
}
.bp-tile-detail__unlock {
    background: rgba(0,100,200,0.08);
    color: #003a7a;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 0.75rem;
}

/* Tile VP is rendered as a gold number on a black hex; the polygon
   itself carries fill/stroke inline. The label just needs the gold
   color and weight (already inline) — no outline needed. */
.industry-tile__vp {
    pointer-events: none;
}

.industry-tile__vp-hex {
    pointer-events: none;
}

.industry-tile__sell-oil,
.industry-tile__star,
.industry-tile__star-label {
    pointer-events: none;
}

.industry-tile__star {
    fill: #f6c544;
    stroke: #7b5c12;
    stroke-width: 0.12;
    stroke-linejoin: round;
}

.industry-tile__star-label {
    fill: #2a1d05;
    font-weight: 800;
    paint-order: stroke;
    stroke: rgba(255, 255, 255, 0.45);
}

.city__tile-res-count {
    font-weight: 700;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 0.06;
}

/* ── Shared resource token (cube + label) — industry tile, markets ── */
.resource-token {
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 0.04;
}

/* The barrel group is composed of multiple shapes; default no stroke
   (the inner shapes have their own fills). When inside .is-legal the
   stroke applies to the body rect for the highlight outline. */
.resource-token.resource-barrel { stroke: none; }
.resource-token.resource-barrel > rect:first-child {
    stroke: rgba(0, 0, 0, 0.55);
    stroke-width: 0.04;
}

.resource-token__label {
    font-weight: 700;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.45);
    stroke-width: 0.04;
}

/* Pipeline bonuses sit directly on the pale map. Money uses dark ink with
   a light halo here instead of the token partial's white-on-dark default. */
.pipeline-edge__bonus .res--money {
    fill: #1f2937;
    stroke: rgba(255, 248, 220, 0.95);
    stroke-width: 0.11;
}

/* Quality reward spaces */
.quality-reward-space {
    cursor: default;
}

.quality-reward-tile__body {
    fill: #f3e4b0;
    stroke: #6f5725;
    stroke-width: 0.16;
}

.quality-reward-space__star {
    fill: #f6c544;
    stroke: #7b5c12;
    stroke-width: 0.12;
    stroke-linejoin: round;
    pointer-events: none;
}

.quality-reward-space__stars {
    fill: #2a1d05;
    font-size: 1.1px;
    font-weight: 800;
    pointer-events: none;
}

.quality-reward-space-hitarea {
    pointer-events: all;
}

.quality-reward-space.is-claimed {
    opacity: 0.5;
}

.quality-reward-tile__claimed-mark {
    stroke: rgba(60, 42, 15, 0.75);
    stroke-width: 0.28;
    stroke-linecap: round;
    pointer-events: none;
}

.quality-reward-space.is-legal {
    filter: drop-shadow(0 0 0.55px rgba(31, 111, 235, 0.75));
    cursor: pointer;
}

.quality-reward-space.is-legal .quality-reward-tile__body {
    stroke: #1f6feb;
    stroke-width: 0.24;
}

@media (hover: hover) {
    .quality-reward-space.is-legal:hover .quality-reward-tile__body {
        stroke: #0d5fd4;
        stroke-width: 0.32;
    }
}

/*  Merchants    */
.merchant-tile {}
.merchant-tile-hitarea { pointer-events: all; }
.merchant-tile.is-legal .merchant-tile-hitarea { cursor: pointer; }

.merchant-tile.is-legal {
    stroke: #1f6feb;
    stroke-width: 0.2;
    filter: drop-shadow(0 0 0.4px rgba(31, 111, 235, 0.6));
    cursor: pointer;
}

@media (hover: hover) {
    .merchant-tile.is-legal:hover  {
        stroke: #0d5fd4;
        stroke-width: 0.3;
    }
}

/* ── Market cubes below the city — legal/hover handled via parent group ─── */
.city__market-price {
    fill: #333;
    font-weight: 600;
    pointer-events: none;
}

.city__market-hitarea { pointer-events: all; }
.city__market.is-legal .city__market-hitarea { cursor: pointer; }

.city__market.is-legal .resource-token {
    stroke: #1f6feb;
    stroke-width: 0.4;
    filter: drop-shadow(0 0 0.4px rgba(31, 111, 235, 0.6));
    cursor: pointer;
}

@media (hover: hover) {
    .city__market.is-legal:hover .resource-token {
        stroke: #0d5fd4;
        stroke-width: 0.3;
    }
}

.city__market.is-legal:active .resource-token {
    stroke: #c63333;
}

/* ── Vanderbilt off-map market ─────────────────────────────────────── */
.vanderbilt-market__item.is-legal .resource-token {
    stroke: #1f6feb;
    stroke-width: 0.4;
    filter: drop-shadow(0 0 0.4px rgba(31, 111, 235, 0.6));
    cursor: pointer;
}
.vanderbilt-market__hitarea { pointer-events: all; }
.vanderbilt-market__item.is-legal .vanderbilt-market__hitarea { cursor: pointer; }

@media (hover: hover) {
    .vanderbilt-market__item.is-legal:hover .resource-token {
        stroke: #0d5fd4;
        stroke-width: 0.5;
    }
}

.vanderbilt-market__item.is-legal:active .resource-token {
    stroke: #c63333;
}

.city__name {
    fill: #111;
    font-weight: 600;
    pointer-events: none;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 0.15;
    transition: fill 140ms ease, stroke 140ms ease, stroke-width 140ms ease, filter 140ms ease;
}

.city__name.city__name--card-highlighted {
    fill: #5d3900;
    font-weight: 800;
    stroke: #ffd54f;
    stroke-width: 0.75;
    filter: drop-shadow(0 0 1.2px rgba(255, 193, 7, 0.95));
    animation: bp-city-card-highlight-pulse 900ms ease-out 1;
}

@keyframes bp-city-card-highlight-pulse {
    0% {
        stroke-width: 0.15;
        filter: drop-shadow(0 0 0 rgba(255, 193, 7, 0));
    }
    55% {
        stroke-width: 1.1;
        filter: drop-shadow(0 0 2px rgba(255, 193, 7, 1));
    }
    100% {
        stroke-width: 0.75;
        filter: drop-shadow(0 0 1.2px rgba(255, 193, 7, 0.95));
    }
}

@media (prefers-reduced-motion: reduce) {
    .city__name.city__name--card-highlighted {
        animation: none;
    }
}

.city__tile-letter {
    fill: #fff;
    font-weight: 700;
    pointer-events: none;
    paint-order: stroke;
    stroke: rgba(0, 0, 0, 0.4);
    stroke-width: 0.06;
}

.city__tile-vp {
    fill: #fff;
    font-weight: 700;
    pointer-events: none;
}

.resource-icon {
    display: inline-block;
    pointer-events: none;
}

/* Legal resource cubes / barrels on edges */
.cube--legal polygon,
.barrel--legal rect,
.barrel--legal ellipse {
    filter: drop-shadow(0 0 1.5px rgba(31, 111, 235, 0.5));
    cursor: pointer;
}

.edge-cube-count {
    font-weight: 700;
    paint-order: stroke;
    stroke: #fff;
    stroke-width: 0.08px;
    pointer-events: none;
}

.space-icon:only-child {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── Due icone: prima in alto-sinistra ───────────────────── */
.space-icon:first-child:not(:only-child) {
    top: 0;
    left: 0;
}

/* ── Due icone: seconda in basso-destra (sopra la prima) ─── */
.space-icon:last-child:not(:only-child) {
    bottom: 0;
    right: 0;
    z-index: 2; /* la seconda passa sopra quando si sovrappongono */
}


.city-market .resource-icon-img {
    width: 16px;
    height: 16px;
}

.res-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    font-size: 9px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 2px #000;
}

.city-market {
    font-size: 0.65rem;
    background: rgba(255, 255, 255, 0.9);
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.city-market.market--legal {
    outline: 2px solid #1f6feb;
    outline-offset: 1px;
    cursor: pointer;
    background: rgba(31, 111, 235, 0.12);
    box-shadow: 0 0 4px rgba(31, 111, 235, 0.4);
}

.city-market.market--legal:hover {
    outline-color: #0d5fd4;
    box-shadow: 0 0 6px rgba(13, 95, 212, 0.7);
    background: rgba(31, 111, 235, 0.22);
}

.city-market.market--legal:active {
    outline-color: #c63333;
    box-shadow: 0 0 6px rgba(198, 51, 51, 0.7);
}

.city-market sub {
    font-size: 0.6rem;
    font-weight: 600;
}

.city-markets-row {
    display: flex;
    gap: 3px;
    justify-content: center;
    margin-top: 1px;
}

.city-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: #333;
    text-align: center;
    line-height: 1.1;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.85);
    padding: 0 3px;
    border-radius: 2px;
}

.city-name small {
    font-size: 0.55rem;
    color: #666;
}

/* Player area tiles */
.resource--tiles {
    display: flex;
    gap: 4px;
    align-items: center;
}

.tile {
    font-size: 0.65rem;
    background: #eee;
    padding: 0 3px;
    border-radius: 2px;
}

.tile sub {
    font-size: 0.5rem;
}

/* .brass-pitt__step is still used as a generic "boxed section" look by
   the tile-pick/token-pick panels (brass-pitt__step--tile-pick/
   --token-pick) and the player-hand section (brass-pitt__step--card), so
   it stays here. .mode-buttons/.btn-mode moved to application.css — the
   single action panel's plain-button fallback list is generic now, used
   by any game, not just Brass Pitt. */
.brass-pitt__step {
    border-top: 1px solid var(--line);
    padding-top: 0.75rem;
    margin-top: 0.75rem;
}

.brass-pitt__cards {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.brass-pitt__card {
    border: 1px solid var(--line);
    border-radius: 4px;
    overflow: hidden;
}

.brass-pitt__card:has([data-entity-info-key]) {
    cursor: help;
}

.brass-pitt__card:has(.entity-info--active) {
    border-color: rgba(31, 111, 235, 0.75);
    box-shadow: 0 0 0 1px rgba(31, 111, 235, 0.35);
}

.brass-pitt__card.is-new {
    animation: bp-card-dealt 1.2s ease-out 1;
}

@keyframes bp-card-dealt {
    0% {
        transform: translateY(-10px) scale(0.94);
        box-shadow: 0 0 0 rgba(255, 213, 79, 0);
        border-color: #ffd54f;
    }
    28% {
        transform: translateY(0) scale(1.08);
        box-shadow: 0 0 18px rgba(255, 213, 79, 0.95);
        border-color: #ffd54f;
    }
    100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 0 0 rgba(255, 213, 79, 0);
        border-color: var(--line);
    }
}

@media (prefers-reduced-motion: reduce) {
    .brass-pitt__card.is-new {
        animation: none;
        box-shadow: none;
        border-color: var(--line);
    }
}

.brass-pitt__card.is-legal {
    border-width: 3px;
    border-color: #04f;
}

@media (hover: hover) {
    .brass-pitt__card.is-legal:hover {
        border-color: red;
    }
}

.btn-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    min-width: 70px;
    width: 100%;
    background: none;
    border: none;
    font: inherit;
    color: inherit;
    cursor: default;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.btn-card * {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.brass-pitt__card.is-legal .btn-card {
    cursor: pointer;
}

.card-type {
    font-size: 0.6rem;
    color: var(--muted);
}

.card-value {
    font-weight: 600;
}

.card-buildable-types {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.2rem;
    max-width: 10rem;
    line-height: 1.15;
}

.card-buildable-primary {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
}

.card-buildable-additional {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.1rem 0.4rem;
    padding-top: 0.2rem;
    border-top: 1px solid color-mix(in srgb, currentColor 18%, transparent);
}

.card-buildable-type {
    font-size: 0.68rem;
    font-weight: 500;
}

/* Oilfield nodes on the map participate in framework entity inspection. */
.brass-pitt__oilfield {
    cursor: pointer;
}

.brass-pitt__oilfield.entity-info--active {
    filter: drop-shadow(0 0 2px rgba(31, 111, 235, 0.75));
}

.edge-hitarea.entity-info--active,
.edge-train-resource-cube.entity-info--active,
.pipeline-hitarea.entity-info--active,
.city__market.entity-info--active,
.merchant-tile.entity-info--active,
.quality-reward-space.entity-info--active {
    filter: drop-shadow(0 0 2px rgba(31, 111, 235, 0.8));
}

.oilfield-name {
    font-size: 0.5rem;
    font-weight: 600;
    color: var(--muted);
}

.oilfield-type {
    font-size: 0.7rem;
    font-weight: 700;
}

.oilfield--flipped .oilfield-type {
    color: var(--accent-success);
}

.oilfield-oil-count {
    font-size: 0.55rem;
}

/* Train resource cubes on edges */

.edge-train-resource-cube {}
.edge-train-resource-cube-hitarea { pointer-events: all; }

.edge-train-resource-cube.is-legal {
    stroke: #1f6feb;
    stroke-width: 0.2;
    filter: drop-shadow(0 0 0.4px rgba(31, 111, 235, 0.6));
    cursor: pointer;
}

@media (hover: hover) {
    .edge-train-resource-cube.is-legal:hover  {
        stroke: #0d5fd4;
        stroke-width: 0.3;
    }
}
