:root {
    --bg: #1a1d23;
    --surface: #252830;
    --surface-raised: #2d3039;
    --border: #3a3d45;
    --border-light: #4a4d55;
    --text: #e4e4e7;
    --text-secondary: #9ca3af;
    --accent: #d4a843;
    --accent-light: #e8c06a;
    --danger: #e05252;
    --felt-top: #2a7a4a;
    --felt-mid: #1a5c38;
    --felt-bottom: #124a2c;
    --felt-border: #5a3a20;
    --seat-default: #e4e4e7;
    --seat-dealer: #7cacf8;
    --seat-self: #e8c06a;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    position: relative;
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.app-shell {
    width: min(1420px, calc(100vw - 20px));
    margin: 10px auto 14px;
}

#wrap {
    width: 100%;
}

.container {
    display: grid;
    gap: 12px;
}

/* ── Login Bar ─────────────────────────────────────── */

.login-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 8px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.login-bar .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 120px;
    min-width: 100px;
}

.login-bar button {
    flex: 0 0 auto;
    align-self: end;
}

/* ── Host Message panel (1.10) ─────────────────────── */

.host-message {
    min-width: 130px;
    border: 1px solid rgba(220, 180, 90, 0.45);
    border-radius: 8px;
    padding: 6px 10px;
    background: linear-gradient(180deg, rgba(220, 160, 60, 0.10), rgba(140, 60, 0, 0.10));
}

.host-message-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}

.host-message-input {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    padding: 3px 6px;
    font-weight: 600;
}

#host-message-send {
    font-size: 11px;
    padding: 3px 10px;
    background: linear-gradient(180deg, #d4a843, #b88830);
    color: #2a1a05;
    font-weight: 700;
    border: 1px solid #8c6618;
    border-radius: 4px;
    cursor: pointer;
}
#host-message-send:hover { background: linear-gradient(180deg, #e6bb55, #c9982d); }
#host-message-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Reactions panel ───────────────────────────────── */

.reactions {
    min-width: 130px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.04);
}

.reactions-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}

.reaction-input {
    flex: 1;
    min-width: 0;
    font-size: 11px;
    padding: 2px 4px;
}

.reaction-anim-select {
    font-size: 11px;
    padding: 2px 2px;
    max-width: 80px;
}

#reaction-send {
    font-size: 11px;
    padding: 2px 8px;
}

/* ── Message overlays (rule-fired / reactions) ─────── */

/* Jitsi (JaaS) video drawer in the sidebar (Phase A: Jitsi's own grid in a panel). */
.video-drawer-summary { cursor: pointer; font-weight: 700; padding: 6px 8px; color: #d7b15a; }
.jitsi-status { font-size: 12px; color: #b9c4bb; margin-top: 4px; }
.jitsi-debug { font-size: 10px; color: #7fa7c9; margin-top: 4px; font-family: monospace; }
.jitsi-hint { font-size: 11px; color: #8a978c; margin-top: 4px; line-height: 1.35; }

.msg-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 30;
    user-select: none;
}

.msg-overlay.dance {
    top: 45%;
    left: -50%;
    font-size: 32px;
    font-weight: 800;
    color: #fff8c4;
    text-shadow: 0 0 10px rgba(0,0,0,0.85), 0 0 22px rgba(255, 200, 80, 0.65);
    padding: 10px 22px;
    border-radius: 28px;
    background: linear-gradient(90deg, rgba(140, 60, 0, 0.92), rgba(220, 120, 30, 0.92));
    border: 2px solid rgba(255, 220, 130, 0.85);
    white-space: nowrap;
    animation: ruleDance 3.6s cubic-bezier(.55,.1,.45,.95) forwards;
}

@keyframes ruleDance {
    0%   { left: -50%; transform: scale(0.7) rotate(-3deg); opacity: 0; }
    12%  { left: 0;    transform: scale(1.05) rotate(0deg); opacity: 1; }
    50%  { left: 30%;  transform: scale(1.15) rotate(-2deg); opacity: 1; }
    88%  { left: 80%;  transform: scale(1.0) rotate(2deg);  opacity: 1; }
    100% { left: 110%; transform: scale(0.6) rotate(-3deg); opacity: 0; }
}

.msg-overlay.slide {
    top: 50%;
    left: -30%;
    font-size: 20px;
    font-weight: 700;
    color: #f4f0e2;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
    padding: 6px 14px;
    border-radius: 16px;
    background: rgba(40, 50, 70, 0.85);
    border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
    animation: ruleSlide 2.8s ease-in-out forwards;
}

@keyframes ruleSlide {
    0%   { left: -30%; opacity: 0; }
    15%  { left: 5%;   opacity: 1; }
    85%  { left: 70%;  opacity: 1; }
    100% { left: 105%; opacity: 0; }
}

.msg-overlay.fireworks,
.msg-overlay.firework {
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 8px rgba(0,0,0,0.85);
    text-align: center;
    animation: fireworkBurst 1.8s ease-out forwards;
}

@keyframes fireworkBurst {
    0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 0; }
    20%  { transform: translate(-50%, -50%) scale(1.4); opacity: 1; filter: drop-shadow(0 0 12px #ffd54d); }
    55%  { transform: translate(-50%, -50%) scale(1.0); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.85); opacity: 0; }
}

.msg-overlay.bubble {
    top: 60%;
    left: 50%;
    transform: translate(-50%, 0);
    font-size: 14px;
    font-weight: 600;
    color: #222;
    background: #fff;
    padding: 8px 14px;
    border-radius: 18px;
    border: 1px solid rgba(0,0,0,0.15);
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
    max-width: 280px;
    animation: bubbleDrift 3.4s ease-out forwards;
}

.msg-overlay.bubble::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 16px;
    border: 6px solid transparent;
    border-top-color: #fff;
}

@keyframes bubbleDrift {
    0%   { transform: translate(-50%, 40%); opacity: 0; }
    15%  { transform: translate(-50%, 0%);  opacity: 1; }
    80%  { transform: translate(-50%, -120%); opacity: 1; }
    100% { transform: translate(-50%, -200%); opacity: 0; }
}

.msg-overlay .msg-sender {
    display: block;
    font-size: 9px;
    font-weight: 500;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 2px;
}

/* ── Host-message modifier: more prominent across all animation types ── */
/* Applied alongside the animation class (e.g. .msg-overlay.host-msg.dance) */

.msg-overlay.host-msg.dance {
    font-size: 44px;
    padding: 14px 30px;
    border-width: 3px;
    border-color: #ffeaa7;
    background: linear-gradient(90deg, rgba(180, 30, 30, 0.95), rgba(220, 140, 30, 0.95) 50%, rgba(180, 30, 30, 0.95));
    box-shadow: 0 0 30px rgba(255, 200, 80, 0.55), 0 8px 24px rgba(0,0,0,0.5);
    animation-duration: 4.6s;
}

.msg-overlay.host-msg.slide {
    font-size: 28px;
    font-weight: 800;
    padding: 10px 22px;
    background: rgba(180, 30, 30, 0.92);
    border: 2px solid #ffeaa7;
    color: #fff8c4;
    box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}

.msg-overlay.host-msg.fireworks,
.msg-overlay.host-msg.firework {
    font-size: 44px;
    text-shadow: 0 0 18px rgba(255, 220, 130, 0.95), 0 0 8px rgba(0,0,0,0.85);
    animation-duration: 2.6s;
}

.msg-overlay.host-msg.bubble {
    font-size: 18px;
    font-weight: 800;
    padding: 12px 20px;
    background: linear-gradient(180deg, #fff8c4, #ffe07a);
    color: #2a1a05;
    border: 2px solid #b88830;
    box-shadow: 0 6px 22px rgba(0,0,0,0.5);
    max-width: 360px;
}

.msg-overlay.host-msg.bubble::after {
    border-top-color: #ffe07a;
}

/* If a host message comes in with no specific animation (shouldn't happen
   but defensive), default to the dance look. */
.msg-overlay.host-msg {
    text-shadow: 0 0 14px rgba(255, 200, 80, 0.75), 0 0 6px rgba(0,0,0,0.85);
}

/* ── Court Jester roast: fires on the host-named per-hand loser. Pure CSS/emoji,
   gold "royal roast" palette to match host messaging. ── */
.roast-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    user-select: none;
    z-index: 31;
    overflow: hidden;
}

.roast-jester {
    position: absolute;
    top: 38%;
    left: -12%;
    font-size: 54px;
    filter: drop-shadow(0 0 10px rgba(255, 200, 80, 0.8));
    animation: roastRun 4.5s cubic-bezier(.45,.05,.55,.95) forwards;
}

@keyframes roastRun {
    0%   { left: -12%; transform: rotate(0deg) scale(0.8); opacity: 0; }
    10%  { opacity: 1; }
    100% { left: 108%; transform: rotate(1080deg) scale(1.1); opacity: 1; }
}

.roast-label {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    color: #ffe9b8;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    padding: 4px 12px;
    border-radius: 14px;
    background: rgba(70, 35, 8, 0.5);
    white-space: nowrap;
    opacity: 0;
    animation: roastLabelPop 3.4s ease-out forwards;
}

@keyframes roastLabelPop {
    0%   { opacity: 0; transform: translateX(-50%) scale(0.6); }
    12%  { opacity: 1; transform: translateX(-50%) scale(1.08); }
    20%  { transform: translateX(-50%) scale(1.0); }
    85%  { opacity: 1; transform: translateX(-50%) scale(1.0); }
    100% { opacity: 0; transform: translateX(-50%) scale(0.9); }
}

.roast-tomato {
    position: absolute;
    top: -10%;
    font-size: 30px;
    opacity: 0;
    animation: roastTomato 1.6s ease-in forwards;
}
.roast-tomato--1 { left: 30%; animation-delay: 0.3s; }
.roast-tomato--2 { left: 45%; animation-delay: 0.6s; }
.roast-tomato--3 { left: 58%; animation-delay: 0.9s; }
.roast-tomato--4 { left: 68%; animation-delay: 1.2s; }

@keyframes roastTomato {
    0%   { top: -10%; opacity: 0; transform: rotate(0deg); }
    15%  { opacity: 1; }
    70%  { top: 55%; opacity: 1; transform: rotate(220deg); }
    80%  { top: 48%; }
    100% { top: 58%; opacity: 0; transform: rotate(300deg); }
}

/* ── Shuffle + Trump dropdowns side-by-side inside the
   Shuffle Strat panel. Keeps the panel layout simple (one
   panel per row in the sidebar) but uses the panel's full
   width for the two selects. */

.shuffle-strategies-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}

.shuffle-strategies-row > .shuffle-options-row {
    flex: 1 1 0;
    min-width: 0;
    margin-top: 0;
}

.shuffle-strategies-row .shuffle-options-row label.names {
    width: 42px;
    flex-shrink: 0;
}

.shuffle-strategies-row .shuffle-strategy-select {
    flex: 1;
    min-width: 0;
}

/* ── Shuffle Strat options panel ───────────────────── */

.shuffle-options {
    min-width: 130px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.04);
}

.shuffle-options-label {
    margin-bottom: 2px;
}

.shuffle-options--locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.shuffle-options-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
}

.shuffle-options-row label {
    font-size: 10px !important;
    width: 62px;
    flex-shrink: 0;
}

.shuffle-strategy-select {
    flex: 1;
    font-size: 11px;
    padding: 2px 4px;
    min-width: 0;
}

/* ── UND options panel ─────────────────────────────── */

.und-options {
    min-width: 110px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.04);
}

.und-options-label {
    margin-bottom: 2px;
}

.und-options--locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.und-options-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.und-options-row label {
    font-size: 10px !important;
    width: 62px;
    flex-shrink: 0;
}

.und-option-input {
    width: 48px;
    padding: 2px 4px;
    font-size: 12px;
    text-align: center;
}

/* ── KINGS options panel ───────────────────────────── */

.kings-options {
    min-width: 130px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.04);
}

.kings-options-label {
    margin-bottom: 2px;
}

.kings-options--locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.kings-grid {
    display: grid;
    gap: 3px;
}

.kings-grid-header,
.kings-grid-row {
    display: grid;
    grid-template-columns: 46px 30px 30px 28px 32px 40px;
    gap: 4px;
    align-items: center;
}

.kings-cnt {
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
}

.kings-pts {
    font-size: 9px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
}

.kings-val {
    font-size: 9px;
    color: var(--accent-light);
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
}

.kings-grid-header span {
    font-size: 9px;
    text-align: center;
    color: var(--text-secondary);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.kings-grid-header span:first-child {
    text-align: left;
}

.kings-game-name {
    font-size: 10px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kings-count-input {
    width: 30px;
    padding: 2px 0;
    font-size: 11px;
    text-align: center;
}

/* ── Inputs ────────────────────────────────────────── */

.field label,
.audio-item label {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

select,
input[type="text"] {
    width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
}

select:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.2);
}

/* ── Buttons ───────────────────────────────────────── */

button,
input[type="button"] {
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

button:hover,
input[type="button"]:hover {
    background: #383b44;
    border-color: #555;
}

button:disabled,
input[type="button"]:disabled {
    opacity: 0.4;
    cursor: default;
}

#join,
#start,
#deal {
    background: var(--accent);
    border-color: var(--accent);
    color: #1a1d23;
}

#join:hover,
#start:hover,
#deal:hover {
    background: var(--accent-light);
    border-color: var(--accent-light);
}

#start.host-locked,
#fast_fwd.host-locked,
#deal.dealer-locked {
    background: #2a2d35 !important;
    border-color: #444 !important;
    color: #888 !important;
    cursor: not-allowed;
    opacity: 0.55;
    box-shadow: none;
}

.host-only-note {
    font-size: 10px;
    font-weight: 600;
    color: rgba(244, 240, 226, 0.55);
    margin-left: 6px;
    letter-spacing: 0.04em;
    text-transform: none;
}

#bid,
#name {
    background: #3d5a3a;
    border-color: #4a6d46;
    color: #d4e8d2;
}

#name {
    display: none;
}

#terminate {
    background: #4a2828;
    border-color: #6b3535;
    color: #f0b0b0;
}

#record.is-recording {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}

/* ── Main Grid ─────────────────────────────────────── */

.main-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 14px;
    align-items: start;
}

.game-area {
    display: grid;
    gap: 12px;
}

/* ── Panels ────────────────────────────────────────── */

.table-card,
.scoreboard-shell,
.help-bar,
.drawer-shell {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}

.table-card,
.scoreboard-shell {
    padding: 14px;
}

.help-bar {
    padding: 10px;
}

.drawer-shell {
    display: grid;
    gap: 10px;
    padding: 14px;
}

/* ── Table Card ────────────────────────────────────── */

.table-card {
    padding: 12px;
    display: grid;
    gap: 10px;
}

.table-and-bid {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.table-shell {
    flex: 0 0 auto;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #1e2128;
}

.table-scroll {
    overflow-x: auto;
    position: relative;
}

/* ── Card Table ────────────────────────────────────── */

#card-table {
    position: relative;
    width: 600px;
    min-width: 600px;
    height: 640px;
    margin: 0 auto;
    border: 8px solid var(--felt-border);
    border-radius: 32px;
    background:
        radial-gradient(circle at 50% 30%, rgba(255, 255, 255, 0.06), transparent 50%),
        linear-gradient(180deg, var(--felt-top), var(--felt-mid) 50%, var(--felt-bottom));
    box-shadow:
        inset 0 2px 8px rgba(255, 255, 255, 0.08),
        inset 0 -4px 12px rgba(0, 0, 0, 0.3),
        0 8px 24px rgba(0, 0, 0, 0.4);
    contain: layout paint;
    isolation: isolate;
}

#card-table::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: 24px;
    border: 1px dashed rgba(255, 255, 255, 0.1);
    pointer-events: none;
    z-index: 1;
}

/* ── Per-seat video tiles (lib-jitsi-meet) ───────────── */
/* Full-table overlay; tiles are positioned by JS at the same seat coordinates the labels use, so
   each player's video sits on their seat. The layer ignores pointer events so cards stay clickable;
   only the control buttons opt back in. Tiles sit above the felt but below the cards (z-index 2). */
#jitsi-tiles {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

/* A tile is a stack: the seat label (name + score) sits just above it, the video is the box, and
   the control buttons sit in their own row below the video. */
.vtile {
    position: absolute;
    width: 80px;
}

.vtile video {
    width: 80px;
    height: 58px;
    object-fit: cover;
    display: block;
    border-radius: 7px;
    background: #0b0b0b;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

/* Mirror only your own camera, the way every video app does. */
.vtile--self video {
    transform: scaleX(-1);
}

/* "Camera off" overlay — covers the video area with a camera-off icon when a player
   (ours or a remote's) has paused their camera, shown via the .vtile--off class. */
.vtile-off {
    position: absolute;
    top: 0;
    left: 0;
    width: 80px;
    height: 58px;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 7px;
    background: #0b0b0b;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.vtile--off .vtile-off { display: flex; }
.vtile-off::before {
    content: "";
    width: 22px;
    height: 22px;
    background-color: #8a978c;
    -webkit-mask: url(../img/videocam_off_24dp_1F1F1F.svg) center / contain no-repeat;
    mask: url(../img/videocam_off_24dp_1F1F1F.svg) center / contain no-repeat;
}

.vtile-ctrls {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 3px;
    pointer-events: none;   /* the layer ignores clicks; only the buttons opt back in */
}

.vtile-btn {
    pointer-events: auto;
    flex: 0 0 auto;          /* don't let the flex row squish the circles into ovals */
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    min-height: 0;           /* defeat the global `button { min-height: 36px }` that made these tall ovals */
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

.vtile-btn:hover { background: rgba(0, 0, 0, 0.85); }
.vtile-btn.off { background: rgba(200, 60, 60, 0.9); }

/* Material mic/camera icons, recolored to white via mask so they read on the dark buttons. The
   art swaps on the `.off` state class (muted / camera-off). */
.vtile-btn .vicon {
    display: block;
    flex: 0 0 auto;          /* the button is a flexbox; without this the icon shrinks horizontally */
    width: 15px;
    height: 15px;
    background-color: #fff;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}
.vtile-mic .vicon {
    -webkit-mask-image: url(../img/mic_none_24dp_1F1F1F.svg);
    mask-image: url(../img/mic_none_24dp_1F1F1F.svg);
}
.vtile-mic.off .vicon {
    -webkit-mask-image: url(../img/mic_off_24dp_1F1F1F.svg);
    mask-image: url(../img/mic_off_24dp_1F1F1F.svg);
}
.vtile-cam .vicon {
    -webkit-mask-image: url(../img/videocam_24dp_1F1F1F.svg);
    mask-image: url(../img/videocam_24dp_1F1F1F.svg);
}
.vtile-cam.off .vicon {
    -webkit-mask-image: url(../img/videocam_off_24dp_1F1F1F.svg);
    mask-image: url(../img/videocam_off_24dp_1F1F1F.svg);
}
.vtile-spk .vicon {
    -webkit-mask-image: url(../img/volume_up_24dp_1F1F1F_FILL0_wght400_GRAD0_opsz24.svg);
    mask-image: url(../img/volume_up_24dp_1F1F1F_FILL0_wght400_GRAD0_opsz24.svg);
}
.vtile-spk.off .vicon {
    -webkit-mask-image: url(../img/volume_off_24dp_1F1F1F_FILL0_wght400_GRAD0_opsz24.svg);
    mask-image: url(../img/volume_off_24dp_1F1F1F_FILL0_wght400_GRAD0_opsz24.svg);
}

.card {
    will-change: top, left, transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    z-index: 2;
    transition: box-shadow 0.1s ease-out, translate 0.1s ease-out;
}

.card:hover {
    border-radius: 6px;
    box-shadow: 0 0 8px 2px rgba(0, 210, 255, 0.5);
    translate: 0 -4px;
    transition: box-shadow 0.1s ease-out, translate 0.1s ease-out;
}

/* A selected (pending-confirm) card lifts ~50% out of the hand with a gold
   highlight. Uses the `translate` property (like :hover) so it coexists with the
   inline `transform: rotate(0deg)` cards.js puts on hand cards. */
.card-preselected {
    translate: 0 -16px !important;
    border-radius: 6px;
    box-shadow: 0 0 0 3px #3b9cff, 0 6px 12px rgba(0, 0, 0, 0.45) !important; /* Cool blue ring vs. the gold confirm lift */
    transition: box-shadow 0.12s ease-out, translate 0.12s ease-out;
}

.card-shake {
    animation: card-shake 0.35s ease-in-out;
}

@keyframes card-shake {
    0%, 100% { translate: 0 0; }
    25% { translate: -5px 0; }
    75% { translate: 5px 0; }
}

.autoplay-card {
    display: none;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-raised);
}

.autoplay-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.autoplay-hint {
    display: none;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(59, 156, 255, 0.15);
    border: 1px solid rgba(59, 156, 255, 0.4);
    color: #9cc9ff;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.card-selected {
    translate: 0 -49px !important;
    z-index: 9998 !important; /* Contends with Card#moveToFront */
    border-radius: 6px;
    box-shadow: 0 0 0 3px #ffd65a, 0 10px 18px rgba(0, 0, 0, 0.5) !important; /* Overrides box-shadow on .card:hover */
    transition: box-shadow 0.12s ease-out, translate 0.12s ease-out;
}

.card-back {
    background: repeating-linear-gradient(
        45deg,
        #8b1a1a,
        #8b1a1a 6px,
        #6b1212 6px,
        #6b1212 12px
    );
    border: 2px solid #5a0e0e;
    border-radius: 4px;
}

/* ── Seat Labels ───────────────────────────────────── */

#middle-left-player,
#top-left-player,
#top-middle-left-player,
#top-middle-right-player,
#top-right-player,
#middle-right-player,
#bottom-left-player,
#bottom-right-player,
#bottom-middle-right-player,
#bottom-middle-left-player {
    position: absolute;
    padding: 4px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    color: var(--seat-default);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    z-index: 3;
}

#bottom-left-player {
    left: 18px;
    top: 500px;
}

#bottom-right-player {
    right: 18px;
    top: 500px;
}

#bottom-middle-right-player {
    left: 315px;
    top: 500px;
}

#bottom-middle-left-player {
    left: 155px;
    top: 500px;
}

#card-table > div:not(.card):empty {
    display: none;
}

.seat-player--dealer {
    border-color: rgba(124, 172, 248, 0.4) !important;
}

.seat-player--self {
    border-color: rgba(232, 192, 106, 0.5) !important;
    background: rgba(212, 168, 67, 0.2) !important;
}

.seat-player--active {
    animation: blinkingText 2s linear infinite, borderGlow 3s ease-in-out infinite;
    border-color: rgba(244, 200, 60, 0.9) !important;
}

#top-middle-left-player {
    top: 18px;
    left: 188px;
}

#top-middle-right-player {
    top: 18px;
    left: auto !important;
    right: 188px !important;
    max-width: 180px;
    text-align: right;
}

#top-left-player {
    top: 50px;
    left: 18px;
}

#top-right-player {
    top: 78px;
    left: auto !important;
    right: 18px !important;
    max-width: 150px;
    text-align: right;
}

#middle-left-player {
    left: 18px;
    top: 213px;
}

#middle-right-player {
    top: 197px;
    left: auto !important;
    right: 18px !important;
    max-width: 150px;
    text-align: right;
}

/* ── Game Actions ──────────────────────────────────── */

.game-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
}

.rec-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

/* ── Replay harness bar ────────────────────────────── */

#replay-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.55);
    border-radius: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

#replay-bar button {
    padding: 2px 10px;
    font-size: 16px;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    color: var(--text);
    border-radius: 4px;
    min-width: 32px;
}

#replay-bar button:hover:not(:disabled) {
    background: rgba(255,255,255,0.18);
}

#replay-bar button:disabled {
    opacity: 0.35;
    cursor: default;
}

#rp-pos {
    font-size: 12px;
    color: var(--text-muted, #aaa);
    min-width: 48px;
    text-align: center;
}

.rp-label {
    font-size: 12px;
    color: var(--text-muted, #aaa);
}

#rp-speed {
    font-size: 12px;
    padding: 2px 4px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.08);
    color: var(--text);
    cursor: pointer;
}

.rp-nav-sep {
    flex: 1;
}

.rp-nav-link {
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.06);
    color: var(--accent-light);
    border-radius: 4px;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s;
}

.rp-nav-link:hover {
    background: rgba(255,255,255,0.15);
}

/* ── Table Side Panel ──────────────────────────────── */

.table-side-panel {
    flex: 1 1 0;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Turn Hint ─────────────────────────────────────── */

.bid-turn-hint {
    display: none;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(212, 168, 67, 0.15);
    border: 1px solid rgba(212, 168, 67, 0.3);
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* Kings: a hand that ended before its last card ("All queens are out — hand over") */
.early-end-banner {
    display: none;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(124, 172, 248, 0.15);
    border: 1px solid rgba(124, 172, 248, 0.4);
    color: var(--text-primary, #f4f0e2);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

/* ── Bid Card ──────────────────────────────────────── */

.bid-card {
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-raised);
}

.bid-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.bid-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--border-light);
    border-radius: 5px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.bid-btn:hover {
    background: var(--surface-raised);
    color: var(--text);
    border-color: var(--accent);
}

.bid-btn--active {
    background: var(--accent);
    border-color: var(--accent-light);
    color: #111;
    font-weight: 700;
}

/* Pre-selected bid (Pre-select on, not my turn yet): same cool blue ring as .card-preselected */
.bid-btn--preselected,
.bid-btn--preselected:hover {
    border-color: #3b9cff;
    box-shadow: 0 0 0 3px #3b9cff;
    background: var(--surface-raised);
    color: var(--text);
    font-weight: 700;
}

.bid-btn--forbidden {
    opacity: 0.3;
    cursor: not-allowed;
    border-style: dashed;
    color: var(--text-secondary);
}

.field--suits {
    min-width: 0;
    display: none;
}

.bidSuite {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 48px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.bidSuite input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.bidSuite label {
    min-width: 40px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
    background: var(--surface-raised);
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.bidSuite label:hover {
    background: #383b44;
}

.bidSuite label.red {
    color: #f06060;
}

.bidSuite label.black {
    color: var(--text);
}

.bidSuite input[type="radio"]:checked + label {
    border-color: var(--accent);
    background: rgba(212, 168, 67, 0.15);
    box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.2);
}

.action-row {
    display: grid;
    gap: 6px;
}

.action-row--bid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* ── Scoreboard ────────────────────────────────────── */

.scoreboard-shell {
    background: var(--surface);
}

.scoreboard-header {
    margin-bottom: 10px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--accent-light);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-align: center;
    text-transform: uppercase;
}

.dealInfo {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
}

.deal-info-row {
    display: flex;
    gap: 6px;
    align-items: baseline;
    line-height: 1.7;
}

.dil {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    min-width: 72px;
    flex-shrink: 0;
}

.seat-stats {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.dealInfo:empty {
    display: none;
}

.dealInfo .trump-suit {
    display: inline-block;
    font-size: 22px;
    font-weight: 900;
    line-height: 1;
    vertical-align: -2px;
    text-shadow:
        0 0 4px rgba(212, 168, 67, 0.9),
        0 0 12px rgba(212, 168, 67, 0.7);
}

.playerInfo {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text);
    font-size: 13px;
    line-height: 1.4;
}

.playerInfo:empty {
    display: none;
}

.scoreboard-shell .scores {
    min-height: 200px;
    max-height: 340px;
    background: #111418;
    border-color: var(--border-light);
}

.scoreboard-shell .urlForLog {
    margin-top: 8px;
}

/* ── Sidebar ───────────────────────────────────────── */

.sidebar {
    position: sticky;
    top: 10px;
}

/* ── Debug Accordion ───────────────────────────────── */

.debug-drawer {
    /* details element — no extra styles needed */
}

.debug-drawer-summary {
    cursor: pointer;
    list-style: none;
    padding: 7px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background 0.15s;
}

.debug-drawer-summary::-webkit-details-marker { display: none; }
.debug-drawer-summary::marker { display: none; }

.debug-drawer-summary::after {
    content: '▾';
    font-size: 11px;
    opacity: 0.6;
    transition: transform 0.2s;
}

.debug-drawer[open] > .debug-drawer-summary::after {
    transform: rotate(-180deg);
}

.debug-drawer[open] > .drawer-shell {
    margin-top: 10px;
}

/* ── Messaging drawer (right sidebar) ──────────────── */

.messaging-drawer {
    margin-bottom: 10px;
}

.messaging-drawer-summary {
    cursor: pointer;
    list-style: none;
    padding: 7px 14px;
    border: 1px solid rgba(220, 180, 90, 0.5);
    border-radius: 8px;
    background: linear-gradient(180deg, rgba(220, 160, 60, 0.12), rgba(140, 60, 0, 0.08));
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    transition: background 0.15s;
}

.messaging-drawer-summary::-webkit-details-marker { display: none; }
.messaging-drawer-summary::marker { display: none; }

.messaging-drawer-summary::after {
    content: '▾';
    font-size: 11px;
    opacity: 0.6;
    transition: transform 0.2s;
}

.messaging-drawer[open] > .messaging-drawer-summary::after {
    transform: rotate(-180deg);
}

.messaging-drawer[open] > .drawer-shell {
    margin-top: 10px;
}

/* ── Info Cards ────────────────────────────────────── */

.info-card {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-raised);
}

.panel-title {
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

.debug-toggle {
    min-height: 28px;
    padding: 4px 12px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── Content Boxes ─────────────────────────────────── */

.serverResponse,
.scores,
.audio,
.broadcast,
.auditorium,
.view {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font-size: 13px;
}

.drawer-shell .serverResponse,
.drawer-shell .broadcast,
.drawer-shell .auditorium {
    background: #1e2128;
    color: #d1d5db;
}

.drawer-shell table {
    color: #d1d5db;
}

.drawer-shell table th {
    color: #e8c06a;
}

.drawer-shell table td {
    color: #d1d5db;
    border-color: #4a4d55;
}

.drawer-shell tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.04);
}

.drawer-shell tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.08);
}

.scores,
.broadcast,
.auditorium,
.view {
    overflow: auto;
}

.scores {
    min-height: 100px;
    max-height: 260px;
}

.broadcast,
.auditorium {
    min-height: 80px;
    max-height: 200px;
}

.audio {
    display: grid;
    gap: 8px;
}

.audio-item {
    display: grid;
    gap: 4px;
}

audio {
    width: 100%;
    height: 30px;
}

.urlForLog {
    min-height: 36px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    background: var(--surface-raised);
    color: var(--text-secondary);
    font-size: 13px;
}

.view {
    display: none;
    min-height: 160px;
    max-height: 300px;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    font-size: 12px;
}

/* ── Help Bar ──────────────────────────────────────── */

.help-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    background: var(--surface);
}

.help-release {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.help-demo-link {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--accent-light);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}

.help-demo-link:hover {
    background: rgba(255,255,255,0.06);
}

.popup {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    background: var(--surface-raised);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.popup .popuptext {
    visibility: hidden;
    width: min(460px, calc(100vw - 40px));
    padding: 12px;
    position: absolute;
    z-index: 5;
    left: 0;
    bottom: calc(100% + 10px);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    background: var(--surface-raised);
    box-shadow: var(--shadow);
    color: var(--text);
}

.popup .popuptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 24px;
    border-width: 8px;
    border-style: solid;
    border-color: var(--surface-raised) transparent transparent transparent;
}

.popup .show {
    visibility: visible;
    animation: fadeIn 0.2s ease-out;
}

#shuffle-strat-click .popuptext {
    width: min(560px, calc(100vw - 40px));
}

.shuffle-strat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 4px;
}

.shuffle-strat-table th,
.shuffle-strat-table td {
    padding: 3px 5px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.shuffle-strat-table th {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 9px;
    letter-spacing: 0.3px;
}

.shuffle-strat-table tr:last-child td {
    border-bottom: none;
}

/* ── BID_SUITS ─────────────────────────────────────── */

#BID_SUITS input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

#BID_SUITS label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--surface-raised);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

#BID_SUITS label[for="P"] {
    min-width: 60px;
    font-size: 13px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

#BID_SUITS input[type="radio"]:checked + label {
    border-color: var(--accent);
    background: rgba(212, 168, 67, 0.15);
    box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.2);
}

/* ── Typography / Colors ───────────────────────────── */

label.red {
    color: #f06060;
    font-size: 18px;
}

label.black {
    color: var(--text);
    font-size: 18px;
}

span.red {
    color: #f06060;
    font-size: 20px;
}

span.black {
    color: #cdd2de;
    font-size: 20px;
}

span.blue {
    color: #7cacf8;
}

span.yellow {
    color: var(--accent-light);
}

span.green-background {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(42, 122, 74, 0.25);
    color: #8fd4a8;
    font-size: 13px;
}

a,
a:visited {
    color: var(--accent-light);
}

img.preload {
    display: none;
}

/* ── Tables ────────────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
}

table,
th,
td {
    border: 1px solid var(--border);
}

thead,
tfoot {
    background: var(--surface-raised);
}

th,
td {
    padding: 6px 8px;
    text-align: left;
    font-size: 13px;
}

tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.scoreboard-shell table {
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
    font-size: 12px;
}

.scoreboard-shell th {
    color: var(--accent-light);
    font-weight: 700;
}

/* ── Winner Banner ─────────────────────────────────── */

#winner-banner {
    display: none;
    position: absolute;
    top: 40%;
    z-index: 200;
    white-space: nowrap;
    pointer-events: none;
    text-align: center;
}

#winner-banner.running {
    display: block;
    animation: runnerSlide 2.8s linear forwards;
}

#winner-banner.game-won {
    display: block;
    left: 50%;
    top: 35%;
    transform: translate(-50%, -50%);
    padding: 22px 36px 18px;
    background: linear-gradient(145deg, rgba(18, 74, 44, 0.96), rgba(42, 122, 74, 0.96));
    border: 2px solid var(--accent);
    border-radius: 16px;
    box-shadow: 0 0 0 4px rgba(212, 168, 67, 0.22), 0 24px 60px rgba(0, 0, 0, 0.55);
    animation: gameWonPop 0.6s cubic-bezier(0.2, 1.4, 0.4, 1) both,
               gameWonGlow 2.4s ease-in-out 0.6s infinite alternate;
    /* Override the slide-variant's nowrap and let long names / many winners wrap inside the box */
    white-space: normal;
    max-width: min(92vw, 560px);
    box-sizing: border-box;
}

#winner-banner.game-won .runner-gif {
    width: 96px;
    height: 96px;
}

#winner-banner.game-won .runner-name {
    font-size: 22px;
    color: var(--accent-light);
    text-shadow: 0 2px 12px rgba(212, 168, 67, 0.45), 0 1px 6px rgba(0, 0, 0, 0.85);
    margin-top: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    line-height: 1.25;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.runner-gifs {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.runner-gif {
    width: 72px;
    height: 72px;
}

.runner-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 6px rgba(0,0,0,0.9);
    letter-spacing: 0.05em;
    margin-top: 2px;
    text-align: center;
}

@keyframes runnerSlide {
    from { left: -120px; }
    to   { left: 660px; }
}

@keyframes gameWonPop {
    0%   { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
    60%  { transform: translate(-50%, -50%) scale(1.08); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes gameWonGlow {
    from { box-shadow: 0 0 0 4px rgba(212, 168, 67, 0.22), 0 24px 60px rgba(0, 0, 0, 0.55); }
    to   { box-shadow: 0 0 0 8px rgba(232, 192, 106, 0.42), 0 24px 80px rgba(232, 192, 106, 0.28); }
}

/* ── Joined Toast ──────────────────────────────────── */

#joined-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-160%);
    z-index: 9999;
    min-width: 280px;
    background: linear-gradient(135deg, rgba(20, 40, 30, 0.96), rgba(36, 80, 55, 0.96));
    border: 2px solid rgba(120, 245, 170, 0.85);
    border-radius: 14px;
    padding: 14px 32px;
    box-shadow: 0 0 0 4px rgba(120, 245, 170, 0.20), 0 18px 50px rgba(0, 0, 0, 0.6);
    opacity: 0;
    text-align: center;
    pointer-events: none;
    transition: transform 0.45s cubic-bezier(0.2, 1.5, 0.4, 1), opacity 0.45s ease;
}

#joined-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    animation: joinedToastPulse 1.6s ease-in-out 0.6s 2 alternate;
}

.joined-toast-title {
    font-size: 20px;
    font-weight: 800;
    color: #78f5aa;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    text-shadow: 0 1px 8px rgba(120, 245, 170, 0.5);
}

.joined-toast-sub {
    font-size: 13px;
    font-weight: 600;
    color: #f4f0e2;
    margin-top: 4px;
    letter-spacing: 0.05em;
}

@keyframes joinedToastPulse {
    from { box-shadow: 0 0 0 4px rgba(120, 245, 170, 0.20), 0 18px 50px rgba(0, 0, 0, 0.6); }
    to   { box-shadow: 0 0 0 10px rgba(120, 245, 170, 0.50), 0 18px 60px rgba(120, 245, 170, 0.35); }
}

/* Host gets the gold treatment instead of the default green. */
#joined-toast.is-host {
    background: linear-gradient(135deg, rgba(46, 34, 14, 0.96), rgba(78, 56, 22, 0.96));
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(212, 168, 67, 0.22), 0 18px 50px rgba(0, 0, 0, 0.6);
}

#joined-toast.is-host.show {
    animation: joinedToastHostPulse 1.6s ease-in-out 0.6s 2 alternate;
}

#joined-toast.is-host .joined-toast-title {
    color: var(--accent-light);
    text-shadow: 0 1px 8px rgba(232, 192, 106, 0.55);
}

@keyframes joinedToastHostPulse {
    from { box-shadow: 0 0 0 4px rgba(212, 168, 67, 0.22), 0 18px 50px rgba(0, 0, 0, 0.6); }
    to   { box-shadow: 0 0 0 10px rgba(232, 192, 106, 0.55), 0 18px 60px rgba(232, 192, 106, 0.35); }
}

/* ── Confirm/Notice Modal ──────────────────────────── */

#confirm-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

#confirm-modal-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

#confirm-modal {
    min-width: 320px;
    max-width: 420px;
    background: linear-gradient(135deg, rgba(28, 32, 40, 0.98), rgba(46, 52, 64, 0.98));
    border: 2px solid rgba(244, 240, 226, 0.18);
    border-radius: 14px;
    padding: 22px 24px 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    color: #f4f0e2;
    transform: scale(0.96);
    transition: transform 0.18s ease;
}

#confirm-modal-overlay.show #confirm-modal {
    transform: scale(1);
}

.confirm-modal-title {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 10px;
    color: #f4f0e2;
}

.confirm-modal-message {
    font-size: 14px;
    line-height: 1.45;
    color: rgba(244, 240, 226, 0.85);
    margin-bottom: 18px;
}

.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-modal-actions button {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 8px;
    border: 1px solid rgba(244, 240, 226, 0.25);
    background: rgba(244, 240, 226, 0.08);
    color: #f4f0e2;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.confirm-modal-actions button:hover {
    background: rgba(244, 240, 226, 0.18);
    border-color: rgba(244, 240, 226, 0.45);
}

.confirm-modal-actions button:focus {
    outline: 2px solid rgba(120, 245, 170, 0.6);
    outline-offset: 2px;
}

.confirm-modal-actions .button-danger {
    background: #4a2828;
    border-color: #6b3535;
    color: #f0b0b0;
}

.confirm-modal-actions .button-danger:hover {
    background: #5e3030;
    border-color: #8a4040;
    color: #fdd;
}

/* ── Animations ────────────────────────────────────── */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blinkingText {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

@keyframes borderGlow {
    0%, 100% { box-shadow: 0 0 3px rgba(244, 200, 60, 0.3); }
    50%       { box-shadow: 0 0 10px rgba(244, 200, 60, 0.85), 0 0 3px rgba(244, 200, 60, 0.5) inset; }
}

/* ── Responsive ────────────────────────────────────── */

@media (max-width: 1280px) {
    .main-grid {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }

    .scoreboard-shell .scores {
        max-height: 280px;
    }
}

@media (max-width: 820px) {
    .app-shell {
        width: min(100vw - 12px, 1420px);
        margin: 6px auto 12px;
    }

    .login-bar {
        flex-direction: column;
    }

    .login-bar .field {
        flex: 1 1 100%;
    }

    .table-and-bid {
        flex-direction: column;
    }

    .table-side-panel {
        min-width: auto;
    }

    .game-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .game-actions {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .popup {
        width: 100%;
        justify-content: center;
    }

    .popup .popuptext {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* ── Bots panel (host, lobby, Kings) ───────────────── */

.bots-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 4px;
}

.bots-field label.names {
    font-size: 10px !important;
}

.bots-help {
    font-size: 10px;
    color: rgba(244, 240, 226, 0.55);
    margin: 4px 0;
}

.bots-message {
    font-size: 11px;
    margin-top: 4px;
    color: #f87171;
}

.bots-message.bots-message--ok {
    color: #86efac;
}

/* ── Lobby seat arrangement (host drags / taps seats to swap them) ── */

.lobby-seat--host::before {
    content: "\1F451\00a0";
}

.lobby-seat--draggable {
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.lobby-seat--dragging {
    opacity: 0.35;
    cursor: grabbing;
}

.lobby-seat--selected {
    border-color: rgba(244, 200, 60, 0.95) !important;
    box-shadow: 0 0 0 2px rgba(244, 200, 60, 0.55);
}

.lobby-seat--target {
    border-color: rgba(134, 239, 172, 0.95) !important;
    background: rgba(134, 239, 172, 0.25) !important;
}

.lobby-seat-ghost {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    transform: translate(-50%, -50%);
    padding: 4px 12px;
    border: 1px solid rgba(244, 200, 60, 0.9);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.8);
    color: #f4f0e2;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.bots-list {
    list-style: none;
    margin: 6px 0 0;
    padding: 0;
}

.bots-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 12px;
    padding: 2px 0;
}

.bots-list .bot-remove {
    padding: 0 6px;
    min-width: 0;
    line-height: 1.4;
    font-size: 11px;
}

/* Up & Down bot level after a seat label: a small letter (E / N / H), full name in the tooltip. */
.bot-level {
    display: inline-block;
    margin-left: 2px;
    padding: 0 3px;
    border-radius: 3px;
    font-size: 0.7em;
    font-weight: 700;
    line-height: 1.3;
    vertical-align: super;
    border: 1px solid rgba(244, 240, 226, 0.45);
    color: rgba(244, 240, 226, 0.9);
    cursor: help;
}

.bot-level--easy { border-color: rgba(134, 239, 172, 0.6); color: #86efac; }
.bot-level--normal { border-color: rgba(215, 177, 90, 0.6); color: #d7b15a; }
.bot-level--hard { border-color: rgba(248, 113, 113, 0.7); color: #f87171; }
.bot-level--expert { border-color: rgba(192, 132, 252, 0.75); color: #c084fc; }

/* ── Autopilot + host transfer ─────────────────────────────────────────────── */
.autopilot-row {
    display: none;   /* shown for seated players of Kings / Up & Down (syncAutopilotToggle) */
}

.autopilot-note {
    display: none;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(134, 239, 172, 0.12);
    border: 1px solid rgba(134, 239, 172, 0.4);
    color: #86efac;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.autopilot-message {
    font-size: 11px;
    color: #f87171;
}

.autopilot-message:empty {
    display: none;
}

.autopilot-message.autopilot-message--ok {
    color: #86efac;
}

.seats-list {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
}

.seats-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 12px;
    padding: 2px 0;
}

.seats-list label {
    flex: 1;
    cursor: pointer;
}

.host-transfer-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}

.host-transfer-row select {
    flex: 1;
    min-width: 0;
}

/* A seat the bot is playing: subtly dimmed with a dashed border. */
.seat-player--autopilot {
    border-style: dashed !important;
    opacity: 0.85;
}
