:root {
    --bg-0: #1b1410;
    --bg-1: #261a13;
    --bg-2: #34231a;
    --panel-0: #f6ead5;
    --panel-1: #edd7b3;
    --panel-2: #e2c99e;
    --ink-0: #1f1712;
    --ink-1: #4a3c31;
    --line-0: #9c6f2f;
    --line-1: #7d5524;
    --gold: #d9a34a;
    --gold-soft: #e8c888;
    --ember: #b84727;
    --ember-soft: #cf6a46;
    --ok: #2f6a3a;
    --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.28);
    --shadow-strong: 0 14px 34px rgba(0, 0, 0, 0.4);
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 9px;
    --type-display: "Optima", "Palatino Linotype", "Book Antiqua", serif;
    --type-rich-building: #a26a2c;
    --type-rich-spell: #2f6fb2;
    --type-rich-creature: #b85a5a;
    --type-rich-artifact: #3f8a49;
    --type-rich-hero: #9b67bd;
    --type-rich-bonus: #c18b1f;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    padding: 20px;
    color: var(--ink-0);
    font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
    background-attachment: fixed;
    background:
        radial-gradient(circle at 8% 5%, rgba(217, 163, 74, 0.14), transparent 34%),
        radial-gradient(circle at 92% -6%, rgba(184, 71, 39, 0.14), transparent 40%),
        radial-gradient(circle at 22% 115%, rgba(217, 163, 74, 0.1), transparent 46%),
        repeating-linear-gradient(0deg, rgba(255, 233, 186, 0.02) 0 1px, transparent 1px 11px),
        linear-gradient(160deg, var(--bg-0), var(--bg-1) 46%, var(--bg-2));
}

body.preGame {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

body.preGame > header {
    width: 100%;
    max-width: 500px;
}

body.preGame > main {
    display: none;
}

h1,
h3,
h4,
h5 {
    margin: 0;
}

h1 {
    font-family: var(--type-display);
    font-size: clamp(1.15rem, 1.7vw, 1.55rem);
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: #3f2a1c;
    text-shadow: 0 1px 0 rgba(255, 244, 223, 0.34);
}

.muted {
    color: var(--ink-1);
}

.topbar {
    border: 1px solid var(--line-0);
    border-radius: var(--radius-lg);
    padding: 14px 14px 12px;
    margin-bottom: 14px;
    background: linear-gradient(150deg, rgba(248, 236, 215, 0.98), rgba(237, 216, 179, 0.95));
    box-shadow: var(--shadow-strong);
    position: relative;
}

.topbar::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg, rgba(184, 71, 39, 0), rgba(184, 71, 39, 0.42), rgba(217, 163, 74, 0.75), rgba(184, 71, 39, 0.42), rgba(184, 71, 39, 0));
}

.topbarNav {
    margin-top: 8px;
    display: flex;
    gap: 10px;
}

.topbarNavLink {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    color: var(--ember);
    text-decoration: none;
    border: 1px solid var(--ember-soft);
    border-radius: 20px;
    min-height: 36px;
    padding: 6px 14px;
    transition: background 0.15s;
}

.topbarNavLink:hover {
    background: rgba(184, 71, 39, 0.08);
}

.topbarNavBtn {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
}

.howToPlayBackdrop {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(10, 8, 6, 0.62);
    z-index: 1200;
}

.howToPlayBackdrop.isOpen {
    display: flex;
}

.howToPlayModal {
    width: min(860px, 100%);
    max-height: 85vh;
    border: 1px solid var(--line-0);
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(246, 233, 208, 0.99), rgba(233, 211, 171, 0.96));
    box-shadow: var(--shadow-strong);
    overflow: hidden;
}

.howToPlayHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(125, 85, 36, 0.35);
    background: linear-gradient(140deg, rgba(255, 246, 229, 0.94), rgba(244, 227, 197, 0.9));
}

.howToPlayHeader h3 {
    font-family: var(--type-display);
    color: #3e2a1d;
    letter-spacing: 0.04em;
}

.howToPlayCloseBtn {
    border: 1px solid var(--line-0);
    border-radius: 10px;
    background: rgba(255, 248, 236, 0.92);
    color: var(--ink-0);
    font-weight: 600;
    padding: 7px 12px;
    cursor: pointer;
}

.howToPlayCloseBtn:hover {
    background: rgba(255, 248, 236, 1);
}

.howToPlayBody {
    padding: 14px 16px 18px;
    max-height: calc(85vh - 62px);
    overflow: auto;
    color: var(--ink-0);
    line-height: 1.45;
}

.howToPlayBody section + section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(125, 85, 36, 0.22);
}

.howToPlayBody h4 {
    margin: 0 0 6px;
    color: #4c311f;
}

.howToPlayBody ul,
.howToPlayBody ol {
    margin: 0;
    padding-left: 20px;
}

.howToPlayBody li + li {
    margin-top: 4px;
}

.feedbackModal {
    width: min(760px, 100%);
}

.feedbackForm {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.feedbackRow2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.feedbackForm label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--ink-0);
    font-size: 0.88rem;
    font-weight: 600;
}

.feedbackForm input,
.feedbackForm select,
.feedbackForm textarea {
    min-height: 38px;
    border: 1px solid var(--line-0);
    border-radius: 10px;
    background: rgba(255, 248, 236, 0.92);
    color: var(--ink-0);
    padding: 8px 10px;
    font: inherit;
}

.feedbackForm textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.4;
}

.feedbackConsent {
    justify-content: center;
}

.feedbackConsent input {
    min-height: 0;
}

.feedbackConsent span {
    font-weight: 500;
}

.feedbackStatus {
    min-height: 20px;
    color: var(--ink-1);
    font-size: 0.84rem;
}

.feedbackStatus.error {
    color: var(--ember);
}

.feedbackStatus.success {
    color: var(--ok);
}

.feedbackActions {
    display: flex;
    justify-content: flex-end;
}

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

.lbModal {
    width: min(760px, 100%);
}

.lbEmpty {
    color: var(--ink-1);
    font-style: italic;
    padding: 20px 0;
    text-align: center;
}

.lbTable {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 248, 236, 0.95);
    border: 1px solid var(--line-1);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.lbTable thead th {
    background: rgba(217, 163, 74, 0.15);
    color: var(--ink-1);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 10px 16px;
    text-align: left;
}

.lbTable thead th.thRight {
    text-align: right;
}

.lbTable tbody tr {
    border-top: 1px solid var(--line-1);
}

.lbTable tbody tr:first-child {
    border-top: none;
}

.lbTable td {
    padding: 11px 16px;
    font-size: 0.95rem;
    color: var(--ink-0);
}

.lbTable td.tdRight {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.lbRank {
    color: var(--ink-1);
    font-size: 0.85rem;
    width: 40px;
}

.lbRank.top3 {
    font-weight: 700;
    color: var(--gold);
}

.lbNameCell {
    font-weight: 600;
}

.lbNameCell.top1 {
    font-size: 1.05rem;
}

.lbNameCell .crown {
    color: var(--gold);
    margin-right: 6px;
}

.lbWinsBadge {
    display: inline-block;
    background: var(--gold-soft);
    color: var(--ink-0);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 20px;
    padding: 2px 12px;
}

.lbVpBadge {
    display: inline-block;
    background: rgba(184, 71, 39, 0.12);
    color: var(--ink-0);
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 20px;
    padding: 2px 12px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 10px 0;
}

.inputGroup {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 160px;
}

.inputGroup label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.roomCodeInput {
    display: flex;
    gap: 6px;
    align-items: center;
}

.toolbar input:not([type="checkbox"]) {
    height: 34px;
    min-width: 140px;
    padding: 0 10px;
    border: 1px solid var(--line-0);
    border-radius: 10px;
    background: rgba(255, 248, 236, 0.9);
    color: var(--ink-0);
}

.toolbar input:not([type="checkbox"]):focus-visible {
    outline: 2px solid rgba(217, 163, 74, 0.55);
    outline-offset: 1px;
}

.toolbar button {
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--line-0);
    border-radius: 10px;
    background: rgba(255, 248, 236, 0.9);
    color: var(--ink-0);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toolbar button:hover {
    background: rgba(255, 248, 236, 1);
    border-color: rgba(217, 163, 74, 0.6);
}

.toolbar button.primaryBtn {
    background: linear-gradient(135deg, rgba(217, 163, 74, 0.95), rgba(184, 123, 39, 0.9));
    border-color: rgba(184, 71, 39, 0.5);
    color: #fff;
    font-weight: 600;
}

.toolbar button.primaryBtn:hover {
    background: linear-gradient(135deg, rgba(217, 163, 74, 1), rgba(184, 123, 39, 1));
    box-shadow: 0 4px 12px rgba(184, 71, 39, 0.3);
}

.toolbar button.copyBtn {
    width: 34px;
    padding: 0;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.joinError {
    margin-top: 4px;
    margin-left: 0;
    padding: 6px 12px;
    color: #fff;
    background: rgba(217, 99, 74, 0.9);
    border: 1px solid rgba(184, 71, 39, 0.4);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.statusRow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.statusIndicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c44;
    animation: pulse-disconnected 2s ease-in-out infinite;
}

.statusIndicator.connected {
    background: #4c4;
    animation: pulse-connected 2s ease-in-out infinite;
}

@keyframes pulse-connected {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes pulse-disconnected {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.statusRow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    padding: 0 10px;
    border: 1px solid var(--line-0);
    border-radius: 999px;
    background: rgba(255, 244, 223, 0.88);
    color: #5b412b;
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.banner {
    margin-top: 9px;
    border: 1px solid var(--line-0);
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 600;
    background: linear-gradient(135deg, rgba(246, 218, 164, 0.94), rgba(231, 178, 97, 0.88));
    box-shadow: var(--shadow-soft);
}

.banner.gameOver {
    border-color: #b26a25;
    background: linear-gradient(135deg, rgba(247, 220, 168, 0.98), rgba(234, 185, 100, 0.92));
    box-shadow: 0 0 0 1px rgba(255, 236, 198, 0.56), 0 8px 18px rgba(217, 163, 74, 0.24);
}

.layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    align-items: start;
}

.playersGrid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 11px;
}

.playerPanel {
    border: 1px solid var(--line-0);
    border-radius: 16px;
    padding: 11px;
    background: linear-gradient(165deg, rgba(246, 233, 208, 0.97), rgba(233, 211, 171, 0.93));
    box-shadow: var(--shadow-soft);
    opacity: 0;
    transform: translateY(12px);
    animation: panelRise 380ms ease-out forwards;
}

.playerPanel.turnActive {
    border-color: #c38b3f;
    box-shadow: 0 0 0 1px rgba(223, 173, 83, 0.52), 0 0 16px rgba(230, 181, 91, 0.24), var(--shadow-soft);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.playerPanel.waitingOn {
    border-color: #79b6ef;
    box-shadow: 0 0 0 1px rgba(121, 182, 239, 0.55), 0 0 18px rgba(121, 182, 239, 0.3), var(--shadow-soft);
    transition: border-color 180ms ease, box-shadow 180ms ease;
}

.playerPanel.winnerPanel {
    border-color: #b26a25;
    box-shadow: 0 0 0 1px rgba(223, 173, 83, 0.6), 0 10px 26px rgba(217, 163, 74, 0.25);
}

.playerPanel.podiumPanel {
    box-shadow: 0 0 0 1px rgba(223, 173, 83, 0.36), 0 10px 22px rgba(0, 0, 0, 0.3);
}

.playerPanel[data-rank] .nameRow::after {
    content: attr(data-rank);
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 0 9px;
    border: 1px solid var(--line-0);
    border-radius: 999px;
    background: rgba(255, 244, 223, 0.88);
    color: #5b412b;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.playerPanel:nth-child(1) { animation-delay: 35ms; }
.playerPanel:nth-child(2) { animation-delay: 70ms; }
.playerPanel:nth-child(3) { animation-delay: 105ms; }
.playerPanel:nth-child(4) { animation-delay: 140ms; }
.playerPanel:nth-child(5) { animation-delay: 175ms; }
.playerPanel:nth-child(6) { animation-delay: 210ms; }

.playerPanel.defenderTargetSelected {
    position: relative;
    isolation: isolate;
    box-shadow: 0 0 0 2px rgba(255, 47, 47, 0.9), 0 0 10px rgba(255, 41, 41, 0.28), var(--shadow-soft);
}

.playerPanel.turnActive.defenderTargetSelected {
    box-shadow: 0 0 0 2px rgba(255, 47, 47, 0.8), 0 0 0 4px rgba(223, 173, 83, 0.44), 0 0 14px rgba(255, 41, 41, 0.24), var(--shadow-soft);
}

.playerPanel.waitingOn.defenderTargetSelected {
    box-shadow: 0 0 0 2px rgba(255, 47, 47, 0.8), 0 0 0 4px rgba(121, 182, 239, 0.45), 0 0 14px rgba(255, 41, 41, 0.24), var(--shadow-soft);
}

.playerPanel.defenderTargetSelected::after {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: 18px;
    border: 1px solid rgba(255, 47, 47, 0.35);
    box-shadow: 0 0 0 0 rgba(255, 47, 47, 0.22);
    animation: defenderTargetPulse 1200ms ease-in-out infinite;
    opacity: 0.45;
    pointer-events: none;
    z-index: 2;
}

.playerHeader {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px;
}

.nameRow {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px;
}

.incomingTargetPill {
    border-color: #a64222;
    background: linear-gradient(135deg, rgba(196, 84, 45, 0.24), rgba(184, 71, 39, 0.42));
    color: #6e2411;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.turnPill {
    border-color: #b5833c;
    background: linear-gradient(135deg, rgba(236, 194, 111, 0.45), rgba(224, 173, 79, 0.55));
    color: #5f3f16;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.thinkingPill {
    border-color: #6eaede;
    background: linear-gradient(135deg, rgba(187, 225, 255, 0.75), rgba(146, 202, 246, 0.72));
    color: #214f75;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.attackInfoLine {
    font-size: 11px;
    color: #6e2411;
    font-weight: 600;
    margin: 2px 0 6px;
    letter-spacing: 0.01em;
}

.name {
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.01em;
}

@keyframes turnPulse {
    0% {
        box-shadow: 0 0 0 1px rgba(223, 173, 83, 0.42), 0 0 10px rgba(230, 181, 91, 0.16), var(--shadow-soft);
    }
    50% {
        box-shadow: 0 0 0 1px rgba(223, 173, 83, 0.58), 0 0 18px rgba(230, 181, 91, 0.28), var(--shadow-soft);
    }
    100% {
        box-shadow: 0 0 0 1px rgba(223, 173, 83, 0.42), 0 0 10px rgba(230, 181, 91, 0.16), var(--shadow-soft);
    }
}

.meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 9px;
    font-size: 12px;
    color: var(--ink-1);
}

.aiProfileControl {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 8px;
    row-gap: 4px;
    margin: -1px 0 8px;
}

.aiProfileLabel {
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #70563d;
}

.aiProfileSelect {
    height: 28px;
    min-width: 120px;
    border: 1px solid var(--line-0);
    border-radius: 8px;
    padding: 0 8px;
    font-size: 12px;
    background: rgba(255, 248, 236, 0.92);
    color: var(--ink-0);
}

.aiRemoveBtn {
    height: 28px;
    border: 1px solid #c88b52;
    border-radius: 8px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(180deg, rgba(255, 237, 214, 0.96), rgba(246, 206, 157, 0.96));
    color: #6a3115;
}

.aiRemoveBtn:disabled {
    opacity: 0.62;
    cursor: default;
}

.aiProfileHint,
.aiTraceHint {
    grid-column: 1 / -1;
    font-size: 11px;
    line-height: 1.35;
    color: #7b654f;
}

.aiTraceHint {
    position: relative;
    color: #5c4836;
    background: rgba(255, 248, 236, 0.65);
    border: 1px dashed rgba(156, 111, 47, 0.4);
    border-radius: 8px;
    padding: 4px 7px 18px;
    white-space: normal;
    overflow: hidden;
    text-overflow: clip;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    cursor: pointer;
}

.aiTraceHint::after {
    content: "▼ more";
    position: absolute;
    bottom: 3px;
    right: 7px;
    font-size: 10px;
    color: #9c6f2f;
    background: rgba(255, 248, 236, 0.92);
    border-radius: 3px;
    padding: 0 3px;
    line-height: 1.5;
    pointer-events: none;
}

.aiTraceHint.isExpanded {
    display: block;
    overflow: visible;
    -webkit-line-clamp: unset;
    -webkit-box-orient: initial;
    padding-bottom: 18px;
}

.aiTraceHint.isExpanded::after {
    content: "▲ less";
}

.aiTraceSep {
    color: #9c7a52;
}

.aiTraceSeg {
    display: inline;
    border-radius: 4px;
    padding: 0 2px;
}

.aiTraceSeg-phase {
    color: #5a4432;
    font-style: italic;
}

/* main phase pick: amber/gold */
.aiTraceSeg-main {
    color: #8a5a10;
    background: rgba(217, 163, 74, 0.18);
}

/* attack-related: ember red */
.aiTraceSeg-attack,
.aiTraceSeg-sequence {
    color: #8c2c16;
    background: rgba(184, 71, 39, 0.14);
}

/* intervene: blue-grey */
.aiTraceSeg-intervene,
.aiTraceSeg-pass {
    color: #2f5a7a;
    background: rgba(70, 120, 180, 0.14);
}

/* roll/gift: soft green */
.aiTraceSeg-roll,
.aiTraceSeg-gift {
    color: #2e6035;
    background: rgba(60, 140, 70, 0.13);
}

/* fallback/idle: muted */
.aiTraceSeg-fallback,
.aiTraceSeg-idle {
    color: #7a6555;
    background: rgba(0, 0, 0, 0.05);
}

.aiProfileControl.readonly .aiProfileLabel {
    color: #8a6f53;
}

.aiProfileControl.readonly .aiProfileSelect {
    opacity: 0.72;
}

.aiProfileControl.readonly .aiRemoveBtn {
    opacity: 0.72;
}

.appToast {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 10010;
    max-width: min(360px, calc(100vw - 28px));
    border-radius: 10px;
    border: 1px solid var(--line-0);
    padding: 8px 11px;
    font-size: 12px;
    color: var(--ink-0);
    background: linear-gradient(180deg, #fff3de, #f2dab2);
    box-shadow: var(--shadow-soft);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: opacity 160ms ease, transform 160ms ease;
}

.appToast.show {
    opacity: 1;
    transform: translateY(0);
}

.appToast.success {
    border-color: #4d7f45;
    background: linear-gradient(180deg, #ecf6df, #d7ebc2);
}

.appToast.error {
    border-color: #ad4c33;
    background: linear-gradient(180deg, #f9e5dd, #efc9bc);
}

.zones {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-top: 8px;
}

.zone {
    border: 1px solid var(--line-0);
    border-radius: 12px;
    padding: 9px;
    background: linear-gradient(180deg, rgba(249, 240, 223, 0.95), rgba(238, 220, 187, 0.92));
}

.zone h5 {
    margin-bottom: 7px;
    color: #684a30;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hint {
    margin-top: 6px;
    color: var(--ink-1);
    font-size: 12px;
    line-height: 1.35;
}

.cards {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

#fateDeckButtons {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    width: 100%;
    max-width: 720px;
}

.fateDeckBtn {
    width: 100%;
}

.fateDeckBtn.fateDeckType-spell {
    border-left: 5px solid var(--type-rich-spell);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 178, 0.52);
}

.fateDeckBtn.fateDeckType-spell:hover:not(:disabled) {
    border-color: var(--type-rich-spell);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 178, 0.58), 0 6px 16px rgba(47, 111, 178, 0.38);
}

.fateDeckBtn.fateDeckType-artifact {
    border-left: 5px solid var(--type-rich-artifact);
    box-shadow: inset 0 0 0 1px rgba(63, 138, 73, 0.5);
}

.fateDeckBtn.fateDeckType-artifact:hover:not(:disabled) {
    border-color: var(--type-rich-artifact);
    box-shadow: inset 0 0 0 1px rgba(63, 138, 73, 0.54), 0 6px 16px rgba(63, 138, 73, 0.36);
}

.fateDeckBtn.fateDeckType-bonus {
    border-left: 5px solid var(--type-rich-bonus);
    box-shadow: inset 0 0 0 1px rgba(193, 139, 31, 0.5);
}

.fateDeckBtn.fateDeckType-bonus:hover:not(:disabled) {
    border-color: var(--type-rich-bonus);
    box-shadow: inset 0 0 0 1px rgba(193, 139, 31, 0.56), 0 6px 16px rgba(193, 139, 31, 0.36);
}

.fateDeckBtn.fateDeckType-building {
    border-left: 5px solid var(--type-rich-building);
    box-shadow: inset 0 0 0 1px rgba(162, 106, 44, 0.52);
}

.fateDeckBtn.fateDeckType-building:hover:not(:disabled) {
    border-color: var(--type-rich-building);
    box-shadow: inset 0 0 0 1px rgba(162, 106, 44, 0.58), 0 6px 16px rgba(162, 106, 44, 0.38);
}

.fateDeckBtn.fateDeckType-creature {
    border-left: 5px solid var(--type-rich-creature);
    box-shadow: inset 0 0 0 1px rgba(184, 90, 90, 0.5);
}

.fateDeckBtn.fateDeckType-creature:hover:not(:disabled) {
    border-color: var(--type-rich-creature);
    box-shadow: inset 0 0 0 1px rgba(184, 90, 90, 0.56), 0 6px 16px rgba(184, 90, 90, 0.38);
}

.fateDeckBtn.fateDeckType-hero {
    border-left: 5px solid var(--type-rich-hero);
    box-shadow: inset 0 0 0 1px rgba(155, 103, 189, 0.48);
}

.fateDeckBtn.fateDeckType-hero:hover:not(:disabled) {
    border-color: var(--type-rich-hero);
    box-shadow: inset 0 0 0 1px rgba(155, 103, 189, 0.54), 0 6px 16px rgba(155, 103, 189, 0.36);
}

.matchStatsGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 8px;
}

body.matchStatsFourPlus .matchStatsGrid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 680px) {
    body.matchStatsFourPlus .matchStatsGrid {
        grid-template-columns: 1fr;
    }
}

.matchStatItem {
    position: relative;
    border: 1px solid rgba(109, 78, 48, 0.16);
    border-radius: 10px;
    padding: 8px 10px;
    background: rgba(255, 248, 235, 0.82);
    cursor: default;
}

.matchStatItem[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 0;
    transform: none;
    width: max-content;
    max-width: 220px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid rgba(109, 78, 48, 0.22);
    background: #2a1f14;
    color: #f0e2c8;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.4;
    letter-spacing: 0;
    text-transform: none;
    white-space: normal;
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.playerPanel:has(.matchStatItem[data-tooltip]:hover) {
    position: relative;
    z-index: 120;
}

.matchStatLabel {
    display: block;
    color: var(--ink-1);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.matchStatValue {
    display: block;
    margin-top: 4px;
    color: var(--ink-0);
    font-size: 18px;
    line-height: 1.1;
}

#handControls .hint {
    flex-basis: 100%;
    margin-top: 2px;
}

#handControls .cards {
    flex-basis: 100%;
    width: 100%;
    margin-top: 2px;
}

.card {
    border: 1px solid var(--line-0);
    border-radius: 11px;
    padding: 6px 10px;
    background: linear-gradient(180deg, #fff7ea, #f4e3c2);
    color: var(--ink-0);
    font-size: 13px;
    line-height: 1.15;
    user-select: none;
    cursor: default;
    transition: transform 140ms ease, box-shadow 180ms ease, filter 140ms ease;
}

.card.white {
    background: linear-gradient(180deg, #fff8ec, #f5e7ca);
    color: var(--ink-0);
}

.card.black {
    border-color: #3a2b20;
    background: linear-gradient(160deg, #18130f, #2a211a);
    color: #f6ead2;
}

.card.cardType-building {
    border-left: 4px solid var(--type-rich-building);
}

.card.cardType-spell {
    border-left: 4px solid var(--type-rich-spell);
}

.card.cardType-creature {
    border-left: 4px solid var(--type-rich-creature);
}

.card.cardType-artifact {
    border-left: 4px solid var(--type-rich-artifact);
}

.card.cardType-hero {
    border-left: 4px solid var(--type-rich-hero);
}

.card.cardType-bonus {
    border-left: 4px solid var(--type-rich-bonus);
}

.card.black.cardType-building {
    box-shadow: inset 0 0 0 1px rgba(162, 106, 44, 0.46);
}

.card.black.cardType-spell {
    box-shadow: inset 0 0 0 1px rgba(47, 111, 178, 0.48);
}

.card.black.cardType-creature {
    box-shadow: inset 0 0 0 1px rgba(184, 90, 90, 0.46);
}

.card.black.cardType-artifact {
    box-shadow: inset 0 0 0 1px rgba(63, 138, 73, 0.48);
}

.card.black.cardType-hero {
    box-shadow: inset 0 0 0 1px rgba(155, 103, 189, 0.46);
}

.card.black.cardType-bonus {
    box-shadow: inset 0 0 0 1px rgba(193, 139, 31, 0.46);
}

.card .sub {
    margin-left: 6px;
    opacity: 0.9;
    font-size: 12px;
}

.card.clickable {
    cursor: pointer;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.card.clickable:hover {
    transform: translateY(-1px);
    filter: brightness(0.99);
}

.cardTooltip {
    position: fixed;
    z-index: 9999;
    display: none;
    max-width: 220px;
    padding: 6px 9px;
    border-radius: 7px;
    background: rgba(26, 19, 13, 0.95);
    color: #f7eddc;
    box-shadow: var(--shadow-strong);
    pointer-events: none;
    text-align: center;
    white-space: normal;
    font-size: 11px;
    line-height: 1.45;
}

.buffBadges {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

.buffBadge {
    display: inline-block;
    padding: 1px 6px;
    border: 1px solid rgba(181, 124, 28, 0.36);
    border-radius: 999px;
    background: rgba(228, 179, 88, 0.22);
    color: #855d1a;
    font-size: 10px;
    line-height: 1.4;
}

.card.black .buffBadge {
    border-color: rgba(230, 194, 130, 0.42);
    background: rgba(232, 191, 115, 0.2);
    color: #f1dab0;
}

.card.bubbled {
    position: relative;
    box-shadow: inset 0 0 0 2px #76abd2;
}

.card.bubbled::after {
    content: "Bubble";
    display: inline-block;
    margin-left: 8px;
    padding: 1px 5px;
    border: 1px solid rgba(91, 168, 212, 0.6);
    border-radius: 999px;
    background: rgba(91, 168, 212, 0.18);
    color: #2d6e9a;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.card.stunned {
    position: relative;
    opacity: 0.75;
}

.card.stunned::after {
    content: "Stunned";
    display: inline-block;
    margin-left: 8px;
    padding: 1px 5px;
    border: 1px solid rgba(176, 90, 42, 0.58);
    border-radius: 999px;
    background: rgba(206, 118, 65, 0.24);
    color: #6e3112;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.card.black.stunned::after {
    border-color: rgba(233, 176, 107, 0.68);
    background: rgba(233, 176, 107, 0.27);
    color: #f7ddb2;
}

.card.spent {
    position: relative;
    opacity: 0.73;
}

.card.spent::before {
    content: "Used";
    margin-right: 6px;
    padding: 1px 5px;
    border: 1px solid rgba(177, 127, 36, 0.48);
    border-radius: 999px;
    background: rgba(211, 169, 85, 0.16);
    color: #9a6d1f;
    font-size: 10px;
}

.card.black.spent::before {
    border-color: rgba(233, 197, 127, 0.52);
    background: rgba(233, 197, 127, 0.11);
    color: #e9c57f;
}

.card.selectedAttacker {
    box-shadow: 0 0 0 2px #9a2318 inset, 0 0 0 1px rgba(154, 35, 24, 0.34);
}

.selectedAttackerBadge {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 5px;
    border: 1px solid rgba(154, 35, 24, 0.48);
    border-radius: 999px;
    background: rgba(169, 56, 34, 0.18);
    color: #7a1f12;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.card.black .selectedAttackerBadge {
    border-color: rgba(236, 170, 131, 0.6);
    background: rgba(184, 83, 54, 0.34);
    color: #f5d5c4;
}

.card.targetedPending {
    position: relative;
    box-shadow: 0 0 0 2px #d08c2f inset, 0 0 0 1px rgba(208, 140, 47, 0.35);
}

.card.targetedPending::before {
    content: "Targeted";
    display: inline-block;
    margin-right: 6px;
    padding: 1px 5px;
    border: 1px solid rgba(208, 140, 47, 0.48);
    border-radius: 999px;
    background: rgba(216, 165, 87, 0.24);
    color: #6e4312;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.card.black.targetedPending::before {
    border-color: rgba(232, 181, 96, 0.68);
    background: rgba(232, 181, 96, 0.28);
    color: #f6dfb7;
}

.controlPanel {
    position: relative;
    z-index: 1;
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 13px;
    background:
        linear-gradient(170deg, rgba(252, 245, 233, 0.98), rgba(242, 227, 200, 0.96)) padding-box,
        linear-gradient(145deg, rgba(217, 163, 74, 0.46), rgba(184, 71, 39, 0.32)) border-box;
    box-shadow: var(--shadow-strong);
}

.controlPanel h3 {
    margin-bottom: 9px;
    color: #4f321d;
    font-family: var(--type-display);
    font-size: 1.18rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.controlHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.commandContext {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
}

.commandBanner {
    border: 1px solid rgba(173, 90, 47, 0.45);
    border-radius: 10px;
    padding: 6px 8px;
    background: linear-gradient(180deg, rgba(255, 242, 219, 0.95), rgba(246, 227, 193, 0.92));
    color: #5f3f28;
    font-size: 12px;
    line-height: 1.35;
}

.pendingChips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pendingChip {
    border: 1px solid rgba(156, 111, 47, 0.45);
    border-radius: 999px;
    padding: 2px 8px;
    background: rgba(255, 248, 236, 0.92);
    color: #6c533e;
    font-size: 11px;
    font-weight: 600;
}

.pendingChip.blocking {
    border-color: rgba(173, 90, 47, 0.5);
    background: rgba(247, 226, 197, 0.95);
    color: #6b3c1f;
}

.compactModeBtn {
    min-height: 30px;
    padding: 4px 9px;
    border-color: var(--line-0);
    background: linear-gradient(180deg, #fff4e2, #f1d4a7);
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#incomingPreview {
    margin-top: 4px;
    padding: 5px 7px;
    border: 1px dashed rgba(156, 111, 47, 0.38);
    border-radius: 8px;
    background: rgba(255, 248, 236, 0.68);
    color: #6b533f;
    line-height: 1.35;
    white-space: pre-line;
}

.compactModeBtn[aria-pressed="true"] {
    border-color: #ad5a2f;
    box-shadow: inset 0 0 0 1px rgba(173, 90, 47, 0.28);
    background: linear-gradient(180deg, #f2d5ac, #e2b56d);
}

.controlFrame {
    display: grid;
    gap: 10px;
    margin-top: 2px;
}

.controlCluster {
    border: 1px solid var(--line-0);
    border-radius: 12px;
    padding: 10px;
    background: linear-gradient(160deg, rgba(252, 244, 230, 0.96), rgba(241, 224, 194, 0.93));
    transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.controlCluster h4 {
    color: #65472f;
    font-size: 0.88rem;
    letter-spacing: 0.075em;
    text-transform: uppercase;
}

.controlCluster .hint {
    color: #856a49;
}

.controlCluster.isActive {
    border-color: #ad5a2f;
    box-shadow: 0 0 0 1px rgba(217, 163, 74, 0.46), 0 10px 20px rgba(184, 71, 39, 0.24);
    background: linear-gradient(160deg, rgba(255, 247, 236, 0.99), rgba(245, 224, 189, 0.97));
}

.controlCluster.isMuted {
    opacity: 0.72;
}

.controlsGrid {
    display: grid;
    gap: 7px;
    margin-top: 8px;
}

.controlsGrid-start {
    grid-template-columns: 1fr;
}

.controlsGrid-main,
.controlsGrid-combat {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.controlsGrid button {
    width: 100%;
}

.controlsGrid button.controlPriority {
    border-color: #ad5a2f;
    background: linear-gradient(180deg, #f7ddb0, #ecbf73);
    box-shadow: 0 0 0 1px rgba(184, 71, 39, 0.29), 0 8px 16px rgba(184, 71, 39, 0.22);
}

.controlsGrid button.controlPriority:hover:not(:disabled) {
    border-color: #923f19;
    box-shadow: 0 0 0 1px rgba(184, 71, 39, 0.4), 0 10px 18px rgba(184, 71, 39, 0.28);
}

.controlsGrid button.controlPriority:disabled {
    border-color: var(--line-0);
    background: linear-gradient(180deg, #f5e8d4, #ead8bc);
    box-shadow: none;
}

.controlsRow {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0;
}

.roomSettingsRow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin: 8px 0;
}

.lobbySettingsRow {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 6px !important;
    margin: 10px 0 !important;
    width: 100%;
    flex-basis: 100%;
}

.lobbyMaxPlayersField input {
    width: 58px;
    min-width: 50px;
    height: 22px;
    font-size: 11px;
}

.lobbyHint {
    margin-top: 8px;
}

.hostRoomPolicyRow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.hostRoomPolicyRow .roomSettingToggle,
.hostRoomPolicyRow .roomSettingField {
    min-height: 42px;
}
.hostRoomPolicyRow .roomSettingToggle {
    justify-content: flex-start;
    font-size: 12px;
    font-weight: 600;
    padding: 0 10px;
}
.hostRoomPolicyRow .roomSettingLabel {
    font-size: 10px;
    letter-spacing: 0.08em;
}

.commandHeadSetting {
    margin-left: auto;
    min-height: 30px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
}

.roomSettingField {
    display: grid;
    gap: 2px;
    border: 1px solid rgba(156, 111, 47, 0.35);
    border-radius: 8px;
    padding: 4px 6px;
    background: rgba(255, 248, 236, 0.72);
}

.roomSettingLabel {
    font-size: 8px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #795c40;
}

.roomSettingSelect {
    height: 30px;
    border: 1px solid var(--line-0);
    border-radius: 8px;
    padding: 0 8px;
    background: rgba(255, 248, 236, 0.92);
    color: var(--ink-0);
    font-size: 12px;
}

.roomSettingToggle {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(156, 111, 47, 0.35);
    border-radius: 8px;
    padding: 4px 8px;
    min-height: auto;
    background: rgba(255, 248, 236, 0.72);
    color: #5d4632;
    font-size: 11px;
    font-weight: 500;
    user-select: none;
}

.roomSettingToggle input {
    margin: 0;
    width: 16px;
    height: 16px;
}

.roomSettingToggle:has(input:disabled) {
    opacity: 0.6;
}

@supports not selector(:has(*)) {
    .roomSettingToggle input:disabled {
        opacity: 0.55;
    }
}

button {
    min-height: 33px;
    padding: 6px 11px;
    border: 1px solid var(--line-0);
    border-radius: 10px;
    background: linear-gradient(180deg, #fff8ec, #f5e4c7);
    color: var(--ink-0);
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: transform 130ms ease, box-shadow 160ms ease, border-color 150ms ease;
}

button:hover:not(:disabled) {
    border-color: #be8430;
    box-shadow: 0 6px 16px rgba(217, 163, 74, 0.4);
    transform: translateY(-1px);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.tutorialAutoTip {
    position: relative;
    z-index: 2;
}

button.tutorialAutoTip::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: calc(100% + 2px);
    transform: translateX(-50%);
    width: 10px;
    height: 10px;
    width: 58px;
    min-width: 50px;
    border-left: 1px solid rgba(156, 111, 47, 0.55);
    border-top: 1px solid rgba(156, 111, 47, 0.55);
    background: linear-gradient(180deg, #fff6e6, #f6dfb4);
    transform-origin: center;
    rotate: 45deg;
}

button.tutorialAutoTip::after {
    content: attr(data-autotip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    min-width: 170px;
    max-width: 240px;
    padding: 6px 8px;
    border: 1px solid rgba(156, 111, 47, 0.58);
    border-radius: 9px;
    background: linear-gradient(180deg, #fff6e6, #f6dfb4);
    color: #5b4129;
    font-size: 11px;
    line-height: 1.35;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 8px 18px rgba(95, 60, 24, 0.22);
    pointer-events: none;
    white-space: normal;
}

.handCardBtn.handType-spell {
    border-left: 5px solid var(--type-rich-spell);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 178, 0.5);
}

.handCardBtn.handType-artifact {
    border-left: 5px solid var(--type-rich-artifact);
    box-shadow: inset 0 0 0 1px rgba(63, 138, 73, 0.5);
}

.handCardBtn.handType-bonus {
    border-left: 5px solid var(--type-rich-bonus);
    box-shadow: inset 0 0 0 1px rgba(193, 139, 31, 0.5);
}

.handCardBtn.handType-spell:hover:not(:disabled) {
    border-color: var(--type-rich-spell);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 178, 0.56), 0 6px 16px rgba(47, 111, 178, 0.38);
}

.handCardBtn.handType-artifact:hover:not(:disabled) {
    border-color: var(--type-rich-artifact);
    box-shadow: inset 0 0 0 1px rgba(63, 138, 73, 0.56), 0 6px 16px rgba(63, 138, 73, 0.36);
}

.handCardBtn.handType-bonus:hover:not(:disabled) {
    border-color: var(--type-rich-bonus);
    box-shadow: inset 0 0 0 1px rgba(193, 139, 31, 0.56), 0 6px 16px rgba(193, 139, 31, 0.36);
}

.chaosCardBtn {
    border-color: #8f5430;
    background: linear-gradient(180deg, #f8e6cb, #ebc893);
    box-shadow: inset 0 0 0 1px rgba(184, 71, 39, 0.24);
}

.chaosCardBtn:hover:not(:disabled) {
    border-color: #a65c2f;
    box-shadow: inset 0 0 0 1px rgba(184, 71, 39, 0.3), 0 5px 14px rgba(184, 71, 39, 0.22);
}

button.handCardBtn:disabled {
    opacity: 0.72;
}

.handCard.selectedCard,
.handCardBtn.selectedCard {
    outline: 2px solid var(--ember);
    background: rgba(184, 71, 39, 0.12);
}

.stealTypeBtn {
    margin-left: 6px;
    margin-top: 4px;
    padding: 3px 8px;
    font-size: 12px;
}

.stealTypeBtn.handType-spell {
    border-left: 5px solid var(--type-rich-spell);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 178, 0.5);
}

.stealTypeBtn.handType-artifact {
    border-left: 5px solid var(--type-rich-artifact);
    box-shadow: inset 0 0 0 1px rgba(63, 138, 73, 0.5);
}

.stealTypeBtn.handType-bonus {
    border-left: 5px solid var(--type-rich-bonus);
    box-shadow: inset 0 0 0 1px rgba(193, 139, 31, 0.5);
}

.stealTypeBtn.handType-spell:hover:not(:disabled) {
    border-color: var(--type-rich-spell);
    box-shadow: inset 0 0 0 1px rgba(47, 111, 178, 0.56), 0 6px 16px rgba(47, 111, 178, 0.34);
}

.stealTypeBtn.handType-artifact:hover:not(:disabled) {
    border-color: var(--type-rich-artifact);
    box-shadow: inset 0 0 0 1px rgba(63, 138, 73, 0.56), 0 6px 16px rgba(63, 138, 73, 0.32);
}

.stealTypeBtn.handType-bonus:hover:not(:disabled) {
    border-color: var(--type-rich-bonus);
    box-shadow: inset 0 0 0 1px rgba(193, 139, 31, 0.56), 0 6px 16px rgba(193, 139, 31, 0.34);
}

.section {
    margin-top: 11px;
    padding-top: 10px;
    border-top: 1px solid rgba(217, 163, 74, 0.35);
}

.section h4 {
    margin-bottom: 2px;
    font-size: 1rem;
    color: #4f321d;
}

.section .hint {
    color: #6f5a42;
}

#checklist {
    white-space: pre-line;
    line-height: 1.4;
}

.matchSummaryList {
    margin: 8px 0 0;
    padding-left: 18px;
    display: grid;
    gap: 4px;
}

.matchSummaryList li {
    color: #5a4635;
    line-height: 1.35;
}

#defensePlanStatus {
    min-height: 1.2em;
    color: var(--ok);
    font-weight: 700;
}

#defensePlanSection {
    border-top: none;
    border: 1px solid rgba(156, 111, 47, 0.36);
    border-radius: 12px;
    padding: 10px 10px 12px;
    background: linear-gradient(165deg, rgba(250, 241, 225, 0.72), rgba(240, 224, 194, 0.62));
    overflow: hidden;
}

.defenseLists {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 8px;
}

.defenseOrder {
    display: grid;
    gap: 6px;
    margin-top: 6px;
}

.defenseRow {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px;
    align-items: center;
}

.defenseRowLabel {
    border: 1px solid var(--line-0);
    border-radius: 10px;
    padding: 6px 8px;
    background: rgba(247, 236, 216, 0.92);
    font-size: 12px;
}

.defenseMove {
    display: flex;
    gap: 4px;
}

.defenseMove button {
    min-width: 30px;
    padding: 4px 6px;
}

.stackRow {
    width: 100%;
    margin-top: 6px;
    text-align: left;
    background: rgba(247, 236, 216, 0.9);
}

.stackRow.current {
    border-color: #be8430;
    background: rgba(236, 218, 185, 0.96);
}

.activityToggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin: 8px 0;
}

.activityToggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #5a4635;
}

.activityHeadRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.activityRoundFilter {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: #5a4635;
}

.activityRoundFilter span {
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 11px;
}

.activityRoundFilter select {
    height: 28px;
    min-width: 110px;
    border: 1px solid var(--line-0);
    border-radius: 8px;
    padding: 0 8px;
    font-size: 12px;
    background: rgba(255, 248, 236, 0.92);
    color: var(--ink-0);
}

.activityFeed {
    width: 100%;
    min-height: 196px;
    max-height: 320px;
    border: 1px solid rgba(175, 123, 43, 0.45);
    border-radius: 14px;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(18, 14, 11, 0.98), rgba(31, 24, 18, 0.98));
    color: #f4ead7;
    font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    overflow-y: scroll;
    scrollbar-gutter: stable;
    white-space: pre-wrap;
    line-height: 1.4;
}

.activityEntry {
    margin: 0 0 4px;
}

.activityEntry:last-child {
    margin-bottom: 0;
}

.activityEntry-actions .activityLine {
    color: #f3ead7;
}

.activityEntry-debug .activityLine {
    color: #d6c6b0;
}

.activityEntry-chat .activityLine {
    color: #e6f1d1;
}

.activityTime {
    color: #d6c0a2;
}

.activityBadge {
    font-weight: 700;
}

.activityBadge-actions {
    color: #f0c46a;
}

.activityBadge-debug {
    color: #8db5df;
}

.activityBadge-chat {
    color: #86c28b;
}

.roundSeparator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0 12px 0;
    color: var(--line-0);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.roundSeparator::before,
.roundSeparator::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--line-0) 20%, var(--line-0) 80%, transparent);
}

.roundNumber {
    padding: 0 8px;
    background: var(--bg-0);
    position: relative;
    z-index: 1;
}

.feedCardRef {
    font-weight: 700;
}

.feedCardRef-spell {
    color: #79b8ff;
}

.feedCardRef-artifact {
    color: #7fd08c;
}

.feedCardRef-bonus {
    color: #f3cb67;
}

.feedCardRef-building {
    color: #d4a574;
}

.feedCardRef-creature {
    color: #e89a9a;
}

.feedCardRef-hero {
    color: #c9a3d9;
}

.feedMention {
    color: #ffd36f;
    font-weight: 700;
}

.activityFeed::-webkit-scrollbar {
    width: 10px;
}

.activityFeed::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}

.activityFeed::-webkit-scrollbar-thumb {
    background: rgba(234, 220, 199, 0.35);
    border-radius: 10px;
}

.activityFeed::-webkit-scrollbar-thumb:hover {
    background: rgba(234, 220, 199, 0.5);
}

.chatComposer {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-top: 8px;
    position: relative;
}

.chatComposerActions {
    display: flex;
    gap: 6px;
}

.chatComposer input {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line-0);
    border-radius: 10px;
    background: rgba(255, 248, 236, 0.92);
    color: var(--ink-0);
}

.chatComposer button {
    min-height: 34px;
    padding: 0 12px;
}

#chatEmojiBtn {
    min-width: 36px;
    padding: 0 8px;
    font-size: 18px;
    line-height: 1;
}

.chatEmojiMenu {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: min(320px, 88vw);
    display: grid;
    grid-template-columns: repeat(8, minmax(28px, 1fr));
    gap: 6px;
    border: 1px solid rgba(175, 123, 43, 0.45);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(23, 17, 13, 0.97), rgba(35, 26, 19, 0.97));
    padding: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
    z-index: 65;
}

.chatEmojiOption {
    border: 1px solid rgba(217, 163, 74, 0.2);
    border-radius: 8px;
    min-height: 30px;
    width: 100%;
    padding: 0;
    background: rgba(255, 248, 236, 0.06);
    color: #f1e2c8;
    font-size: 18px;
    line-height: 1;
    font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chatEmojiOption:hover,
.chatEmojiOption:focus-visible {
    border-color: rgba(255, 211, 111, 0.72);
    background: rgba(255, 211, 111, 0.14);
    color: #ffdc8f;
}

.chatMentionMenu {
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(100% + 8px);
    display: grid;
    gap: 4px;
    margin-top: 0;
    max-height: 154px;
    overflow-y: auto;
    border: 1px solid rgba(175, 123, 43, 0.45);
    border-radius: 10px;
    background: linear-gradient(180deg, rgba(23, 17, 13, 0.97), rgba(35, 26, 19, 0.97));
    padding: 6px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
    z-index: 60;
}

.chatMentionOption {
    border: 1px solid rgba(217, 163, 74, 0.25);
    border-radius: 8px;
    min-height: 30px;
    padding: 0 10px;
    background: rgba(255, 248, 236, 0.06);
    color: #f1e2c8;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
}

.chatMentionOption:hover,
.chatMentionOption.isActive {
    border-color: rgba(255, 211, 111, 0.72);
    background: rgba(255, 211, 111, 0.14);
    color: #ffdc8f;
}

@media (min-width: 980px) {
    .layout {
        grid-template-columns: minmax(620px, 1.75fr) minmax(360px, 1fr);
        gap: 14px;
    }

    .controlPanel {
        position: sticky;
        top: 12px;
        max-height: none;
        overflow: visible;
    }

    .defenseLists {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 979px) {
    body {
        padding: 12px;
    }

    .controlsGrid-main,
    .controlsGrid-combat {
        grid-template-columns: 1fr;
    }

    .controlPanel {
        order: -1;
    }

    .topbar {
        padding: 12px;
    }

    .toolbar {
        gap: 8px;
    }

    .toolbar input:not([type="checkbox"]) {
        min-width: 120px;
    }

    .toolbar button.primaryBtn {
        white-space: nowrap;
    }

    .roomSettingsRow {
        grid-template-columns: 1fr;
    }

    .hostRoomPolicyRow {
        grid-template-columns: 1fr;
    }
}

body.compactControls .controlPanel {
    padding: 9px;
}

body.compactControls .controlFrame {
    gap: 7px;
}

body.compactControls .controlCluster {
    padding: 7px;
}

body.compactControls .controlCluster .hint {
    display: none;
}

body.compactControls .controlsGrid {
    gap: 5px;
    margin-top: 6px;
}

body.compactControls button {
    min-height: 29px;
    padding: 4px 8px;
}

body.compactControls .section {
    margin-top: 8px;
    padding-top: 8px;
}

body.compactControls .cards {
    gap: 5px;
}

body.compactControls .card {
    padding: 4px 8px;
    font-size: 12px;
}

@keyframes panelRise {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

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

@keyframes defenderTargetPulse {
    0% {
        border-width: 1px;
        border-color: rgba(255, 47, 47, 0.35);
        box-shadow: 0 0 0 0 rgba(255, 47, 47, 0.1);
        opacity: 0.45;
    }

    50% {
        border-width: 3px;
        border-color: rgba(255, 47, 47, 0.95);
        box-shadow: 0 0 0 5px rgba(255, 47, 47, 0.16);
        opacity: 0.9;
    }

    100% {
        border-width: 1px;
        border-color: rgba(255, 47, 47, 0.35);
        box-shadow: 0 0 0 0 rgba(255, 47, 47, 0.1);
        opacity: 0.45;
    }
}

body.compact-mode-tournament {
    padding: 16px;
}

body.compact-mode-tournament .topbar {
    padding: 10px 11px;
    margin-bottom: 10px;
}

body.compact-mode-tournament .controlPanel {
    padding: 6px;
}

body.compact-mode-tournament .controlFrame {
    gap: 5px;
}

body.compact-mode-tournament .controlCluster {
    padding: 5px;
    border-radius: 10px;
}

body.compact-mode-tournament .controlCluster h4 {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
}

body.compact-mode-tournament .controlCluster .hint {
    display: none;
}

body.compact-mode-tournament .controlsGrid {
    gap: 4px;
    margin-top: 4px;
}

body.compact-mode-tournament .controlsGrid-main,
body.compact-mode-tournament .controlsGrid-combat {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.compact-mode-tournament button {
    min-height: 28px;
    padding: 3px 7px;
    font-size: 12px;
    letter-spacing: 0.005em;
}

body.compact-mode-tournament .playerPanel {
    padding: 8px;
    border-radius: 14px;
}

body.compact-mode-tournament .section {
    margin-top: 6px;
    padding-top: 6px;
    margin-bottom: 6px;
}

body.compact-mode-tournament .cards {
    gap: 4px;
}

body.compact-mode-tournament .card {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 11px;
}

body.compact-mode-tournament .playersGrid {
    gap: 8px;
}

body.compact-mode-stream {
    padding: 22px;
}

body.compact-mode-stream .topbar {
    padding: 16px 16px 14px;
    margin-bottom: 16px;
}

body.compact-mode-stream .controlPanel {
    padding: 12px;
}

body.compact-mode-stream .controlFrame {
    gap: 12px;
}

body.compact-mode-stream .controlCluster {
    padding: 11px;
    border-radius: 14px;
    background: linear-gradient(160deg, rgba(252, 244, 231, 0.94), rgba(242, 226, 197, 0.9));
}

body.compact-mode-stream .controlCluster h4 {
    margin-bottom: 6px;
    font-size: 0.95rem;
    letter-spacing: 0.065em;
}

body.compact-mode-stream .controlCluster .hint {
    margin-top: 6px;
    font-size: 12px;
}

body.compact-mode-stream .controlsGrid {
    gap: 8px;
    margin-top: 10px;
}

body.compact-mode-stream .controlsGrid-main,
body.compact-mode-stream .controlsGrid-combat {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.compact-mode-stream button {
    min-height: 36px;
    padding: 8px 12px;
    font-size: 14px;
    letter-spacing: 0.015em;
    font-weight: 600;
}

body.compact-mode-stream button.controlPriority {
    box-shadow: 0 0 0 1px rgba(143, 93, 26, 0.28), 0 8px 16px rgba(117, 81, 28, 0.18);
}

body.compact-mode-stream .playerPanel {
    padding: 13px;
    border-radius: 18px;
}

body.compact-mode-stream .section {
    margin-top: 12px;
    padding-top: 12px;
    margin-bottom: 10px;
}

body.compact-mode-stream .cards {
    gap: 8px;
}

body.compact-mode-stream .card {
    min-height: 28px;
    padding: 7px 11px;
    font-size: 13px;
}

body.compact-mode-stream .playersGrid {
    gap: 13px;
}

/* Floating Damage/Healing Numbers */
@keyframes floatingDamageUp {
    0% {
        transform: translate(-50%, -50%);
        opacity: 1;
        font-size: 2rem;
    }
    100% {
        transform: translate(-50%, calc(-50% - 72px));
        opacity: 0;
        font-size: 1.7rem;
    }
}

@keyframes floatingHealingUp {
    0% {
        transform: translate(0, 0);
        opacity: 1;
        font-size: 1.1rem;
    }
    100% {
        transform: translate(0, -60px);
        opacity: 0;
        font-size: 0.9rem;
    }
}

.floatingNumber {
    font-weight: 700;
    font-family: "Courier New", monospace;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.62);
    line-height: 1;
    letter-spacing: 0.05em;
    font-size: 2rem;
    white-space: nowrap;
    animation: floatingDamageUp 1.6s ease-out forwards;
}

.floatingNumber-damage {
    color: #cf6a46;
}

.floatingNumber-healing {
    color: #2f6a3a;
}

.floatingNumber-artifact {
    color: #d9a34a;
}

.boardTransferChip {
    position: fixed;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10020;
    padding: 12px 16px;
    border-radius: 12px;
    border: 2px solid rgba(217, 163, 74, 0.8);
    background: linear-gradient(150deg, rgba(44, 29, 21, 0.96), rgba(26, 19, 14, 0.96));
    color: #f0ddbf;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.44);
}

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

.chipCardName {
    font-size: 0.95rem;
    font-weight: 700;
    color: #f0ddbf;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
    text-align: center;
    max-width: 120px;
    line-height: 1.2;
}

.chipCardValues {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    font-size: 0.85rem;
    font-weight: 700;
}

.chipValue {
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
}

.chipValue.attack {
    background: rgba(207, 106, 70, 0.3);
    color: #cf6a46;
    border: 1px solid rgba(207, 106, 70, 0.5);
}

.chipValue.health {
    background: rgba(47, 106, 58, 0.3);
    color: #2f6a3a;
    border: 1px solid rgba(47, 106, 58, 0.5);
}

.zoneTransferPulse {
    animation: zoneTransferPulse 820ms ease-out;
}

@keyframes zoneTransferPulse {
    0% {
        box-shadow: inset 0 0 0 0 rgba(217, 163, 74, 0.55), 0 0 0 0 rgba(217, 163, 74, 0.25);
    }
    55% {
        box-shadow: inset 0 0 0 2px rgba(217, 163, 74, 0.9), 0 0 0 10px rgba(217, 163, 74, 0);
    }
    100% {
        box-shadow: inset 0 0 0 0 rgba(217, 163, 74, 0), 0 0 0 0 rgba(217, 163, 74, 0);
    }
}

/* VP Milestone Pulse */
@keyframes vpPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes vpGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(217, 163, 74, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(217, 163, 74, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(217, 163, 74, 0);
    }
}

#p0Vp.vpMilestonePulse,
#p1Vp.vpMilestonePulse,
#p2Vp.vpMilestonePulse,
#p3Vp.vpMilestonePulse,
#p4Vp.vpMilestonePulse,
#p5Vp.vpMilestonePulse {
    animation: vpPulse 0.5s ease-out;
}

#p0VpLabel.vpMilestonePulse,
#p1VpLabel.vpMilestonePulse,
#p2VpLabel.vpMilestonePulse,
#p3VpLabel.vpMilestonePulse,
#p4VpLabel.vpMilestonePulse,
#p5VpLabel.vpMilestonePulse {
    animation: vpGlow 0.5s ease-out;
}
