/* ── Game HUD: board-first layout (replaces web dashboard chrome) ── */

body.in-match .top-bar,
body.in-match #phase-strip {
    display: none;
}

body.in-match #app-shell {
    background: #04060a;
}

body.in-match .game-root {
    grid-template-rows: 1fr auto;
    overflow: visible;
    position: relative;
    --action-bar-h: 3.35rem;
}

/* Hand cards use global --hand-card-w from style.css (large size) */

/* Match HUD bar */
.match-hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 22;
    pointer-events: none;
    padding: 0.45rem 0.65rem;
    background: linear-gradient(180deg, rgba(4, 6, 10, 0.92) 0%, rgba(4, 6, 10, 0.55) 70%, transparent 100%);
}

.hud-top {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
    pointer-events: auto;
}

.hud-opponent {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.hud-opponent-name {
    font-family: 'Bangers', cursive;
    font-size: clamp(0.85rem, 2.2vmin, 1.05rem);
    letter-spacing: 0.06em;
    color: #fca5a5;
    text-shadow: 1px 1px 0 #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hud-life {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.hud-life-pip {
    width: 0.55rem;
    height: 0.85rem;
    border-radius: 2px;
    background: linear-gradient(180deg, #ef4444, #991b1b);
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.hud-life-count {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gold);
    margin-left: 0.15rem;
}

.hud-phase-gem {
    justify-self: center;
    padding: 0.25rem 0.85rem;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #fff;
    background: linear-gradient(180deg, #fb7185, #be123c);
    border: 2px solid #000;
    box-shadow: 0 2px 0 #000, 0 0 14px rgba(225, 29, 72, 0.45);
}

.hud-you {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
}

.hud-turn-badge {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #fef08a;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    background: rgba(120, 53, 15, 0.85);
    border: 1px solid var(--gold);
    animation: turnPulse 1.5s ease-in-out infinite;
}

@keyframes turnPulse {
    50% { box-shadow: 0 0 12px rgba(251, 191, 36, 0.5); }
}

.hud-icon-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    background: rgba(15, 23, 42, 0.85);
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    transition: filter 0.15s, border-color 0.15s;
}

.hud-icon-btn:hover {
    filter: brightness(1.15);
    border-color: var(--gold);
    color: var(--gold);
}

/* Full-viewport playmat */
body.in-match .playmat {
    flex: 1;
    min-height: 0;
    padding: 2.5rem 0.5rem calc(var(--hand-card-h) * 0.45 + 0.5rem);
    overflow: visible;
}

/* Shift player side up to clear hand + fixed action bar */
body.in-match .playmat .player-board.self {
    flex: 0.92;
    transform: translateY(-1.35rem);
    margin-top: -0.35rem;
}

body.in-match .playmat .center-line {
    margin: 0.05rem 1rem 0.2rem;
}

body.in-match .player-board .zone {
    overflow: visible;
}

body.in-match .player-board .zone-cards,
body.in-match .player-board .zone-leader .zone-cards,
body.in-match .player-board .zone-stage .zone-cards {
    overflow: visible;
}

body.in-match .player-board .zone-chars {
    overflow: visible;
    position: relative;
    z-index: 2;
    backdrop-filter: none;
}

body.in-match .player-board .zone-chars:has(.tcg-card.selected),
body.in-match .player-board .zone-chars:has(.tcg-card.targetable),
body.in-match .player-board .zone-chars:has(.tcg-card.clickable:hover) {
    z-index: 24;
}

body.in-match .player-board .zone-chars .char-scroll-shell {
    overflow: visible;
    min-width: 0;
    width: 100%;
}

body.in-match .zone-stage .zone-cards {
    min-width: var(--card-w);
    min-height: var(--card-h);
}

body.in-match .zone-life .zone-cards--empty {
    min-width: var(--card-w);
    min-height: var(--card-h);
}

body.in-match .tcg-card.clickable:hover,
body.in-match .tcg-card.clickable:focus-visible {
    z-index: 50;
}

body.in-match .tcg-card.selected,
body.in-match .tcg-card.targetable {
    z-index: 70;
}

body.in-match .tcg-card.selected:hover,
body.in-match .tcg-card.selected:focus-visible,
body.in-match .tcg-card.targetable:hover,
body.in-match .tcg-card.targetable:focus-visible {
    z-index: 80;
}

body.in-match .zone-chars {
    min-height: calc(var(--card-h) + 0.75rem);
    max-width: calc(var(--card-w) * 5 + 2.75rem);
}

body.in-match .player-board.self .zone-chars {
    align-self: end;
}

body.in-match .player-board.opponent .zone-chars {
    align-self: start;
}

body.in-match .zone-chars .zone-cards.chars.char-scroll-row {
    min-height: var(--card-h);
    min-width: var(--card-w);
    --char-card-pop: 1.85rem;
    --char-card-inset: 0.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: var(--char-card-pop);
    padding-left: var(--char-card-inset);
    margin-top: calc(-1 * var(--char-card-pop));
}

body.in-match .zone-chars .char-scroll-row .tcg-card.selected,
body.in-match .zone-chars .char-scroll-row .tcg-card.targetable {
    z-index: 70;
}

body.in-match .zone-chars .char-scroll-row .tcg-card.selected:hover,
body.in-match .zone-chars .char-scroll-row .tcg-card.selected:focus-visible,
body.in-match .zone-chars .char-scroll-row .tcg-card.targetable:hover,
body.in-match .zone-chars .char-scroll-row .tcg-card.targetable:focus-visible,
body.in-match .zone-chars .char-scroll-row .tcg-card.clickable:hover,
body.in-match .zone-chars .char-scroll-row .tcg-card.clickable:focus-visible {
    z-index: 80;
}

body.in-match .player-board.is-active {
    filter: brightness(1.05);
}

body.in-match .player-board:not(.is-active) {
    filter: brightness(0.88) saturate(0.85);
}

body.in-match .player-board.is-active .zone {
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.25), inset 0 0 20px rgba(251, 191, 36, 0.06);
}

/* Zones without admin labels */
.zone--visual .zone-title {
    display: none;
}

.hud-icon-btn.lens-active {
    color: var(--gold);
    border-color: var(--gold);
    background: rgba(120, 53, 15, 0.55);
    box-shadow: 0 0 12px rgba(251, 191, 36, 0.4);
}

body.lens-mode .playmat {
    cursor: help;
}

/* Life — horizontal stack with ◀ ▶ when more than one page */
body.in-match .player-board .zone-life {
    min-width: calc(var(--card-w) * 2.85 + 2rem);
    max-width: none;
}

body.in-match .player-board .zone-life .life-nav-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    min-width: 0;
}

body.in-match .player-board .zone-life .life-viewport {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

body.in-match .player-board .zone-life .zone-cards {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: flex-end;
    gap: 0;
    max-height: none;
    overflow: hidden;
    position: relative;
    isolation: isolate;
}

body.in-match .zone-life .tcg-card {
    flex-shrink: 0;
    margin-top: 0;
    margin-left: calc(var(--card-w) * -0.48);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    isolation: isolate;
    z-index: var(--life-i, 1);
}

body.in-match .zone-life .zone-cards .tcg-card:first-child {
    margin-left: 0;
}

body.in-match .zone-life .tcg-card .card-overlay {
    z-index: 1;
}

body.in-match .zone-life .tcg-card.clickable:hover,
body.in-match .zone-life .tcg-card.clickable:focus-visible {
    z-index: calc(var(--life-i, 1) + 50);
}

body.in-match .zone-life .tcg-card.selected,
body.in-match .zone-life .tcg-card.targetable {
    z-index: calc(var(--life-i, 1) + 50);
}

body.in-match .zone-life .tcg-card.selected:hover,
body.in-match .zone-life .tcg-card.selected:focus-visible,
body.in-match .zone-life .tcg-card.targetable:hover,
body.in-match .zone-life .tcg-card.targetable:focus-visible {
    z-index: calc(var(--life-i, 1) + 60);
}

body.in-match .zone-life .life-count-badge {
    position: relative;
    z-index: 0;
    flex-shrink: 0;
    align-self: center;
    margin-top: 0;
    margin-left: 0.1rem;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--gold);
    background: rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(251, 191, 36, 0.35);
}

body.in-match .zone-life .life-nav-row .nav-btn {
    flex-shrink: 0;
    width: 1.65rem;
    height: 1.65rem;
    font-size: 0.75rem;
}

body.in-match .zone-life .life-nav-row .nav-btn.nav-hidden {
    visibility: hidden;
    pointer-events: none;
}

body.in-match .zone-don .zone-cards {
    min-height: var(--card-don-h);
}

.don-slot-empty {
    width: var(--card-don-w);
    height: var(--card-don-h);
    border-radius: 6px;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    background: rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
}

.pile-label {
    font-size: 0;
    width: 0;
    height: 0;
    overflow: hidden;
}

.char-scroll-shell {
    min-width: 0;
    width: 100%;
    overflow: visible;
}

.zone-cards.chars.char-scroll-row {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: flex-end;
    scrollbar-width: thin;
    padding-bottom: 0.15rem;
    --char-card-pop: 1.85rem;
    --char-card-inset: 0.5rem;
    padding-top: var(--char-card-pop);
    padding-left: var(--char-card-inset);
    margin-top: calc(-1 * var(--char-card-pop));
}

.zone-cards.chars.char-scroll-row::-webkit-scrollbar {
    height: 4px;
}

.zone-cards.chars.char-scroll-row::-webkit-scrollbar-thumb {
    background: rgba(251, 191, 36, 0.35);
    border-radius: 4px;
}

/* Floating hand fan overlay */
.hand-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: var(--action-bar-h, 3.35rem);
    z-index: 25;
    display: flex;
    justify-content: center;
    padding: 0 0.5rem;
    pointer-events: none;
    overflow: visible;
}

.hand-overlay::before {
    content: '';
    position: absolute;
    left: 5%;
    right: 5%;
    bottom: 0;
    height: calc(var(--hand-card-h) + 1.5rem);
    background: linear-gradient(0deg, rgba(4, 6, 10, 0.75) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

.hand-fan {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    pointer-events: auto;
    overflow: visible;
    padding-top: 1.25rem;
    max-width: min(96vw, 920px);
    margin: 0 auto;
}

.hand-fan .hand-fan-slot {
    flex-shrink: 0;
    margin-left: calc(var(--hand-card-w) * -0.28);
}

.hand-fan .hand-fan-slot:first-child {
    margin-left: 0;
}

.hand-fan .hand-fan-slot .tcg-card {
    width: var(--hand-card-w);
    height: var(--hand-card-h);
    transform-origin: center bottom;
    transform: rotate(var(--fan-rotate, 0deg)) translateY(var(--fan-y, 0px));
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hand-fan .hand-fan-slot .tcg-card.clickable:hover,
.hand-fan .hand-fan-slot .tcg-card.clickable:focus-visible {
    transform: rotate(var(--fan-rotate, 0deg)) translateY(calc(var(--fan-y, 0px) - 18px)) scale(1.05);
    z-index: 60;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.65), 0 0 0 2px rgba(251, 191, 36, 0.55);
}

/* Fixed bottom action bar — reserved height so board never jumps */
body.in-match .action-dock-bar {
    flex: 0 0 var(--action-bar-h);
    min-height: var(--action-bar-h);
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-top: 3px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.65);
    z-index: 26;
}

/* Action dock */
.action-dock {
    flex: 0 0 auto;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    margin: 0 auto;
    min-height: 2.5rem;
    max-width: min(96vw, 640px);
    width: 100%;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

.action-dock:empty {
    display: flex;
}

.hud-btn {
    padding: 0.45rem 1rem;
    border-radius: 10px;
    border: 2px solid #000;
    font-family: 'Bangers', 'Rajdhani', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.1s, filter 0.15s, box-shadow 0.15s;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.55);
}

.hud-btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

.hud-btn-primary {
    color: #fff;
    background: linear-gradient(180deg, #fb7185 0%, #e11d48 55%, #be123c 100%);
    border-color: #000;
}

.hud-btn-secondary {
    color: #e2e8f0;
    background: linear-gradient(180deg, #334155, #1e293b);
    border-color: #000;
}

.hud-btn-secondary.active-mode {
    color: #fef08a;
    background: linear-gradient(180deg, #854d0e, #713f12);
    box-shadow: 0 3px 0 #000, 0 0 12px rgba(251, 191, 36, 0.35);
}

.hud-btn-activate {
    font-size: 0.78rem;
    padding: 0.35rem 0.65rem;
}

.action-dock .win-text {
    width: 100%;
    text-align: center;
    margin-bottom: 0.15rem;
}

/* Choice prompt overlay */
.choice-overlay {
    position: absolute;
    top: 2.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 24;
    max-width: min(92vw, 480px);
    text-align: center;
    padding: 0.55rem 1.1rem;
    background: linear-gradient(90deg, rgba(120, 53, 15, 0.95), rgba(180, 83, 9, 0.92));
    border: 2px solid var(--gold);
    border-radius: 10px;
    color: #fef3c7;
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    pointer-events: none;
}

/* Game over overlay */
.game-over-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(4, 6, 10, 0.82);
    backdrop-filter: blur(4px);
}

.game-over-card {
    text-align: center;
    padding: 1.5rem 2rem;
    background: linear-gradient(160deg, #1a2233, #0f172a);
    border: 3px solid #000;
    border-radius: 16px;
    box-shadow: 0 8px 0 rgba(0, 0, 0, 0.5), 0 0 40px rgba(225, 29, 72, 0.25);
    min-width: min(320px, 88vw);
}

.game-over-card .win-text {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    display: block;
}

.game-over-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Card inspect modal */
.card-inspect-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(4, 6, 10, 0.88);
    backdrop-filter: blur(6px);
}

.card-inspect-modal.hidden {
    display: none;
}

.inspect-panel {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1rem;
    max-width: min(520px, 96vw);
    padding: 1rem;
    background: linear-gradient(160deg, #1a2233, #111827);
    border: 3px solid #000;
    border-radius: 14px;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.5);
}

.inspect-art {
    width: clamp(100px, 28vw, 140px);
    aspect-ratio: 1 / 1.39;
    flex-shrink: 0;
}

.inspect-art.card-inspect-face {
    border: none;
    object-fit: unset;
    box-shadow: none;
}

.inspect-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.inspect-name:empty {
    display: none;
}

.inspect-name {
    font-family: 'Bangers', cursive;
    color: var(--gold);
    font-size: 1.15rem;
    letter-spacing: 0.05em;
}

.inspect-meta {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.inspect-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #e2e8f0;
    flex: 1;
}

.inspect-close {
    grid-column: 1 / -1;
    justify-self: center;
    margin-top: 0.25rem;
}

.zone-op-modal {
    position: fixed;
    inset: 0;
    z-index: 210;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(4, 6, 10, 0.9);
    backdrop-filter: blur(6px);
}

.zone-op-modal.hidden {
    display: none;
}

.zone-op-panel {
    width: min(560px, 96vw);
    max-height: 86vh;
    overflow: auto;
    padding: 1rem;
    background: linear-gradient(160deg, #1a2233, #111827);
    border: 3px solid #000;
    border-radius: 14px;
    box-shadow: 0 6px 0 rgba(0, 0, 0, 0.5);
}

.zone-op-title {
    display: block;
    font-family: 'Bangers', cursive;
    letter-spacing: 0.05em;
    color: var(--gold);
    font-size: 1.1rem;
}

.zone-op-subtitle {
    margin-top: 0.35rem;
    margin-bottom: 0.55rem;
    color: #e2e8f0;
    font-size: 0.85rem;
}

.zone-op-list {
    display: grid;
    gap: 0.35rem;
}

.zone-op-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    justify-content: space-between;
    padding: 0.45rem 0.6rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.03);
    color: #f8fafc;
    font-size: 0.84rem;
}

.zone-op-item button {
    min-width: 2rem;
}

.zone-op-actions {
    display: flex;
    gap: 0.45rem;
    justify-content: center;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

/* HUD settings menu */
.hud-menu {
    position: absolute;
    top: 2.5rem;
    right: 0.65rem;
    z-index: 26;
    min-width: 10rem;
    padding: 0.35rem;
    background: rgba(8, 12, 20, 0.96);
    border: 2px solid rgba(0, 0, 0, 0.9);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.hud-menu.hidden {
    display: none;
}

.hud-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.45rem 0.65rem;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.hud-menu-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--gold);
}

body.in-match .log-panel {
    top: 2.6rem;
    right: 2.75rem;
}

body.in-match .toast {
    top: 2.75rem;
}

@media (max-width: 640px) {
    .hand-fan .hand-fan-slot {
        margin-left: calc(var(--hand-card-w) * -0.24);
    }

    .hand-overlay {
        bottom: var(--action-bar-h, 3.35rem);
    }

    .inspect-panel {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .inspect-art {
        justify-self: center;
    }
}
