/* Game: shared parts */
.score-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    background: var(--panel);
}
.score-cell {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
    border-right: 2px solid var(--shadow);
}
.score-cell:last-child {
    border-right: 0;
}
.score-cell small {
    display: block;
    font: 10px var(--mono);
    color: var(--dim);
}
.score-cell strong {
    font: 900 20px var(--mono);
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.score-cell.accent {
    background: var(--well);
}
.score-cell.accent strong {
    color: var(--accent);
    text-shadow: 2px 2px 0 var(--accent-low);
}
.boss-panel {
    display: grid;
    min-width: 0;
    background: var(--panel-2);
    border-bottom: 2px solid var(--shadow);
}
.boss-portrait {
    image-rendering: pixelated;
    touch-action: manipulation;
}
.boss-portrait.charging[aria-disabled="false"] {
    cursor: pointer;
    box-shadow: inset 0 0 0 2px var(--danger);
}
.boss-portrait:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
}
.boss-summary {
    min-width: 0;
}
.boss-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}
.boss-heading h2 {
    overflow: hidden;
    font: 700 15px var(--display);
    letter-spacing: 0.3px;
    color: var(--danger);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.boss-level {
    flex-shrink: 0;
    font: 700 10px var(--mono);
    color: var(--special);
}
.boss-health {
    height: 14px;
    overflow: hidden;
    background: var(--well);
    border: 2px solid var(--shadow);
    outline: 1px solid var(--danger-low);
}
.boss-health > div {
    height: 100%;
    background: repeating-linear-gradient(90deg, var(--danger) 0 8px, var(--danger-low) 8px 10px);
    transition: width 0.15s steps(5);
}
.boss-detail {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font: 10px var(--mono);
    color: var(--muted);
    white-space: nowrap;
}
.boss-detail strong {
    color: var(--danger);
}
.boss-contributors {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}
.boss-contributor {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 5px;
    font: 9px var(--mono);
    color: var(--muted);
    white-space: nowrap;
}
.connection-banner {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 10px;
    font: 700 11px var(--mono);
    color: var(--warning-ink);
    background: var(--warning-surface);
    border-bottom: 2px solid var(--accent-low);
}
.connection-banner button {
    font: 700 11px var(--mono);
    color: var(--accent);
    text-decoration: underline;
}
.connection-banner button:hover {
    color: var(--accent-hi);
}
.pause-banner {
    color: var(--info);
    background: var(--info-surface);
    border-bottom-color: var(--info);
}
.board-card {
    --player: var(--info);
    position: relative;
    min-width: 0;
    background: var(--panel);
    border: 2px solid var(--edge);
    box-shadow:
        4px 4px 0 var(--shadow),
        inset 0 0 0 1px var(--shadow);
}
.board-card.mine {
    border-color: var(--player);
}
.board-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.player-info {
    display: flex;
    flex: 1;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
.player-name {
    display: flex;
    align-items: center;
    gap: 4px;
    font: 700 11px var(--mono);
}
.player-name .name {
    min-width: 0;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.you-tag {
    padding: 0 4px;
    font: 800 8px var(--mono);
    color: var(--identity-inverse, var(--inverse));
    background: var(--player);
}
.player-state {
    margin-top: 1px;
    font: 8px var(--mono);
    letter-spacing: 0.6px;
    color: var(--dim);
}
.player-score {
    min-width: 40px;
    font: 800 14px var(--mono);
    color: var(--identity-ink, var(--player));
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.6px;
    text-align: right;
}
.player-score small {
    display: block;
    font: 8px var(--mono);
    letter-spacing: 0.7px;
    color: var(--dim);
}
.board-shell {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: var(--board-bg, var(--well));
    border: 3px solid var(--shadow);
    outline: 2px solid var(--player);
    outline-offset: -2px;
}
.board-shell:after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
    background: repeating-linear-gradient(0deg, transparent 0 2px, var(--scanline) 2px 3px);
}
.board-shell.warning {
    outline-color: var(--danger);
}
.board-shell.attacked {
    outline-color: var(--special);
}
.board-canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
    outline: none;
    cursor: default;
    touch-action: none;
}
.mine .board-canvas {
    cursor: crosshair;
}
.board-canvas:focus-visible {
    box-shadow: inset 0 0 0 2px var(--focus);
}
.effect-canvas,
.effect-labels {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.board-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    background: var(--board-shade);
}
.board-overlay h3 {
    margin: 8px 0;
    font: 700 19px/1.1 var(--display);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--accent);
    text-shadow: 2px 2px 0 var(--shadow);
}
.board-overlay p {
    max-width: 205px;
    margin: auto;
    font-size: 11px;
    line-height: 1.6;
    color: var(--muted);
}
.board-overlay .icon {
    width: 30px;
    height: 30px;
    color: var(--identity-ink, var(--player));
}
.power-state {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    overflow: hidden;
    font: 9px var(--mono);
    color: var(--muted);
}
.power-state > span {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.power-state .icon {
    width: 13px;
    height: 13px;
}
.power-state .combo {
    flex-shrink: 0;
    color: var(--accent);
}
/*
 * Queue funnel: a square-cornered glass shelf on the board's top edge. The next piece waits in
 * the left bay and drops through the chute; later pieces line up to its right. The outer box is
 * the rim colour and the inset ::before is the glass.
 */
.queue-funnel {
    position: relative;
    height: 52px;
    background: var(--glass-edge);
}
.queue-funnel:before,
.queue-funnel:after {
    content: "";
    position: absolute;
    inset: 2px 2px 3px;
    pointer-events: none;
}
.queue-funnel:before {
    background:
        linear-gradient(180deg, var(--glass-sheen), transparent 38%),
        linear-gradient(0deg, var(--inset-shadow), transparent 45%),
        linear-gradient(var(--glass-tint), var(--glass-tint)), var(--board-bg, var(--well));
    box-shadow:
        inset 0 2px 0 var(--bevel-light),
        inset 2px 0 0 var(--bevel-dark),
        inset -2px 0 0 var(--bevel-dark);
}
.queue-funnel:after {
    z-index: 2;
    background: repeating-linear-gradient(0deg, transparent 0 2px, var(--scanline) 2px 3px);
}
/* The opening in the bottom rim under the next bay; its centre matches the canvas's first stop. */
.funnel-chute {
    position: absolute;
    bottom: 0;
    left: 20%;
    width: 14%;
    height: 5px;
    transform: translateX(-50%);
    background: var(--board-bg, var(--well));
    box-shadow:
        inset 2px 0 0 var(--accent),
        inset -2px 0 0 var(--accent);
    pointer-events: none;
}
.funnel-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
}
.tray-label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font: 700 8px var(--mono);
    letter-spacing: 1px;
    color: var(--dim);
}
.tray-label button {
    padding: 0;
    font: 8px var(--mono);
    color: var(--accent);
    text-decoration: underline;
}
.power-tray {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
}
.power-slot {
    --power: var(--dim);
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    color: var(--gift-ink, var(--power));
    background: var(--gift-surface, var(--well));
    border: 2px solid var(--edge);
    transition:
        transform var(--motion-control) var(--ease-control),
        border-color var(--motion-control) var(--ease-control),
        background-color var(--motion-control) var(--ease-control);
}
.power-slot .power-name {
    color: var(--ink);
    max-width: 100%;
    overflow: hidden;
    font: 700 8px/1.1 var(--mono);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.power-slot.empty {
    font-size: 16px;
    color: var(--edge);
    border-style: dashed;
    cursor: default;
}
.power-slot:hover:not(:disabled):not(.empty) {
    border-color: var(--power);
    background: color-mix(in srgb, var(--power) 10%, var(--gift-surface, var(--well)));
}
.power-slot:active:not(:disabled):not(.empty) {
    transform: translateY(1px);
    transition-duration: var(--motion-fast);
}
.power-slot.selected {
    border-color: var(--power);
    background: color-mix(in srgb, var(--power) 22%, var(--gift-surface, var(--well)));
    box-shadow:
        0 0 0 2px var(--shadow),
        inset 0 -3px 0 var(--power);
}
.power-slot .sender-badge {
    position: absolute;
    top: 2px;
    right: 2px;
}
.power-slot .hotkey {
    position: absolute;
    top: 2px;
    left: 4px;
    font: 8px var(--mono);
    color: var(--dim);
}
/* Grow-and-jiggle nudge on the first power when the player has not been using powers. */
.power-slot.power-hint {
    z-index: 1;
    border-color: var(--accent);
    box-shadow:
        0 0 0 2px var(--shadow),
        0 0 0 4px var(--accent-low);
    animation: power-hint 2.4s infinite;
}
@keyframes power-hint {
    0%,
    40%,
    100% {
        transform: none;
        animation-timing-function: steps(2, end);
    }
    8%,
    30% {
        transform: scale(1.12);
        animation-timing-function: steps(1, end);
    }
    12%,
    20% {
        transform: scale(1.12) rotate(-4deg);
        animation-timing-function: steps(1, end);
    }
    16%,
    24% {
        transform: scale(1.12) rotate(4deg);
        animation-timing-function: steps(1, end);
    }
}
body.reduced .power-slot.power-hint,
body.effects-off .power-slot.power-hint {
    animation: none;
    transform: none;
}
@media (prefers-reduced-motion: reduce) {
    .power-slot.power-hint {
        animation: none;
        transform: none;
    }
}
.power-slot .charges {
    position: absolute;
    right: 3px;
    bottom: 2px;
    font: 700 9px var(--mono);
    color: var(--ink);
}
.team-tabs {
    display: none;
}
.info-rail {
    display: none;
}
/* Game: compact layout (phones, short windows). Gameplay owns the viewport. */
body.playing {
    height: 100dvh;
    min-height: 0;
}
.playing .app {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr) auto;
}
.playing main {
    min-width: 0;
    min-height: 0;
    /* This is the shake viewport; translating its child must not scroll the page. */
    overflow: clip;
}
.playing .topbar {
    min-height: 40px;
    padding: 4px 8px 8px;
}
.playing .brand {
    gap: 6px;
}
.playing .brandmark {
    width: 22px;
    height: 22px;
}
.playing .wordmark {
    font-size: 26px;
    letter-spacing: -0.5px;
}
.playing .footbar {
    padding: 2px 8px;
    font-size: 8px;
}
.playing .footbar .right {
    gap: 12px;
}
.playing .footbar button {
    font-size: 9px;
}
.playing .game-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.playing .hud {
    display: flex;
    flex: 0 0 auto;
    flex-direction: column;
}
.playing .score-strip {
    flex: 0 0 38px;
    border-bottom: 2px solid var(--shadow);
}
.playing .score-cell {
    padding: 3px 10px;
}
.playing .score-cell .stat-label {
    font-size: 8px;
    letter-spacing: 0.6px;
}
.playing .score-cell small {
    font-size: 8px;
}
.playing .boss-panel {
    grid-template-columns: 58px minmax(0, 1fr);
    grid-template-rows: 44px;
    gap: 2px 8px;
    padding: 4px 8px;
}
.playing .boss-portrait {
    width: auto;
    max-width: 100%;
    height: 44px;
    aspect-ratio: 69 / 53;
    object-fit: contain;
}
.playing .boss-summary {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 22px 18px;
    gap: 2px 12px;
    align-items: center;
}
.playing .boss-heading h2 {
    font-size: 12px;
}
.playing .boss-level {
    font-size: 9px;
}
.playing .boss-health {
    grid-column: 1;
    grid-row: 2;
    height: 12px;
}
.playing .boss-detail {
    grid-column: 2;
    grid-row: 2;
    font-size: 9px;
}
.playing .boss-contributors {
    grid-column: 2;
    grid-row: 1;
    max-width: 400px;
}
.playing .connection-banner {
    font-size: 10px;
}
.playing .arena-layout {
    flex: 1;
    min-height: 0;
    padding: 6px;
}
.playing .boards {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 100%;
}
.playing .board-card {
    flex: 0 1 var(--board-width, 280px);
    width: var(--board-width, 280px);
    padding: 6px;
}
.playing .board-head {
    height: 28px;
    margin-bottom: 4px;
}
.playing .board-head .avatar {
    width: 24px;
    height: 24px;
}
.playing .player-name {
    font-size: 10px;
}
.playing .player-state {
    font-size: 8px;
}
.playing .player-score {
    min-width: 30px;
    font-size: 12px;
}
.playing .player-score small {
    font-size: 8px;
}
.playing .power-state {
    height: 18px;
    margin: 3px 0 2px;
    font-size: 8px;
}
.playing .queue-funnel {
    height: 48px;
}
.playing .tray-label {
    height: 10px;
    margin: 2px 0 3px;
    font-size: 8px;
}
.playing .power-tray,
.playing .power-slot {
    height: 36px;
}
.playing .power-slot .power-symbol {
    width: 17px;
    height: 17px;
}
.playing .power-slot .power-name {
    font-size: 8px;
}

/*
 * Game: cabinet layout. Status on the left, the well in the middle, notes on the right.
 * The client adds .cabinet when the window is big enough for the current player count.
 */
.playing .game-view.cabinet {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    grid-template-rows: auto auto auto minmax(0, 1fr);
    gap: 0 14px;
    padding: 12px 14px;
}
.playing .cabinet .hud {
    grid-column: 1;
    grid-row: 1 / -1;
    gap: 12px;
    min-height: 0;
    contain: size;
    overflow-y: auto;
    scrollbar-width: thin;
}
.playing .cabinet .connection-banner {
    grid-column: 2;
    margin-bottom: 10px;
    border: 2px solid var(--accent-low);
}
.playing .cabinet .pause-banner {
    border-color: var(--info);
}
.playing .cabinet .score-strip {
    display: flex;
    flex: none;
    flex-direction: column;
    border: 2px solid var(--edge);
    box-shadow: 4px 4px 0 var(--shadow);
}
.playing .cabinet .score-cell,
.playing .cabinet .score-cell:nth-child(n + 3) {
    min-height: 34px;
    padding: 4px 12px;
    border-right: 0;
    border-bottom: 2px solid var(--shadow);
}
.playing .cabinet .score-cell:last-child {
    border-bottom: 0;
}
.playing .cabinet .score-cell small {
    display: none;
}
.playing .cabinet .score-cell .stat-label {
    font-size: 9px;
}
.playing .cabinet .score-cell strong {
    font-size: 17px;
}
.playing .cabinet .score-cell.accent {
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 12px 10px;
}
.playing .cabinet .score-cell.accent small {
    display: block;
}
.playing .cabinet .score-cell.accent strong {
    font-size: 34px;
    line-height: 1.1;
    text-align: right;
}
.playing .cabinet .boss-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 2px solid var(--danger-low);
    box-shadow: 4px 4px 0 var(--shadow);
}
.playing .cabinet .boss-portrait {
    align-self: center;
    width: min(100%, calc(22vh * 69 / 53));
    height: auto;
    background: var(--well);
    border: 2px solid var(--shadow);
    outline: 1px solid var(--danger-low);
}
.playing .cabinet .boss-summary {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
}
.playing .cabinet .boss-heading h2 {
    font-size: 17px;
}
.playing .cabinet .boss-health {
    height: 16px;
}
.playing .cabinet .boss-contributors {
    flex-wrap: wrap;
    max-width: none;
}
.playing .cabinet .arena-layout {
    display: grid;
    grid-column: 2;
    grid-row: 4;
    grid-template-columns: minmax(0, 1fr) 240px;
    grid-template-rows: minmax(0, 1fr);
    gap: 14px;
    padding: 0;
}
.playing .cabinet .info-rail .panel {
    flex-shrink: 0;
}
.playing .cabinet.three .arena-layout,
.playing .cabinet.four .arena-layout {
    grid-template-columns: minmax(0, 1fr);
}
.playing .cabinet.three .info-rail,
.playing .cabinet.four .info-rail {
    display: none;
}
.playing .cabinet .info-rail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding-right: 4px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.playing .cabinet .boards {
    align-items: center;
    padding: 12px;
    background:
        linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 24px 24px,
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px) 0 0 / 24px 24px,
        var(--well);
    border: 2px solid var(--edge);
    box-shadow: inset 4px 4px 0 var(--bevel-dark);
}
.playing .cabinet .board-card {
    padding: 8px;
}
.playing .cabinet .board-card.mine {
    box-shadow: 4px 4px 0 var(--shadow);
}
.playing .cabinet .board-head {
    height: 30px;
}
.playing .cabinet .power-state {
    height: 20px;
}
.playing .cabinet .queue-funnel {
    height: 58px;
}
.playing .cabinet .power-tray,
.playing .cabinet .power-slot {
    height: 42px;
}
.playing .cabinet .power-slot .power-name {
    font-size: 8px;
}

/* Medium-height windows trade the extra notes for room to breathe. */
@media (max-height: 820px) {
    .playing .cabinet .info-rail .feed-panel {
        display: none;
    }
}

/* The raised clock floats over the cabinet without adding a header row. */
.boss-timer {
    display: none;
}
.playing .boss-timer {
    --timer-rim: var(--accent-low);
    --timer-ink: var(--ink);
    --timer-surface: var(--panel);
    position: absolute;
    z-index: 5;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 132px;
    padding: 5px 14px 7px;
    background:
        linear-gradient(var(--bevel-light), var(--bevel-light)) top / 100% 2px no-repeat,
        repeating-linear-gradient(0deg, transparent 0 3px, var(--scanline) 3px 4px),
        var(--timer-surface);
    border: 2px solid var(--timer-rim);
    border-top-color: var(--accent);
    box-shadow:
        4px 4px 0 var(--shadow),
        inset 0 -3px 0 var(--bevel-dark);
    white-space: nowrap;
    pointer-events: none;
}
.boss-timer:before,
.boss-timer:after {
    content: "";
    position: absolute;
    top: 6px;
    width: 3px;
    height: 3px;
    background: var(--edge-hi);
}
.boss-timer:before {
    left: 6px;
}
.boss-timer:after {
    right: 6px;
}
.boss-timer strong {
    width: 5ch;
    color: var(--timer-ink);
    font: 700 30px/1 var(--mono);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
    text-align: center;
}
.playing .boss-timer.urgent {
    --timer-rim: var(--danger);
    --timer-ink: var(--danger);
    --timer-surface: var(--well);
    border-top-color: var(--danger);
}

/* Stacked desktop HUDs need the clock entirely inside the existing header. */
@media (max-width: 1279px), (max-height: 700px) {
    .playing:not(.mobile-layout) .boss-timer {
        top: 2px;
        bottom: 2px;
        padding: 0 10px;
    }
    .playing:not(.mobile-layout) .boss-timer strong {
        font-size: clamp(20px, 4.8vh, 30px);
    }
}

/* Desktop uses the existing card flow; mobile gives these groups explicit space. */
.board-stage,
.board-controls {
    display: contents;
}
.mobile-rotate,
.mobile-menu-button {
    display: none;
}

.mobile-stat {
    display: none;
}

/* Diagnostics consume real gameplay space, including when their text wraps. */
.playing .perf {
    flex: 0 0 auto;
    min-width: 0;
    padding: 2px 8px;
    line-height: 12px;
    overflow-wrap: anywhere;
}
.playing .perf[hidden] {
    display: none;
}

.playing .cabinet .perf {
    grid-column: 2;
}
