/* Catan Online - Modern Tabletop Styling */

:root {
    --bg-dark: #0b132b;
    --bg-surface: #1c2541;
    --bg-panel: #243054;
    --border-color: #3a506b;
    --accent-gold: #f1c40f;
    --accent-gold-hover: #f39c12;
    --accent-blue: #3a86ff;
    --accent-red: #e63946;
    --text-primary: #f8f9fa;
    --text-secondary: #ced4da;
    --text-muted: #6c757d;

    /* Player Colors */
    --catan-red: #e74c3c;
    --catan-blue: #3498db;
    --catan-orange: #e67e22;
    --catan-white: #ecf0f1;
    --catan-green: #2ecc71;
    --catan-brown: #8d6e63;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

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

.hidden {
    display: none !important;
}

/* ================= LOBBY SCREEN ================= */

.screen-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#view-lobby {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #1c2541 0%, #0b132b 100%);
    padding: 20px;
    overflow-y: auto;
}

.lobby-card {
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.lobby-header {
    text-align: center;
    margin-bottom: 28px;
}

.lobby-header h1 {
    font-size: 2.5rem;
    letter-spacing: 3px;
    color: var(--accent-gold);
    text-shadow: 0 2px 8px rgba(241, 196, 15, 0.4);
}

.lobby-header .subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: 6px;
}

.lobby-panels-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 28px;
}

@media (max-width: 768px) {
    .lobby-panels-grid {
        grid-template-columns: 1fr;
    }
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
}

.panel h2 {
    font-size: 1.3rem;
    color: var(--accent-gold);
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"], select {
    width: 100%;
    padding: 10px 14px;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus, select:focus {
    border-color: var(--accent-gold);
}

.radio-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-cards.mini {
    flex-direction: row;
}

.radio-card {
    display: flex;
    align-items: center;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-card input {
    margin-right: 12px;
    accent-color: var(--accent-gold);
}

.radio-card .card-content {
    display: flex;
    flex-direction: column;
}

.radio-card .card-content strong {
    font-size: 0.95rem;
    color: #fff;
}

.radio-card .card-content span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.radio-card:hover {
    border-color: var(--accent-gold);
    background: #16203a;
}

.host-info-box {
    margin-top: 20px;
    padding: 12px;
    background: rgba(58, 134, 255, 0.1);
    border-left: 4px solid var(--accent-blue);
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.4;
}

.host-info-box h3 {
    font-size: 0.9rem;
    color: var(--accent-blue);
    margin-bottom: 6px;
}

/* Waiting Lobby */
.waiting-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.waiting-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 18px;
}

.highlight-code {
    color: var(--accent-gold);
    background: #0f172a;
    padding: 4px 12px;
    border-radius: 6px;
    letter-spacing: 2px;
    font-family: monospace;
}

.lobby-player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 500px;
    margin: 16px auto;
}

.lobby-player-row {
    display: flex;
    align-items: center;
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 16px;
    gap: 12px;
}

.player-color-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
}

.bot-badge, .host-badge {
    margin-left: auto;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 2px 8px;
    border-radius: 4px;
}

.bot-badge {
    background: #6c757d;
    color: #fff;
}

.host-badge {
    background: var(--accent-gold);
    color: #000;
}

.host-controls-box {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ================= GAME SCREEN ================= */

#view-game {
    display: grid;
    grid-template-rows: 48px auto 1fr 88px;
    background: #0b2545;
}

.game-header {
    background: #134074;
    border-bottom: 2px solid #000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 10;
}

.game-header-left, .game-header-center, .game-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.game-logo {
    font-weight: 900;
    color: var(--accent-gold);
    letter-spacing: 1.5px;
    font-size: 1.1rem;
    margin-right: 6px;
}

.badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.turn-badge {
    background: var(--accent-gold);
    color: #000;
    font-weight: bold;
    font-size: 0.9rem;
}

.btn-header-icon {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.btn-header-icon:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Phase Banner */
.phase-banner {
    padding: 8px 16px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    z-index: 5;
}

.banner-normal {
    background: #1d3557;
    color: #f1faee;
}

.banner-setup {
    background: #2a9d8f;
    color: #fff;
}

.banner-alert {
    background: #e76f51;
    color: #fff;
    animation: banner-pulse 1.5s infinite;
}

.banner-robber {
    background: #d62828;
    color: #fff;
}

.banner-special {
    background: #6a4c93;
    color: #fff;
}

.banner-victory {
    background: #f1c40f;
    color: #000;
    font-weight: bold;
    font-size: 1.1rem;
}

@keyframes banner-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Cancel Placement Bar */
.cancel-placement-bar {
    position: absolute;
    top: 96px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    border: 2px solid var(--accent-gold);
    padding: 8px 18px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 20;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
}

.btn-cancel-mini {
    background: var(--accent-red);
    color: #fff;
    border: none;
    padding: 4px 10px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
}

/* Active Trade Banner */
.active-trade-banner {
    background: #3e2723;
    border-bottom: 2px solid var(--accent-gold);
    padding: 8px 16px;
    z-index: 8;
}

.trade-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    flex-wrap: wrap;
    gap: 10px;
}

.trade-banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-trade-yes {
    background: var(--catan-green);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.btn-trade-no, .btn-trade-cancel {
    background: var(--accent-red);
    color: #fff;
    border: none;
    padding: 5px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.btn-trade-accept-confirm {
    background: var(--accent-gold);
    color: #000;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

/* Main Workspace */
.game-main-area {
    display: grid;
    grid-template-columns: 1fr 320px;
    overflow: hidden;
    position: relative;
}

@media (max-width: 900px) {
    .game-main-area {
        grid-template-columns: 1fr 260px;
    }
}

@media (max-width: 700px) {
    .game-main-area {
        grid-template-columns: 1fr;
    }
    .game-sidebar {
        display: none; /* Hide sidebar on tiny screens to maximize board */
    }
}

.board-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #1b4965;
}

#catan-board-svg {
    width: 100%;
    height: 100%;
    cursor: grab;
}

#catan-board-svg:active {
    cursor: grabbing;
}

/* Sidebar */
.game-sidebar {
    background: var(--bg-surface);
    border-left: 2px solid #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
}

.players-section {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    max-height: 48%;
    overflow-y: auto;
}

.players-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.players-sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.player-sidebar-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-left-width: 6px;
    border-radius: 8px;
    padding: 8px 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.player-sidebar-card.active-turn {
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.6);
    border-color: var(--accent-gold);
}

.player-sidebar-card.special-turn {
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.6);
    border-color: #a855f7;
}

.player-sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.player-name {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-stats-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.player-badges-row {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.trophy-badge {
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
}

.road-badge {
    background: #e67e22;
    color: #fff;
}

.army-badge {
    background: #e74c3c;
    color: #fff;
}

/* Chat & Logs */
.log-chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.log-chat-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.log-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 0;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

.log-tab.active {
    color: var(--accent-gold);
    border-bottom: 2px solid var(--accent-gold);
    background: rgba(255, 255, 255, 0.05);
}

.messages-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #0f172a;
}

.log-line {
    color: #cbd5e1;
    line-height: 1.3;
}

.chat-line {
    line-height: 1.3;
    word-break: break-word;
}

.chat-time {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.chat-input-bar {
    display: flex;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
}

.chat-input-bar input {
    flex: 1;
    border-radius: 0;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-send {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    padding: 0 16px;
    cursor: pointer;
    font-weight: bold;
}

/* ================= BOTTOM HUD ================= */

.game-hud {
    background: #14213d;
    border-top: 2px solid #000;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    padding: 8px 16px;
    gap: 16px;
    z-index: 10;
}

@media (max-width: 800px) {
    .game-hud {
        grid-template-columns: 1fr;
        height: auto;
        padding: 6px;
        gap: 8px;
    }
}

/* Resource Hand */
.hud-resources-hand {
    display: flex;
    gap: 8px;
}

.res-card-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 70px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: default;
    transition: transform 0.15s;
}

.res-card-pill:hover {
    transform: translateY(-4px);
}

.res-wood  { background: linear-gradient(135deg, #2d6a4f, #1b4332); }
.res-brick { background: linear-gradient(135deg, #d97736, #b25d2b); }
.res-sheep { background: linear-gradient(135deg, #52b788, #2d6a4f); }
.res-wheat { background: linear-gradient(135deg, #e9c46a, #d4a373); color: #000; }
.res-ore   { background: linear-gradient(135deg, #6c757d, #495057); }

.res-icon { font-size: 1.4rem; }
.res-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; margin-top: 2px; }
.res-count { font-size: 1.1rem; font-weight: 800; margin-top: 2px; }

/* Dev Cards in Hand */
.hud-dev-cards-area {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding: 0 8px;
}

.dev-cards-title {
    font-size: 0.75rem;
    font-weight: bold;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.dev-cards-container {
    display: flex;
    gap: 8px;
    align-items: center;
}

.empty-cards-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-style: italic;
}

.dev-card-item {
    background: #0f172a;
    border: 1px solid var(--accent-gold);
    border-radius: 6px;
    padding: 4px 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.btn-play-dev {
    background: var(--accent-gold);
    color: #000;
    border: none;
    border-radius: 4px;
    padding: 2px 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.75rem;
}

.wait-label, .vp-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.vp-label {
    color: #2ecc71;
    font-weight: bold;
}

/* Action Buttons */
.hud-action-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.hud-btn {
    padding: 12px 18px;
    border-radius: 8px;
    border: none;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    transition: all 0.15s;
    white-space: nowrap;
}

.hud-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.5);
}

.btn-dice-roll {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    animation: btn-shake 2s infinite;
}

@keyframes btn-shake {
    0%, 90%, 100% { transform: rotate(0deg); }
    92% { transform: rotate(-3deg); }
    96% { transform: rotate(3deg); }
}

.btn-build-main {
    background: linear-gradient(135deg, #f39c12, #d35400);
    color: #fff;
}

.btn-trade-main {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: #fff;
}

.btn-end-main {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: #fff;
}

.btn-special-main {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
    color: #fff;
}

/* Build Popup Menu */
.build-btn-wrapper {
    position: relative;
}

.build-popup-menu {
    position: absolute;
    bottom: 56px;
    right: 0;
    background: var(--bg-panel);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 280px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    z-index: 30;
}

.build-menu-item {
    background: #0f172a;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: #fff;
    padding: 10px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.build-menu-item:hover:not(.disabled-btn) {
    background: #1e293b;
    border-color: var(--accent-gold);
}

.disabled-btn {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Common Buttons */
.btn-primary {
    background: var(--accent-gold);
    color: #000;
    border: none;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover {
    background: var(--accent-gold-hover);
}

.btn-secondary {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    font-weight: bold;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-large {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.btn-subtle {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
}

.btn-action {
    background: #0f172a;
    color: #fff;
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

/* ================= MODALS ================= */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: var(--bg-surface);
    border: 2px solid var(--accent-gold);
    border-radius: 14px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
}

.modal-wide {
    max-width: 680px;
}

.modal-header-with-close {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    line-height: 1;
}

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 14px;
}

/* Discard & Trade Counters */
.discard-counters-grid, .trade-res-counters {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 16px 0;
}

.discard-res-row, .trade-count-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0f172a;
    padding: 8px 12px;
    border-radius: 6px;
}

.counter-btns {
    display: flex;
    gap: 6px;
}

.counter-btns button {
    width: 28px;
    height: 28px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    line-height: 1;
}

/* Steal Targets */
.steal-targets-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}

.btn-steal-target {
    background: #0f172a;
    border: 2px solid;
    color: #fff;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.15s;
}

.btn-steal-target:hover {
    background: #1e293b;
}

/* Trade Modal Specifics */
.trade-modal-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.trade-tab-btn {
    flex: 1;
    background: #0f172a;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.trade-tab-btn.active {
    background: var(--bg-panel);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

.trade-split-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.trade-col h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.bank-rates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 8px;
    margin: 14px 0;
}

.bank-rate-badge {
    background: #0f172a;
    border: 1px solid var(--border-color);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    font-size: 0.8rem;
}

.bank-exchange-form {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.form-row select {
    width: 60%;
}

/* Victory Box */
.victory-box {
    text-align: center;
    padding: 40px 24px;
}

.trophy-icon {
    font-size: 4rem;
    margin-bottom: 12px;
    animation: trophy-bounce 1s infinite alternate;
}

@keyframes trophy-bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.winner-title {
    font-size: 1.2rem;
    margin: 16px 0 24px;
}

/* ================= SVG BOARD ANIMATIONS (GPU OPTIMIZED) ================= */

#catan-board-svg {
    will-change: transform;
    shape-rendering: geometricPrecision;
    text-rendering: optimizeLegibility;
}

#board-root {
    will-change: transform;
}

.pulse-vertex {
    animation: pulse-vertex-anim 0.9s infinite alternate ease-in-out;
    cursor: pointer;
    will-change: opacity, fill;
}

@keyframes pulse-vertex-anim {
    from { opacity: 0.7; fill: #f1c40f; }
    to { opacity: 1; fill: #e67e22; }
}

.pulse-road {
    animation: pulse-road-anim 0.8s infinite alternate ease-in-out;
    cursor: pointer;
    will-change: opacity;
}

@keyframes pulse-road-anim {
    from { opacity: 0.55; }
    to { opacity: 1; }
}

.pulse-hex {
    animation: pulse-hex-anim 1.1s infinite alternate ease-in-out;
    cursor: pointer;
    will-change: opacity;
}

@keyframes pulse-hex-anim {
    from { stroke: #f1c40f; opacity: 0.75; }
    to { stroke: #e74c3c; opacity: 1; }
}

.edge-click-target, .vertex-click-target {
    cursor: pointer;
}

.vertex-group:not(.vertex-selectable) .vertex-click-target {
    pointer-events: none;
}

.edge-group:not(.edge-selectable) .edge-click-target {
    pointer-events: none;
}

.edge-selectable {
    cursor: pointer;
}

.edge-selectable .edge-click-target {
    pointer-events: stroke;
    stroke: rgba(255, 255, 255, 0.01);
    stroke-width: 24;
}

.vertex-selectable {
    cursor: pointer;
}

.vertex-selectable .vertex-click-target {
    pointer-events: all;
}

/* Comfortable browser table, including small touch screens. */
:root { --accent-gold: #f4cb78; --accent-gold-hover: #e6b75b; --bg-dark: #0b1825; --bg-surface: #15283a; --bg-panel: #20394c; --border-color: #385364; }
body { background: radial-gradient(ellipse at top, #23485c, #0b1825 70%); }
button, input, select { font: inherit; }
button { transition: background .15s, transform .15s; }
button:not(:disabled):active { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #f4cb78; outline-offset: 3px; }
input, textarea, code { user-select: text; -webkit-user-select: text; }
.lobby-card { border-radius: 24px; box-shadow: 0 24px 90px #0006; border: 1px solid #63879a55; }
.lobby-header h1 { letter-spacing: .1em; }
.lobby-intro { margin-top: 14px; color: #c3d5df; line-height: 1.6; }
.panel { border-radius: 16px; }
.connection-status { position: fixed; bottom: 8px; left: 10px; z-index: 90; background: #402d22; color: #ffd49d; padding: 5px 10px; border-radius: 20px; font-size: 11px; pointer-events: none; }
.connection-status.connected { background: #123e35; color: #9de1c0; }
.app-toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; width: max-content; max-width: calc(100vw - 32px); padding: 16px 22px; background: #f4cb78; color: #172b3b; border-radius: 12px; box-shadow: 0 8px 40px #0006; }
#lobby-online-link, #lobby-wifi-link { overflow-wrap: anywhere; user-select: text; -webkit-user-select: text; }
.waiting-header { flex-wrap: wrap; gap: 10px; }
#catan-board-svg { touch-action: none; }
#btn-toggle-players { display: none; }
@media (max-width: 700px) {
    #btn-toggle-players { display: inline-block; }
    .game-header { flex-wrap: wrap; gap: 6px; padding: 8px; }
    .game-header-left, .game-header-right { flex-wrap: wrap; gap: 4px; }
    .game-header-center { width: 100%; order: 3; text-align: center; }
    .game-main-area { min-height: 180px; }
    .game-sidebar { display: none; }
    .show-sidebar .game-sidebar { display: flex; position: absolute; inset: 0 0 0 auto; width: min(340px, 92vw); z-index: 15; box-shadow: -10px 0 30px #0006; }
    .hud-resources-hand { justify-content: center; gap: 6px; }
    .res-card-pill { width: 52px; height: 52px; }
    .res-card-pill .res-icon { font-size: 1.15rem; }
    .hud-action-buttons { flex-wrap: wrap; justify-content: center; gap: 6px; }
    .hud-btn { min-height: 44px; padding: 8px 12px; }
    .hud-dev-cards-area { max-height: 64px; overflow: auto; }
    .game-hud { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
    .modal-box { max-height: 88dvh; overflow-y: auto; padding: 20px 14px; }
    .trade-split-grid { grid-template-columns: 1fr; }
    .trade-modal-tabs { flex-wrap: wrap; }
    .lobby-header h1 { font-size: 1.65rem; }
    input, select { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
#view-game { display: flex; flex-direction: column; height: 100dvh; }
.game-header, .phase-banner, .cancel-placement-bar, .active-trade-banner, .game-hud { flex-shrink: 0; }
.game-header { min-height: 48px; }
.game-main-area { flex: 1; min-height: 0; }
@media (max-width: 700px) { .game-header { min-height: 76px; } }
