/* Game view — board, cards, controls, modals */
@import 'variables.css';

body.game-page {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
    background: var(--ritual-bg);
    color: var(--text-color);
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
    padding-bottom: var(--safe-bottom);
    box-sizing: border-box;
    /* Ritual room: fire or blood ambience */
    background-image: radial-gradient(ellipse 120% 100% at 50% 80%, var(--ritual-bg-radial) 0%, transparent 55%),
                      radial-gradient(ellipse 90% 70% at 50% 50%, rgba(40, 20, 15, 0.15) 0%, transparent 65%);
}

.game-nav {
    background: linear-gradient(180deg, var(--bg-elevated) 0%, rgba(10, 8, 8, 0.98) 100%);
    padding: 10px max(16px, var(--safe-left)) 10px max(16px, var(--safe-right));
    padding-top: max(10px, var(--safe-top));
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--border-color);
    flex-shrink: 0;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.game-nav .nav-right-buttons {
    margin-left: auto;
    display: flex;
    gap: inherit;
    align-items: center;
}

.game-nav .nav-left-buttons {
    display: flex;
    gap: inherit;
    align-items: center;
}

.game-nav .top-right-btn {
    position: relative;
    z-index: 100;
}

.game-nav a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.game-nav a:hover {
    color: var(--accent-color);
}

.nav-player-banner {
    flex: 1;
    text-align: center;
    font-weight: 700;
    font-size: clamp(0.85rem, 3vw, 1.1rem);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.nav-player-banner .banner-class {
    font-size: 0.9em;
    color: var(--class-color);
    font-weight: 600;
}

.top-right-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.top-right-btn:hover {
    border-color: var(--accent-color);
    background: var(--accent-glow);
    box-shadow: 0 0 12px rgba(201, 77, 40, 0.2);
}

.selection-hint {
    flex-shrink: 0;
    text-align: center;
    font-size: 0.8rem;
    color: var(--magic-color);
    padding: 4px 8px;
    min-height: 1.2em;
}

/* View switcher: neighbours only vs all (6+ players) — prominent so player can see full table */
#view-switcher-wrap {
    display: none;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    padding: 6px 12px;
    background: rgba(201, 77, 40, 0.15);
    border: 2px solid var(--accent-color);
    border-radius: var(--radius-md);
}
#view-switcher-wrap.visible {
    display: flex;
}
.view-switcher-btn {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 8px 14px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: var(--radius-sm);
    min-height: var(--touch-min);
}
.view-switcher-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
    background: rgba(201, 77, 40, 0.1);
}
.view-switcher-btn.active {
    border-color: var(--accent-color);
    color: var(--accent-color);
    background: rgba(201, 77, 40, 0.25);
}
.view-switcher-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-color);
}

.clickable-class:not(.empty) {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.clickable-class:not(.empty):hover {
    color: var(--magic-color);
}

#game-board {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: clamp(6px, 1.5vw, 10px);
    box-sizing: border-box;
    gap: 6px;
    position: relative;
}

/* 2–12 players: padding so no player card leaves the screen (top, bottom, left, right) */
#game-board:has(.ritual-table[data-player-count="2"]) {
    padding: clamp(40px, 12%, 64px);
    padding-top: clamp(48px, 14%, 72px);
    box-sizing: border-box;
}
#game-board:has(.ritual-table[data-player-count="3"]),
#game-board:has(.ritual-table[data-player-count="4"]),
#game-board:has(.ritual-table[data-player-count="5"]) {
    padding: clamp(40px, 12%, 64px);
    box-sizing: border-box;
}
#game-board:has(.ritual-table[data-player-count="6"]),
#game-board:has(.ritual-table[data-player-count="7"]),
#game-board:has(.ritual-table[data-player-count="8"]),
#game-board:has(.ritual-table[data-player-count="9"]),
#game-board:has(.ritual-table[data-player-count="10"]),
#game-board:has(.ritual-table[data-player-count="11"]),
#game-board:has(.ritual-table[data-player-count="12"]) {
    padding: clamp(48px, 14%, 72px);
    box-sizing: border-box;
}

#game-board #ritual-table { flex: 1; min-height: 0; position: relative; }
#game-board #controls-bar { flex-shrink: 0; }

/* Ritual circle — oval table, dark base, simple sigil (concentric circles, pentagram, eye, runes, rays) */
.ritual-table {
    position: relative;
    overflow: visible;
    border-radius: 50%;
    padding: 6%;
    box-sizing: border-box;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='xMidYMid slice'%3E%3Crect width='100' height='100' fill='%231a1612'/%3E%3C/svg%3E"),
        radial-gradient(ellipse 80% 70% at 50% 30%, var(--ritual-table-highlight) 0%, transparent 55%),
        radial-gradient(20% 20% at 76% 24%, var(--ritual-candle-glow) 0%, transparent 60%),
        radial-gradient(20% 20% at 94% 50%, var(--ritual-candle-glow) 0%, transparent 60%),
        radial-gradient(20% 20% at 76% 76%, var(--ritual-candle-glow) 0%, transparent 60%),
        radial-gradient(20% 20% at 50% 94%, var(--ritual-candle-glow) 0%, transparent 60%),
        radial-gradient(20% 20% at 24% 76%, var(--ritual-candle-glow) 0%, transparent 60%),
        radial-gradient(ellipse 100% 100% at 50% 50%, rgba(40,35,30,0.2) 0%, transparent 45%),
        radial-gradient(ellipse 100% 100% at 50% 42%, var(--ritual-table-light) 0%, var(--ritual-table-surface) 38%, var(--ritual-table-rim) 75%, #050403 100%);
    background-size: cover, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 100% 100%;
    background-position: center, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
    background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
    border: 3px solid var(--ritual-ring-color);
    /* 3D carved disc: rim lip highlight, deep bowl shadow, edge darkening, outer glow */
    box-shadow:
        inset 0 -4px 30px var(--ritual-table-highlight),
        inset 0 10px 50px var(--ritual-table-groove),
        inset 0 0 0 1px rgba(0,0,0,0.35),
        inset 0 0 100px rgba(0,0,0,0.25),
        inset 0 0 0 1px rgba(255,248,240,0.03),
        0 0 0 1px rgba(0,0,0,0.5),
        0 10px 50px rgba(0,0,0,0.55),
        0 0 60px var(--ritual-sigil-glow);
}

/* Outer ritual ring — flush to table edge */
.ritual-table::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 3px solid var(--ritual-ring-color);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: inset 0 0 25px rgba(0,0,0,0.3);
}

/* Inner ritual ring */
.ritual-table::after {
    content: '';
    position: absolute;
    inset: 15%;
    border: 2px solid var(--ritual-rune);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.25);
}

/* Ambient candles around the circle — positioned on the rim */
.ritual-candles {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
}

/* Thin lines connecting candle clusters (ritual light) — behind candles */
.ritual-candle-lines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}
.ritual-line {
    fill: none;
    stroke: var(--ritual-candle-glow);
    stroke-width: 0.5;
    stroke-opacity: 0.7;
    filter: drop-shadow(0 0 6px var(--ritual-candle-glow));
}

.ambient-candle {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    transform: translate(-50%, -50%);
}

/* 30 candles in 10 clusters (3 per pentagram point); cluster offset in px */
/* Cluster 1: top — remove 3 candles from top of page */

/* Cluster 2 */
.ritual-candles .ambient-candle:nth-child(4) { left: 83.2%; top: 39.1%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.08s; }
.ritual-candles .ambient-candle:nth-child(5) { left: 83.2%; top: 39.1%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.15s; }
.ritual-candles .ambient-candle:nth-child(6) { left: 83.2%; top: 39.1%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.2s; }
/* Cluster 3 */
.ritual-candles .ambient-candle:nth-child(7) { left: 70.6%; top: 78.4%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.1s; }
.ritual-candles .ambient-candle:nth-child(8) { left: 70.6%; top: 78.4%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.18s; }
.ritual-candles .ambient-candle:nth-child(9) { left: 70.6%; top: 78.4%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.22s; }
/* Cluster 4 */
.ritual-candles .ambient-candle:nth-child(10) { left: 29.4%; top: 78.4%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.12s; }
.ritual-candles .ambient-candle:nth-child(11) { left: 29.4%; top: 78.4%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.2s; }
.ritual-candles .ambient-candle:nth-child(12) { left: 29.4%; top: 78.4%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.04s; }
/* Cluster 5 (left) */
.ritual-candles .ambient-candle:nth-child(13) { left: 16.8%; top: 39.1%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.16s; }
.ritual-candles .ambient-candle:nth-child(14) { left: 16.8%; top: 39.1%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.08s; }
.ritual-candles .ambient-candle:nth-child(15) { left: 16.8%; top: 39.1%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.24s; }
/* Cluster 6 */
.ritual-candles .ambient-candle:nth-child(16) { left: 62.9%; top: 32.4%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.06s; }
.ritual-candles .ambient-candle:nth-child(17) { left: 62.9%; top: 32.4%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.14s; }
.ritual-candles .ambient-candle:nth-child(18) { left: 62.9%; top: 32.4%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.1s; }
/* Cluster 7 */
.ritual-candles .ambient-candle:nth-child(19) { left: 70.9%; top: 56.7%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.12s; }
.ritual-candles .ambient-candle:nth-child(20) { left: 70.9%; top: 56.7%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.2s; }
.ritual-candles .ambient-candle:nth-child(21) { left: 70.9%; top: 56.7%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.02s; }
/* Cluster 8 (bottom centre) — hide so candle not in front of player 1 */
.ritual-candles .ambient-candle:nth-child(22),
.ritual-candles .ambient-candle:nth-child(23),
.ritual-candles .ambient-candle:nth-child(24) { display: none; }
/* Cluster 9 */
.ritual-candles .ambient-candle:nth-child(25) { left: 29.1%; top: 56.7%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.1s; }
.ritual-candles .ambient-candle:nth-child(26) { left: 29.1%; top: 56.7%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.22s; }
.ritual-candles .ambient-candle:nth-child(27) { left: 29.1%; top: 56.7%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.08s; }
/* Cluster 10 (upper-left); candle 30 hidden via attribute selector (SVG is 1st child so nth ≠ data-candle) */
.ritual-candles .ambient-candle:nth-child(28) { left: 37.1%; top: 32.4%; transform: translate(-50%, -50%) translate(-10px, 0); animation-delay: 0.16s; }
.ritual-candles .ambient-candle:nth-child(29) { left: 37.1%; top: 32.4%; transform: translate(-50%, -50%) translate(10px, 0); animation-delay: 0.04s; }
.ritual-candles .ambient-candle:nth-child(30) { left: 37.1%; top: 32.4%; transform: translate(-50%, -50%) translate(0, 12px); animation-delay: 0.2s; }
.ritual-candles .ambient-candle[data-candle="30"] { display: none; }
.ritual-candles .ambient-candle[data-candle="1"],
.ritual-candles .ambient-candle[data-candle="2"] { display: none; }

.ambient-flame-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2px;
}

.ambient-flame {
    width: 12px;
    height: 16px;
    background: linear-gradient(180deg, var(--flame-inner) 0%, var(--flame-mid) 45%, var(--flame-outer) 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    box-shadow: 0 0 14px var(--flame-glow), 0 0 8px var(--flame-outer);
    animation: candle-flicker 2.4s ease-in-out infinite;
}

.ritual-candles .ambient-candle:nth-child(odd) .ambient-flame { animation-duration: 2.1s; animation-delay: 0.2s; }
.ritual-candles .ambient-candle:nth-child(3n) .ambient-flame { animation-duration: 2.6s; animation-delay: 0.4s; }

.ambient-wax {
    width: 16px;
    height: 32px;
    background: linear-gradient(90deg, var(--candle-wax) 0%, var(--candle-wax-shadow) 50%, var(--candle-wax) 100%);
    border: 1px solid var(--candle-wax-shadow);
    border-radius: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Flickering flame keyframes */
@keyframes candle-flicker {
    0%, 100% { transform: scale(1) translateX(0); opacity: 1; filter: brightness(1); }
    15% { transform: scale(1.05) translateX(1px); opacity: 0.95; filter: brightness(1.1); }
    30% { transform: scale(0.98) translateX(-1px); opacity: 1; filter: brightness(0.95); }
    45% { transform: scale(1.02) translateX(0.5px); opacity: 0.98; filter: brightness(1.05); }
    60% { transform: scale(0.99) translateX(-0.5px); opacity: 1; filter: brightness(0.98); }
    75% { transform: scale(1.03) translateX(0); opacity: 0.97; filter: brightness(1.08); }
}

/* Center zone: The Dark — upper centre so it doesn't cover player 1 at bottom */
.ritual-center-zone {
    position: absolute;
    left: 50%;
    top: 41%;
    transform: translate(-50%, -50%);
    width: min(22vw, 150px);
    height: min(22vw, 150px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

/* 2-player: The Dark below P2 (opponent at top), enough gap so no overlap */
.ritual-table[data-player-count="2"] .ritual-center-zone {
    left: 50%;
    top: 50%;
}

.ritual-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Discard pile: stacked face up, last card on top, in centre of dark circle */
.ritual-discard-pile {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 0;
    pointer-events: none;
    z-index: 2;
}

.ritual-discard-pile .g-card {
    width: clamp(22px, 5vw, 32px);
    height: clamp(30px, 6.5vw, 42px);
    font-size: 0.5rem;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.ritual-discard-pile .g-card .tl,
.ritual-discard-pile .g-card .br { font-size: 0.45rem; }
.ritual-discard-pile .g-card .mid { font-size: 0.6rem; }

/* Flying card animation: discard to The Dark */
.flying-discard-card {
    position: absolute;
    left: 50%;
    top: 88%;
    transform: translate(-50%, -50%);
    z-index: 150;
    pointer-events: none;
    transition: top 0.4s ease-out, left 0.4s ease-out;
}

.flying-discard-card.landed {
    top: 38%;
    left: 50%;
}
.ritual-table[data-player-count="2"] .flying-discard-card.landed {
    left: 50%;
    top: 50%;
}

/* 2-player: single shadow (no Left/Right split), contain so it doesn't leak out of the card */
.ritual-table[data-player-count="2"] .ritual-seat-you .shadow-split-wrap {
    overflow: hidden;
}
.ritual-table[data-player-count="2"] .ritual-seat-you .shadow-split-wrap .shadow-from-neighbour:last-of-type {
    display: none;
}
.ritual-table[data-player-count="2"] .ritual-seat-you .shadow-sublabel {
    display: none;
}
.ritual-table[data-player-count="2"] .ritual-seat-you .shadow-split-wrap .shadow-from-neighbour:first-of-type {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
    overflow: hidden;
}
.ritual-table[data-player-count="2"] .ritual-seat-you .shadow-split-wrap .shadow-zone {
    overflow: hidden;
}
.nb-shadow-split-wrap.shadow-single .shadow-from-neighbour {
    flex: 1 1 100%;
    min-width: 0;
    max-width: none;
}
.nb-shadow-split-wrap.shadow-single .shadow-single-zone .nb-shadow-zone {
    width: 100%;
}

.flying-discard-card .g-card {
    width: clamp(36px, 8vw, 48px);
    height: clamp(50px, 11vw, 64px);
}

/* The Dark — void pit at centre: creepy, always on top */
.dark-ritual-symbol {
    width: clamp(56px, 13vw, 88px);
    height: clamp(56px, 13vw, 88px);
    margin: 0;
    border-radius: 50%;
    background: radial-gradient(ellipse 100% 100% at 50% 50%, #080204 0%, #030102 35%, #000 70%);
    border: 4px solid rgba(60, 20, 30, 0.9);
    box-shadow:
        inset 0 0 50px rgba(0,0,0,0.98),
        inset 0 0 0 2px rgba(100, 30, 50, 0.2),
        0 0 0 1px rgba(0,0,0,0.8),
        0 0 30px var(--dark-glow),
        0 0 60px rgba(0,0,0,0.9);
    position: relative;
    flex-shrink: 0;
    animation: dark-pulse 5s ease-in-out infinite;
}
.dark-ritual-symbol::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 45%;
    height: 45%;
    border: 1px solid rgba(120, 40, 60, 0.25);
    border-radius: 50%;
    pointer-events: none;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.9);
}
.dark-ritual-symbol::after {
    content: '▼';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -48%);
    font-size: clamp(14px, 3.2vw, 24px);
    color: rgba(40, 15, 30, 0.95);
    text-shadow: 0 0 20px rgba(0,0,0,1), 0 0 8px rgba(80, 20, 40, 0.4);
    pointer-events: none;
    line-height: 1;
}
@keyframes dark-pulse {
    0%, 100% { box-shadow: inset 0 0 50px rgba(0,0,0,0.98), inset 0 0 0 2px rgba(100, 30, 50, 0.2), 0 0 0 1px rgba(0,0,0,0.8), 0 0 28px var(--dark-glow), 0 0 55px rgba(0,0,0,0.9); }
    50% { box-shadow: inset 0 0 55px rgba(0,0,0,0.99), inset 0 0 0 2px rgba(120, 40, 60, 0.3), 0 0 0 1px rgba(0,0,0,0.8), 0 0 38px var(--dark-glow), 0 0 70px rgba(0,0,0,0.95); }
}

.ritual-center-label {
    font-size: clamp(0.55rem, 1.6vw, 0.7rem);
    color: rgba(80, 50, 60, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.25em;
    font-weight: 700;
    text-shadow: 0 0 12px rgba(0,0,0,1), 0 0 4px rgba(60, 20, 40, 0.5);
}

.log-panel {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    max-width: min(220px, 35vw);
}

.log-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    min-height: var(--touch-min);
}

.log-toggle:hover {
    color: var(--text-color);
    border-color: var(--accent-color);
}

.log-panel.collapsed #game-log {
    display: none;
}

.log-panel.collapsed .log-toggle::after {
    content: ' ▶';
}

.log-panel:not(.collapsed) .log-toggle::after {
    content: ' ▼';
}

#game-board .game-log .log-seq {
    color: #666;
    font-size: 0.85em;
    margin-right: 2px;
}
#game-board .game-log {
    width: 100%;
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.7rem;
    padding: 8px;
    background: rgba(6, 5, 8, 0.92);
    border: 2px solid var(--border-color);
    color: #b8b4ac;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 16px rgba(0,0,0,0.5);
}

/* Seats: expand with content; fixed padding; contain so nothing leaks */
.ritual-seat {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: linear-gradient(180deg, rgba(22, 18, 16, 0.95) 0%, rgba(14, 12, 10, 0.98) 100%);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 6px;
    box-sizing: border-box;
    box-shadow:
        inset 0 0 20px rgba(0,0,0,0.4),
        0 0 12px rgba(201, 77, 40, 0.04);
    max-width: min(220px, 28vw);
    overflow: visible;
    margin: 4px;
}

.ritual-seat-other {
    min-width: max(144px, clamp(88px, 18vw, 150px));
    max-width: 165px;
}

.ritual-seat-you {
    min-width: max(268px, clamp(160px, 45vw, 300px));
    max-width: min(95%, calc(100% - 24px));
}


.ritual-other-seats {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.ritual-other-seats .ritual-seat {
    pointer-events: auto;
}

.ritual-seat-you {
    z-index: 5;
}

.ritual-seat-other {
    transform: translate(-50%, -50%);
}

.ritual-seat-other.targetable {
    cursor: pointer;
    border-color: var(--target-color);
    box-shadow: 0 0 16px var(--target-glow), inset 0 0 20px rgba(0,0,0,0.4);
}

/* 4+ players: full info, slightly smaller; seat still wider than shadow row (2×68+8=144) */
.ritual-seat-other.seat-many {
    min-width: 144px;
    max-width: 145px;
    padding: 5px;
}
/* 8+ players (9 total): smaller seats so they don't overlap; still wider than shadow row */
.ritual-seat-other.seat-crowded {
    min-width: calc(2 * (2 * 24px + 4px + 8px) + 8px);
    max-width: 132px;
    padding: 4px;
}
.ritual-seat-other.seat-crowded .seat-header { font-size: 0.6rem; margin-bottom: 2px; }
.ritual-seat-other.seat-crowded .seat-hand-label,
.ritual-seat-other.seat-crowded .seat-shadow-label { font-size: 0.48rem; margin-top: 2px; }
.ritual-seat-other.seat-crowded .nb-hand-zone,
.ritual-seat-other.seat-crowded .nb-shadow-zone,
.ritual-seat-other.seat-crowded .seat-shadow-zone { min-height: 28px; padding: 2px; gap: 2px; }
.ritual-seat-other.seat-crowded .g-card.small { width: 24px; height: 32px; font-size: 0.5rem; }
.ritual-seat-other.seat-crowded .candle-visual { width: 14px; height: 36px; margin: 2px auto; }
.ritual-seat-other.seat-crowded .candle-flame { width: 8px; height: 10px; }
.ritual-seat-other.seat-crowded .candle-wax { max-height: 22px; }
.ritual-seat-other.seat-crowded .nb-shadow-split-wrap .shadow-from-neighbour {
    min-width: calc(2 * 24px + 4px + 8px);
    max-width: calc(2 * 24px + 4px + 8px);
}
.ritual-seat-other.seat-crowded .nb-shadow-zone,
.ritual-seat-other.seat-crowded .seat-shadow-zone { min-width: calc(2 * 24px + 4px + 8px); }

.ritual-seat-other.seat-many .seat-header {
    margin-bottom: 3px;
    font-size: 0.7rem;
}

.ritual-seat-other.seat-many .seat-hand-label,
.ritual-seat-other.seat-many .seat-shadow-label {
    font-size: 0.55rem;
    margin-top: 3px;
}

.ritual-seat-other.seat-many .candle-visual {
    width: 18px;
    height: 44px;
    margin: 3px auto;
}

.ritual-seat-other.seat-many .candle-flame {
    width: 10px;
    height: 12px;
}

.ritual-seat-other.seat-many .candle-wax {
    max-height: 30px;
}

.ritual-seat-other.seat-many .nb-hand-zone,
.ritual-seat-other.seat-many .nb-shadow-zone,
.ritual-seat-other.seat-many .seat-shadow-zone {
    min-height: 34px;
    padding: 3px;
    gap: 3px;
}

.ritual-seat-other.seat-many .nb-hand-zone {
    min-height: 32px;
}

.ritual-seat-other.seat-many .g-card.small {
    width: 28px;
    height: 38px;
    font-size: 0.58rem;
}

.ritual-seat-other.seat-many .g-card.small .tl,
.ritual-seat-other.seat-many .g-card.small .br {
    font-size: 0.55rem;
}

.ritual-seat-other.seat-many .g-card.small .mid {
    font-size: 0.75rem;
}

.ritual-seat-you {
    bottom: 2%;
    left: 50%;
    transform: translateX(-50%);
}

.seat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-bottom: 4px;
    font-size: clamp(0.7rem, 2vw, 0.85rem);
}

/* Ritual icon on current player(s) turn — highly visible */
.ritual-seat.active-turn .seat-header::before {
    content: '✦';
    color: var(--accent-color);
    font-size: 1.35em;
    margin-right: 6px;
    text-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-glow);
    animation: ritual-pulse 1.2s ease-in-out infinite;
    display: inline-block;
    line-height: 1;
}
.ritual-seat.active-turn {
    border-color: var(--accent-color);
    border-width: 2px;
    box-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(201, 77, 40, 0.25), inset 0 0 20px rgba(0,0,0,0.4);
    outline: 1px solid rgba(201, 77, 40, 0.4);
}

/* Concurrent flame indicator (6+ players: player(s) acting at same time) */
.seat-header .concurrent-badge {
    display: inline;
    font-size: 0.75em;
    margin-left: 2px;
    font-weight: 700;
}
@keyframes ritual-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.seat-name {
    font-weight: 700;
    color: var(--text-color);
}

.seat-class {
    font-size: 0.85em;
    color: var(--class-color);
    font-weight: 600;
}

.seat-hand-label,
.seat-shadow-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-top: 4px;
}

/* Candle visual — shortens/grows with value (--candle-pct: 0–100), flickering flame */
.candle-visual {
    --candle-pct: 100;
    width: 24px;
    height: 64px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    margin: 4px auto;
}

.candle-flame {
    width: 14px;
    height: 18px;
    background: linear-gradient(180deg, var(--flame-inner) 0%, var(--flame-mid) 40%, var(--flame-outer) 100%);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    box-shadow: 0 0 14px var(--flame-glow), 0 0 8px var(--flame-outer);
    flex-shrink: 0;
    margin-bottom: 2px;
    animation: candle-flicker 2.2s ease-in-out infinite;
}

.candle-wax {
    width: 20px;
    height: calc(var(--candle-pct, 100) * 0.46px);
    min-height: 4px;
    max-height: 46px;
    background: linear-gradient(90deg, var(--candle-wax) 0%, var(--candle-wax-shadow) 50%, var(--candle-wax) 100%);
    border: 1px solid var(--candle-wax-shadow);
    border-radius: 2px;
    transition: min-height var(--transition-normal), height var(--transition-normal);
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}

.ritual-seat-you.salted {
    border-color: var(--salt-color);
    box-shadow: 0 0 12px rgba(255, 248, 225, 0.2) inset;
}

.seat-candle-wrap {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.nb-shadow-zone,
.seat-shadow-zone {
    min-height: 44px;
    min-width: calc(2 * 28px + 4px + 8px);
    border: 1px dashed var(--border-color);
    background: rgba(8, 6, 10, 0.9);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    padding: 4px;
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 12px rgba(0,0,0,0.5);
    align-content: start;
    justify-items: center;
    overflow: visible;
}

.nb-hand-zone {
    min-height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    padding: 4px;
}

/* Left and Right shadow zones: allow full ghost cards to be visible (no clipping) */
.shadow-split-wrap,
.nb-shadow-split-wrap {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    min-width: 0;
    position: relative;
    z-index: 1;
    overflow: visible;
}
/* Each shadow column (Left, Right): wide enough for 2 cards; overflow visible so full cards show */
.shadow-split-wrap .shadow-from-neighbour,
.nb-shadow-split-wrap .shadow-from-neighbour {
    flex: 1 1 0;
    min-width: calc(2 * 56px + 6px + 12px);
    max-width: calc(2 * 56px + 6px + 12px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: visible;
}
.nb-shadow-split-wrap .shadow-from-neighbour {
    min-width: calc(2 * 28px + 4px + 8px);
    max-width: none;
}


.shadow-sublabel {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* Shadow zones: always wider than 2 cards; overflow visible so full ghost cards show */
.shadow-zone {
    min-height: 56px;
    min-width: calc(2 * 56px + 6px + 12px);
    width: 100%;
    border: 1px solid var(--border-color);
    background: rgba(8, 6, 10, 0.9);
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    padding: 6px;
    border-radius: var(--radius-sm);
    align-content: start;
    justify-items: center;
    box-shadow: inset 0 0 14px rgba(0,0,0,0.5);
    overflow: visible;
}
.shadow-zone.shadow-cols-1 { grid-template-columns: 1fr; }
.shadow-zone.shadow-cols-2 { grid-template-columns: repeat(2, 1fr); }
.shadow-zone.shadow-cols-3 { grid-template-columns: repeat(3, 1fr); }
.shadow-zone.shadow-cols-auto { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }

.hand-zone {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    width: 100%;
    padding: 8px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}

/* Cards — ritual deck, candlelit */
.g-card {
    width: 56px;
    height: 80px;
    background: linear-gradient(145deg, #1e1c18 0%, #161412 100%);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
    position: relative;
    cursor: pointer;
    user-select: none;
    transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: var(--shadow-card), inset 0 0 0 1px rgba(201, 77, 40, 0.06);
}
.g-card::before {
    content: '';
    position: absolute;
    inset: 3px;
    border: 1px solid rgba(180, 160, 120, 0.12);
    border-radius: 6px;
    pointer-events: none;
}
.g-card .card-face {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
    pointer-events: none;
}
.g-card:has(.card-face) .tl,
.g-card:has(.card-face) .mid,
.g-card:has(.card-face) .br {
    display: none;
}
.g-card.card-face-failed .card-face {
    display: none;
}
.g-card.back .card-face.card-back {
    border-radius: 6px;
}

.g-card.small {
    width: 38px;
    height: 54px;
    font-size: 0.75rem;
}

.g-card:hover {
    transform: translateY(-6px);
    border-color: var(--accent-color);
    box-shadow: var(--shadow-card-hover);
    z-index: 10;
}

.g-card.selected {
    border: 2px solid var(--ice-color);
    transform: translateY(-18px);
    z-index: 20;
    box-shadow: 0 0 16px var(--ice-color);
}

.g-card.targetable {
    border: 2px dashed var(--magic-color);
    cursor: crosshair;
    animation: target-pulse 1.2s ease-in-out infinite;
}

.g-card.red {
    color: #ef5350;
}

.g-card.black {
    color: #b0b0b0;
}

.g-card.ghost {
    border-color: var(--ghost-color);
    opacity: 0.95;
    background: linear-gradient(145deg, #1c1a18 0%, #141210 100%);
    box-shadow: var(--shadow-card), 0 0 8px rgba(140, 130, 120, 0.15);
}

.g-card.wall-card {
    border-color: #3d3830;
    color: #6a6560;
    background: linear-gradient(145deg, #1a1816 0%, #12100e 100%);
}

.g-card.back {
    background: linear-gradient(145deg, #141210 0%, #0e0c0a 100%);
    background-image: repeating-linear-gradient(135deg, transparent 0px, transparent 4px, rgba(201, 77, 40, 0.06) 4px, rgba(201, 77, 40, 0.06) 8px);
    color: transparent;
}
.g-card.back::before {
    border-color: rgba(201, 77, 40, 0.15);
}

.g-card .tl {
    position: absolute;
    top: 4px;
    left: 4px;
    font-size: 0.65rem;
}
/* Class card images (character/curse selection and seat headers) */
.class-card-img {
    display: block;
    object-fit: contain;
    border-radius: 4px;
}
.class-box .class-card-img {
    width: 80px;
    height: 112px;
    margin: 0 auto 8px;
    border: 1px solid var(--border-color);
}
.class-box-text {
    text-align: center;
}
.seat-class-img {
    width: 28px;
    height: 40px;
    vertical-align: middle;
    margin-right: 4px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}
.ritual-seat-you .seat-class-img {
    width: 36px;
    height: 50px;
}

.g-card .mid {
    font-size: 1.4em;
    line-height: 1;
}

.g-card .br {
    position: absolute;
    bottom: 4px;
    right: 4px;
    font-size: 0.65rem;
    transform: rotate(180deg);
}

/* Card info (i) — cast/summon effect, non-invasive */
.g-card {
    position: relative;
}
.card-info-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    z-index: 2;
    border: 1px solid var(--border-color);
    line-height: 1;
}
.card-info-btn:hover {
    background: var(--bg-elevated);
    color: var(--accent-color);
    border-color: var(--accent-color);
}
.card-effect-tooltip {
    position: fixed;
    display: none;
    max-width: 260px;
    padding: 8px 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    z-index: 200;
    pointer-events: none;
    font-size: 0.8rem;
    line-height: 1.35;
}
.card-effect-tooltip.visible {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.card-effect-tooltip .card-effect-rank-suit {
    font-size: 1.1em;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-color);
}
.card-effect-tooltip .card-effect-rank-suit.red {
    color: #ef5350;
}
.card-effect-tooltip .card-effect-name {
    font-weight: 700;
    color: var(--accent-color);
}
.card-effect-tooltip .card-effect-text {
    color: var(--text-color);
}

/* The Dark — big preview (bottom right) */
.dark-preview {
    position: fixed;
    bottom: 70px;
    right: 16px;
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--accent-color);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 24px rgba(0,0,0,0.6);
    pointer-events: auto;
}
.dark-preview.visible {
    display: flex;
}
.dark-preview-label {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--accent-color);
}
.dark-preview-card {
    line-height: 0;
}
.dark-preview-card .g-card {
    width: clamp(80px, 12vw, 120px);
    height: clamp(114px, 17vw, 171px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.dark-preview-card .g-card .tl,
.dark-preview-card .g-card .br { font-size: 0.65rem; }
.dark-preview-card .g-card .mid { font-size: 1rem; }

@keyframes target-pulse {
    0%, 100% { border-color: var(--border-color); }
    50% { border-color: var(--magic-color); }
}

/* Controls bar — ritual altar strip, creepy */
#controls-bar {
    position: relative;
    display: flex;
    gap: clamp(6px, 1.5vw, 10px);
    justify-content: center;
    align-items: center;
    background: linear-gradient(0deg, #0a0806 0%, #080605 50%, #060404 100%);
    border-top: 3px solid var(--ritual-ring-color);
    padding: clamp(10px, 2vw, 14px);
    flex-wrap: wrap;
    min-height: var(--touch-min);
    box-shadow:
        0 -6px 30px rgba(0,0,0,0.6),
        inset 0 1px 0 rgba(120, 60, 40, 0.08);
}
#controls-bar::before {
    content: '✦';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--ritual-ring-color);
    opacity: 0.6;
    pointer-events: none;
}
#controls-bar::after {
    content: '✦';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.7rem;
    color: var(--ritual-ring-color);
    opacity: 0.6;
    pointer-events: none;
}

#controls-bar #btn-actions {
    display: none;
}

.actions-modal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 12px;
    margin: 16px 0 0;
}

.actions-modal-grid .game-btn {
    min-width: 0;
    padding: 12px 10px;
    font-size: 0.85rem;
}

@media (max-width: 640px) {
    .actions-modal-grid .game-btn {
        padding: 14px 12px;
        font-size: 0.95rem;
        min-height: 44px;
    }
}

.game-btn {
    padding: 12px 16px;
    min-height: var(--touch-min);
    min-width: max(72px, 44px);
    background: var(--accent-color);
    color: #fff;
    border: 1px solid rgba(0,0,0,0.4);
    font-size: clamp(0.75rem, 2vw, 0.85rem);
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: filter var(--transition-fast), transform 0.1s ease, box-shadow 0.15s ease;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.1), 0 2px 6px rgba(0,0,0,0.4);
}
.game-btn:hover:not(:disabled) {
    filter: brightness(1.1);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.15), 0 0 12px var(--accent-glow);
}

.game-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.game-btn:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

.game-btn.panic {
    background: var(--panic-color);
}

.game-btn.magic {
    background: var(--magic-color);
    color: #000;
}

.game-btn.seance {
    background: var(--life-color);
    color: #000;
}

.game-btn.flicker {
    background: var(--ice-color);
    color: #000;
}

.game-btn.class-ability {
    background: var(--class-color);
    color: #000;
}


/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 2, 4, 0.94);
    z-index: 2000;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: linear-gradient(180deg, var(--bg-card) 0%, #0e0c0a 100%);
    padding: 24px;
    border: 2px solid var(--accent-color);
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 92%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.6),
        0 0 0 1px rgba(201, 77, 40, 0.15),
        inset 0 0 40px rgba(0,0,0,0.3);
}

.modal-content h2 {
    margin-top: 0;
    font-family: var(--font-heading);
    font-size: 1.5rem;
}

.class-desc-modal-content .class-desc-card-img {
    display: block;
    width: 100%;
    max-width: 180px;
    height: auto;
    margin: 12px auto 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.cheatsheet-content {
    max-width: 520px;
    text-align: left;
}
.cheatsheet-content #cheatsheet-body {
    margin: 0.5em 0 1em;
    font-size: 0.88rem;
    line-height: 1.5;
}
.cheatsheet-content #cheatsheet-body .cs-section {
    margin-bottom: 1.25em;
    padding-bottom: 1em;
    border-bottom: 1px solid var(--border-color);
}
.cheatsheet-content #cheatsheet-body .cs-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}
.cheatsheet-content #cheatsheet-body .cs-section h3 {
    font-size: 1rem;
    color: var(--accent-color);
    margin: 0 0 0.4em;
    font-family: var(--font-heading);
}
.cheatsheet-content #cheatsheet-body .cs-list {
    margin: 0.3em 0;
    padding-left: 1.25em;
}
.cheatsheet-content #cheatsheet-body .cs-list li {
    margin: 0.25em 0;
}
.cheatsheet-content #cheatsheet-body .cs-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}
.cheatsheet-content #cheatsheet-body .cs-table td {
    padding: 0.35em 0.5em;
    vertical-align: top;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.cheatsheet-content #cheatsheet-body .cs-table td:first-child {
    font-weight: 700;
    color: var(--magic-color);
    width: 1.8em;
}
.cheatsheet-content #cheatsheet-body .cs-table td:nth-child(2) {
    font-weight: 600;
    width: 5em;
}
.cheatsheet-content #cheatsheet-body p {
    margin: 0.4em 0;
}
.alert-modal-content p {
    margin: 1em 0;
    line-height: 1.5;
}

body.game-page.ritual-theme-fire #theme-btn-fire,
body.game-page.ritual-theme-blood #theme-btn-blood {
    border-color: var(--accent-color);
    box-shadow: 0 0 12px var(--accent-glow);
}

.card-slot-inline {
    display: flex;
    justify-content: center;
    margin: 8px 0;
}
.card-slot-inline .g-card { margin: 0; }
.card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 14px;
}


#player-setup-list {
    max-height: 280px;
    overflow-y: auto;
    width: 100%;
    margin-bottom: 16px;
    border: 2px solid var(--ritual-ring-color);
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(10, 8, 6, 0.9);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.4);
}

.setup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    background: rgba(18, 14, 10, 0.95);
    padding: 10px 14px;
    margin-bottom: 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.setup-row .setup-name-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    box-sizing: border-box;
}

.setup-row .setup-name-input::placeholder {
    color: var(--text-muted);
}

.setup-row .setup-row-label {
    font-weight: 600;
    color: var(--text-color);
}

.type-toggle {
    cursor: pointer;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    transition: border-color 0.15s, background 0.15s;
}
.type-toggle.type-human {
    color: var(--ice-color);
    background: rgba(110, 181, 192, 0.15);
    border-color: rgba(110, 181, 192, 0.4);
}
.type-toggle.type-ai {
    color: var(--text-muted);
    background: rgba(60, 55, 50, 0.5);
    border-color: var(--border-color);
}
.type-toggle:hover {
    border-color: var(--accent-color);
    background: rgba(201, 77, 40, 0.1);
}

.setup-remove-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: rgba(80, 40, 30, 0.4);
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.setup-remove-btn:hover:not(:disabled) {
    border-color: var(--accent-color);
    background: rgba(201, 77, 40, 0.15);
    color: var(--text-color);
}
.setup-remove-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.class-choice-container {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.class-box {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 20px;
    width: 200px;
    cursor: pointer;
    text-align: center;
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.class-box:hover {
    border-color: var(--accent-color);
    background: var(--bg-elevated);
}

.class-title {
    color: var(--accent-color);
    font-weight: 700;
    display: block;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
    font-family: var(--font-heading);
}

.status-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-salt {
    background: var(--salt-color);
    color: #000;
}

#possession-warning {
    display: none;
    position: absolute;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--panic-color);
    font-weight: 700;
    background: rgba(12, 6, 8, 0.95);
    padding: 8px 16px;
    border: 2px solid var(--panic-color);
    border-radius: var(--radius-sm);
    z-index: 100;
    animation: target-pulse 1s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(199, 58, 46, 0.3), inset 0 0 20px rgba(0,0,0,0.4);
}

@media (max-width: 640px) {
    /* Mobile: show ACTIONS button, hide individual action buttons (actions open in modal) */
    #controls-bar #btn-haunt,
    #controls-bar #btn-banish,
    #controls-bar #btn-seance,
    #controls-bar #btn-cast,
    #controls-bar #btn-class,
    #controls-bar #btn-flicker,
    #controls-bar #btn-panic { display: none !important; }
    #controls-bar #btn-actions { display: block !important; }
    #controls-bar {
        padding: 8px 10px;
        gap: 8px;
        flex-wrap: nowrap;
        justify-content: center;
    }
    #controls-bar .game-btn.actions-trigger {
        padding: 10px 20px;
        font-size: 0.85rem;
        min-width: 100px;
    }
    /* P1 hand & shadow cards: slightly larger for comfortable play */
    .ritual-seat-you .hand-zone .g-card {
        width: clamp(32px, 8.5vw, 40px);
        height: clamp(44px, 11.5vw, 54px);
        font-size: 0.68rem;
    }
    .ritual-seat-you .hand-zone .g-card .tl,
    .ritual-seat-you .hand-zone .g-card .br { font-size: 0.62rem; }
    .ritual-seat-you .hand-zone .g-card .mid { font-size: 0.85rem; }
    /* P1 shadow: same size */
    .ritual-seat-you .shadow-zone .g-card {
        width: clamp(32px, 8.5vw, 40px);
        height: clamp(44px, 11.5vw, 54px);
        font-size: 0.68rem;
    }
    .ritual-seat-you .shadow-zone .g-card .tl,
    .ritual-seat-you .shadow-zone .g-card .br { font-size: 0.62rem; }
    .ritual-seat-you .shadow-zone .g-card .mid { font-size: 0.85rem; }
    /* Fallback for other .g-card (e.g. modals) */
    .g-card { width: clamp(40px, 11vw, 48px); height: clamp(56px, 15vw, 66px); font-size: 0.8rem; }
    .ritual-seat-left { left: 2%; min-width: 90px; }
    .ritual-seat-right { right: 2%; min-width: 90px; }
    .ritual-seat-you {
        bottom: 2%;
        min-width: 110px;
        max-width: 92%;
        padding: 5px;
    }
    .ritual-seat-you .seat-header { font-size: 0.75rem; }
    .ritual-seat-you .seat-hand-label,
    .ritual-seat-you .seat-shadow-label { font-size: 0.55rem; }
    .candle-visual { width: 18px; height: 48px; }
    .candle-flame { width: 10px; height: 12px; }
    .candle-wax { max-height: 32px; }
    /* Other player seats: smaller on phone so they fit; margin so cards don't overlap */
    .ritual-seat-other {
        min-width: 64px;
        max-width: 110px;
        padding: 4px;
        margin: 4px;
    }
    .ritual-seat-other .seat-header { font-size: 0.6rem; }
    .ritual-seat-other .seat-hand-label,
    .ritual-seat-other .seat-shadow-label { font-size: 0.48rem; }
    .ritual-seat-other .candle-visual {
        width: 14px;
        height: 36px;
        margin: 2px auto;
    }
    .ritual-seat-other .candle-flame { width: 8px; height: 10px; }
    .ritual-seat-other .candle-wax { max-height: 24px; }
    /* Other players' hand: card backs stay small */
    .ritual-seat-other .nb-hand-zone .g-card {
        width: 22px;
        height: 30px;
    }
    /* Other players' shadow ghosts: LARGER so readable on phone */
    .ritual-seat-other .nb-shadow-zone .g-card,
    .ritual-seat-other .seat-shadow-zone .g-card {
        width: 44px;
        height: 60px;
        font-size: 0.78rem;
    }
    .ritual-seat-other .nb-shadow-zone .g-card .tl,
    .ritual-seat-other .nb-shadow-zone .g-card .br,
    .ritual-seat-other .seat-shadow-zone .g-card .tl,
    .ritual-seat-other .seat-shadow-zone .g-card .br { font-size: 0.7rem; }
    .ritual-seat-other .nb-shadow-zone .g-card .mid,
    .ritual-seat-other .seat-shadow-zone .g-card .mid { font-size: 1.05rem; }
    .ritual-seat-other .nb-hand-zone,
    .ritual-seat-other .nb-shadow-zone,
    .ritual-seat-other .seat-shadow-zone {
        min-height: 38px;
        padding: 3px;
        gap: 3px;
    }
    /* 4+ players on phone: seat compact but ghosts still readable */
    .ritual-seat-other.seat-many {
        min-width: 62px;
        max-width: 92px;
        padding: 3px;
    }
    .ritual-seat-other.seat-many .seat-header { font-size: 0.55rem; }
    .ritual-seat-other.seat-many .candle-visual {
        width: 12px;
        height: 30px;
    }
    .ritual-seat-other.seat-many .candle-flame { width: 6px; height: 8px; }
    .ritual-seat-other.seat-many .candle-wax { max-height: 20px; }
    .ritual-seat-other.seat-many .nb-hand-zone .g-card {
        width: 20px;
        height: 26px;
    }
    .ritual-seat-other.seat-many .nb-shadow-zone .g-card,
    .ritual-seat-other.seat-many .seat-shadow-zone .g-card {
        width: 38px;
        height: 52px;
        font-size: 0.72rem;
    }
    .ritual-seat-other.seat-many .nb-shadow-zone .g-card .tl,
    .ritual-seat-other.seat-many .nb-shadow-zone .g-card .br,
    .ritual-seat-other.seat-many .seat-shadow-zone .g-card .tl,
    .ritual-seat-other.seat-many .seat-shadow-zone .g-card .br { font-size: 0.65rem; }
    .ritual-seat-other.seat-many .nb-shadow-zone .g-card .mid,
    .ritual-seat-other.seat-many .seat-shadow-zone .g-card .mid { font-size: 0.95rem; }
    .ritual-seat-other.seat-many .nb-hand-zone,
    .ritual-seat-other.seat-many .nb-shadow-zone,
    .ritual-seat-other.seat-many .seat-shadow-zone {
        min-height: 32px;
        padding: 2px;
        gap: 2px;
    }
    /* 5+ players on mobile: extra compact so no overlap in full circle */
    .ritual-seat-other.seat-mobile-many {
        min-width: 52px;
        max-width: 78px;
        padding: 2px;
    }
    .ritual-seat-other.seat-mobile-many .seat-header { font-size: 0.5rem; }
    .ritual-seat-other.seat-mobile-many .seat-hand-label,
    .ritual-seat-other.seat-mobile-many .seat-shadow-label { font-size: 0.45rem; }
    .ritual-seat-other.seat-mobile-many .candle-visual {
        width: 10px;
        height: 24px;
    }
    .ritual-seat-other.seat-mobile-many .candle-flame { width: 5px; height: 6px; }
    .ritual-seat-other.seat-mobile-many .candle-wax { max-height: 16px; }
    .ritual-seat-other.seat-mobile-many .nb-hand-zone .g-card {
        width: 18px;
        height: 24px;
    }
    .ritual-seat-other.seat-mobile-many .nb-shadow-zone .g-card,
    .ritual-seat-other.seat-mobile-many .seat-shadow-zone .g-card {
        width: 30px;
        height: 42px;
        font-size: 0.62rem;
    }
    .ritual-seat-other.seat-mobile-many .nb-shadow-zone .g-card .mid,
    .ritual-seat-other.seat-mobile-many .seat-shadow-zone .g-card .mid { font-size: 0.82rem; }
    .ritual-seat-other.seat-mobile-many .nb-hand-zone,
    .ritual-seat-other.seat-mobile-many .nb-shadow-zone,
    .ritual-seat-other.seat-mobile-many .seat-shadow-zone {
        min-height: 26px;
        padding: 2px;
        gap: 2px;
    }
    /* Nav: smaller so it doesn't overflow */
    .nav-player-banner { font-size: 0.75rem; gap: 4px; }
    .game-nav { padding: 8px 10px; gap: 8px; }
    .top-right-btn { padding: 6px 10px; font-size: 0.7rem; }
    #game-board { padding: 4px; gap: 4px; }
    /* 3–4 player mobile: keep same padding all sides so no card leaves screen */
    #game-board:has(.ritual-table[data-player-count="3"]),
    #game-board:has(.ritual-table[data-player-count="4"]) {
        padding: clamp(36px, 12%, 56px);
        box-sizing: border-box;
    }
    .selection-hint { font-size: 0.7rem; padding: 2px 6px; }
    #game-board .game-log { max-height: 90px; font-size: 0.65rem; }
    .log-panel { max-width: min(200px, 45vw); }
}

@media (min-width: 641px) and (max-width: 900px) {
    .g-card { width: 52px; height: 72px; }
    .game-btn { min-width: 68px; }
}
