/**
 * Sava game lobby — "Drow Grimoire" board cabinet.
 * Obsidian scrying-board, bronze chrome, carved stone tokens, blood-and-arcane
 * faction colors (red = blood, blue = icy arcane teal). Tokens + fonts live in
 * theme.css (loaded first). All class hooks preserved for the game JS.
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--sava-font-serif);
    color: var(--sava-bone);
    background-color: var(--sava-stone-0);
    /* Gradients only until html.sava-branding-ready (theme.css) attaches sigil+stone. */
    background-image:
        radial-gradient(ellipse 120% 70% at 50% -10%, rgba(120, 70, 30, 0.18), transparent 55%),
        radial-gradient(ellipse 90% 60% at 50% 120%, rgba(90, 20, 20, 0.18), transparent 55%),
        linear-gradient(180deg, rgba(8, 6, 5, 0.8), rgba(8, 6, 5, 0.94));
    background-size: cover, cover, cover;
    background-attachment: fixed;
    background-position: center, center, center;
    background-repeat: no-repeat, no-repeat, no-repeat;
    min-height: 100vh;
    overflow-x: hidden;
}

body.game-lobby {
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    overflow: hidden;
    padding-top: var(--sava-top-bar-height);
}

body.game-lobby .site-top-bar-hamburger {
    position: static;
}

body.game-lobby .container {
    height: calc(100dvh - var(--sava-top-bar-height));
    min-height: 0;
}

body.game-lobby .lobby-content {
    height: 100%;
    min-height: 0;
    max-height: 100dvh;
}

body.game-lobby .lobby-sidebar {
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
}

body.game-lobby .game-board-container {
    height: 100%;
    min-height: 0;
    overflow: hidden;
    align-items: stretch;
    justify-content: stretch;
}

/* Sidebar-open: board + fallen/spider bar must share the cabinet height
   instead of 82vh board pushing the bottom panels out of view. */
body.game-lobby .unified-game-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    overflow: hidden;
}

body.game-lobby .game-board {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: none;
    width: 100%;
}

body.game-lobby .captured-pieces-board {
    flex: 0 0 auto;
    max-height: min(18vh, 140px);
    min-height: 0;
    padding: 0.45vh 0.75vw 0.85vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.container {
    background: transparent;
    max-width: none;
    width: 100%;
    margin: 0;
    min-height: 100vh;
}

.lobby-content {
    display: grid;
    grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
    gap: 0;
    align-items: stretch;
    position: relative;
    min-height: 100vh;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    transition: grid-template-columns 0.3s ease;
}

/* ===================== Reduced motion (game specifics) ===================== */
@media (prefers-reduced-motion: reduce) {
    .node.legal-move,
    .node.first-move,
    .node.second-move,
    .node.wizard-move-3,
    .node.wizard-first-move,
    .node.wizard-second-move,
    .node.wizard-third-move,
    .mobile-timer-value.danger,
    .timer-value.danger,
    .sacrifice-candidate,
    .spider-control-candidate,
    .controlled-piece,
    .die.rolling-fast,
    .die.bounce,
    .site-hero .logo,
    .check-indicator,
    .check-line,
    .chat-message.new {
        animation: none !important;
    }
    .promotion-piece:hover,
    .btn:hover,
    .chat-toggle:hover,
    .node:hover,
    .captured-piece:hover,
    .player-item:hover,
    .node:active,
    .node.selected:active {
        transform: none !important;
    }
    .rain-container { display: none; }
}

/* ===================== Focus / tactile feedback ===================== */
:is(a, button, input, textarea, select, summary, [tabindex]):focus { outline: none; }
:is(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--sava-focus);
    outline-offset: 3px;
    box-shadow: 0 0 0 3px var(--sava-focus-ring);
}

.hamburger-menu:active,
.btn:active:not(:disabled),
.lobby-sidebar .nav-btn:active,
.send-btn:active:not(:disabled),
.game-over-btn:active,
.promotion-confirm:active:not(:disabled),
.close-rules-btn:active,
.spider-dice:active:not(:disabled),
.dice-roll-button:active:not(:disabled),
.promotion-piece:active {
    transform: translateY(var(--sava-tap-press));
    filter: brightness(0.95);
}
.chat-toggle:active { transform: translateY(var(--sava-tap-press)); }
.close-chat-btn:active { background: rgba(0, 0, 0, 0.4); transform: scale(0.96); }

.turn-timer:focus-within,
.chat-window:focus-within,
.unified-game-area:focus-within,
.rules-sidebar:focus-within {
    box-shadow: var(--sava-shadow-panel), 0 0 0 2px var(--sava-focus-ring);
}
.chat-input-container:focus-within { background: rgba(0, 0, 0, 0.4); }

.timer-section,
.player-item,
.mobile-timer-section {
    transition: transform var(--sava-duration) var(--sava-ease),
        box-shadow var(--sava-duration) var(--sava-ease),
        border-color var(--sava-duration) var(--sava-ease);
}
.timer-section:hover { box-shadow: inset 0 0 0 1px var(--sava-edge); }
.current-turn-timer:hover { filter: brightness(1.06); }
.player-item:hover { transform: translateY(var(--sava-tap-lift)); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5); }

/* ===================== Hamburger ===================== */
.hamburger-menu {
    display: block;
    background: var(--sava-gradient-bronze);
    border: 2px solid var(--sava-border-ink);
    border-radius: 2px;
    padding: 0.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 248, 232, 0.3);
    transition: transform var(--sava-duration) var(--sava-ease), box-shadow var(--sava-duration) var(--sava-ease);
}
.hamburger-menu:hover { transform: translateY(-2px); }
.hamburger-menu .bar {
    width: 20px;
    height: 2px;
    background: #2a1c08;
    margin: 4px 0;
    transition: transform var(--sava-duration) var(--sava-ease), opacity var(--sava-duration);
    border-radius: 1px;
}
.hamburger-menu.active .bar:nth-child(1) { transform: rotate(-45deg) translate(-5px, 6px); }
.hamburger-menu.active .bar:nth-child(2) { opacity: 0; }
.hamburger-menu.active .bar:nth-child(3) { transform: rotate(45deg) translate(-5px, -6px); }

.mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.65);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.mobile-overlay.open { opacity: 1; visibility: visible; }

/* ===================== Desktop sidebar layout (JS-driven classes) ===================== */
@media (min-width: 769px) {
    .lobby-sidebar {
        position: relative;
        left: auto;
        top: auto;
        width: auto;
        height: auto;
        z-index: auto;
        transition: none;
        overflow-y: auto;
    }
    .lobby-sidebar.hamburger-hidden { display: none; }
    .lobby-content.sidebar-collapsed { grid-template-columns: 1fr; }
    .mobile-overlay.open { background: rgba(0, 0, 0, 0.45); }
    .lobby-content.sidebar-collapsed .game-board-container {
        width: 100%;
        max-width: none;
        padding: 0.75rem;
        height: 100vh;
        transition: all 0.3s ease;
    }
    .lobby-content.sidebar-collapsed .game-board {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        flex: 1;
        height: auto;
        min-height: 0;
        transition: all 0.3s ease;
    }
    .lobby-content.sidebar-collapsed .unified-game-area {
        display: flex;
        flex-direction: column;
        height: 92vh;
    }
    .lobby-content.sidebar-collapsed .captured-pieces-board {
        flex: 0 0 auto;
        min-height: 10vh;
        padding: 0.5vh 0 1.5vh 0;
    }
    .mobile-overlay { display: none; }
}

/* ===================== Ledger rail (lobby sidebar) ===================== */
.lobby-sidebar {
    background-color: var(--sava-stone-1);
    /* Stone tile applied under html.sava-branding-ready (theme.css). */
    background-image: linear-gradient(180deg, rgba(22, 16, 11, 0.92), rgba(8, 6, 5, 0.96));
    background-size: cover;
    padding: 1.1rem;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
    min-width: 0;
    max-width: 100%;
    border-right: 2px solid var(--sava-bronze);
    box-shadow: inset -10px 0 24px rgba(0, 0, 0, 0.45), 8px 0 28px rgba(0, 0, 0, 0.5);
}
.lobby-sidebar > * {
    max-width: 100%;
    box-sizing: border-box;
}

.lobby-sidebar .lobby-header {
    text-align: left;
    margin-bottom: 0.85rem;
    padding: 0.4rem 0.65rem;
    border: 1px solid var(--sava-bronze-dk);
    border-image: none;
    background: var(--sava-gradient-stone-panel);
    box-shadow: var(--sava-shadow-inset);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 0.5rem;
}
.lobby-sidebar .lobby-header .logo {
    width: 1.55rem;
    height: 1.55rem;
    flex: 0 0 auto;
    background: var(--sava-icon-crest) center / contain no-repeat;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.65));
}
.lobby-sidebar .lobby-header h1 {
    margin: 0;
    color: var(--sava-bronze-lt);
    font-family: var(--sava-font-display);
    font-size: 1.35rem;
    font-weight: 400;
    line-height: 1;
    text-shadow: 0 1px 0 #000;
}
.lobby-sidebar .lobby-header .lobby-id-sr[hidden] {
    display: none !important;
}

.lobby-sidebar .nav-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--sava-edge);
}
.lobby-sidebar .nav-btn {
    flex: 1;
    background: var(--sava-gradient-stone-panel);
    color: var(--sava-bone);
    border: 1px solid var(--sava-edge);
    padding: 0.55rem 0.5rem;
    cursor: pointer;
    font-size: 0.74rem;
    font-family: var(--sava-font-head);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: transform var(--sava-duration) var(--sava-ease), border-color var(--sava-duration), color var(--sava-duration);
    font-weight: 700;
}
.lobby-sidebar .nav-btn:hover {
    transform: translateY(-2px);
    border-color: var(--sava-bronze);
    color: var(--sava-bronze-lt);
}

.player-section { margin-bottom: 1.5rem; }
.player-section h3 {
    color: var(--sava-bronze-lt);
    font-family: var(--sava-font-head);
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--sava-edge);
}
.roster-section {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin: 0.35rem 0 0.75rem;
}
.roster-section .player-section {
    margin: 0;
}
.player-list { list-style: none; }
.player-list-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
}
.player-item {
    background: rgba(0, 0, 0, 0.35);
    padding: 0.55rem 0.55rem;
    margin-bottom: 0;
    border: 1px solid var(--sava-edge);
    border-left: 3px solid var(--sava-bronze);
    box-shadow: inset 0 1px 0 rgba(232, 200, 130, 0.08);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--sava-bone);
    font-size: 0.85rem;
    min-width: 0;
}
.player-item.player-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    min-height: 4.25rem;
}
.player-item.player-card .player-info {
    width: 100%;
}
.player-item.is-placeholder {
    grid-column: 1 / -1;
    min-height: 0;
    flex-direction: row;
    opacity: 0.75;
    font-size: 0.82rem;
}
.player-item.spectator { border-left-color: var(--sava-pewter); opacity: 0.9; }
.player-item[data-color="red"] { border-left-color: var(--sava-red, #ce4030); }
.player-item[data-color="blue"] { border-left-color: var(--sava-blue, #46c8c3); }
.player-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #2a1f14, #0c0908);
    border: 1px solid var(--sava-bronze);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--sava-bronze-lt);
    font-weight: bold;
    font-size: 0.72rem;
    flex: 0 0 auto;
}
.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 700; color: var(--sava-bone); word-break: break-word; font-size: 0.82rem; line-height: 1.25; }
.player-role { font-size: 0.72rem; color: var(--sava-bone-faint); }

.game-status {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid var(--sava-edge);
    font-family: var(--sava-font-mono);
    font-size: 0.86rem;
    color: var(--sava-bone-dim);
}
.inactivity-claim-console {
    display: grid;
    gap: 0.3rem;
    width: 100%;
    margin-top: 0.2rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--sava-edge);
    text-align: center;
}
.inactivity-claim-console[hidden] { display: none; }
.inactivity-claim-label {
    color: var(--sava-warn-fg);
    font: 0.68rem var(--sava-font-serif);
    line-height: 1.25;
}
.inactivity-claim-btn {
    width: 100%;
    padding: 0.35rem 0.55rem;
    font-size: 0.72rem;
    border-color: var(--sava-bronze);
    color: var(--sava-bone);
}
.status-indicator {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.5rem;
    box-shadow: 0 0 6px currentColor;
}
.status-waiting { background: var(--sava-warn-fg); color: var(--sava-warn-fg); }
.status-ready { background: var(--sava-ok-fg); color: var(--sava-ok-fg); }
.status-playing { background: var(--sava-blue); color: var(--sava-blue); }

/* ===================== Board cabinet ===================== */
.game-board-container {
    background: transparent;
    padding: 1rem;
    text-align: center;
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: width var(--sava-duration) var(--sava-ease), padding var(--sava-duration) var(--sava-ease);
}

.unified-game-area {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    border: 6px solid transparent;
    border-image: var(--sava-gradient-bronze) 1;
    overflow: hidden;
    background:
        radial-gradient(ellipse 70% 70% at 50% 42%, rgba(40, 20, 18, 0.5), transparent 70%),
        linear-gradient(180deg, #0a0807 0%, #060403 100%);
    box-shadow: var(--sava-shadow-panel), inset 0 0 70px rgba(0, 0, 0, 0.85);
    transition: box-shadow var(--sava-duration) var(--sava-ease);
}
/* ornate filigree corners on the cabinet */
.unified-game-area::before,
.unified-game-area::after {
    content: "";
    position: absolute;
    width: 52px;
    height: 52px;
    background: var(--sava-bronze-lt);
    -webkit-mask: url("/static/img/corner.svg") center / contain no-repeat;
    mask: url("/static/img/corner.svg") center / contain no-repeat;
    opacity: 0.85;
    pointer-events: none;
    z-index: 20;
}
.unified-game-area::before { top: 4px; left: 4px; }
.unified-game-area::after { bottom: 4px; right: 4px; transform: rotate(180deg); }

/* Board overflow menu (top-right ⋯) */
.board-overflow-menu {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 40;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}
.board-menu-button {
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--sava-bronze-dk);
    background: rgba(10, 8, 6, 0.82);
    color: var(--sava-bronze-lt);
    font-family: var(--sava-font-mono);
    font-size: 1.15rem;
    line-height: 1;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.45);
}
.board-menu-button:hover,
.board-overflow-menu.is-open .board-menu-button {
    border-color: var(--sava-bronze);
    color: var(--sava-bone, #f0e6d4);
    background: rgba(22, 16, 12, 0.92);
}
.board-menu-panel {
    min-width: 13.5rem;
    padding: 0.35rem;
    border: 1px solid var(--sava-bronze-dk);
    background:
        linear-gradient(180deg, rgba(28, 20, 14, 0.97), rgba(10, 8, 6, 0.98));
    box-shadow: var(--sava-shadow-panel, 0 8px 28px rgba(0, 0, 0, 0.55));
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.board-menu-panel[hidden] {
    display: none !important;
}
.board-menu-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    margin: 0;
    padding: 0.55rem 0.65rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--sava-bone-dim, #c8b8a0);
    font-family: var(--sava-font-serif);
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    box-sizing: border-box;
}
.board-menu-item:hover {
    border-color: var(--sava-edge, rgba(176, 133, 52, 0.35));
    background: rgba(176, 133, 52, 0.08);
    color: var(--sava-bone, #f0e6d4);
}
.board-menu-check {
    user-select: none;
}
.board-menu-check input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--sava-bronze);
    cursor: pointer;
}
.board-menu-danger {
    color: #d8a090;
}
.board-menu-danger:hover {
    border-color: rgba(180, 70, 50, 0.45);
    background: rgba(120, 30, 20, 0.22);
    color: #f0c8bc;
}

.sava-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    padding: 12px 20px;
    background: #0a0807;
    border: 1px solid var(--sava-bronze);
    color: var(--sava-bone, #f0e6d4);
    font-family: var(--sava-font-mono);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
}
.sava-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.game-board {
    position: relative;
    width: 100%;
    height: 82vh;
    margin: 0;
    background:
        radial-gradient(circle at 50% 45%, rgba(58, 30, 26, 0.4), transparent 60%),
        radial-gradient(circle at 50% 45%, rgba(0, 0, 0, 0.2), #07050400 65%);
    padding: 0;
    transition: width var(--sava-duration) var(--sava-ease), height var(--sava-duration) var(--sava-ease),
        padding var(--sava-duration) var(--sava-ease);
    min-height: 60vh;
}
.game-board::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--sava-bg-sigil) center 45% / min(66vh, 42rem) no-repeat;
    opacity: 0.16;
    filter: drop-shadow(0 0 22px rgba(139, 26, 26, 0.35));
    pointer-events: none;
    z-index: 1;
}

/* ===================== Trophy shelf + dice altar ===================== */
.captured-pieces-board {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: clamp(0.35rem, 1vw, 1.5vw);
    margin: 0;
    padding: 1vh 1vw 2vh;
    background: linear-gradient(180deg, rgba(20, 14, 10, 0.85), rgba(6, 4, 3, 0.95));
    border-top: 2px solid var(--sava-bronze-dk);
    position: relative;
    min-height: 10vh;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
}
.captured-pieces-board::before {
    content: "";
    position: absolute;
    top: 0;
    left: 12%;
    right: 12%;
    height: 2px;
    background: linear-gradient(to right, transparent, var(--sava-bronze), transparent);
}
.piece-tutorial-overlay {
    position: absolute;
    inset: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    gap: clamp(0.5rem, 1.6vw, 1.4rem);
    padding: 0.6rem clamp(0.85rem, 2vw, 1.5rem);
    box-sizing: border-box;
    background: linear-gradient(90deg, rgba(24, 12, 9, 0.98), rgba(12, 8, 6, 0.96));
    border-top: 1px solid var(--sava-bronze);
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(232, 200, 130, 0.14);
    color: var(--sava-bone);
    text-align: left;
    overflow-y: auto;
    animation: piece-tutorial-in var(--sava-duration) var(--sava-ease) both;
}
.piece-tutorial-overlay[hidden] { display: none; }
.piece-tutorial-art-wrap { display: grid; place-items: center; width: clamp(2.4rem, 6vw, 4.8rem); height: clamp(2.4rem, 6vw, 4.8rem); flex: 0 0 auto; border: 1px solid var(--sava-bronze-dk); background: radial-gradient(circle, rgba(176, 133, 52, 0.18), rgba(0, 0, 0, 0.35)); }
.piece-tutorial-art { width: 72%; height: 72%; filter: invert(86%) sepia(28%) saturate(510%) hue-rotate(358deg) drop-shadow(0 0 8px rgba(232, 200, 130, 0.3)); }
.piece-tutorial-overlay.is-playing .piece-tutorial-art { animation: tutorial-piece-pulse 1.6s ease-in-out infinite; }
.piece-tutorial-copy { min-width: 0; overflow: hidden; }
.piece-tutorial-kicker { color: var(--sava-bronze-lt); font: 0.58rem var(--sava-font-mono); letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.piece-tutorial-copy h3 { margin: 0.1rem 0 0.05rem; color: var(--sava-bone); font: 700 clamp(0.78rem, 1.6vw, 1.1rem) var(--sava-font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.piece-tutorial-copy p { margin: 0; color: var(--sava-bone-dim); font: clamp(0.68rem, 1.3vw, 0.95rem) var(--sava-font-serif); line-height: 1.2; }
.piece-tutorial-movement { display: flex; flex-wrap: wrap; gap: 0.1rem 0.7rem; margin: 0.2rem 0 0; padding: 0; list-style: none; color: var(--sava-bone-faint); font: clamp(0.6rem, 1.1vw, 0.7rem) var(--sava-font-mono); }
.piece-tutorial-movement li { opacity: 0; min-width: 0; animation: tutorial-step-in 0.3s var(--sava-ease) calc(var(--tutorial-step) * 70ms + 80ms) forwards; }
.piece-tutorial-movement li::before { content: "✦ "; color: var(--sava-bronze); }
@keyframes piece-tutorial-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes tutorial-piece-pulse { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-3px) rotate(2deg); } }
@keyframes tutorial-step-in { from { opacity: 0; transform: translateX(-5px); } to { opacity: 1; transform: translateX(0); } }
.captured-section {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
    padding: 0.5vh clamp(0.35rem, 1vw, 1vw);
    border: 1px solid var(--sava-edge);
    background: rgba(0, 0, 0, 0.35);
    overflow: hidden;
}
.captured-section.faction-red { border-top: 3px solid var(--sava-red); }
.captured-section.faction-blue { border-top: 3px solid var(--sava-blue); }
.captured-section h4 {
    margin: 0 0 0.8vh 0;
    font-size: clamp(0.78rem, 1.6vw, 1rem);
    color: var(--sava-bone-dim);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-family: var(--sava-font-head);
}
.captured-section.faction-red h4 { color: #e0998f; }
.captured-section.faction-blue h4 { color: #8fd6db; }

.center-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6vh;
    padding: 0 clamp(0.25rem, 1vw, 1.5vw);
    flex: 1.15 1 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.center-controls .btn,
.center-controls .move-hint,
.spider-dice-decision .btn {
    max-width: 100%;
    white-space: normal;
    text-wrap: balance;
}
.dice-help-text {
    font-size: clamp(0.62rem, 1.1vw, 0.8rem);
    color: var(--sava-bone-faint);
    font-family: var(--sava-font-mono);
    text-align: center;
}
.dice-glyph { font-size: 1.1em; }

.captured-pieces-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5vw;
    min-height: 5vh;
    align-items: center;
}
.captured-pieces-list:empty::after {
    content: "—";
    color: var(--sava-bone-faint);
    font-style: italic;
    font-size: clamp(0.8rem, 1.5vw, 1rem);
}

/* legacy captured-pieces (sidebar fallback) */
.captured-pieces {
    background: rgba(0, 0, 0, 0.35);
    padding: 1rem;
    border: 1px solid var(--sava-edge);
    margin-bottom: 1rem;
}
.captured-pieces h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.85rem;
    color: var(--sava-bone-dim);
    font-family: var(--sava-font-head);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.captured-piece {
    width: clamp(26px, 3vw, 42px);
    height: clamp(26px, 3vw, 42px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(0.9rem, 2vw, 1.35rem);
    border: 2px solid var(--sava-bronze-dk);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.6), 0 2px 5px rgba(0, 0, 0, 0.5);
    color: var(--sava-bone);
}
.captured-piece:hover { transform: scale(1.12); }
.captured-piece.red {
    background: radial-gradient(circle at 35% 30%, #c0392b, #4a0e0e);
    border-color: var(--sava-red);
}
.captured-piece.blue {
    background: radial-gradient(circle at 35% 30%, #2f8f99, #0c2b2f);
    border-color: var(--sava-blue);
}

@media (max-width: 1200px) {
    .game-board { height: 77vh; padding: 2.5vw; min-height: 55vh; }
}

/* ===================== Board nodes / pieces ===================== */
.node {
    position: absolute;
    width: 25px;
    height: 25px;
    background: radial-gradient(circle at 35% 30%, #241c14, #0a0706);
    border: 2px solid var(--sava-bronze-dk);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color var(--sava-duration) var(--sava-ease),
        border-color var(--sava-duration) var(--sava-ease), box-shadow var(--sava-duration) var(--sava-ease),
        transform var(--sava-duration) var(--sava-ease);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    line-height: 1;
    z-index: 10;
    min-width: 20px;
    min-height: 20px;
    max-width: 60px;
    max-height: 60px;
    color: var(--sava-bone);
    box-shadow: inset 0 -1px 3px rgba(0, 0, 0, 0.7), 0 1px 2px rgba(0, 0, 0, 0.5);
}

.piece-icon {
    display: block;
    width: 68%;
    height: 68%;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
    pointer-events: none;
}
.piece-glyph {
    line-height: 1;
    pointer-events: none;
}
.captured-piece .piece-icon,
.promotion-piece-symbol .piece-icon {
    width: 72%;
    height: 72%;
}
.promotion-piece-symbol {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.35rem;
    color: var(--sava-bronze-lt);
}
.promotion-piece-symbol .piece-icon {
    width: 2.4rem;
    height: 2.4rem;
    color: var(--sava-bronze-lt);
}
.node:hover {
    border-color: var(--sava-bronze-lt);
    transform: scale(1.18);
    box-shadow: 0 0 12px rgba(232, 200, 130, 0.45);
}

/* carved faction tokens */
.node.piece-red {
    background: radial-gradient(circle at 35% 28%, #d4493b 0%, #8b1a1a 48%, #3a0b0a 100%);
    border-color: var(--sava-red);
    color: #ffe9e2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.6), inset 0 2px 3px rgba(255, 200, 190, 0.25),
        0 0 8px rgba(200, 60, 50, 0.4);
}
.node.piece-blue {
    background: radial-gradient(circle at 35% 28%, #44c0ca 0%, #1f7780 48%, #0a2b2f 100%);
    border-color: var(--sava-blue);
    color: #e6fbfb;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.6), inset 0 2px 3px rgba(200, 245, 245, 0.25),
        0 0 8px rgba(70, 200, 195, 0.4);
}

.node.selected {
    border-color: var(--sava-bronze-lt);
    box-shadow: 0 0 0 2px #060403, 0 0 0 4px var(--sava-bronze-lt), 0 0 16px rgba(232, 200, 130, 0.6);
    z-index: 12;
}
.node.selected:focus-visible { outline: 2px solid var(--sava-bronze-lt); outline-offset: 2px; }
/* Intermediate weaponmaster hop — must not linger after the move completes */
.node.weaponmaster-waypoint {
    border-color: var(--sava-bronze-lt);
    background: radial-gradient(circle at 50% 45%, rgba(232, 200, 130, 0.28), rgba(40, 28, 12, 0.55));
    box-shadow: 0 0 0 2px #060403, 0 0 0 3px rgba(232, 200, 130, 0.7), 0 0 12px rgba(232, 200, 130, 0.45);
    z-index: 11;
}

.node.legal-move {
    background: radial-gradient(circle at 50% 45%, rgba(70, 206, 196, 0.35), rgba(10, 40, 42, 0.6));
    border-color: var(--sava-blue);
    box-shadow: 0 0 16px rgba(70, 206, 196, 0.6);
    animation: pulse-node-breathe 1.5s infinite;
}
.node.legal-move:hover,
.node.first-move:hover,
.node.second-move:hover,
.node.wizard-move-3:hover,
.node.wizard-first-move:hover,
.node.wizard-second-move:hover,
.node.wizard-third-move:hover {
    filter: brightness(1.15);
    box-shadow: 0 0 0 2px #060403, 0 0 20px rgba(70, 206, 196, 0.55);
}
.node:active:not(.enemy-piece) { transform: scale(1.08); }
.node.selected:active { transform: scale(1.06); }

.node.first-move {
    background: radial-gradient(circle at 50% 45%, rgba(120, 220, 210, 0.35), rgba(10, 40, 42, 0.6));
    border-color: #5fd0c8;
    box-shadow: 0 0 14px rgba(120, 220, 210, 0.55);
    animation: pulse-node-breathe 1.5s infinite;
}
.node.second-move {
    background: radial-gradient(circle at 50% 45%, rgba(40, 150, 145, 0.45), rgba(8, 30, 32, 0.7));
    border-color: #2f8f99;
    box-shadow: 0 0 14px rgba(40, 150, 145, 0.6);
    animation: pulse-node-breathe 1.5s infinite;
}
.node.wizard-move-3,
.node.wizard-first-move,
.node.wizard-second-move,
.node.wizard-third-move {
    border-color: var(--sava-bronze);
    animation: pulse-node-breathe 1.5s infinite;
}
.node.wizard-first-move {
    background: radial-gradient(circle at 50% 45%, rgba(232, 200, 130, 0.35), rgba(40, 28, 12, 0.6));
    box-shadow: 0 0 14px rgba(232, 200, 130, 0.5);
}
.node.wizard-second-move {
    background: radial-gradient(circle at 50% 45%, rgba(200, 165, 88, 0.4), rgba(36, 24, 10, 0.7));
    box-shadow: 0 0 14px rgba(200, 165, 88, 0.55);
}
.node.wizard-third-move,
.node.wizard-move-3 {
    background: radial-gradient(circle at 50% 45%, rgba(170, 130, 60, 0.45), rgba(30, 20, 8, 0.75));
    box-shadow: 0 0 14px rgba(176, 133, 52, 0.6);
}

.node.enemy-piece { cursor: not-allowed; opacity: 0.8; }
.node.enemy-piece:hover { transform: scale(1.08); box-shadow: 0 0 12px rgba(192, 57, 43, 0.5); }

@keyframes pulse-node-breathe {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

.strand {
    position: absolute;
    background: rgba(182, 166, 120, 0.45);
    z-index: 5;
}

/* ===================== Buttons ===================== */
.btn {
    background: var(--sava-gradient-bronze);
    color: #241606;
    border: 2px solid var(--sava-border-ink);
    padding: 10px 20px;
    border-radius: 2px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: var(--sava-font-head);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: transform var(--sava-duration) var(--sava-ease), box-shadow var(--sava-duration) var(--sava-ease);
    box-shadow: 0 3px 0 var(--sava-bronze-dk), 0 6px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 248, 232, 0.35);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--sava-bronze-dk), 0 9px 20px rgba(0, 0, 0, 0.5); }
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.5);
    box-shadow: 0 2px 0 var(--sava-border-ink);
}
.btn.secondary { background: var(--sava-gradient-blood); color: var(--sava-bone); box-shadow: 0 3px 0 var(--sava-blood-dk), 0 6px 14px rgba(0, 0, 0, 0.45); }

/* ===================== Blood rain ===================== */
.rain-container { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 9999; overflow: hidden; }
.raindrop {
    position: absolute;
    width: 2px;
    height: 22px;
    background: linear-gradient(to bottom, transparent, rgba(150, 20, 18, 0.8));
    animation: fall linear infinite;
}
@keyframes fall {
    0% { transform: translateY(-100vh); opacity: 1; }
    100% { transform: translateY(100vh); opacity: 0; }
}

/* ===================== Game over plaque ===================== */
.game-over-overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 4, 3, 0.9);
    backdrop-filter: blur(3px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.game-over-content {
    background-color: var(--sava-parchment);
    background-image: linear-gradient(178deg, rgba(255, 252, 244, 0.5), rgba(203, 191, 168, 0.3)), var(--sava-tex-parchment);
    background-size: cover, cover;
    padding: 3rem;
    border: 4px solid transparent;
    border-image: var(--sava-gradient-bronze) 1;
    max-width: min(90vw, 30rem);
    box-shadow: var(--sava-shadow-panel), 0 0 0 4px rgba(0, 0, 0, 0.6);
    color: var(--sava-ink);
}
.game-over-title {
    font-family: var(--sava-font-display);
    font-size: 3.4rem;
    line-height: 1;
    margin-bottom: 1rem;
    color: var(--sava-blood-dk);
}
.game-over-message { font-size: 1.25rem; margin-bottom: 2rem; color: var(--sava-ink-muted); font-style: italic; }
.game-over-btn {
    background: var(--sava-gradient-bronze);
    color: #241606;
    border: 2px solid var(--sava-border-ink);
    padding: 0.85rem 2rem;
    font-size: 0.9rem;
    font-family: var(--sava-font-head);
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform var(--sava-duration) var(--sava-ease);
    box-shadow: 0 3px 0 var(--sava-bronze-dk), 0 6px 14px rgba(0, 0, 0, 0.4);
}
.game-over-btn:hover { transform: translateY(-2px); }

/* ===================== Dev features ===================== */
.dev-feature { display: none; }
.dev-mode .dev-feature { display: block; }
.dev-mode .dev-feature.inline { display: inline-block; }
.dev-mode .dev-feature.flex { display: flex; }

/* ===================== Spider dice ===================== */
.spider-dice {
    background: var(--sava-gradient-blood);
    color: var(--sava-bone);
    border: 2px solid var(--sava-border-ink);
    padding: 0.7rem 1.4rem;
    border-radius: 2px;
    font-size: 0.85rem;
    font-family: var(--sava-font-head);
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    box-shadow: 0 3px 0 var(--sava-blood-dk), 0 6px 14px rgba(0, 0, 0, 0.5);
}
.spider-dice:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.1); }
.spider-dice:disabled,
.spider-dice.disabled {
    cursor: not-allowed;
    background: var(--sava-gradient-stone-panel);
    color: var(--sava-bone-faint);
    border-color: var(--sava-edge);
    box-shadow: 0 2px 0 #000;
    text-shadow: none;
}
.spider-dice.rolling { animation: rolling 0.5s infinite; filter: brightness(1.25); }
@keyframes rolling { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(4deg); } 75% { transform: rotate(-4deg); } }

.dice-roll-button { position: relative; overflow: hidden; }
.dice-roll-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(232, 200, 130, 0.28), transparent);
    transition: left 0.5s;
}
.dice-roll-button:hover::before { left: 100%; }

/* ===================== Bottom-Bar Altar & Embedded 3D Spider Dice ===================== */
.center-controls {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35vh;
    padding: 0 clamp(0.25rem, 0.8vw, 1.2vw);
    flex: 1.2 1 0;
    min-width: clamp(8rem, 24vw, 16rem);
    max-width: 100%;
    min-height: clamp(5.2rem, 9.5vh, 7.8rem);
    overflow: hidden;
}

.dice-altar-dock {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    width: 100%;
    transition: opacity 0.24s ease, transform 0.24s ease;
}

/* When the embedded dice roll is active, dismiss the dock text/buttons smoothly.
   #dice-status-row (the "Turns until dice" / action badge) is a sibling of the
   dock, not a child, so it needs to be listed explicitly to fade with it. */
.center-controls.is-rolling .dice-altar-dock,
.center-controls.is-revealing-dice .dice-altar-dock,
.center-controls.is-rolling #dice-status-row,
.center-controls.is-revealing-dice #dice-status-row {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92);
}

.bottom-bar-dice-stage {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    transform: scale(0.94);
    /* stay below .piece-tutorial-overlay (z-index: 8) so hover tutorials always win */
    z-index: 5;
}

.bottom-bar-dice-stage.show {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.bottom-bar-dice-stage .dice-canvas {
    width: 100%;
    height: clamp(3.6rem, 6.8vh, 5.4rem);
    max-height: 100%;
    display: block;
}

.dice-stage-ribbon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.15rem 0.35rem;
    transition: opacity 0.2s ease;
}

.dice-chips-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.dice-chip-inline {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.42rem;
    border-radius: 3px;
    font: 700 clamp(0.68rem, 1.1vw, 0.8rem) var(--sava-font-mono);
    border: 1px solid var(--sava-edge);
    background: rgba(12, 8, 7, 0.9);
    color: var(--sava-bone);
    white-space: nowrap;
}

.dice-chip-inline.is-spider {
    border-color: rgba(78, 235, 177, 0.7);
    background: rgba(10, 32, 22, 0.9);
    color: #b5ffd9;
    box-shadow: 0 0 8px rgba(78, 235, 177, 0.35);
}

.dice-chip-inline.is-knife {
    border-color: rgba(232, 93, 69, 0.7);
    background: rgba(36, 12, 10, 0.9);
    color: #ffd2c7;
    box-shadow: 0 0 8px rgba(232, 93, 69, 0.35);
}

.dice-vs-inline {
    color: var(--sava-bronze-lt);
    font-size: 0.65rem;
    opacity: 0.6;
}

.dice-stage-msg {
    font-family: var(--sava-font-head);
    font-weight: 700;
    font-size: clamp(0.7rem, 1.2vw, 0.85rem);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sava-bronze-lt);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Active Double-Spiders Glow in Bottom Bar */
.bottom-bar-dice-stage.is-double-spiders .dice-stage-msg {
    color: #8efad2;
    text-shadow: 0 0 8px rgba(78, 235, 177, 0.8);
}

/* Active Double-Knives Glow in Bottom Bar */
.bottom-bar-dice-stage.is-double-knives .dice-stage-msg {
    color: #ffa899;
    text-shadow: 0 0 8px rgba(232, 93, 69, 0.8);
}

/* Smooth fade-in action badges replacing the dice stage */
.dice-action-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    max-width: 100%;
    padding: 0.28rem 0.5rem;
    border-radius: 3px;
    font-family: var(--sava-font-head);
    font-weight: 700;
    font-size: clamp(0.6rem, 1.1vw, 0.88rem);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: badge-fade-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.dice-action-badge.is-sacrifice {
    background: var(--sava-gradient-blood);
    color: var(--sava-bone);
    border: 2px solid var(--sava-blood-lt);
    box-shadow: 0 0 12px rgba(200, 60, 50, 0.55);
    animation: pulse-sacrifice-badge 1.5s infinite alternate;
}

.dice-action-badge.is-spider-control {
    background: var(--sava-gradient-bronze);
    color: #241606;
    border: 2px solid var(--sava-bronze-lt);
    box-shadow: 0 0 12px rgba(232, 200, 130, 0.55);
    animation: pulse-spider-badge 1.5s infinite alternate;
}

@keyframes badge-fade-in {
    from { opacity: 0; transform: translateY(6px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulse-sacrifice-badge {
    from { box-shadow: 0 0 8px rgba(200, 60, 50, 0.4); }
    to { box-shadow: 0 0 16px rgba(200, 60, 50, 0.8); }
}

@keyframes pulse-spider-badge {
    from { box-shadow: 0 0 8px rgba(232, 200, 130, 0.4); }
    to { box-shadow: 0 0 16px rgba(232, 200, 130, 0.8); }
}

/* ===================== Sacrifice / control highlights ===================== */
.sacrifice-candidate {
    border: 3px solid var(--sava-blood-lt) !important;
    box-shadow: 0 0 14px rgba(200, 60, 50, 0.7) !important;
    animation: pulse-sacrifice 1.5s infinite;
}
@keyframes pulse-sacrifice { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }
.spider-control-candidate {
    border: 3px solid var(--sava-bronze-lt) !important;
    box-shadow: 0 0 14px rgba(232, 200, 130, 0.7) !important;
    animation: pulse-spider-control 1.5s infinite;
}
.controlled-piece {
    border: 3px solid var(--sava-blood-lt) !important;
    box-shadow: 0 0 18px rgba(200, 60, 50, 0.85) !important;
    animation: pulse-controlled 2s infinite;
}
@keyframes pulse-spider-control { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes pulse-controlled {
    0%, 100% { transform: scale(1); box-shadow: 0 0 16px rgba(200, 60, 50, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 24px rgba(200, 60, 50, 0.95); }
}

/* ===================== Chat (whispers) ===================== */
.chat-widget {
    position: fixed;
    bottom: 1.25rem;
    right: 1rem;
    z-index: 1001;
    display: flex;
    flex-direction: column-reverse;
    align-items: flex-end;
    gap: 0.5rem;
}
.chat-widget.dragging { cursor: grabbing; }
.chat-widget.dragging .chat-toggle { transform: scale(1.04); cursor: grabbing; }
.chat-toggle {
    position: relative;
    background: var(--sava-gradient-bronze);
    color: #241606;
    border: 2px solid var(--sava-border-ink);
    width: 52px;
    height: 52px;
    border-radius: 2px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 248, 232, 0.3);
    transition: transform var(--sava-duration) var(--sava-ease);
    touch-action: none;
    flex-shrink: 0;
}
.chat-toggle:hover { transform: translateY(-2px); }
.chat-toggle.active { background: var(--sava-gradient-blood); color: var(--sava-bone); }
.chat-icon { width: 24px; height: 24px; display: flex; }
.chat-icon svg { width: 100%; height: 100%; }

.chat-window {
    position: relative;
    width: 350px;
    height: min(500px, calc(100dvh - var(--sava-top-bar-height, 3.25rem) - 8rem));
    max-height: calc(100dvh - var(--sava-top-bar-height, 3.25rem) - 8rem);
    background-color: var(--sava-stone-1);
    background-image: linear-gradient(180deg, rgba(22, 16, 11, 0.95), rgba(8, 6, 5, 0.97)), var(--sava-tex-stone);
    background-size: cover, 420px;
    box-shadow: var(--sava-shadow-panel);
    display: none;
    flex-direction: column;
    border: 2px solid transparent;
    border-image: var(--sava-gradient-bronze) 1;
}
.chat-window.open { display: flex; }
.chat-header {
    background: var(--sava-gradient-stone-panel);
    color: var(--sava-bronze-lt);
    padding: 0.9rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--sava-bronze);
    cursor: grab;
    touch-action: none;
    user-select: none;
}
.chat-title { font-family: var(--sava-font-head); font-weight: 700; font-size: 1rem; letter-spacing: 0.12em; text-transform: uppercase; }
.close-chat-btn {
    background: transparent;
    border: 1px solid var(--sava-edge);
    color: var(--sava-bone);
    font-size: 1.4rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--sava-duration) var(--sava-ease);
}
.close-chat-btn:hover { background: rgba(192, 57, 43, 0.4); }

/* ===================== Turn timer vials ===================== */
.turn-timer {
    margin: 1rem 0;
    padding: 0.9rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--sava-edge);
    box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.5);
}
.turn-timer h4 {
    margin: 0 0 0.85rem 0;
    color: var(--sava-bronze-lt);
    font-family: var(--sava-font-head);
    font-size: 0.85rem;
    text-align: center;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}
.timer-display { display: flex; flex-direction: column; gap: 0.5rem; }
.timer-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.65rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--sava-edge);
}
.timer-section.red { border-left: 5px solid var(--sava-red); }
.timer-section.blue { border-left: 5px solid var(--sava-blue); }
.current-turn-timer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem;
    background: var(--sava-gradient-stone-panel);
    color: var(--sava-bronze-lt);
    border: 1px solid var(--sava-bronze);
    font-weight: bold;
}
.timer-label {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
    min-width: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--sava-bone-dim);
}
.timer-color-name {
    font-family: var(--sava-font-head);
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sava-bone-faint, #9a8b78);
}
.timer-player-id {
    font-family: var(--sava-font-mono);
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--sava-bone);
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.timer-player-id a {
    color: inherit;
    text-decoration: none;
}
.timer-player-id a:hover {
    color: var(--sava-bronze-lt);
    text-decoration: underline;
}
.timer-value { font-size: 1.05rem; font-weight: bold; font-family: var(--sava-font-mono); color: var(--sava-bone); }
.timer-value.warning { color: var(--sava-warn-fg); }
.timer-value.danger { color: var(--sava-danger); animation: pulse-timer-blink 1s infinite; }
@keyframes pulse-timer-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* ===================== Chat messages ===================== */
.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 380px;
}
.chat-welcome {
    text-align: center;
    color: var(--sava-bone-faint);
    font-style: italic;
    padding: 1rem;
    border: 1px dashed var(--sava-edge);
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.86rem;
}
.chat-message { display: flex; flex-direction: column; gap: 0.25rem; }
.chat-message.own { align-items: flex-end; }
.chat-message.other,
.chat-message.spectator { align-items: flex-start; }
.message-header { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--sava-bone-faint); }
.message-header .player-name { font-weight: bold; }
.message-header .player-name.red { color: #e0998f; }
.message-header .player-name.blue { color: #8fd6db; }
.message-header .player-name.spectator { color: var(--sava-pewter); }
.message-timestamp { font-size: 0.68rem; color: var(--sava-bone-faint); }
.message-content {
    background: rgba(0, 0, 0, 0.45);
    color: var(--sava-bone);
    padding: 0.65rem 0.9rem;
    max-width: 250px;
    word-wrap: break-word;
    line-height: 1.45;
    border: 1px solid var(--sava-edge);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: box-shadow var(--sava-duration) var(--sava-ease), transform var(--sava-duration) var(--sava-ease);
}
.chat-message:not(.new) .message-content:hover { transform: translateY(var(--sava-tap-lift)); }
.chat-message.own .message-content {
    background: var(--sava-gradient-stone-panel);
    color: var(--sava-bronze-lt);
    border-color: var(--sava-bronze);
}
.chat-message.spectator .message-content { border-left: 4px solid var(--sava-pewter); }
.chat-input-container {
    padding: 0.85rem;
    border-top: 1px solid var(--sava-edge);
    display: flex;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.4);
}
.chat-input-container input {
    flex: 1;
    padding: 0.65rem;
    border: 1px solid var(--sava-edge);
    outline: none;
    font-size: 0.9rem;
    font-family: var(--sava-font-serif);
    background: rgba(0, 0, 0, 0.5);
    color: var(--sava-bone);
}
.chat-input-container input:focus { border-color: var(--sava-bronze); box-shadow: 0 0 0 2px var(--sava-focus-ring); }
.send-btn {
    background: var(--sava-gradient-bronze);
    color: #241606;
    border: 2px solid var(--sava-border-ink);
    padding: 0.65rem 1.1rem;
    cursor: pointer;
    font-weight: 700;
    font-family: var(--sava-font-head);
    font-size: 0.78rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: transform var(--sava-duration) var(--sava-ease);
    box-shadow: 0 3px 0 var(--sava-bronze-dk);
}
.send-btn:hover { transform: translateY(-2px); }
.send-btn:disabled { background: var(--sava-stone-3); color: var(--sava-bone-faint); cursor: not-allowed; transform: none; box-shadow: none; }
.chat-message.new { animation: messageSlideIn 0.3s ease-out; }
@keyframes messageSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===================== Rules grimoire drawer ===================== */
.rules-sidebar {
    position: fixed;
    top: var(--sava-top-bar-height);
    right: -420px;
    width: 420px;
    height: calc(100dvh - var(--sava-top-bar-height));
    background-color: var(--sava-parchment);
    background-image: linear-gradient(178deg, rgba(255, 252, 244, 0.5), rgba(203, 191, 168, 0.25)), var(--sava-tex-parchment);
    background-size: cover, cover;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
    transition: right var(--sava-duration) var(--sava-ease);
    z-index: 1000;
    overflow-y: auto;
    padding: 1.5rem 1.75rem 2rem;
    border-left: 4px solid transparent;
    border-image: var(--sava-gradient-bronze) 1;
    color: var(--sava-ink);
}
.rules-sidebar.open { right: 0; }
.rules-overlay {
    position: fixed;
    top: var(--sava-top-bar-height);
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    height: auto;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}
.rules-overlay.open { opacity: 1; visibility: visible; }
.rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(110, 77, 30, 0.5);
}
.rules-title {
    font-family: var(--sava-font-head);
    font-size: 1.35rem;
    color: var(--sava-blood-dk);
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.close-rules-btn {
    background: rgba(110, 77, 30, 0.12);
    color: var(--sava-ink);
    border: 1px solid var(--sava-bronze-dk);
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}
.close-rules-btn:hover { background: var(--sava-blood); color: var(--sava-parchment); }
.rules-content { line-height: 1.5; color: var(--sava-ink); }
.rules-content h2 {
    color: var(--sava-blood-dk);
    margin: 0 0 0.45rem;
    font-family: var(--sava-font-head);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(110, 77, 30, 0.4);
    padding-bottom: 0.2rem;
}
.rules-content h3 { color: var(--sava-bronze-dk); margin: 1rem 0 0.4rem; font-family: var(--sava-font-head); font-size: 1.05rem; }
.rules-content p { margin-bottom: 0.55rem; text-align: justify; font-size: 0.92rem; }
.rules-content p:last-child { margin-bottom: 0; }
.rules-content .rules-lede::first-letter {
    font-family: var(--sava-font-display);
    font-size: 2.4rem;
    line-height: 0.72;
    float: left;
    margin: 0.15rem 0.35rem 0 0;
    color: var(--sava-blood);
}
.rules-content .rules-folio {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
    margin-bottom: 0.85rem;
}
.rules-content .rules-panel--board {
    padding: 0.55rem 0.7rem;
    background: rgba(110, 77, 30, 0.07);
    border: 1px solid rgba(110, 77, 30, 0.28);
}
.rules-content .rules-movement { margin-bottom: 0.75rem; }
.rules-content .rules-pieces {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
}
.rules-content .rules-pieces li {
    margin: 0;
    padding: 0.5rem 0.6rem;
    background: rgba(255, 252, 244, 0.28);
    border-left: 3px solid var(--sava-bronze-dk);
    font-size: 0.88rem;
    line-height: 1.4;
}
.rules-content .rules-pieces strong {
    display: block;
    font-family: var(--sava-font-head);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--sava-blood-dk);
    margin-bottom: 0.15rem;
}
.rules-content .rules-piece--matron {
    border-left-color: var(--sava-blood);
    background: rgba(139, 26, 26, 0.06);
}
.rules-content .rules-faq dl {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
    margin: 0.45rem 0 0;
}
.rules-content .rules-faq dl > div {
    padding: 0.45rem 0.55rem;
    border-top: 1px solid rgba(110, 77, 30, 0.35);
    background: rgba(255, 252, 244, 0.22);
}
.rules-content .rules-faq dt {
    font-family: var(--sava-font-head);
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--sava-bronze-dk);
    margin-bottom: 0.15rem;
}
.rules-content .rules-faq dd { margin: 0; font-size: 0.88rem; line-height: 1.4; }
.rules-content .rules-appendix { margin-top: 0.75rem; }
.rules-content .rules-appendix-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.45rem;
}
.rules-content .rules-appendix-grid p {
    margin: 0;
    padding: 0.45rem 0.55rem;
    border-top: 1px solid rgba(110, 77, 30, 0.35);
    background: rgba(255, 252, 244, 0.22);
    font-size: 0.88rem;
    line-height: 1.4;
}
.highlight { background: rgba(139, 26, 26, 0.08); padding: 0.8rem; border-left: 4px solid var(--sava-blood); margin: 1rem 0; font-size: 0.92rem; }
.loading { text-align: center; color: var(--sava-ink-muted); font-style: italic; padding: 2rem; }
.error { text-align: center; color: var(--sava-danger); padding: 2rem; background: rgba(192, 57, 43, 0.1); border: 1px solid rgba(192, 57, 43, 0.4); }

/* ===================== Orc promotion plaque ===================== */
.promotion-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(6, 4, 3, 0.85);
    backdrop-filter: blur(3px);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}
.promotion-overlay.show { display: flex; }
.promotion-modal {
    background-color: var(--sava-parchment);
    background-image: linear-gradient(178deg, rgba(255, 252, 244, 0.5), rgba(203, 191, 168, 0.3)), var(--sava-tex-parchment);
    background-size: cover, cover;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--sava-shadow-panel), 0 0 0 4px rgba(0, 0, 0, 0.6);
    position: relative;
    border: 3px solid transparent;
    border-image: var(--sava-gradient-bronze) 1;
    color: var(--sava-ink);
}
.promotion-header { text-align: center; margin-bottom: 1.5rem; }
.promotion-header h3 { color: var(--sava-blood-dk); margin: 0 0 0.5rem 0; font-family: var(--sava-font-head); font-size: 1.5rem; text-transform: uppercase; letter-spacing: 0.03em; }
.promotion-header p { color: var(--sava-ink-muted); margin: 0; font-size: 1rem; font-style: italic; }
.promotion-pieces { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.promotion-piece {
    background: radial-gradient(circle at 40% 25%, #2a2018, #0a0706);
    border: 2px solid var(--sava-bronze-dk);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: transform var(--sava-duration) var(--sava-ease), box-shadow var(--sava-duration) var(--sava-ease), border-color var(--sava-duration);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--sava-bone);
    box-shadow: inset 0 -2px 6px rgba(0, 0, 0, 0.6);
}
.promotion-piece:hover { transform: translateY(-2px); border-color: var(--sava-bronze-lt); box-shadow: 0 0 14px rgba(232, 200, 130, 0.4); }
.promotion-piece.selected { border-color: var(--sava-bronze-lt); box-shadow: 0 0 0 2px var(--sava-bronze-lt), 0 0 16px rgba(232, 200, 130, 0.5); }
.promotion-piece-symbol { color: var(--sava-bronze-lt); }
.promotion-piece-name { font-size: 0.85rem; font-weight: 600; text-transform: capitalize; color: var(--sava-bone-dim); }
.promotion-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.promotion-confirm {
    background: var(--sava-gradient-bronze);
    color: #241606;
    border: 2px solid var(--sava-border-ink);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-weight: 700;
    font-family: var(--sava-font-head);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    transition: transform var(--sava-duration) var(--sava-ease);
    flex: 1;
    box-shadow: 0 3px 0 var(--sava-bronze-dk);
}
.promotion-confirm:hover { transform: translateY(-2px); }
.promotion-confirm:disabled { background: var(--sava-stone-3); color: var(--sava-bone-faint); cursor: not-allowed; transform: none; box-shadow: none; }

/* ===================== Check indicators ===================== */
.check-indicator {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    font-size: 2rem;
    color: var(--sava-blood-lt);
    opacity: 0.8;
    text-shadow: 0 0 6px rgba(200, 60, 50, 0.7);
    animation: checkPulse 2s infinite;
    transform: translate(-50%, -50%);
}
@keyframes checkPulse {
    0%, 100% { opacity: 0.8; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
}
.check-line {
    position: absolute;
    pointer-events: none;
    z-index: 8;
    background: linear-gradient(90deg, transparent 0%, rgba(200, 60, 50, 0.65) 20%, rgba(200, 60, 50, 0.9) 50%, rgba(200, 60, 50, 0.65) 80%, transparent 100%);
    height: 4px;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(200, 60, 50, 0.5);
    animation: checkLineFlash 2s infinite;
}
@keyframes checkLineFlash { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }

/* ===================== Mobile ===================== */
@media (max-width: 768px) {
    .lobby-content { grid-template-columns: 1fr; }
    .lobby-sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 300px;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 4px 0 28px rgba(0, 0, 0, 0.6);
    }
    .lobby-sidebar.open { left: 0; }

    .game-board { width: 100%; max-width: none; height: 74vh; margin: 0; padding: 1.25rem; min-height: 50vh; }
    .game-board-container { padding: 0.5rem; }
    .game-board .node { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
    .game-board svg { max-width: 100%; max-height: 100%; }

    .captured-pieces-board { flex-direction: column; gap: 1vh; padding: 1vh 1vw 2vh; min-height: 12vh; }
    .center-controls { order: -1; padding: 1vh 0; width: 100%; }
    .unified-game-area { border-width: 4px; }
    .unified-game-area::before, .unified-game-area::after { width: 34px; height: 34px; }

    .rules-sidebar {
        top: calc(var(--sava-top-bar-height) + 1rem);
        left: 50%;
        right: auto;
        transform: translate(-50%, 0);
        width: 90vw;
        max-width: 420px;
        height: auto;
        max-height: calc(100dvh - var(--sava-top-bar-height) - 2rem);
        padding: 1.5rem;
        opacity: 0;
        visibility: hidden;
        scale: 0.92;
        transition: opacity var(--sava-duration) var(--sava-ease), visibility var(--sava-duration) var(--sava-ease), scale var(--sava-duration) var(--sava-ease);
    }
    .rules-sidebar.open { opacity: 1; visibility: visible; scale: 1; }

    .chat-widget { left: auto; top: auto; }
    .chat-window {
        position: fixed;
        top: 0; right: 0; left: 0; bottom: 0;
        width: 100%; height: 100%; max-height: none;
        z-index: 1001;
    }
    .chat-toggle { width: 46px; height: 46px; }
    .chat-messages { max-height: none; flex: 1; }
    .message-content { max-width: 80%; }

    .dice-result { padding: 1rem; }
    .dice-result h3 { font-size: 1.5rem; }
    .dice-results { gap: 1rem; }
    .die { width: 62px; height: 62px; font-size: 2.1rem; }
    #dice-message { font-size: 1rem; }

    .promotion-modal { margin: 1rem; width: calc(100% - 2rem); padding: 1.5rem; }
    .promotion-pieces { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }

    /* Mobile turn timer bar */
    .mobile-turn-timer {
        position: fixed;
        top: calc(var(--sava-top-bar-height) + 0.75rem);
        left: 4.5rem;
        right: 4.5rem;
        z-index: 998;
        background: rgba(8, 6, 5, 0.92);
        border: 1px solid var(--sava-bronze);
        padding: 0.25rem 0.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
        min-height: 2.25rem;
    }
    .mobile-timer-display { display: flex; justify-content: space-between; align-items: center; gap: 0.3rem; }
    .mobile-timer-section {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.15rem 0.25rem;
        background: rgba(0, 0, 0, 0.5);
        border: 1px solid var(--sava-edge);
        height: 1.8rem;
    }
    .mobile-timer-section.red { border-left: 3px solid var(--sava-red); }
    .mobile-timer-section.blue { border-left: 3px solid var(--sava-blue); }
    .mobile-current-turn-timer {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.15rem 0.25rem;
        background: var(--sava-gradient-stone-panel);
        color: var(--sava-bronze-lt);
        border: 1px solid var(--sava-bronze);
        height: 1.8rem;
    }
    .mobile-timer-value { font-size: 0.72rem; font-weight: bold; font-family: var(--sava-font-mono); color: var(--sava-bone); }
    .mobile-timer-value.warning { color: var(--sava-warn-fg); }
    .mobile-timer-value.danger { color: var(--sava-danger); animation: pulse-timer-blink 1s infinite; }
}

@media (max-width: 480px) {
    .game-board { height: 68vh; padding: 1rem; min-height: 45vh; }
    .captured-pieces-board { min-height: 15vh; }
}

/* Responsive topology contract: one square circular graph at every viewport. */
body.game-lobby .game-board {
    width: 100%;
    aspect-ratio: auto;
    height: auto;
    min-height: 0;
    max-width: none;
    max-height: none;
    padding: 0;
    margin-inline: auto;
    flex: 1 1 auto;
}
body.game-lobby .unified-game-area {
    overflow: auto;
}
body.game-lobby .responsive-board-topology {
    position: absolute;
    inset: 0;
    z-index: 5;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}
body.game-lobby .responsive-board-topology circle,
body.game-lobby .responsive-board-topology path {
    fill: none;
    stroke: rgba(182, 166, 120, 0.58);
    stroke-width: clamp(1.5px, 0.28vw, 3px);
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}
body.game-lobby .responsive-board-topology path { stroke: rgba(182, 166, 120, 0.7); }

@media (max-width: 768px) {
    body.game-lobby .game-board-container { overflow: auto; }
    body.game-lobby .game-board {
        width: max(360px, calc(100vw - 1rem));
        min-width: 360px;
        height: auto;
        max-width: none;
        max-height: none;
        min-height: 0;
        flex: 1 1 auto;
    }
    body.game-lobby .unified-game-area { overflow: auto; }
    body.game-lobby .captured-pieces-board {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(8.5rem, 1.05fr) minmax(0, 1fr);
        align-items: stretch;
        gap: clamp(0.35rem, 1.5vw, 0.65rem);
        flex: 0 0 clamp(8.5rem, 18dvh, 11rem);
        min-height: 8.5rem;
        max-height: 11rem;
        padding: 0.55rem;
        overflow: visible;
    }
    body.game-lobby .captured-section {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        min-height: 0;
        padding: 0.55rem 0.35rem;
        overflow: hidden;
    }
    body.game-lobby .captured-section h4 {
        margin: 0 0 0.35rem;
        font-size: clamp(0.62rem, 2.2vw, 0.78rem);
        line-height: 1.15;
        letter-spacing: 0.08em;
        white-space: nowrap;
    }
    body.game-lobby .captured-pieces-list {
        min-height: 0;
        flex: 1 1 auto;
        align-content: center;
        gap: 0.3rem;
        overflow: auto;
    }
    body.game-lobby .center-controls {
        order: 0;
        width: auto;
        min-width: 0;
        padding: 0.35rem 0.4rem;
        overflow: hidden;
    }
    body.game-lobby #spider-dice-btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.72rem;
    }
    body.game-lobby .bottom-bar-dice-stage .dice-canvas {
        height: clamp(2.6rem, 5.5vh, 4rem);
    }
}

/* --- Phase 2 UX modules --- */
.position-name {
    margin: 0.35rem 0 0.75rem;
    padding: 0;
    max-width: 100%;
    min-width: 0;
}
.position-name-slug {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0.35rem 0.45rem;
    border: 1px solid rgba(201, 162, 39, 0.35);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.28);
    color: var(--sava-gold, #c9a227);
    font-style: italic;
    font-family: var(--sava-font-serif, Georgia, serif);
    font-size: 0.92rem;
    line-height: 1.35;
    text-align: left;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    cursor: pointer;
}
.position-name-slug:hover,
.position-name-slug:focus-visible {
    border-color: var(--sava-gold, #c9a227);
    outline: none;
}
.position-name-expand {
    margin-top: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}
.position-name-expand[hidden] {
    display: none !important;
}
.position-name-details {
    margin: 0;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--sava-edge);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    color: var(--sava-bone-dim, #c8b8a0);
    font-size: 0.78rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}
.position-name.is-expanded .position-name-slug {
    border-color: var(--sava-bronze-lt, #d4b56a);
}
.position-name .move-history-panel {
    margin: 0;
    max-height: 160px;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--sava-edge);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.35);
}

.center-controls {
    gap: 0.35vh;
}
.dice-status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}
.dice-cooldown-tile {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0.24rem 0.4rem;
    border: 1px solid var(--sava-edge);
    background: rgba(0, 0, 0, 0.35);
    color: var(--sava-bronze-lt);
    font-size: clamp(0.58rem, 1vw, 0.8rem);
    font-family: var(--sava-font-mono);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
}
.dice-cooldown-tile[hidden] { display: none !important; }
.dice-help-btn {
    flex: 0 0 auto;
    width: 1.4rem;
    height: 1.4rem;
    padding: 0;
    border: 1px solid var(--sava-bronze);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    color: var(--sava-bronze-lt);
    font-family: var(--sava-font-serif);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}
.dice-help-btn:hover:not(:disabled) {
    border-color: var(--sava-bronze-lt);
    color: var(--sava-bone);
}
.dice-help-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
#spider-dice-btn[hidden] { display: none !important; }
#spider-dice-btn {
    padding: 0.35rem 0.7rem;
    font-size: clamp(0.72rem, 1.3vw, 0.85rem);
}

.dice-preview-panel {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.dice-preview-panel.open { display: flex; }
.dice-preview-card {
    background: var(--sava-gradient-stone-panel);
    border: 1px solid var(--sava-bronze);
    border-radius: 8px;
    padding: 1.25rem;
    max-width: 420px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
}
.dice-outcome-list {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0;
}
.dice-outcome-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--sava-edge);
    font-size: 0.88rem;
    line-height: 1.4;
}
.dice-outcome-list li span { color: var(--sava-gold); float: right; }
.dice-preview-warning {
    color: var(--sava-warn-fg);
    font-size: 0.85rem;
}
.dice-preview-footer {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.sacrifice-planner {
    background: rgba(80, 10, 10, 0.35);
    border: 1px solid var(--sava-blood, #8b1a1a);
    border-radius: 6px;
    padding: 0.75rem;
    margin: 0.75rem 0;
}
.sacrifice-planner h4 { margin: 0 0 0.5rem; color: var(--sava-blood-lt); font-size: 0.9rem; }
.sacrifice-recommendation { font-size: 0.82rem; color: var(--sava-bone); margin: 0 0 0.5rem; }
.sacrifice-list {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.8rem;
}
.sacrifice-list li { padding: 0.2rem 0; }
.sacrifice-list li.recommended { color: var(--sava-gold); font-weight: bold; }
.node.sacrifice-candidate {
    animation: pulse-sacrifice 1.2s infinite;
    box-shadow: 0 0 0 2px var(--sava-blood);
}
@keyframes pulse-sacrifice {
    0%, 100% { box-shadow: 0 0 0 2px rgba(139, 26, 26, 0.6); }
    50% { box-shadow: 0 0 12px rgba(206, 64, 48, 0.9); }
}

.resurrection-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin: 0.5rem 0 0.85rem;
    padding: 0.45rem 0.55rem;
    cursor: pointer;
    color: var(--sava-bone-dim, #c8b8a0);
    border: 1px solid var(--sava-edge);
    background: rgba(0, 0, 0, 0.28);
    max-width: 100%;
    box-sizing: border-box;
    user-select: none;
}
.resurrection-toggle input {
    flex: 0 0 auto;
    width: 1rem;
    height: 1rem;
    accent-color: var(--sava-bronze, #c9a227);
    cursor: pointer;
}
.resurrection-zones-hidden .resurrection-zones-layer,
.resurrection-zones-layer.is-hidden,
#resurrection-zones-svg.is-hidden,
#resurrection-zones-svg[hidden] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

.capture-spatter {
    position: absolute;
    pointer-events: none;
    z-index: 15;
    transform: translate(-50%, -50%);
    animation: spatter-fade 0.8s ease-out forwards;
}
.capture-spatter.reduced-motion { animation: none; opacity: 0.7; }
.spatter-blob {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sava-blood, #8b1a1a);
    left: calc(50% + var(--sx, 0px));
    top: calc(50% + var(--sy, 0px));
}
@keyframes spatter-fade {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.4); }
}

.chat-window.spectator-chat { border-color: #6b5b95; }
.chat-window.spectator-chat .chat-header { background: rgba(60, 45, 90, 0.5); }

.piece-glossary-popover {
    position: fixed;
    z-index: 1100;
    background: var(--sava-gradient-stone-panel);
    border: 1px solid var(--sava-bronze);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    max-width: 280px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.piece-glossary-popover .glossary-close {
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: var(--sava-bone);
    font-size: 1.25rem;
    cursor: pointer;
}
.piece-glossary-popover h4 { margin: 0 0 0.35rem; color: var(--sava-gold); }
.piece-glossary-popover .glossary-alias { font-size: 0.78rem; color: var(--sava-bronze-lt); }
.piece-glossary-popover ul { margin: 0.5rem 0; padding-left: 1.1rem; font-size: 0.82rem; }
.piece-glossary-popover .glossary-spider { font-size: 0.8rem; color: var(--sava-warn-fg); }

.check-line[data-player="red"] { background: linear-gradient(90deg, transparent, rgba(206, 64, 48, 0.85)); }
.check-line[data-player="blue"] { background: linear-gradient(90deg, transparent, rgba(70, 200, 195, 0.85)); }
.check-indicator[data-player="red"] { color: var(--sava-red); }
.check-indicator[data-player="blue"] { color: var(--sava-blue); }

@media (max-width: 768px) {
    .dice-preview-card { max-width: 100%; }
    .piece-glossary-popover {
        left: 0.5rem !important;
        right: 0.5rem;
        max-width: none;
        bottom: 0.5rem;
        top: auto !important;
    }
    .move-history-panel { max-height: 120px; }
}

/* Phase 3: onboarding */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: none;
}
.onboarding-overlay[hidden] { display: none !important; }
.onboarding-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 6, 12, 0.72);
    pointer-events: auto;
}
.onboarding-spotlight {
    position: fixed;
    border: 2px solid var(--sava-gold);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(8, 6, 12, 0.72);
    pointer-events: none;
    z-index: 9001;
}
.onboarding-tooltip {
    position: fixed;
    z-index: 9002;
    max-width: 320px;
    background: var(--sava-panel, #1a1424);
    border: 1px solid var(--sava-gold);
    border-radius: 8px;
    padding: 1rem;
    pointer-events: auto;
    color: var(--sava-bone);
}
.onboarding-step-title { margin: 0 0 0.5rem; color: var(--sava-gold); }
.onboarding-step-body { margin: 0 0 0.75rem; font-size: 0.9rem; line-height: 1.45; }
.onboarding-step-indicator { font-size: 0.75rem; color: var(--sava-bronze-lt); margin-bottom: 0.75rem; }
.onboarding-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.onboarding-actions .btn { flex: 1; min-width: 4rem; }

/* Phase 3: move history (nested under position-name expand) */
.move-history-panel {
    margin: 0;
    max-height: 160px;
    display: flex;
    flex-direction: column;
}
.move-history-panel h4 {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    color: var(--sava-gold);
}
.move-history-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    margin: 0 0 0.4rem;
}
.move-history-step {
    width: 2rem;
    height: 1.8rem;
    padding: 0;
    border: 1px solid var(--sava-bronze);
    border-radius: 4px;
    color: var(--sava-gold);
    background: rgba(0, 0, 0, 0.28);
    cursor: pointer;
    font-size: 1.05rem;
    line-height: 1;
}
.move-history-step:hover:not(:disabled),
.move-history-step:focus-visible {
    background: rgba(212, 168, 75, 0.18);
    outline: 2px solid var(--sava-gold);
    outline-offset: 1px;
}
.move-history-step:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.move-history-review-status {
    min-width: 5rem;
    text-align: center;
    color: var(--sava-bronze-lt);
    font-size: 0.72rem;
    font-family: ui-monospace, monospace;
}
.move-history-list {
    overflow-y: auto;
    margin: 0;
    padding: 0 0 0 1.25rem;
    font-size: 0.78rem;
    line-height: 1.4;
    font-family: ui-monospace, monospace;
}
.move-history-list li.is-review-active {
    margin-left: -0.35rem;
    padding: 0.16rem 0.35rem;
    border-left: 2px solid var(--sava-gold);
    color: var(--sava-gold);
    background: rgba(212, 168, 75, 0.14);
}
body.board-review-locked .game-board {
    box-shadow: 0 0 0 2px var(--sava-gold), 0 0 22px rgba(212, 168, 75, 0.2);
}
body.board-review-locked .game-board::after {
    content: "REVIEW MODE - MOVES DISABLED";
    position: absolute;
    top: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--sava-gold);
    border-radius: 999px;
    color: var(--sava-gold);
    background: rgba(17, 13, 10, 0.9);
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    pointer-events: none;
}
.move-history-empty {
    margin: 0;
    font-size: 0.8rem;
    color: var(--sava-bronze-lt);
}
.move-history-empty[hidden] { display: none; }

/* Phase 3: invite + bot + password */
.invite-banner {
    margin: 0.5rem 0;
    padding: 0.5rem 0.65rem;
    background: rgba(212, 168, 75, 0.12);
    border: 1px solid var(--sava-gold);
    border-radius: 6px;
    font-size: 0.85rem;
}
.bot-badge {
    display: inline-block;
    margin: 0.35rem 0;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    background: rgba(70, 200, 195, 0.15);
    border: 1px solid var(--sava-blue);
    color: var(--sava-blue);
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    box-sizing: border-box;
}
/* Author display must not override the hidden attribute (was showing in real games). */
.bot-badge[hidden] { display: none !important; }
.lobby-password-overlay {
    position: fixed;
    inset: 0;
    z-index: 8500;
    background: rgba(8, 6, 12, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
}
.lobby-password-overlay[hidden] { display: none !important; }
.lobby-password-modal {
    background: var(--sava-panel, #1a1424);
    border: 1px solid var(--sava-gold);
    border-radius: 8px;
    padding: 1.25rem;
    max-width: 360px;
    width: 90%;
}
.lobby-password-modal h3 { margin: 0 0 0.75rem; color: var(--sava-gold); }
.lobby-password-modal input {
    width: 100%;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
}
.lobby-password-error {
    color: var(--sava-red);
    font-size: 0.85rem;
    min-height: 1.2rem;
}
.game-over-overlay.hard-mode-finish .game-over-content {
    border-color: #c0392b;
    box-shadow: 0 0 34px rgba(192, 57, 43, 0.42), var(--sava-shadow-panel);
}
