:root {
    --felt-deep: #0d3d28;
    --felt-mid: #164d33;
    --felt-edge: #06291b;
    --gold: #d4af37;
    --gold-soft: #f0d879;
    --ivory: #f4ede0;
    --ash: #9ca69c;
    --danger: #d03030;
    --danger-dim: #7a1a1a;
    --accent-cyan: #66ccff;
    --accent-green: #9cff57;
    --accent-ember: #ff7d57;
}
* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    background: radial-gradient(ellipse at center, var(--felt-mid) 0%, var(--felt-deep) 55%, var(--felt-edge) 100%);
    color: var(--ivory);
    height: 100vh;
    overflow: hidden;
    display: flex;
}

/* ===== layout ===== */
#game-container {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
}

#cards-section {
    padding: 14px 20px 80px 20px;
    overflow-y: auto;
    position: relative;
    height: 100%;
}
#cards-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg, rgba(0,0,0,0.04) 0 2px, transparent 2px 6px);
    pointer-events: none;
}

#counter-section {
    padding: 14px 12px;
    border-left: 1px solid rgba(212,175,55,0.15);
    background: linear-gradient(180deg, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.55) 100%);
    overflow-y: auto;
    transition: opacity 0.2s;
}
body.counter-open #counter-section { }

/* ===== log modal ===== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal.hidden { display: none; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.72);
    backdrop-filter: blur(3px);
}
.modal-panel {
    position: relative;
    width: min(640px, 92vw);
    max-height: 80vh;
    background: linear-gradient(180deg, rgba(20,30,24,0.96), rgba(8,14,10,0.98));
    border: 1px solid rgba(212,175,55,0.35);
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 0 1px rgba(0,0,0,0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(212,175,55,0.2);
}
.modal-head h2 {
    margin: 0;
    color: var(--gold);
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    letter-spacing: 3px;
    text-transform: uppercase;
}
.modal-close {
    background: transparent;
    border: 1px solid rgba(212,175,55,0.3);
    color: var(--gold);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 13px;
    cursor: pointer;
}
.modal-close:hover { background: rgba(212,175,55,0.18); }
#log-modal #log-container {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}

/* ===== exposed cards modal ===== */
#exposed-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}

/* ===== settings modal ===== */
#settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
}

#burn-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px;
}
.burn-target {
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid rgba(212,175,55,0.22);
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(32,46,36,0.85) 0%, rgba(10,18,12,0.92) 100%);
    box-shadow: inset 0 0 24px rgba(0,0,0,0.45), 0 2px 6px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.burn-target:last-child { margin-bottom: 4px; }
.burn-target-head {
    display: flex;
    gap: 12px;
    align-items: center;
}
.burn-target-portrait {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    border: 2px solid rgba(212,175,55,0.45);
    box-shadow: 0 0 14px rgba(212,175,55,0.35), 0 3px 10px rgba(0,0,0,0.5);
    flex-shrink: 0;
    background: radial-gradient(circle at 40% 30%, rgba(50,68,54,0.9), rgba(10,16,10,1));
}
.burn-target-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.burn-target-name {
    font-family: 'Playfair Display', serif;
    font-size: 16px;
    color: var(--gold-soft);
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1;
}
.burn-target-bullets {
    display: flex;
    align-items: center;
    gap: 4px;
}
.burn-chip {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #333, #0a0a0a);
    border: 1px solid rgba(255,255,255,0.15);
    display: inline-block;
}
.burn-chip.loaded {
    background: radial-gradient(circle at 35% 30%, #ff6b6b 0%, #c41212 50%, #6a0404 100%);
    box-shadow: 0 0 6px rgba(208,48,48,0.7);
    border-color: rgba(208,48,48,0.6);
}
.burn-chip-count {
    font-size: 10px;
    color: var(--ash);
    letter-spacing: 1px;
    margin-left: 4px;
}
.burn-target-hint {
    font-size: 10px;
    color: rgba(156,166,156,0.75);
    letter-spacing: 1px;
    text-transform: uppercase;
}
.burn-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.35);
    border-radius: 6px;
    border: 1px dashed rgba(255,255,255,0.06);
    justify-content: flex-start;
}
.burn-card-opt {
    cursor: pointer;
    border-radius: 5px;
    transition: transform 0.15s, box-shadow 0.15s;
}
.burn-card-opt:hover {
    transform: translateY(-4px) scale(1.06);
    box-shadow: 0 4px 12px rgba(208,48,48,0.6), 0 0 0 2px var(--danger);
}
.setting-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(212,175,55,0.12);
}
.setting-row:last-child { border-bottom: none; }
.setting-title {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    color: var(--gold);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.setting-desc {
    font-size: 12px;
    color: var(--ash);
    line-height: 1.5;
    margin-bottom: 4px;
}
.setting-desc strong { color: var(--gold-soft); }
.setting-control {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.toggle-option {
    flex: 1 1 auto;
    min-width: 100px;
    padding: 10px 16px;
    background: linear-gradient(180deg, #1a1a1a, #0a0a0a);
    border: 1px solid rgba(212,175,55,0.35);
    color: var(--ivory);
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
}
.toggle-option:hover { border-color: var(--gold); color: var(--gold); }
.toggle-option.active {
    background: linear-gradient(180deg, var(--gold), #a88420);
    color: #0a0a0a;
    border-color: var(--gold);
    box-shadow: 0 0 14px rgba(212,175,55,0.45);
}
.exposed-summary {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(212,175,55,0.18);
}
.exposed-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.exposed-stat-num {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    color: var(--gold-soft);
    line-height: 1;
}
.exposed-stat-lbl {
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--ash);
    text-transform: uppercase;
    margin-top: 4px;
    text-align: center;
    line-height: 1.3;
}
.exposed-stat-lbl small {
    display: block;
    font-size: 7px;
    letter-spacing: 1px;
    opacity: 0.7;
    text-transform: none;
    margin-top: 1px;
}
.exposed-source-breakdown {
    display: flex;
    justify-content: space-around;
    padding: 6px 0 14px 0;
    border-bottom: 1px solid rgba(212,175,55,0.12);
    margin-bottom: 12px;
    font-size: 10px;
    color: var(--ash);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.exposed-source-breakdown span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.exposed-suit-row {
    margin-bottom: 10px;
}
.exposed-suit-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
    padding-left: 2px;
}
.exposed-suit-symbol {
    font-size: 20px;
    font-family: 'Playfair Display', serif;
    line-height: 1;
}
.exposed-suit-symbol.red { color: #ff6b6b; }
.exposed-suit-symbol.black { color: var(--ivory); }
.exposed-suit-count {
    font-size: 10px;
    color: var(--ash);
    letter-spacing: 1.5px;
    font-family: 'Playfair Display', serif;
}

.card-placeholder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 60px;
    margin: 1px;
    border: 1px dashed rgba(255,255,255,0.18);
    border-radius: 4px;
    background: rgba(255,255,255,0.02);
    color: rgba(255,255,255,0.22);
    font-family: 'Playfair Display', serif;
    font-size: 12px;
    font-weight: 700;
}
.card-placeholder.joker { color: rgba(212,175,55,0.25); }
.exposed-item-missing { opacity: 0.85; }

/* Source color-coding on exposed cards: thick top + bottom bars so the color
   stays visible even when cards overlap horizontally in the stack. */
.exposed-item { position: relative; }
.exposed-item .card {
    border-width: 0;
    /* no default source border — the .exposed-item-* variants set it */
}
.exposed-item-bar .card {
    box-shadow:
        0 -4px 0 var(--gold),
        0 4px 0 var(--gold),
        0 2px 4px rgba(0,0,0,0.5),
        0 0 0 1px rgba(0,0,0,0.35);
}
.exposed-item-you .card {
    box-shadow:
        0 -4px 0 var(--accent-green),
        0 4px 0 var(--accent-green),
        0 2px 4px rgba(0,0,0,0.5),
        0 0 0 1px rgba(0,0,0,0.35);
}
.exposed-item-revealed .card {
    box-shadow:
        0 -4px 0 var(--accent-cyan),
        0 4px 0 var(--accent-cyan),
        0 2px 4px rgba(0,0,0,0.5),
        0 0 0 1px rgba(0,0,0,0.35);
}
.exposed-item-dead .card {
    box-shadow:
        0 -4px 0 var(--danger),
        0 4px 0 var(--danger),
        0 2px 4px rgba(0,0,0,0.5),
        0 0 0 1px rgba(0,0,0,0.35);
}
/* Small corner chip so color is visible even at full-overlap in the stack */
.exposed-item::before {
    content: '';
    position: absolute;
    top: -5px;
    right: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    z-index: 2;
    border: 1px solid rgba(0,0,0,0.7);
    display: none;
}
.exposed-item-bar::before     { background: var(--gold);          display: block; }
.exposed-item-you::before     { background: var(--accent-green);  display: block; }
.exposed-item-revealed::before { background: var(--accent-cyan);  display: block; }
.exposed-item-dead::before    { background: var(--danger);        display: block; }
.exposed-items {
    display: flex;
    flex-wrap: wrap;
    padding-left: 22px;
    row-gap: 20px;
}
.exposed-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: -22px;
    transition: transform 0.15s, margin 0.15s;
    position: relative;
}
.exposed-item:hover {
    z-index: 10;
    transform: translateY(-4px);
    margin-right: 18px;
}
.exposed-item .card,
.exposed-item .card-back {
    margin: 0;
}
.exposed-owner-group {
    margin: 6px 0 10px 0;
}
.exposed-owner-label {
    font-size: 10px;
    letter-spacing: 1.5px;
    color: var(--ivory);
    text-transform: uppercase;
    margin-bottom: 4px;
    opacity: 0.85;
}
.exposed-owner-count {
    color: var(--ash);
    font-size: 9px;
    margin-left: 4px;
}
.exposed-bar { border-left: 2px solid var(--gold); padding-left: 8px; }
.exposed-you { border-left: 2px solid var(--accent-green); padding-left: 8px; }
.exposed-revealed { border-left: 2px solid var(--accent-cyan); padding-left: 8px; }
.exposed-dead { border-left: 2px solid var(--danger-dim); padding-left: 8px; }
.exposed-empty {
    text-align: center;
    color: var(--ash);
    font-size: 12px;
    padding: 20px;
}

/* ===== sudden death banner ===== */
.sudden-death-banner {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-family: 'Playfair Display', serif;
    font-weight: 900;
    font-size: clamp(32px, 9vw, 72px);
    letter-spacing: clamp(3px, 1.6vw, 12px);
    color: var(--danger);
    text-shadow:
        0 0 18px rgba(208, 48, 48, 0.8),
        0 0 40px rgba(208, 48, 48, 0.5),
        0 2px 0 rgba(0,0,0,0.8);
    pointer-events: none;
    z-index: 900;
    text-align: center;
    white-space: nowrap;
    max-width: 95vw;
    line-height: 1;
}
@media (max-width: 480px) {
    .sudden-death-banner {
        white-space: normal;
        line-height: 1.05;
        letter-spacing: 4px;
    }
}
.death-screen-tint {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(208,30,30,0.55) 0%, rgba(120,10,10,0.35) 60%, rgba(80,0,0,0.15) 100%);
    pointer-events: none;
    z-index: 726;
}

/* ===== headers ===== */
h1 {
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 900;
    font-size: clamp(22px, 5vw, 38px);
    letter-spacing: clamp(2px, 0.7vw, 5px);
    color: var(--gold);
    text-align: center;
    margin: 4px auto 2px auto;
    padding: 0 160px;
    max-width: 100%;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6), 0 0 24px rgba(212,175,55,0.18);
}
@media (max-width: 600px) {
    #top-toolbar h1 {
        font-size: 16px;
        letter-spacing: 2px;
    }
    #settings-btn, #log-toggle, #exposed-toggle, #rules-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}
h1::after {
    content: '';
    display: block;
    width: 120px;
    height: 2px;
    margin: 6px auto 0;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
h2, h3 {
    text-align: center;
    color: var(--gold-soft);
    letter-spacing: 2px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    margin: 8px 0;
}

/* ===== setup ===== */
#setup {
    text-align: center;
    margin: 16px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: center;
}
#setup.hidden { display: none; }
#setup h2 { width: 100%; margin: 4px 0; }
#setup > div { width: 100%; }
@media (max-width: 520px) {
    #setup { padding: 0 8px; flex-direction: column; gap: 4px; }
    #setup label, #setup select, #setup button, #actions button {
        padding: 9px 12px;
        font-size: 12px;
        letter-spacing: 1px;
        margin: 2px;
    }
    #setup select { width: 80%; max-width: 260px; }
    #setup button { width: 80%; max-width: 260px; min-width: 0; }
    #setup > div { display: flex; justify-content: center; width: 100%; }
    #actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; padding: 0 4px; }
    #actions button { flex: 1 1 auto; min-width: 58px; }
}

#lobby {
    margin: 16px auto;
    max-width: 540px;
    padding: 20px 22px;
    border: 1px solid rgba(212,175,55,0.35);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(0,0,0,0.35));
    text-align: center;
}
#lobby.hidden { display: none; }
#lobby h2 {
    margin: 0 0 14px 0;
    letter-spacing: 3px;
    color: var(--gold);
    font-size: 14px;
}
#lobby-code-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 12px;
    margin-bottom: 10px;
}
.lobby-label {
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ash);
}
#lobby-code {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    letter-spacing: 6px;
    color: var(--gold);
}
#lobby-invite-row {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}
#lobby-invite {
    flex: 1;
    padding: 7px 10px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(212,175,55,0.3);
    color: var(--ivory);
    border-radius: 4px;
    font-family: 'Inter', monospace;
    font-size: 11px;
    letter-spacing: 0.5px;
}
#lobby-copy {
    padding: 7px 14px;
    background: linear-gradient(180deg, #1a1a1a, #0a0a0a);
    border: 1px solid var(--gold);
    color: var(--gold);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
#lobby-copy:hover { background: linear-gradient(180deg, var(--gold), #a88420); color: #0a0a0a; }
#lobby-players {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 14px 0;
}
.lobby-player {
    padding: 5px 10px;
    border-radius: 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 12px;
    color: var(--ivory);
}
.lobby-player.you { background: rgba(212,175,55,0.15); border-color: var(--gold); color: var(--gold); }
.lobby-player.host::before { content: '★ '; color: var(--gold); }
#lobby-host-controls {
    margin: 12px 0;
    padding: 10px 0;
    border-top: 1px solid rgba(212,175,55,0.12);
    border-bottom: 1px solid rgba(212,175,55,0.12);
}
#lobby-host-controls.hidden { display: none; }
#lobby-leave {
    margin-top: 10px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid rgba(208,48,48,0.4);
    color: var(--danger);
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}
#lobby-leave:hover { background: rgba(208,48,48,0.15); }
#setup select, #setup button, #actions button {
    padding: 10px 20px;
    margin: 4px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    border: 1px solid var(--gold);
    border-radius: 3px;
    cursor: pointer;
    background: linear-gradient(180deg, #1a1a1a 0%, #0a0a0a 100%);
    color: var(--gold);
    transition: all 0.2s;
    font-family: inherit;
}
#setup select { background: #0a0a0a; color: var(--ivory); }
#setup button:hover, #actions button:hover:not(:disabled) {
    background: linear-gradient(180deg, var(--gold) 0%, #a88420 100%);
    color: #0a0a0a;
    box-shadow: 0 0 12px rgba(212,175,55,0.4);
}
#actions button:disabled { opacity: 0.35; cursor: not-allowed; }
#actions { text-align: center; margin: 12px 0; display: none; }

/* Draw button when the deck is empty — flashes red to warn that pulling
   triggers sudden death instead of a normal draw. */
#actions button#draw-cards.death-warning {
    background: linear-gradient(180deg, var(--danger), #6a0a0a) !important;
    color: var(--ivory) !important;
    border-color: var(--danger) !important;
    animation: deathPulse 1.4s ease-in-out infinite;
    letter-spacing: 3px !important;
    font-weight: 800 !important;
}
@keyframes deathPulse {
    0%, 100% { box-shadow: 0 0 6px rgba(208,48,48,0.5); }
    50%      { box-shadow: 0 0 24px rgba(208,48,48,0.9); }
}

/* Top toolbar — plain static header at the top of the scroll container.
   Scrolls away with the rest of the content; only #bar is sticky. */
#top-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 4px 8px 4px;
}
#top-toolbar h1 {
    margin: 0;
    padding: 0;
    flex: 1;
    text-align: left;
    font-size: clamp(18px, 3.2vw, 28px);
    letter-spacing: clamp(2px, 0.5vw, 4px);
}
.toolbar-icons {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
#settings-btn, #log-toggle, #exposed-toggle, #rules-btn {
    position: static;
    background: rgba(0,0,0,0.55);
    border: 1px solid rgba(212,175,55,0.35);
    color: var(--gold);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    flex-shrink: 0;
}
#mute-btn:hover, #log-toggle:hover, #exposed-toggle:hover, #rules-btn:hover {
    background: rgba(212,175,55,0.22);
    border-color: var(--gold);
}
#log-toggle.has-new { animation: log-pulse 1.2s ease-in-out infinite; border-color: var(--gold); }
@keyframes log-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(212,175,55,0); }
    50% { box-shadow: 0 0 12px rgba(212,175,55,0.6); }
}

/* ===== bar ===== */
/* The bar is in-game chrome — it should never be visible on the homepage
   before a match starts. body.game-active is added by rules.js::startGame
   for both classic and story modes. !important wins over the story-mode
   display:flex override that lives in campaign-board.css. */
body:not(.game-active) #bar { display: none !important; }
#bar {
    position: sticky;
    top: 0;
    z-index: 30;
    border: 1px solid rgba(212,175,55,0.4);
    padding: 12px;
    margin-bottom: 14px;
    min-height: 130px;
    background:
        radial-gradient(ellipse at center, rgba(26,77,51,0.96) 0%, rgba(10,41,27,0.98) 100%),
        rgba(8,24,15,1);
    border-radius: 10px;
    text-align: center;
    box-shadow: inset 0 0 30px rgba(0,0,0,0.5), 0 6px 14px rgba(0,0,0,0.55);
    backdrop-filter: blur(6px);
}
#bar-total {
    font-family: 'Playfair Display', serif;
    font-size: 28px;
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 2px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    margin-bottom: 8px;
}
.bar-total-prev {
    font-size: 11px;
    color: var(--ash);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: 2px;
    opacity: 0.85;
}
.bar-total-prev::before {
    content: '↩ ';
    color: var(--gold);
    opacity: 0.7;
}
#bar-cards {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 0;
    min-height: 60px;
    align-items: center;
    padding-left: 44px; /* matches the overlap offset below so the first card isn't clipped */
    overflow-x: auto;
}
#bar-cards > .card,
#bar-cards > .card-back {
    margin-left: -44px;
    flex-shrink: 0;
}
#deck-count {
    font-size: 10px;
    color: var(--ash);
    letter-spacing: 2px;
    margin-top: 8px;
    text-transform: uppercase;
}

/* ===== players ===== */
#players { display: flex; flex-direction: column; gap: 10px; }
.you-row { position: relative; }
.you-row::after {
    content: '— clockwise ↓↑ clockwise —';
    display: block;
    text-align: center;
    font-size: 9px;
    letter-spacing: 3px;
    color: var(--ash-dim);
    text-transform: uppercase;
    margin-top: 8px;
}
.table-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.table-col { display: flex; flex-direction: column; gap: 10px; }
.table-stack { display: flex; flex-direction: column; gap: 6px; }

.player {
    border: 1px solid rgba(255,255,255,0.08);
    padding: 8px 12px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04) 0%, rgba(0,0,0,0.2) 100%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

/* Character portrait — bottom-right anchored, sitting behind the cards so the
   upper-body of the illustration peeks up from the bottom-right corner. Cards
   and stats remain on top via z-index. */
.player-portrait {
    position: absolute;
    right: 0;
    bottom: 0;
    height: 160%;
    width: auto;
    max-width: 40%;
    object-fit: contain;
    object-position: bottom right;
    opacity: 0.55;
    pointer-events: none;
    z-index: 0;
    filter: drop-shadow(-4px -2px 8px rgba(0,0,0,0.6));
    /* Fade the portrait out toward the left so it blends into the row. */
    mask-image: linear-gradient(90deg, transparent 0%, black 45%, black 100%);
    -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 45%, black 100%);
}
.player.dead .player-portrait {
    filter: grayscale(1);
    opacity: 0.25;
}

/* Name caption sits under the portrait in the bottom-right corner, inside the
   player box. Kept above the portrait image via z-index so the text stays
   readable against the illustration. */
.player-portrait-name {
    position: absolute;
    right: 8px;
    bottom: 4px;
    z-index: 2;
    font-family: 'Playfair Display', serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--gold-soft);
    text-shadow: 0 1px 3px rgba(0,0,0,0.9), 0 0 6px rgba(0,0,0,0.7);
    pointer-events: none;
    max-width: 38%;
    text-align: right;
    line-height: 1;
}
.player.dead .player-portrait-name {
    color: var(--ash);
    opacity: 0.5;
}

/* ===== character picker (settings modal) ===== */
/* The picker wraps everything: current-pick preview, search + gender
   filters, then the tile grid. Large pool (36+ characters) makes filtering
   important; tiles are smaller and lazy-loaded. */
#character-picker {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.charpicker-current {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(36,50,38,0.85), rgba(10,18,12,0.92));
    border: 1px solid rgba(212,175,55,0.3);
    box-shadow: inset 0 0 16px rgba(0,0,0,0.45);
}
.charpicker-current img,
.charpicker-current-random {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    object-fit: contain;
    object-position: center;
    border: 2px solid var(--gold);
    box-shadow: 0 0 14px rgba(212,175,55,0.4);
    flex-shrink: 0;
    background: radial-gradient(circle at 40% 30%, rgba(50,68,54,0.9), rgba(10,16,10,1));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
}
.charpicker-current-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.charpicker-current-label {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--ash);
    text-transform: uppercase;
}
.charpicker-current-name {
    font-family: 'Playfair Display', serif;
    font-size: 17px;
    color: var(--gold);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    line-height: 1;
}
.charpicker-current-sub {
    font-size: 11px;
    color: var(--ash);
    letter-spacing: 1px;
}
.charpicker-clear,
.charpicker-change {
    background: transparent;
    border: 1px solid rgba(212,175,55,0.4);
    color: var(--gold-soft);
    font-family: inherit;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.charpicker-clear:hover,
.charpicker-change:hover {
    background: rgba(212,175,55,0.12);
    color: var(--ivory);
}
.charpicker-change {
    background: linear-gradient(180deg, rgba(212,175,55,0.22), rgba(136,108,24,0.35));
    border-color: var(--gold);
    color: var(--gold-soft);
}
.charpicker-preview-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
/* The character picker sub-modal uses a wider panel so the grid can breathe.
   Elevated z-index so it layers above the settings modal when opened from
   the preview's "Change" button. */
#character-modal { z-index: 850; }
.modal-panel-wide {
    width: min(880px, 96vw) !important;
    max-height: 92vh !important;
}
#character-picker-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px 18px 20px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
#character-picker-body .character-grid {
    max-height: none; /* unclamped inside its own modal */
    overflow-y: visible;
}
.charpicker-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.charpicker-search-wrap { display: flex; }
.charpicker-search {
    flex: 1;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(212,175,55,0.25);
    color: var(--ivory);
    font-family: inherit;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
}
.charpicker-search:focus { border-color: var(--gold); }
.charpicker-search::placeholder { color: var(--ash); }
.charpicker-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.charpicker-filter {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(156,166,156,0.25);
    color: var(--ash);
    font-family: inherit;
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 12px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s;
}
.charpicker-filter:hover { color: var(--ivory); border-color: var(--ivory); }
.charpicker-filter.active {
    background: linear-gradient(180deg, rgba(212,175,55,0.22), rgba(136,108,24,0.3));
    border-color: var(--gold);
    color: var(--gold-soft);
}
.charpicker-empty {
    padding: 20px 8px;
    text-align: center;
    color: var(--ash);
    font-size: 12px;
    letter-spacing: 1px;
    font-style: italic;
}
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    max-height: 460px;
    overflow-y: auto;
    padding: 2px;
}
.char-tile {
    position: relative;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(212,175,55,0.25);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
    color: var(--ivory);
    font-family: inherit;
    /* Let content (wrapper div + name) determine the tile's height. */
}
.char-tile .char-tile-img {
    aspect-ratio: 1 / 1;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
    background: radial-gradient(circle at 40% 35%, rgba(140,160,130,0.35), rgba(60,86,72,0.55));
    display: block;
}
.char-tile .char-tile-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}
.char-tile .char-random {
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: linear-gradient(135deg, rgba(212,175,55,0.15), rgba(0,0,0,0.35));
    border-radius: 4px;
}
.char-tile .char-name {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-align: center;
    color: var(--ash);
    line-height: 1.1;
}
.char-tile:hover {
    transform: translateY(-2px);
    border-color: var(--gold);
    box-shadow: 0 4px 14px rgba(0,0,0,0.4);
}
.char-tile.selected {
    border-color: var(--gold);
    box-shadow: 0 0 0 2px var(--gold), 0 0 18px rgba(212,175,55,0.45);
}
.char-tile.selected .char-name {
    color: var(--gold);
}
.player > .player-stats,
.player > .player-hand,
.player > .player-settled {
    position: relative;
    z-index: 1;
}
.player.current-player {
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(212,175,55,0.35), inset 0 0 20px rgba(212,175,55,0.08);
}
.player.dead {
    opacity: 0.35;
    filter: grayscale(0.8);
}

.player-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.stats-identity {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}
.stats-meters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.player-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--ivory);
    letter-spacing: 0.5px;
}
.player-name.you { color: var(--gold); font-size: 16px; }
.star { color: var(--gold); }
.tag-dead {
    font-size: 10px;
    color: var(--danger);
    letter-spacing: 1.5px;
    padding: 1px 4px;
    border: 1px solid var(--danger-dim);
    border-radius: 2px;
    margin-left: 4px;
}
.player-persona {
    display: inline-block;
    font-size: 9px;
    color: var(--ash);
    letter-spacing: 1.8px;
    text-transform: uppercase;
    padding: 1px 6px;
    border: 1px solid rgba(156,166,156,0.3);
    border-radius: 10px;
}
.player-total {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    color: var(--gold-soft);
    font-weight: 600;
    line-height: 1;
}
.total-unknown {
    color: var(--ash);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    letter-spacing: 1px;
    font-weight: 500;
}
.player-claim {
    font-size: 10px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 3px;
    background: rgba(0,0,0,0.3);
}
.claim-par { color: var(--accent-cyan); }
.claim-low { color: var(--accent-green); }

.player-settled, .player-hand {
    padding: 10px 14px;
    min-height: 128px;
    border-radius: 6px;
    background: rgba(0,0,0,0.25);
    border: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    gap: 14px;
}
.slot-label {
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ash);
    min-width: 82px;
    text-align: left;
    flex-shrink: 0;
}
.slot-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
    min-height: 106px;
    align-items: center;
}
@media (max-width: 720px) {
    /* Mobile keeps desktop-sized cards (68×100). To save horizontal space we
       overlap them heavily inside the slot, but the slot itself grows tall
       enough to contain them comfortably. */
    .slot-cards {
        gap: 0;
        padding-left: 44px;
        flex-wrap: nowrap;
        overflow: visible;
    }
    .slot-cards > .card,
    .slot-cards > .card-back,
    .slot-cards > .card-exposed,
    .slot-cards > .card-secret,
    .slot-cards > .clickable-joker {
        margin-left: -44px;
        flex-shrink: 0;
    }
    .exposed-items { padding-left: 44px; }
    .exposed-items > .exposed-item { margin-left: -44px; }
    /* Slot dimensions: card is 100 tall + 3px margin = 106 visual. slot-cards
       gets 112 (6px buffer). player-settled/player-hand add 4px padding + a
       small buffer → 124 so the card plus its 🔒 lock overlay can't clip
       into neighboring rows. */
    .player-settled, .player-hand {
        height: 124px;
        min-height: 124px;
        padding: 6px 8px;
        gap: 10px;
        box-sizing: border-box;
        overflow: visible;
    }
    .slot-cards {
        height: 112px;
        min-height: 112px;
        overflow: visible;
    }
    .slot-label { min-width: 60px; font-size: 9px; letter-spacing: 1px; }
    .player { padding: 6px 10px; gap: 4px; }
    .player-name { font-size: 12px; letter-spacing: 0.3px; }
    .player-name.you { font-size: 13px; }
    .player-total { font-size: 21px; }
    .total-unknown { font-size: 20px; letter-spacing: 2px; }
    .player-claim { font-size: 9px; }
    .revolver { padding: 2px 5px; gap: 1px; }
    .chamber { width: 7px; height: 7px; }
    .revolver-count { font-size: 8px; margin-left: 3px; }
    .stats-meters { gap: 6px; }
    .stats-identity { gap: 6px; }
    .you-row::after { content: '↓ accuse target ↓   (reverse turn order)'; font-size: 8px; letter-spacing: 1.5px; }
}

/* ===== revolver chamber ===== */
.revolver {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px 6px;
    background: linear-gradient(180deg, #2a2a2a, #111);
    border: 1px solid #333;
    border-radius: 10px;
    margin-top: 2px;
    width: fit-content;
}
.chamber {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #444, #0a0a0a);
    border: 1px solid #000;
    box-shadow: inset 0 0 2px #000;
    transition: background 0.3s;
}
.chamber.loaded {
    background: radial-gradient(circle at 35% 30%, #ff6b6b 0%, #c41212 50%, #6a0404 100%);
    box-shadow: 0 0 4px rgba(255,0,0,0.5), inset 0 0 2px #000;
}
.revolver-count {
    color: var(--danger);
    font-size: 9px;
    letter-spacing: 1px;
    margin-left: 4px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}

/* ===== playing cards ===== */
.card {
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 5px;
    margin: 3px;
    width: 68px;
    height: 100px;
    border-radius: 6px;
    background: linear-gradient(180deg, #fefefe 0%, #e9e5d8 100%);
    color: #1a1a1a;
    font-family: 'Playfair Display', 'Georgia', serif;
    font-weight: 700;
    text-align: left;
    position: relative;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.35);
    user-select: none;
    transition: transform 0.18s;
    overflow: hidden;
}
.card:hover { transform: translateY(-2px); }
.card.red { color: #c41212; }
.card.black { color: #0a0a0a; }
.card-rank {
    line-height: 0.95;
    font-size: 17px;
    font-weight: 800;
}
.card-suit-big {
    font-size: 32px;
    text-align: center;
    line-height: 1;
    align-self: center;
    margin: 0;
}
.card-corner-bottom {
    transform: rotate(180deg);
    align-self: flex-end;
    font-size: 15px;
    line-height: 0.95;
    font-weight: 800;
}
.card.ghost { opacity: 0.3; }
.card.joker {
    background: linear-gradient(145deg, #f8d75c 0%, #d4af37 50%, #a88420 100%);
    color: #3a2100;
}
.card.joker .card-rank { font-size: 14px; }
.card.joker .card-suit-big { font-size: 30px; color: #3a2100; }

/* Visibility indicator on your own cards: 🔒 lock only on hidden cards.
   Revealed cards show no icon — they just look normal. */
.card-exposed, .card-secret {
    display: inline-block;
    position: relative;
}
.card-secret::after {
    content: '🔒';
    position: absolute;
    bottom: -4px;
    left: -4px;
    font-size: 11px;
    line-height: 1;
    z-index: 3;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px #000);
}

/* Clickable joker affordance — the user can tap their Joker to burn it. */
.clickable-joker {
    display: inline-block;
    position: relative;
    cursor: pointer;
    border-radius: 6px;
    transition: transform 0.15s;
    animation: joker-pulse 2s ease-in-out infinite;
}
.clickable-joker::after {
    content: '🔥 Click to burn';
    position: absolute;
    bottom: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--danger);
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 1px 3px #000;
}
.clickable-joker:hover:not(.disabled) { transform: translateY(-6px) scale(1.05); }
.clickable-joker:hover:not(.disabled) .card.joker {
    box-shadow:
        0 8px 20px rgba(212,175,55,0.8),
        0 0 0 3px var(--danger),
        0 0 24px rgba(208,48,48,0.6);
}
.clickable-joker.disabled {
    animation: none;
    opacity: 0.75;
    cursor: not-allowed;
}
.clickable-joker.disabled::after {
    content: 'No targets yet';
    color: var(--ash);
}
@keyframes joker-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(212,175,55,0); }
    50%      { box-shadow: 0 0 18px rgba(212,175,55,0.7); }
}

.card-back {
    display: inline-block;
    width: 68px;
    height: 100px;
    margin: 3px;
    border-radius: 6px;
    background:
        repeating-linear-gradient(45deg, rgba(212,175,55,0.2) 0 3px, transparent 3px 6px),
        repeating-linear-gradient(-45deg, rgba(212,175,55,0.2) 0 3px, transparent 3px 6px),
        linear-gradient(180deg, #6a1d2a 0%, #3a0510 100%);
    border: 1px solid rgba(212,175,55,0.4);
    box-shadow: 0 2px 4px rgba(0,0,0,0.5), inset 0 0 8px rgba(0,0,0,0.5);
    position: relative;
}
.card-back::after {
    content: '♦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--gold);
    font-size: 34px;
    text-shadow: 0 0 4px rgba(0,0,0,0.8);
}

/* ===== log ===== */
#log-container { overflow: auto; flex: 1; display: flex; flex-direction: column; }
#log {
    border: 1px solid rgba(212,175,55,0.2);
    padding: 10px 12px;
    flex: 1;
    overflow-y: auto;
    background: rgba(0,0,0,0.4);
    border-radius: 6px;
    color: var(--ivory);
    font-size: 11px;
    line-height: 1.5;
}
#log p {
    margin: 0 0 4px 0;
    padding: 3px 4px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    display: flex;
    gap: 6px;
    align-items: flex-start;
    line-height: 1.4;
}
#log p.log-latest { color: var(--gold-soft); font-weight: 600; background: rgba(212,175,55,0.06); border-radius: 3px; }
.log-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 13px;
}
.log-body { flex: 1; }
.log-you { color: var(--gold); font-weight: 700; }
.log-opp { color: var(--ivory); font-weight: 600; }
.log-bar { color: var(--gold-soft); }
.log-draw { color: #cfd8e3; }
.log-low { color: var(--accent-green); }
.log-par { color: var(--accent-cyan); }
.log-bust { color: #ff9966; }
.log-correct { color: var(--accent-green); }
.log-wrong { color: #ff8888; }
.log-die { color: var(--danger); font-weight: 700; }
.log-survive { color: #a9e0a9; }
.log-bullet { color: #ff6b6b; }
.log-suit { color: var(--gold); font-weight: 700; }
.log-facepull { color: var(--gold-soft); }
.log-cycle { color: var(--ash); font-style: italic; }
.log-round { color: var(--gold); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.log-death { color: var(--danger); font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; }
.log-win { color: var(--gold); font-weight: 700; letter-spacing: 1.5px; }
.log-turn { color: var(--ivory); }
.log-neutral { color: var(--ash); }
.log-skip { color: var(--ash-dim); font-style: italic; }

/* ===== game over ===== */
#game-over {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 700;
    min-width: 480px;
    max-width: min(820px, 96vw);
    max-height: 92vh;
    overflow-y: auto;
    text-align: center;
    padding: 28px 32px;
    background: linear-gradient(180deg, rgba(14,20,16,0.97), rgba(6,10,8,0.99));
    border: 1px solid rgba(212,175,55,0.4);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.7), 0 0 40px rgba(212,175,55,0.2);
    font-family: 'Playfair Display', serif;
    animation: go-pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1);
}
#game-over:empty { display: none; }
@keyframes go-pop {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
    60%  { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
    100% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
.go-verdict {
    font-size: clamp(28px, 6vw, 46px);
    font-weight: 900;
    letter-spacing: clamp(3px, 0.8vw, 6px);
    margin-bottom: 8px;
    line-height: 1;
}
.go-verdict.won  { color: var(--gold);   text-shadow: 0 0 24px rgba(212,175,55,0.6), 0 2px 0 rgba(0,0,0,0.8); }
.go-verdict.lost { color: var(--danger); text-shadow: 0 0 24px rgba(208,48,48,0.6), 0 2px 0 rgba(0,0,0,0.8); }
.go-verdict.draw { color: var(--ash);    text-shadow: 0 0 16px rgba(120,120,120,0.6), 0 2px 0 rgba(0,0,0,0.8); }
.go-sub {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ash);
    margin-bottom: 18px;
}
.go-sub strong { color: var(--gold-soft); letter-spacing: 1px; }

/* Winner spotlight inside the game-over modal: portrait, name, final total,
   plus their hand + settled piles so you see what they ended with. */
.go-winner {
    display: flex;
    align-items: center;
    gap: 14px;
    justify-content: center;
    padding: 14px 16px;
    margin: 10px auto 6px auto;
    max-width: 740px;
    border-radius: 10px;
    background:
        linear-gradient(180deg, rgba(36,50,38,0.85) 0%, rgba(12,20,14,0.92) 100%);
    border: 1px solid rgba(212,175,55,0.35);
    box-shadow: inset 0 0 22px rgba(0,0,0,0.5);
}
.go-winner-portrait {
    width: 92px;
    height: 92px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top center;
    border: 3px solid var(--gold);
    box-shadow: 0 0 22px rgba(212,175,55,0.6), 0 4px 14px rgba(0,0,0,0.55);
    background: radial-gradient(circle at 40% 30%, rgba(50,68,54,0.9), rgba(10,16,10,1));
    flex-shrink: 0;
}
.go-winner-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
}
.go-winner-name {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    color: var(--gold);
    line-height: 1;
}
.go-winner-total {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    letter-spacing: 2px;
    color: var(--ivory);
    text-transform: uppercase;
}
.go-cards {
    margin: 10px auto 0 auto;
    max-width: 760px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.go-cards-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    padding: 8px 10px;
    background: rgba(0,0,0,0.35);
    border-radius: 8px;
    border: 1px dashed rgba(255,255,255,0.08);
}
.go-cards-label {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--ash);
    text-transform: uppercase;
    min-width: 72px;
    text-align: left;
    flex-shrink: 0;
}
.go-cards-line {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    flex: 1;
}
/* Overlapping-stacks layout: cards in a row collapse into a fan so a long
   hand reads compactly. Multiple rows when one row would overflow. */
.go-cards-stacks {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}
.go-cards-stack {
    display: flex;
    justify-content: center;
    padding-left: 28px;        /* counter-balance the negative margin so the row stays centered */
}
.go-cards-stack > * {
    margin-left: -28px;
    transition: transform 0.18s ease, z-index 0s ease 0.18s;
    position: relative;
    z-index: 1;
}
.go-cards-stack > *:hover {
    transform: translateY(-6px) scale(1.04);
    z-index: 20;
    transition: transform 0.18s ease, z-index 0s;
}
@media (max-width: 720px) {
    #game-over { min-width: 0; padding: 20px 16px; }
    .go-cards-stack > * { margin-left: -34px; }
    .go-cards-stack { padding-left: 34px; }
}
.go-cards-empty {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: var(--ash);
    letter-spacing: 1px;
    padding: 8px;
}
#game-over button {
    display: inline-block;
    margin-top: 18px;
    padding: 10px 24px;
    background: linear-gradient(180deg, var(--gold) 0%, #a88420 100%);
    border: none;
    color: #0a0a0a;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-family: 'Inter', sans-serif;
}

/* ===== discard pile ===== */
.discard-wrap { margin-top: 16px; }
.discard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    margin-bottom: 4px;
}
.discard-title {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--ash);
    font-weight: 600;
}
.discard-count {
    font-size: 10px;
    color: var(--ash-dim);
    letter-spacing: 1px;
}
.discarded {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    overflow: visible;
    padding: 10px 10px 10px 10px;
    gap: 4px;
    background: rgba(0,0,0,0.3);
    border-radius: 6px;
    margin-top: 8px;
    border: 1px dashed rgba(255,255,255,0.08);
}
.discard-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 68px;
}
.discard-column .card,
.discard-column .card-back {
    margin: 0 0 0 0;
    margin-top: -68px;
    transition: transform 0.15s, margin-top 0.15s, z-index 0s;
    position: relative;
}
.discard-column .card:hover {
    z-index: 20;
    transform: translate(-2px, -6px);
    box-shadow: 0 6px 14px rgba(0,0,0,0.7), 0 0 0 1px rgba(212,175,55,0.4);
}

/* ===== counter widget ===== */
.counter-head {
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(212,175,55,0.2);
    padding-bottom: 6px;
}
.counter-title {
    color: var(--gold);
    font-size: 12px;
    letter-spacing: 3px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 6px;
}
.counter-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 3px;
    font-size: 9px;
    color: var(--ash);
    letter-spacing: 0.5px;
}
.counter-legend span { display: inline-flex; align-items: center; gap: 3px; text-transform: uppercase; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 2px; }
.dot-deck { background: #2a3a30; border: 1px solid #1a2a20; }
.dot-bar { background: var(--gold); }
.dot-you { background: var(--accent-green); }
.dot-known { background: var(--accent-cyan); }
.dot-hidden { background: var(--danger); }

.counter-grid {
    width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
    font-size: 10px;
    table-layout: fixed;
}
.counter-grid th {
    width: 16px;
    padding: 2px;
    font-size: 13px;
}
.counter-grid th.red { color: #ff6060; }
.counter-grid th.black { color: var(--ivory); }
.cell, .joker-cell {
    padding: 2px 0;
    text-align: center;
    border-radius: 2px;
    font-family: 'Playfair Display', serif;
    font-weight: 700;
    font-size: 10px;
    color: transparent;
    cursor: default;
    transition: background 0.3s, color 0.3s;
    height: 18px;
}
.cell.cell-deck { background: #2a3a30; color: #4a5a50; border: 1px solid #1a2a20; }
.cell.cell-bar { background: var(--accent-cyan); color: #0a2035; }
.cell.cell-you { background: var(--gold); color: #0a0a0a; }
.cell.cell-known { background: var(--accent-green); color: #0a2010; }
.cell.cell-hidden { background: var(--danger-dim); color: #f8c5c5; }

.counter-jokers {
    margin-top: 8px;
    color: var(--ash);
    font-size: 10px;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}
.joker-cell {
    display: inline-block;
    width: 24px;
    height: 22px;
    line-height: 22px;
    font-weight: 700;
}

.counter-summary {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(212,175,55,0.2);
    font-size: 11px;
    letter-spacing: 1px;
}
.sum-row { display: flex; justify-content: space-between; padding: 2px 0; color: var(--ash); }
.sum-row strong { color: var(--gold); }

/* ===== animation overlay ===== */
#anim-overlay {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 720;
    overflow: hidden;
}
#anim-canvas {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 721;
}
.flying-card {
    position: fixed;
    z-index: 725;
    pointer-events: none;
}
.flying-card .card, .flying-card .card-back {
    margin: 0;
    box-shadow: 0 8px 20px rgba(0,0,0,0.6);
}
.flash-overlay {
    position: fixed;
    pointer-events: none;
    z-index: 722;
    border-radius: 8px;
}
/* Self-call badge (Low / Par / Thief / Liar when no target) — big glyph +
   bold label rising above the caller so it's immediately clear WHY the
   chamber count is about to change. */
.call-badge {
    position: fixed;
    pointer-events: none;
    z-index: 724;
    transform: translate(-50%, -50%);
    text-align: center;
    font-family: 'Playfair Display', serif;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.8));
}
.call-badge-glyph {
    font-size: 64px;
    line-height: 1;
    margin-bottom: 4px;
}
.call-badge-text {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 6px;
    text-transform: uppercase;
}
.call-bullet-preview {
    position: fixed;
    pointer-events: none;
    z-index: 724;
    font-size: 30px;
    line-height: 1;
    filter: drop-shadow(0 0 10px rgba(208,48,48,0.9));
    transform: translate(-50%, -50%);
}

/* ===== misc ===== */
#link {
    position: absolute;
    color: var(--ash);
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    right: 100px;
    top: 20px;
    text-decoration: none;
    opacity: 0.5;
    z-index: 20;
}
#link:hover { opacity: 1; color: var(--gold); }

#rules-link {
    display: inline-block;
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--ash);
    text-decoration: none;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(212,175,55,0.25);
    transition: color 0.2s;
}
#rules-link:hover { color: var(--gold); border-color: var(--gold); }

#home-link {
    position: fixed;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    color: var(--ash);
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 6px 14px;
    border: 1px solid rgba(212,175,55,0.25);
    border-radius: 20px;
    background: rgba(0,0,0,0.55);
    text-decoration: none;
    opacity: 0.8;
    z-index: 20;
    transition: all 0.2s;
}
#home-link:hover { opacity: 1; color: var(--gold); border-color: var(--gold); }

/* ===== responsive ===== */
@media (max-width: 1100px) {
    #game-container { grid-template-columns: 1fr; }
    #counter-section {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 30;
        transform: translateX(100%);
        transition: transform 0.25s ease;
    }
    body:not(.counter-closed) #counter-section { transform: translateX(0); }
    body.counter-closed #counter-section { transform: translateX(100%); }
}
@media (max-width: 800px) {
    .modal-panel { width: 94vw; max-height: 86vh; }
}

/* ===== stage overlay =====
   Full-screen takeover on mobile, centered sized modal on desktop.
   Slots stack top (actor) and bottom (target) so mobile can actually fit the
   portrait + hand + settled cards without side-by-side squeeze.
   Reuses the standard .player markup inside each slot — no bespoke layout.
   Shown while an AI is acting; hidden whenever it's your turn. */
#stage {
    position: fixed;
    inset: 0;
    z-index: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}
#stage.hidden { display: none; }
#stage-backdrop {
    position: absolute;
    inset: 0;
    /* Same green felt as the body — opaque (no bleed-through of the main
       table beneath) but visually consistent with the game's aesthetic. */
    background: radial-gradient(ellipse at center, var(--felt-mid) 0%, var(--felt-deep) 55%, var(--felt-edge) 100%);
    pointer-events: auto;
}
#stage-panel {
    position: relative;
    width: min(620px, 94vw);
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    gap: 14px;
    /* Extra bottom padding reserves space for the absolute-positioned wheel. */
    padding: 16px 16px 196px 16px;
    overflow-y: auto;
    pointer-events: auto;
}
#stage .stage-slot {
    flex: 0 0 auto;
    overflow: hidden;
}
#stage .stage-slot.empty { display: none; }
/* Enter: slide in from the right. Exit: slide out to the left.
   Applied by stage.js via the .entering / .exiting classes on the slot. */
/* Actor slot enters from the right. Target slot enters from the LEFT —
   opposite direction so the two slide toward each other when an accusation
   or joker burn populates the target. */
#stage #stage-actor.entering .player {
    animation: stage-slide-in-right 0.32s cubic-bezier(0.2,0.65,0.3,1) both;
}
#stage #stage-actor.exiting .player {
    animation: stage-slide-out-left 0.24s cubic-bezier(0.4,0,0.8,0.4) both;
}
#stage #stage-target.entering .player {
    animation: stage-slide-in-left 0.32s cubic-bezier(0.2,0.65,0.3,1) both;
}
#stage #stage-target.exiting .player {
    animation: stage-slide-out-right 0.24s cubic-bezier(0.4,0,0.8,0.4) both;
}
@keyframes stage-slide-in-right {
    from { opacity: 0; transform: translateX(40%) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes stage-slide-out-left {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(-40%) scale(0.96); }
}
@keyframes stage-slide-in-left {
    from { opacity: 0; transform: translateX(-40%) scale(0.96); }
    to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes stage-slide-out-right {
    from { opacity: 1; transform: translateX(0) scale(1); }
    to   { opacity: 0; transform: translateX(40%) scale(0.96); }
}
/* Slight visual separation between actor and target when both present. */
#stage.has-target #stage-target .player {
    border-color: rgba(208,48,48,0.45);
    box-shadow: 0 0 0 1px rgba(208,48,48,0.2);
}
#stage.has-target #stage-actor .player {
    border-color: rgba(212,175,55,0.5);
    box-shadow: 0 0 0 1px rgba(212,175,55,0.2);
}
/* Compact bar inside the stage panel. Row layout: total + deck count stacked
   in the top-left, cards flowing to the right. */
#stage .stage-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(212,175,55,0.4);
    padding: 8px 12px;
    min-height: 70px;
    background:
        radial-gradient(ellipse at center, rgba(26,77,51,0.96) 0%, rgba(10,41,27,0.98) 100%),
        rgba(8,24,15,1);
    border-radius: 8px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5), 0 4px 10px rgba(0,0,0,0.5);
    flex: 0 0 auto;
}
#stage .bar-compact-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    flex-shrink: 0;
    min-width: 60px;
}
#stage .bar-total.compact {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    color: var(--gold);
    font-weight: 700;
    letter-spacing: 2px;
    line-height: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}
#stage .deck-count.compact {
    font-size: 9px;
    color: var(--ash);
    letter-spacing: 2px;
    margin-top: 4px;
    text-transform: uppercase;
}
#stage .bar-cards.compact {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    flex: 1;
    min-height: 38px;
    padding-left: 30px;
    overflow-x: auto;
}
#stage .bar-cards.compact > .card,
#stage .bar-cards.compact > .card-back {
    margin-left: -30px;
    flex-shrink: 0;
}

/* 3D cover-flow wheel at the bottom of the stage. All alive players shown;
   current turn centered and scaled up, neighbors recede with rotateY +
   translateZ + opacity falloff. paintWheel() in js/stage.js writes the
   per-tile transform / opacity / z-index inline. */
.stage-wheel {
    position: absolute;
    left: 50%;
    bottom: 64px;
    transform: translateX(-50%);
    width: 420px;
    height: 92px;
    pointer-events: none;
}
.wheel-tile {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 56px;
    height: 56px;
    transform: translate(-50%, -50%);
    transition: transform 0.5s cubic-bezier(0.22, 0.85, 0.35, 1.05),
                opacity 0.45s ease;
    will-change: transform, opacity;
}
.wheel-tile img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 18%;
    border: 2px solid rgba(255,255,255,0.18);
    box-shadow: 0 4px 12px rgba(0,0,0,0.55);
    background: radial-gradient(circle at 40% 35%, rgba(36,50,38,0.9), rgba(6,14,10,0.96));
    display: block;
}
.wheel-tile.current img {
    border-color: var(--gold);
    box-shadow: 0 0 18px rgba(212,175,55,0.75), 0 4px 14px rgba(0,0,0,0.6);
}
/* The local user's tile always carries a soft blue ring so you can locate
   yourself at a glance — blends with the gold "current" ring when it's
   also your turn (gold dominates, blue becomes an outer halo). */
.wheel-tile.you img {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(102,204,255,0.65), 0 4px 12px rgba(0,0,0,0.55);
}
.wheel-tile.you.current img {
    border-color: var(--gold);
    box-shadow:
        0 0 0 2px rgba(102,204,255,0.8),
        0 0 18px rgba(212,175,55,0.85),
        0 4px 14px rgba(0,0,0,0.6);
}
.wheel-tile.dead {
    filter: grayscale(1) brightness(0.45);
}
.wheel-tile .wheel-star {
    position: absolute;
    top: -6px;
    right: -4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    background: radial-gradient(circle at 35% 30%, var(--gold-soft) 0%, var(--gold) 60%, #806412 100%);
    color: #2a1c04;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.6);
    box-shadow: 0 0 10px rgba(212,175,55,0.85);
    font-weight: 900;
    line-height: 1;
    z-index: 2;
}
.wheel-tile .wheel-name {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    color: var(--ivory);
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    white-space: nowrap;
    text-shadow: 0 2px 6px rgba(0,0,0,0.9), 0 0 8px rgba(0,0,0,0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease 0.05s;
}
.wheel-tile.current .wheel-name { opacity: 1; }
.wheel-tile.current .wheel-name { top: calc(100% + 2px); font-size: 12px; }

/* Mobile: full-screen takeover, no side padding. */
@media (max-width: 720px) {
    #stage-panel {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        /* Extra top padding + safe-area so the bar isn't clipped by the
           browser chrome / notch on phones. */
        padding: calc(env(safe-area-inset-top, 0px) + 48px) 8px calc(env(safe-area-inset-bottom, 0px) + 170px) 8px;
        justify-content: flex-start;
    }
    #stage .stage-bar { padding: 6px 8px; min-height: 60px; }
    #stage .bar-total.compact { font-size: 18px; }
    .stage-wheel { width: 320px; height: 78px; bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); }
    .wheel-tile { width: 48px; height: 48px; }
    .wheel-tile .wheel-star { width: 16px; height: 16px; font-size: 10px; top: -4px; right: -4px; }
}

/* Joker-burn modal self-target tag + disabled card option. */
.burn-target.self { border-color: rgba(102,204,255,0.55); box-shadow: inset 0 0 14px rgba(102,204,255,0.12); }
.burn-self-tag {
    display: inline-block;
    margin-left: 6px;
    font-size: 9px;
    letter-spacing: 2px;
    font-family: 'Inter', sans-serif;
    background: var(--accent-cyan, #66ccff);
    color: #002030;
    padding: 2px 6px;
    border-radius: 3px;
    vertical-align: middle;
    font-weight: 700;
}
.burn-card-opt.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.4);
}
.burn-card-opt.disabled::after {
    content: attr(data-disabled-reason);
    display: block;
    font-size: 9px;
    letter-spacing: 1px;
    color: var(--ash);
    text-align: center;
    margin-top: 2px;
    text-transform: uppercase;
}

/* Character picker tile: small species sub-label under the canonical name. */
.char-tile .char-species {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--ash);
    text-transform: uppercase;
    margin-top: 2px;
}
