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

/* ═══════════════════════════════════════════════════════
   БЛОК УПРАВЛЕНИЯ ТЕМОЙ
   ═══════════════════════════════════════════════════════ */
:root {
    --bg-deep: #0f0e0c; /* Убрали синий отлив */
    --bg-surface: rgba(20, 20, 18, 0.92); /* Убрали синий */
    --accent: #c9794f;
    --accent-light: #e0a97a;
    --accent-glow: rgba(201, 121, 79, 0.15);
    --text-primary: #e4e2de;
    --text-secondary: #8a847c; /* Сделали теплее */
    --border-subtle: rgba(255, 255, 255, 0.06);

    /* Специфичные для игры цвета */
    --color-success: #5a9e8f;
    --color-success-dim: rgba(90, 158, 143, 0.12);
    --color-danger: #b85450;
    --color-danger-dim: rgba(184, 84, 80, 0.1);
    --color-info: #7a9aad; /* Замена чисто синему */
    --color-info-dim: rgba(122, 154, 173, 0.15);
    --radius: 14px;
    --radius-sm: 10px;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    background: var(--bg-deep);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* ---- LOBBY ---- */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(12, 12, 10, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(12px);
}

.lobby-box {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    min-width: 350px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}

.lobby-box h2 {
    margin-bottom: 5px;
    color: var(--text-primary);
    font-weight: 700;
}

.lobby-hint {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 0.9em;
}

#lobby-players {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 224px; /* Фиксированная высота под 4 слота */
    margin-bottom: 24px;
}

.lobby-slot {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 12px;
    font-size: 0.95em;
}

.lobby-player {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
}

.lobby-player .dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lobby-slot.empty {
    border: 1px dashed rgba(255, 255, 255, 0.08);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85em;
    font-style: italic;
    justify-content: center;
    opacity: 0.5;
}

.lobby-waiting {
    color: var(--text-secondary);
    margin-top: 15px;
    font-style: italic;
}

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

.lobby-btn {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    transition:
        transform 0.18s,
        box-shadow 0.18s,
        background 0.2s;
}
.lobby-btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-deep);
    box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover {
    background: var(--accent-light);
}
.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ---- BOT PICKER MODAL ---- */
.bot-picker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}
.bot-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 15px 12px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.bot-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
    transform: translateY(-2px);
}
.bot-card-header {
    font-weight: 700;
    font-size: 1em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.bot-card-header span {
    font-size: 1.2em;
}
.bot-card-desc {
    font-size: 0.78em;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ---- TOP BAR ---- */
#top-bar {
    height: 50px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    backdrop-filter: blur(20px);
}

#turn-info {
    font-weight: 600;
    font-size: 1em;
    flex: 1;
}

.die {
    font-size: 1.8em;
    margin: 0 3px;
    transition: transform 0.3s;
}
.die.rolling {
    animation: roll 0.5s ease-out;
}
@keyframes roll {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.3);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

#phase-info {
    color: var(--accent-light);
    font-size: 0.9em;
    font-weight: 500;
}

/* ---- MAIN AREA ---- */
#main-area {
    display: flex;
    height: calc(100vh - 50px);
}

/* Players panel */
#players-panel {
    width: 220px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    padding: 10px;
    overflow-y: auto;
    backdrop-filter: blur(20px);
}

.player-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    transition:
        border-color 0.3s,
        box-shadow 0.3s;
}
.player-card.active {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}
.player-card.me {
    border-color: var(--color-info);
}

.player-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}
.player-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%; /* ← это делает круг, не прямоугольник */
    flex-shrink: 0;
    /* НЕ должно быть background: var(--accent) или подобного */
}
.player-name {
    font-weight: 600;
    font-size: 0.9em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.player-vp {
    background: var(--accent);
    color: var(--bg-deep);
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 0.8em;
    font-weight: 700;
}
.player-stats {
    font-size: 0.75em;
    color: var(--text-secondary);
    line-height: 1.4;
}
.player-badge {
    display: inline-block;
    background: var(--accent-glow);
    color: var(--accent-light);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.7em;
    margin-top: 3px;
}

/* Map */
#map-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}
#game-map {
    width: 100%;
    height: 100%;
    cursor: grab;
    user-select: none;
}
#game-map:active {
    cursor: grabbing;
}

.hex-tile {
    cursor: pointer;
    transition:
        opacity 0.3s,
        filter 0.2s;
}
.hex-tile polygon {
    stroke: rgba(255, 255, 255, 0.1);
    stroke-width: 1.5;
    transition:
        stroke 0.2s,
        stroke-width 0.2s,
        filter 0.2s;
}
.hex-tile:hover polygon {
    stroke: var(--accent-light);
    stroke-width: 2.5;
}
.hex-tile.clickable polygon {
    stroke: var(--color-success);
    stroke-width: 2;
    stroke-dasharray: 5, 3;
    animation: pulse-stroke 1.5s infinite;
}
.hex-tile.legal-target polygon {
    filter: drop-shadow(0 0 6px rgba(201, 121, 79, 0.55));
}

@keyframes pulse-stroke {
    0%,
    100% {
        stroke-opacity: 1;
    }
    50% {
        stroke-opacity: 0.4;
    }
}

.hex-number {
    font-size: 14px;
    font-weight: bold;
    fill: #fff;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}
.hex-number-bg {
    fill: rgba(0, 0, 0, 0.7);
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 1;
}
.hex-emoji {
    font-size: 20px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.vertex-dot {
    fill: rgba(255, 255, 255, 0.08);
    stroke: none;
    cursor: pointer;
    transition:
        fill 0.2s,
        r 0.2s,
        filter 0.2s;
}
.vertex-dot:hover {
    fill: rgba(255, 255, 255, 0.3);
}
.vertex-dot.clickable {
    fill: rgba(90, 158, 143, 0.4);
    stroke: var(--color-success);
    stroke-width: 1.5;
    animation: pulse-vertex 1.5s infinite;
}
.vertex-dot.legal-target {
    filter: drop-shadow(0 0 6px rgba(201, 121, 79, 0.55));
}
@keyframes pulse-vertex {
    0%,
    100% {
        r: 6;
    }
    50% {
        r: 9;
    }
}

.building {
    pointer-events: none;
}
.road-line {
    stroke-width: 4;
    stroke-linecap: round;
    pointer-events: none;
}

.edge-line {
    stroke: transparent;
    stroke-width: 12;
    stroke-linecap: round;
    cursor: pointer;
    transition:
        stroke 0.2s,
        filter 0.2s;
}
.edge-line:hover {
    stroke: rgba(255, 255, 255, 0.08);
}
.edge-line.clickable {
    stroke: rgba(90, 158, 143, 0.25);
    animation: pulse-edge 1.5s infinite;
}
.edge-line.legal-target {
    opacity: 0.5;
    filter: drop-shadow(0 0 6px rgba(201, 121, 79, 0.55));
}
@keyframes pulse-edge {
    0%,
    100% {
        stroke-opacity: 1;
    }
    50% {
        stroke-opacity: 0.3;
    }
}

/* Terrain Colors */
.terrain-forest {
    fill: #2d4a27;
}
.terrain-hills {
    fill: #6b3a1f;
}
.terrain-fields {
    fill: #8a7a32;
}
.terrain-pasture {
    fill: #4a7a4a;
}
.terrain-mountains {
    fill: #505050;
}
.terrain-desert {
    fill: #7a6a5a;
}
.terrain-ruins {
    fill: #4d3939;
}
.terrain-unknown {
    fill: #151a22;
}
.pirate-marker {
    font-size: 22px;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
    filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.8));
}

.hex-tile.just-rolled {
    animation: hex-glow-group 2s ease-out;
}
.hex-tile.just-rolled polygon {
    animation: hex-glow-stroke 2s ease-out;
}
@keyframes hex-glow-group {
    0% {
        filter: drop-shadow(0 0 10px var(--accent));
    }
    100% {
        filter: none;
    }
}
@keyframes hex-glow-stroke {
    0% {
        stroke: var(--accent);
        stroke-width: 4;
    }
    100% {
        stroke: rgba(255, 255, 255, 0.1);
        stroke-width: 1.5;
    }
}

/* Action panel */
#action-panel {
    width: 300px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    padding: 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    backdrop-filter: blur(20px);
}

#my-resources,
#my-cards {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 10px;
}
.res-title {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
}
.res-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.res-item {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
    font-size: 0.85em;
}
.res-icon {
    font-size: 1.1em;
}
.res-count {
    font-weight: bold;
    margin-left: auto;
}

.card-item {
    display: flex;
    align-items: center;
    gap: 5px;
    width: 100%;
    padding: 7px 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 0.8em;
    cursor: pointer;
    transition:
        background 0.2s,
        border-color 0.2s;
    color: var(--text-primary);
    text-align: left;
}
.card-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--color-info);
}
.card-item.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

#action-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.action-btn {
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85em;
    text-align: left;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}
.action-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--color-info);
}
.action-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.action-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg-deep);
    font-weight: 700;
}
.action-btn.primary:hover {
    background: var(--accent-light);
}
.action-btn.secondary {
    background: rgba(255, 255, 255, 0.06);
}
.action-btn.end-turn {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: #fff;
}
.action-btn .cost {
    margin-left: auto;
    font-size: 0.75em;
    color: var(--text-secondary);
}

.action-hint {
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
    background: var(--color-info-dim);
    border: 1px solid rgba(122, 154, 173, 0.2);
    color: var(--text-primary);
    font-size: 0.9em;
    line-height: 1.35;
}
.target-note {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Cost Reference */
.cost-ref {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
}
.cost-ref-title {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}
.cost-ref-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 0.75em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.cost-ref-row:last-child {
    border-bottom: none;
}
.cost-ref-name {
    color: var(--text-primary);
}
.cost-ref-icons {
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

/* ---- MODAL ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 25px;
    min-width: 300px;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.modal h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.modal-btn {
    padding: 10px 20px;
    background: var(--color-info);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    margin: 3px;
    font-size: 0.9em;
    transition:
        background 0.2s,
        transform 0.15s;
}
.modal-btn:hover {
    background: var(--text-secondary);
    transform: translateY(-1px);
}
.modal-btn.cancel {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}
.modal-btn.cancel:hover {
    background: rgba(255, 255, 255, 0.15);
}

.modal-resource-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}
.modal-resource-btn {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
    user-select: none;
}
.modal-resource-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--color-info);
}
.modal-resource-btn.selected {
    background: var(--color-success-dim);
    border-color: var(--color-success);
}
.modal-resource-btn.selected-give {
    outline: 2px solid var(--accent);
    background: var(--accent-glow);
}
.modal-resource-btn.selected-recv {
    outline: 2px solid var(--color-success);
    background: var(--color-success-dim);
}

/* Trade Banner */
#trade-banner {
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-surface);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 10px 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    width: max-content;
    max-width: 90%;
    backdrop-filter: blur(20px);
}
.trade-banner-text {
    font-size: 0.9em;
    text-align: center;
}
.trade-banner-items {
    font-size: 1.2em;
    letter-spacing: 2px;
}
.trade-banner-actions {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

/* ── Модалка предложения обмена ─────────────────────────── */
.trade-propose-columns {
    display: flex;
    gap: 16px;
    margin-bottom: 15px;
}
.trade-propose-col {
    flex: 1;
    min-width: 0;
}
.trade-propose-label {
    display: block;
    color: #888;
    font-size: 0.8em;
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.trade-pt-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.trade-pt-icon {
    width: 28px;
    font-size: 1.15em;
    text-align: center;
    flex-shrink: 0;
}
.trade-pt-btn {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    border-radius: 8px;
    font-size: 1em;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.15s,
        border-color 0.15s;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.trade-pt-btn:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}
.trade-pt-btn:active {
    transform: scale(0.92);
}
.trade-pt-val {
    min-width: 22px;
    text-align: center;
    font-weight: 700;
    font-size: 0.95em;
    color: var(--text-primary);
}
.trade-pt-have {
    font-size: 0.72em;
    color: var(--text-secondary);
    margin-left: 2px;
}
.trade-propose-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.trade-propose-actions .modal-btn {
    flex: 1;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Victory overlay */
#victory-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(8px);
}
.victory-box {
    text-align: center;
    padding: 50px;
}
.victory-box h1 {
    font-size: 3em;
    color: var(--accent-light);
    margin-bottom: 20px;
}
.victory-box p {
    font-size: 1.3em;
    color: var(--text-secondary);
}

/* ---- MOBILE ---- */
#mobile-players-strip,
#mobile-fab-area,
#bottom-nav,
#mobile-bottom-sheet,
#mobile-sheet-backdrop,
#mobile-log-panel {
    display: none;
}

@media (max-width: 1100px) {
    #top-bar,
    #players-panel,
    #action-panel,
    .chat-toggle,
    #desktop-chat-panel {
        display: none !important;
    }
    #mobile-players-strip {
        display: flex;
    }
    #mobile-fab-area {
        display: flex;
    }
    #bottom-nav {
        display: flex !important;
    }
    body {
        height: 100dvh;
        overflow: hidden;
    }
    #game-container {
        padding-top: 44px;
        padding-bottom: 56px;
        height: 100dvh;
        position: relative;
    }
    #main-area {
        height: calc(100dvh - 44px - 56px);
        display: block;
    }
    #map-container {
        width: 100%;
        height: 100%;
        position: relative;
    }

    /* BOTTOM NAV */
    #bottom-nav {
        display: none;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-surface);
        border-top: 1px solid var(--border-subtle);
        z-index: 600;
        backdrop-filter: blur(20px);
    }
    .bottom-nav-btn {
        position: relative;
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        font-size: 0.7em;
        font-weight: 500;
        color: var(--text-secondary);
        background: none;
        border: none;
        cursor: pointer;
    }
    .bottom-nav-btn .icon {
        font-size: 1.4em;
        margin-bottom: 2px;
    }
    .bottom-nav-btn.active {
        color: var(--accent-light);
    }

    .nav-badge {
        display: none;
        position: absolute;
        top: 4px;
        right: calc(50% - 20px);
        min-width: 16px;
        height: 16px;
        background: var(--color-danger);
        border-radius: 8px;
        font-size: 0.6em;
        color: white;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
        pointer-events: none;
        font-weight: bold;
        line-height: 1;
    }
    .nav-badge.visible {
        display: flex;
    }

    /* PLAYERS STRIP */
    #mobile-players-strip {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 44px;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border-subtle);
        z-index: 400;
        align-items: center;
        padding: 0 8px;
        gap: 6px;
        overflow-x: auto;
        scrollbar-width: none;
        backdrop-filter: blur(20px);
    }
    #mobile-players-strip::-webkit-scrollbar {
        display: none;
    }
    .mobile-player-chip {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 4px 8px;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border-subtle);
        flex-shrink: 0;
        font-size: 0.75em;
    }
    .mobile-player-chip.active-turn {
        border-color: var(--accent);
        box-shadow: 0 0 8px var(--accent-glow);
    }
    .mobile-player-chip.is-me {
        border-color: var(--color-info);
    }
    .mobile-player-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
    }
    .mobile-player-vp {
        font-weight: bold;
        color: var(--accent-light);
    }

    /* FABs */
    #mobile-fab-area {
        position: absolute;
        bottom: 16px;
        right: 16px;
        flex-direction: column;
        align-items: flex-end;
        gap: 10px;
        z-index: 300;
        pointer-events: none;
    }
    #mobile-primary-fab,
    #mobile-more-btn,
    .mobile-quick-btn {
        pointer-events: auto;
    }

    #mobile-primary-fab {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        border: none;
        background: var(--accent);
        color: var(--bg-deep);
        font-size: 1.8em;
        cursor: pointer;
        box-shadow: 0 4px 20px var(--accent-glow);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 2;
    }
    #mobile-primary-fab.fab-action {
        background: var(--color-info);
        box-shadow: 0 4px 20px rgba(122, 138, 158, 0.3);
    }
    #mobile-primary-fab.fab-end-turn {
        background: var(--color-danger);
        box-shadow: 0 4px 20px rgba(184, 84, 80, 0.3);
    }
    #mobile-primary-fab.fab-wait {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-secondary);
        box-shadow: none;
    }
    #mobile-primary-fab.fab-my-turn::after {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        border-radius: 50%;
        border: 2px solid var(--accent-light);
        animation: fab-pulse 2s ease-out infinite;
        opacity: 0;
        pointer-events: none;
    }
    @keyframes fab-pulse {
        0% {
            transform: scale(1);
            opacity: 0.7;
        }
        100% {
            transform: scale(1.6);
            opacity: 0;
        }
    }

    .mobile-quick-btn {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 0 12px;
        height: 40px;
        border-radius: 20px;
        border: 1px solid var(--border-subtle);
        background: var(--bg-surface);
        color: var(--text-primary);
        font-size: 0.85em;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
        animation: quick-btn-in 0.2s ease-out backwards;
        backdrop-filter: blur(16px);
    }
    .mobile-quick-btn .qb-cost {
        font-size: 0.75em;
        color: var(--text-secondary);
    }
    @keyframes quick-btn-in {
        from {
            opacity: 0;
            transform: translateY(10px) scale(0.9);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    /* BOTTOM SHEET */
    #mobile-sheet-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 700;
        display: none;
        opacity: 0;
        transition: opacity 0.25s;
    }
    #mobile-sheet-backdrop.visible {
        display: block;
        opacity: 1;
    }
    #mobile-bottom-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 56px;
        max-height: 75vh;
        background: rgba(18, 21, 30, 0.98);
        border-radius: 20px 20px 0 0;
        z-index: 800;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
        display: none;
        flex-direction: column;
        overflow: hidden;
        border-top: 1px solid var(--border-subtle);
    }
    #mobile-bottom-sheet.open {
        display: flex;
        transform: translateY(0);
    }
    #mobile-sheet-handle {
        width: 40px;
        height: 5px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 3px;
        margin: 10px auto;
    }
    #mobile-sheet-content {
        overflow-y: auto;
        padding: 0 20px 20px;
    }

    .sheet-section-title {
        font-size: 0.75em;
        color: var(--text-secondary);
        text-transform: uppercase;
        margin: 15px 0 10px;
        border-bottom: 1px solid var(--border-subtle);
        padding-bottom: 5px;
        font-weight: 700;
        letter-spacing: 0.06em;
    }
    .sheet-resource-row {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 6px 0;
        font-size: 0.9em;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    }
    .sheet-resource-row .sr-count {
        font-weight: bold;
        margin-left: auto;
    }
    .sheet-card-btn {
        width: 100%;
        padding: 12px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border-subtle);
        border-radius: 8px;
        margin-bottom: 8px;
        color: var(--text-primary);
        text-align: left;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .sheet-price-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 2px;
        font-size: 0.88em;
        border-bottom: 1px solid rgba(255, 255, 255, 0.04);
        color: var(--text-primary);
    }

    #mobile-log-panel,
    #mobile-players-full {
        position: fixed;
        left: 0;
        right: 0;
        top: 44px;
        bottom: 56px;
        background: var(--bg-deep);
        z-index: 500;
        display: none;
        overflow-y: auto;
    }
    #mobile-log-panel.visible,
    #mobile-players-full.visible {
        display: flex;
        flex-direction: column;
    }
    #mobile-log-messages {
        flex: 1;
        overflow-y: auto;
        padding: 15px;
        font-size: 0.85em;
    }
    #mobile-chat-area {
        display: flex;
        padding: 10px;
        gap: 8px;
        background: var(--bg-surface);
        border-top: 1px solid var(--border-subtle);
    }
    #mobile-chat-input {
        flex: 1;
        padding: 10px;
        background: rgba(0, 0, 0, 0.3);
        border: 1px solid var(--border-subtle);
        border-radius: 8px;
        color: white;
        outline: none;
    }

    .mobile-side-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: 1px solid var(--border-subtle);
        background: var(--bg-surface);
        color: var(--text-primary);
        font-size: 1.3em;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        backdrop-filter: blur(16px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
        pointer-events: auto;
        transition:
            background 0.15s,
            transform 0.15s;
        position: relative;
    }
    .mobile-side-btn:active {
        transform: scale(0.92);
        background: rgba(255, 255, 255, 0.08);
    }
    .mobile-side-btn-label {
        position: absolute;
        bottom: -16px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 0.55em;
        color: var(--text-secondary);
        white-space: nowrap;
        pointer-events: none;
    }
    .mobile-side-btn {
        animation: side-btn-in 0.2s ease-out backwards;
    }
    @keyframes side-btn-in {
        from {
            opacity: 0;
            transform: scale(0.7) translateX(15px);
        }
        to {
            opacity: 1;
            transform: scale(1) translateX(0);
        }
    }
    /* Мобильные всплывающие логи и позиционирование FAB-кнопок */
    #floating-log-container {
        position: fixed;
        top: 70px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        flex-direction: column;
        gap: 8px;
        z-index: 4500;
        pointer-events: none;
        width: 90%;
        max-width: 400px;
        align-items: center;
    }

    #mobile-fab-row {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    #mobile-side-actions {
        display: flex;
        flex-direction: row;
        gap: 8px;
        align-items: center;
    }

    #mobile-help-btn {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--bg-surface);
        border: 1px solid var(--border-subtle);
        color: var(--text-primary);
        font-size: 1.1em;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        backdrop-filter: blur(4px);
    }
    #trade-banner {
        top: 55px;
    }
    .trade-propose-columns {
        flex-direction: column;
        gap: 12px;
    }
    .trade-pt-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1em;
    }
}

/* Desktop Chat */
.chat-toggle {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    transition: all 0.2s ease;
    color: var(--text-primary);
    backdrop-filter: blur(16px);
}
.chat-toggle:hover {
    transform: scale(1.08);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}
.chat-toggle.active {
    border-color: var(--color-success);
}

.desktop-chat-panel {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(calc(100% + 40px));
    width: min(500px, 60vw);
    height: 550px; /* Было 400px */
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    z-index: 1500;
    opacity: 0;
    transition:
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease;
    pointer-events: none;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.6);
}
.desktop-chat-panel.open {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: all;
}
.desktop-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.desktop-chat-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.2s;
}
.desktop-chat-close:hover {
    color: var(--text-primary);
}
.desktop-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.desktop-chat-input-area {
    display: flex;
    padding: 10px 12px;
    gap: 8px;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.desktop-chat-input {
    flex: 1;
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: white;
    outline: none;
    font-size: 0.9em;
    transition: border-color 0.2s;
}
.desktop-chat-input:focus {
    border-color: var(--color-info);
}
.desktop-chat-input::placeholder {
    color: var(--text-secondary);
}
.desktop-chat-send {
    padding: 8px 16px;
    background: var(--accent);
    border: none;
    border-radius: 20px;
    color: var(--bg-deep);
    cursor: pointer;
    font-size: 1em;
    font-weight: 700;
    transition: opacity 0.2s;
}
.desktop-chat-send:hover {
    opacity: 0.85;
}

.chat-message {
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.85em;
    word-break: break-word;
}
.chat-message.system {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-style: italic;
}
.chat-message.player {
    background: var(--color-success-dim);
    border-left: 3px solid var(--color-success);
}
.chat-message.player strong {
    color: var(--color-success);
}

/* Floating logs */
.chat-log-container,
.sys-log-container {
    z-index: 5500 !important;
    pointer-events: none;
}
.port-indicator {
    font-size: 10px;
    text-anchor: middle;
    fill: #ffffff;
    pointer-events: none;
    filter: drop-shadow(
        0 1px 2px rgba(0, 0, 0, 0.8)
    ); /* Добавляет контраст на любом фоне */
}

/* Счетчик сброса карт в модалке */
.discard-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 3px 0;
}
.discard-controls button {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
}
.discard-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}
.discard-controls .count {
    width: 25px;
    text-align: center;
    font-weight: bold;
}

/* ── Лобби: слоты ──────────────────────────────────────────────────── */

.lobby-slot.empty.clickable {
    cursor: pointer;
    border: 1px dashed rgba(255, 255, 255, 0.15);
    transition:
        background 0.15s,
        border-color 0.15s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.lobby-slot.empty.clickable:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--accent);
}

.slot-plus {
    font-size: 1.4em;
    color: var(--text-secondary);
    opacity: 0.5;
    line-height: 1;
    flex-shrink: 0;
}

.slot-empty-text {
    flex: 1;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9em;
}

.slot-add-hint {
    font-size: 0.75em;
    color: var(--accent-light);
    opacity: 0;
    transition: opacity 0.15s;
}

.lobby-slot.empty.clickable:hover .slot-add-hint {
    opacity: 1;
}

.lobby-me-badge {
    color: var(--accent-light);
    font-size: 0.8em;
    font-weight: 400;
}

.lobby-bot-badge {
    font-size: 0.75em;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 1px 6px;
    margin-right: 6px;
}

.lobby-hint-text {
    color: var(--text-secondary);
    font-size: 0.85em;
    text-align: center;
    padding: 8px 0;
    font-style: italic;
}

/* ── Бот-пикер ─────────────────────────────────────────────────────── */

.bot-picker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.bot-card {
    padding: 14px 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    transition:
        background 0.15s,
        border-color 0.15s,
        transform 0.1s;
}

.bot-card:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.bot-card:active {
    transform: translateY(0);
}

.bot-card-icon {
    font-size: 2em;
    margin-bottom: 6px;
    line-height: 1;
}

.bot-card-name {
    font-weight: 700;
    font-size: 0.95em;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.bot-card-desc {
    font-size: 0.75em;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Блок «Об игре» (правая панель) ───────────────────────────────── */

.game-info-block {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    margin-bottom: 10px;
}

.game-info-goal {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    min-width: 80px;
}

.game-info-label {
    font-size: 0.65em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-bottom: 3px;
    white-space: nowrap;
}

.game-info-pts {
    font-size: 1.05em;
    color: var(--accent-light);
    font-weight: 800;
    white-space: nowrap;
}

.game-info-players {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1px;
    min-width: 0;
}

.game-info-diff {
    font-size: 0.8em;
    color: var(--accent-light);
    font-weight: 700;
    white-space: nowrap;
}

.game-info-mods-title {
    font-size: 0.62em;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-bottom: 5px;
}

.game-info-mods {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.game-info-mod-tag {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.72em;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    padding: 2px 7px;
    white-space: nowrap;
}
/* ── Инструменты комнаты (десктоп) ────────────────────────────────── */

.room-tools-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.tool-btn {
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.78em;
    font-weight: 600;
    transition:
        background 0.15s,
        color 0.15s,
        border-color 0.15s;
    white-space: nowrap;
}

.tool-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-primary);
}

.tool-btn.warn {
    color: #c8813a;
}

.tool-btn.warn:hover {
    color: #f0b36f;
    border-color: rgba(240, 179, 111, 0.25);
}

.tool-btn.danger {
    color: #a05050;
}

.tool-btn.danger:hover {
    color: #ff8f8f;
    border-color: rgba(255, 143, 143, 0.25);
}

/* ── Мобильные tool-кнопки в sheet ───────────────────────────────── */

.sheet-tool-warn {
    color: #f0b36f !important;
}

.sheet-tool-danger {
    color: #ff8f8f !important;
}

.road-line {
    stroke-width: 5px;
    stroke-linecap: round;
    pointer-events: none;
}

/* Тёмная подложка под дорогой — даёт контраст на любом фоне гекса */
.road-shadow {
    stroke-width: 9px; /* шире road-line на 4px с каждой стороны */
    stroke-linecap: round;
    pointer-events: none;
    display: none; /* скрыта по умолчанию, показывается из JS */
}

/* Вершины — куда можно поставить поселение/город */
.vertex-dot.legal-target {
    fill: rgba(255, 255, 255, 0.85);
    stroke: var(--accent);
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 5px var(--accent));
    animation: pulse-target 1.4s ease-in-out infinite;
}

/* Рёбра — куда можно построить дорогу */
.edge-line.legal-target {
    stroke: var(--accent-light);
    stroke-width: 8px;
    stroke-linecap: round;
    stroke-opacity: 0.55;
    filter: drop-shadow(0 0 4px var(--accent));
    animation: pulse-target 1.4s ease-in-out infinite;
}

/* Гексы — куда можно поставить пирата */
.hex-tile.legal-target polygon,
.hex-tile.legal-target .hex-poly {
    stroke: var(--accent-light);
    stroke-width: 3px;
    stroke-opacity: 0.7;
    filter: drop-shadow(0 0 6px var(--accent));
}

@keyframes pulse-target {
    0%,
    100% {
        opacity: 0.55;
    }
    50% {
        opacity: 0.9;
    }
}
