/* 
 * Catan Multiplayer - Colonist.io Style Theme
 */

:root {
    --color-ocean: #2b87b3;
    --color-ocean-dark: #1a6a8f;
    --color-ocean-light: #3d9ec8;
    --color-bg-dark: #2c3e50;
    --color-bg-medium: #34495e;
    --color-bg-light: #4a6278;
    --color-bg-panel: #e8e0d4;
    --color-bg-card: #ffffff;
    
    --color-primary: #f39c12;
    --color-primary-dark: #d68910;
    --color-primary-light: #f5b041;
    
    --color-text-dark: #2c3e50;
    --color-text-medium: #7f8c8d;
    --color-text-light: #bdc3c7;
    --color-text-white: #ffffff;
    
    --color-success: #27ae60;
    --color-danger: #c0392b;
    --color-warning: #f39c12;
    
    --color-wood: #2d7a3a;
    --color-brick: #b5432a;
    --color-ore: #6b7280;
    --color-wheat: #dbb540;
    --color-sheep: #6dbf47;
    --color-desert: #c8a85c;
    
    --player-red: #e74c3c;
    --player-blue: #3498db;
    --player-orange: #e67e22;
    --player-green: #27ae60;
    
    --sidebar-width: 300px;
    --bottom-bar-height: 90px;
    
    --font-main: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-display: 'Inter', 'Segoe UI', system-ui, sans-serif;
    
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-md: 0 3px 6px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.12);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.15), 0 3px 6px rgba(0,0,0,0.10);
    --border-radius: 8px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-main);
    background: var(--color-ocean);
    color: var(--color-text-dark);
    line-height: 1.5;
}

#app {
    height: 100%;
    position: relative;
}

/* Connection Status */
#connection-status {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    padding: 6px 12px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    background: rgba(0,0,0,0.6);
    color: white;
    backdrop-filter: blur(4px);
}

#connection-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-danger);
}

#connection-status.connected .status-dot {
    background: var(--color-success);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.screen.active {
    display: flex;
    opacity: 1;
}

/* ==================== LANDING SCREEN ==================== */
#landing-screen {
    background: linear-gradient(135deg, var(--color-ocean-dark) 0%, var(--color-ocean) 50%, var(--color-ocean-light) 100%);
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.landing-content {
    text-align: center;
    z-index: 10;
    padding: 40px;
    max-width: 420px;
    width: 100%;
}

.logo-container {
    margin-bottom: 40px;
}

.game-title {
    font-family: var(--font-display);
    font-size: 3.5rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 4px 8px rgba(0,0,0,0.3);
    letter-spacing: 0.15em;
    margin-bottom: 8px;
}

.game-subtitle {
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

.menu-container {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
}

.input-group {
    margin-bottom: 16px;
    text-align: left;
}

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

.input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: var(--border-radius);
    background: #fafafa;
    color: var(--color-text-dark);
    font-family: var(--font-main);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.input-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}

.input-group input::placeholder {
    color: #bbb;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(243, 156, 18, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(243, 156, 18, 0.5);
}

.btn-secondary {
    background: #f5f5f5;
    color: var(--color-text-dark);
    border: 2px solid #e0e0e0;
}

.btn-secondary:hover:not(:disabled) {
    background: #ebebeb;
    border-color: #ccc;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-icon {
    font-size: 1.1rem;
}

.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--color-text-light);
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

.divider span {
    padding: 0 12px;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.decorative-elements {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.hex-pattern {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150%;
    height: 150%;
    opacity: 0.1;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='115'%3E%3Cpolygon fill='none' stroke='%23ffffff' stroke-width='1' points='50,5 95,30 95,80 50,105 5,80 5,30'/%3E%3C/svg%3E");
    background-size: 100px 115px;
}

/* ==================== LOBBY SCREEN ==================== */
#lobby-screen {
    background: linear-gradient(135deg, var(--color-ocean-dark) 0%, var(--color-ocean) 100%);
    justify-content: center;
    align-items: center;
}

.lobby-container {
    background: white;
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 480px;
    width: 90%;
}

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

.lobby-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text-dark);
    margin-bottom: 16px;
}

.game-code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: var(--border-radius);
    border: 2px solid #e0e0e0;
}

.game-code-display .label {
    color: var(--color-text-medium);
    font-size: 0.9rem;
}

.game-code-display .code {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    letter-spacing: 0.15em;
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 1;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.player-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fafafa;
    border-radius: var(--border-radius);
    border: 2px solid transparent;
}

.player-slot.filled {
    background: white;
    border-color: #e0e0e0;
}

.player-slot.you {
    border-color: var(--color-primary);
    background: rgba(243, 156, 18, 0.05);
}

.player-color {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.8);
    box-shadow: var(--shadow-sm);
}

.player-name {
    flex: 1;
    font-weight: 500;
    color: var(--color-text-dark);
}

.player-tag {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    background: rgba(243, 156, 18, 0.15);
    padding: 3px 8px;
    border-radius: 10px;
    text-transform: uppercase;
}

.lobby-info {
    text-align: center;
    margin-bottom: 20px;
    color: var(--color-text-medium);
    font-size: 0.9rem;
}

.lobby-settings,
.lobby-settings-readonly {
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.lobby-settings h3,
.lobby-settings-readonly h3 {
    margin: 0 0 12px;
    font-size: 0.95rem;
    color: var(--color-text-dark);
}

.lobby-setting {
    margin-bottom: 12px;
}

.lobby-setting-row {
    display: flex;
    gap: 12px;
}

.lobby-setting-row .lobby-setting {
    flex: 1;
}

.lobby-setting label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-medium);
}

.lobby-setting input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
}

.lobby-settings-readonly p {
    margin: 0;
    color: var(--color-text-medium);
    font-size: 0.9rem;
}

.chat-message.system-message {
    background: rgba(52, 152, 219, 0.12);
    border-left: 3px solid var(--color-primary);
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}

.chat-message.system-message strong {
    color: var(--color-primary-dark);
}

.info-note {
    font-size: 0.8rem;
    margin-top: 4px;
    color: var(--color-text-light);
}

.lobby-actions {
    display: flex;
    gap: 12px;
}

.lobby-actions .btn {
    flex: 1;
}

/* ==================== GAME SCREEN ==================== */
#game-screen {
    background: #2d65a1;
}

.game-layout {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Left Sidebar */
.left-sidebar {
    width: 44px;
    background: rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 6px;
    z-index: 10;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: rgba(255,255,255,0.2);
}

.tool-btn.active {
    background: var(--color-primary);
}

/* Game Main Area */
.game-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Board Container */
.board-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-height: 0;
}

#game-board {
    width: 100%;
    height: 100%;
    max-width: 900px;
    max-height: 750px;
    cursor: grab;
    touch-action: none;
    /* Draw outside the SVG's own viewport box so a zoomed/panned board can fill
       the whole game area. Clipping is handled by .game-main (overflow: hidden)
       instead of this smaller box, which otherwise "cuts" the map. */
    overflow: visible;
}

#game-board.is-panning {
    cursor: grabbing;
}

/* Zoom/pan is a single transform on the viewport group. transform-box + a
   centred origin make the transform operate in the SVG user-coordinate space
   with the origin at user (0,0), matching the zoom-to-cursor math in game.js. */
#board-viewport {
    transform-box: view-box;
    transform-origin: 50% 50%;
    transition: transform 0.14s ease-out;
    will-change: transform;
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    right: 16px;
    bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
}

.zoom-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: #2c3e50;
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: background 0.15s, transform 0.1s;
}

.zoom-btn:hover {
    background: #ffffff;
}

.zoom-btn:active {
    transform: scale(0.94);
}

.zoom-btn.zoom-reset {
    font-size: 1.1rem;
}

/* ==================== BOTTOM BAR ==================== */
.bottom-bar {
    height: var(--bottom-bar-height);
    background: linear-gradient(180deg, rgba(30,50,65,0.85) 0%, rgba(20,35,50,0.95) 100%);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    gap: 12px;
}

/* Resource Cards - Colonist.io Style */
.resources-display {
    display: flex;
    gap: 5px;
    align-items: flex-end;
}

.resource-card {
    width: 56px;
    height: 74px;
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
    cursor: pointer;
    transition: transform 0.15s;
    border: 2px solid rgba(255,255,255,0.15);
    overflow: hidden;
}

.resource-card:hover {
    transform: translateY(-6px);
}

/* Per-resource backgrounds use the same gradient palette as the hex tiles
   (TILE_GRADIENTS in game.js), so the hand + bank cards visually match the map. */
.resource-card.wood  { background: linear-gradient(180deg, #8ed17a, #4a9a3a); }
.resource-card.brick { background: linear-gradient(180deg, #f0946a, #c65a30); }
.resource-card.ore   { background: linear-gradient(180deg, #c8ced4, #8590a0); }
.resource-card.wheat { background: linear-gradient(180deg, #f9d766, #d99a1e); }
.resource-card.sheep { background: linear-gradient(180deg, #c8e88f, #7fbf4a); }

.resource-card-icon {
    font-size: 2.2rem;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
    line-height: 1;
}

.resource-card-count {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 22px;
    height: 22px;
    background: #27ae60;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    padding: 0 4px;
    z-index: 2;
    border: 1.5px solid rgba(255,255,255,0.5);
}

.resource-card-count.zero {
    background: #95a5a6;
}

/* Action Buttons Bar */
.action-buttons-bar {
    display: flex;
    gap: 6px;
    align-items: center;
    background: rgba(0,0,0,0.3);
    padding: 6px 10px;
    border-radius: 12px;
}

.action-btn {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 2px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.08);
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.action-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

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

.action-btn:not(:disabled) {
    border-color: rgba(255,255,255,0.3);
}

.action-btn.roll:not(:disabled) {
    background: rgba(243, 156, 18, 0.3);
    border-color: var(--color-primary);
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(243, 156, 18, 0); }
    50% { box-shadow: 0 0 12px 2px rgba(243, 156, 18, 0.4); }
}

.action-btn.end-turn {
    background: rgba(192, 57, 43, 0.3);
}

.action-btn.end-turn:not(:disabled) {
    border-color: var(--color-danger);
    background: rgba(192, 57, 43, 0.5);
}

.action-btn.end-turn:hover:not(:disabled) {
    background: var(--color-danger);
}

/* Build cost tooltip */
.build-btn-wrap {
    position: relative;
    display: flex;
}

.build-cost-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: rgba(20, 24, 33, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 8px 10px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.12s ease, transform 0.12s ease;
    z-index: 50;
    white-space: nowrap;
}

.build-cost-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(20, 24, 33, 0.97);
}

.build-btn-wrap:hover .build-cost-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.build-cost-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.75);
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: 0.02em;
}

.build-cost-items {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.build-cost-items .cost-item {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.9rem;
    font-weight: 700;
    color: white;
}

.build-cost-items .cost-item img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

/* Turn + Dice Area */
.turn-dice-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.dice-display {
    display: flex;
    gap: 6px;
}

.die {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f0e6;
    color: #2c2416;
    border-radius: 8px;
    font-size: 1.3rem;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.5);
    border: 2px solid #c4a870;
}

.die.rolling {
    animation: diceRoll 0.4s ease-out;
}

@keyframes diceRoll {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(10deg) scale(1.1); }
    75% { transform: rotate(-10deg) scale(1.1); }
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0,0,0,0.3);
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}

.current-player-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: white;
}

.turn-text {
    display: flex;
    flex-direction: column;
}

.current-player-name {
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.2;
}

.turn-status {
    color: rgba(255,255,255,0.6);
    font-size: 0.75rem;
    line-height: 1.2;
}

/* ==================== RIGHT SIDEBAR ==================== */
.right-sidebar {
    width: var(--sidebar-width);
    background: var(--color-bg-panel);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-left: 1px solid #c4b99a;
}

.sidebar-section {
    border-bottom: 1px solid #c4b99a;
}

.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #d6cbb8;
    font-weight: 600;
    font-size: 0.78rem;
    color: #5a4e3a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.phase-badge {
    font-size: 0.7rem;
    background: rgba(0,0,0,0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.chat-toggle {
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Game Log */
.game-log-section {
    flex: 1;
    min-height: 120px;
    display: flex;
    flex-direction: column;
}

.game-log {
    padding: 6px 10px;
    overflow-y: auto;
    flex: 1;
    max-height: 240px;
    font-size: 0.78rem;
    background: #e0d8ca;
}

.log-entry {
    padding: 3px 0;
    color: #5a4e3a;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    display: flex;
    align-items: flex-start;
    gap: 5px;
    line-height: 1.35;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry .player-name {
    font-weight: 600;
    color: var(--color-text-dark);
}

.log-entry .log-icon {
    flex-shrink: 0;
}

/* Chat */
.chat-section {
    min-height: 100px;
}

.chat-messages {
    padding: 6px 10px;
    max-height: 70px;
    overflow-y: auto;
    font-size: 0.8rem;
    background: #e0d8ca;
}

.chat-input-container {
    display: flex;
    padding: 6px 10px;
    gap: 6px;
    background: #d6cbb8;
}

.chat-input {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #b8a88c;
    border-radius: 16px;
    font-size: 0.8rem;
    outline: none;
    background: #ede5d5;
}

.chat-input:focus {
    border-color: var(--color-primary);
    background: white;
}

.chat-send-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

/* Bank Supply + Scores Section */
.bank-scores-section {
    background: #c4b99a;
    padding: 6px 8px;
    border-bottom: 1px solid #a89a78;
}

.bank-supply-row {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}

.bank-icon {
    font-size: 1.3rem;
    margin-right: 2px;
    opacity: 0.7;
}

.bank-card {
    width: 42px;
    height: 56px;
    border-radius: 5px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
    border: 1.5px solid rgba(0,0,0,0.12);
    cursor: default;
}

/* Match hex tile gradients (same palette as .resource-card). devcard keeps its
   illustrated card-dev.png face and needs no background of its own. */
.bank-card.wood  { background: linear-gradient(180deg, #8ed17a, #4a9a3a); }
.bank-card.brick { background: linear-gradient(180deg, #f0946a, #c65a30); }
.bank-card.sheep { background: linear-gradient(180deg, #c8e88f, #7fbf4a); }
.bank-card.wheat { background: linear-gradient(180deg, #f9d766, #d99a1e); }
.bank-card.ore   { background: linear-gradient(180deg, #c8ced4, #8590a0); }

/* Illustrated card face - a full-card image containing baked-in border, colored
   background, and icon (used by bank supply, trade picker, trade rows, trade hand).
   Fills its parent card container (which already has position: relative + overflow: hidden).
   Uses object-fit: fill so the image's own baked-in border stays fully visible on all four
   sides even when the container's aspect ratio doesn't exactly match the artwork's. */
.card-face-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: fill;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
    border-radius: inherit;
}

/* Transparent map-tile icon centered on the card, used by the hand row and
   bank supply (see resourceIconHtml in game.js). Uses object-fit: contain so
   the icon keeps its aspect ratio inside cards with a slightly different
   aspect than the source PNG. */
.resource-card-icon-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 2px;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
}

.bank-card .resource-card-icon-img { padding: 1px; }

.bank-card-count {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 18px;
    height: 18px;
    background: #27ae60;
    border-radius: 9px;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    z-index: 1;
    border: 1px solid rgba(255,255,255,0.5);
}

/* Players Panel */
.players-panel {
    flex: 1;
    overflow-y: auto;
}

/* Player Card - Colonist.io Style */
.player-info-card {
    padding: 8px 10px;
    background: #d0c6b2;
    border-bottom: 1px solid #b8a88c;
}

.player-info-card.current-turn {
    background: #ddd4c0;
    box-shadow: inset 0 0 0 2px var(--color-primary);
}

.player-info-card.you {
    background: #ede5d5;
    border-left: 3px solid #3498db;
}

.player-card-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: #4a3e2a;
    margin-bottom: 4px;
    padding-left: 2px;
}

.player-card-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Avatar + VP section */
.player-card-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 46px;
}

.player-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.player-card-vp {
    background: white;
    border: 1px solid #aaa;
    border-radius: 3px;
    padding: 0 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #333;
    text-align: center;
    line-height: 1.6;
    margin-top: -4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Stat cards (resource count, dev card count) */
.player-card-stats {
    display: flex;
    gap: 6px;
    align-items: center;
    flex: 1;
}

.player-stat-card {
    position: relative;
    width: 34px;
    height: 46px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.player-stat-card.res-card {
    background: linear-gradient(180deg, #2471a3 0%, #2e86c1 50%, #3498db 100%);
    color: white;
    border: 1.5px solid #1a5276;
    font-weight: 700;
    font-family: serif;
}

.player-stat-card.dev-card {
    background: linear-gradient(180deg, #6c3483 0%, #7d3c98 50%, #8e44ad 100%);
    color: white;
    border: 1.5px solid #512e5f;
    overflow: hidden;
}

.player-stat-card .dev-card-inner {
    width: 22px;
    height: 22px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.player-stat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: #27ae60;
    border-radius: 9px;
    color: white;
    font-size: 0.6rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    z-index: 1;
    border: 1px solid rgba(255,255,255,0.5);
}

/* Building stats (settlements, roads) */
.player-building-stats {
    display: flex;
    gap: 12px;
    align-items: center;
}

.player-building-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.player-building-icon {
    font-size: 1rem;
    opacity: 0.5;
    line-height: 1.2;
}

.player-building-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: #5a4e3a;
    line-height: 1.2;
}

/* Achievements in player card */
.player-achievements {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    padding-left: 2px;
}

.achievement-badge {
    font-size: 0.75rem;
    opacity: 0.2;
}

.achievement-badge.active {
    opacity: 1;
}

/* ==================== SVG Board ==================== */
.ocean-bg {
    fill: var(--color-ocean);
}

/* Interactive top polygon: transparent fill so the tile body shows through,
   but keeps stroke + hover state + valid-robber-target animation fully visible. */
.hex-tile {
    fill: transparent;
    stroke: rgba(60, 44, 28, 0.55);
    stroke-width: 2;
    stroke-linejoin: round;
    cursor: pointer;
    transition: stroke 0.15s ease, stroke-width 0.15s ease;
}

.hex-tile:hover {
    stroke: var(--color-primary);
    stroke-width: 3.5;
}

/* Solid fallback colour beneath the resource gradient (shows if a <defs>
   gradient fails to resolve, which shouldn't happen in normal operation). */
.hex-tile-base.wood { fill: #4a9a3a; }
.hex-tile-base.brick { fill: #c65a30; }
.hex-tile-base.ore { fill: #8590a0; }
.hex-tile-base.wheat { fill: #d99a1e; }
.hex-tile-base.sheep { fill: #7fbf4a; }
.hex-tile-base.desert { fill: #c9a05a; }

/* The per-resource gradient body sits on top of the base fill. */
.hex-tile-gradient {
    pointer-events: none;
}

/* Soft white gloss overlay for a subtle glassy sheen at the top of each hex. */
.hex-tile-gloss {
    pointer-events: none;
    mix-blend-mode: screen;
}

/* Single resource icon painted in the upper portion of the hex. */
.tile-icon-img {
    pointer-events: none;
    filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

.tile-icon-img.has-robber {
    opacity: 0.55;
    filter: grayscale(0.4) drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

/* Number token — sits in the lower portion of the hex. */
.tile-number-bg {
    fill: #f7ecd2;
    stroke: #6e5a3a;
    stroke-width: 1.5;
    filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.3));
}

.tile-number {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    fill: var(--color-text-dark);
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.tile-number.high-prob {
    fill: var(--color-danger);
}

.probability-dots {
    font-size: 6px;
    fill: var(--color-text-medium);
    text-anchor: middle;
}

.probability-dots.high-prob {
    fill: var(--color-danger);
}

/* Vertices */
.vertex {
    fill: rgba(255, 255, 255, 0.2);
    stroke: rgba(255, 255, 255, 0.4);
    stroke-width: 1.5;
    cursor: pointer;
    transition: all 0.2s ease;
}

.vertex:hover {
    fill: var(--color-primary);
    r: 10;
}

.vertex.valid-placement {
    fill: rgba(39, 174, 96, 0.9);
    stroke: white;
    stroke-width: 3;
    filter: drop-shadow(0 0 8px rgba(39, 174, 96, 1));
    animation: pulse-vertex 1s infinite;
    cursor: pointer;
}

@keyframes pulse-vertex {
    0%, 100% { 
        r: 10;
        filter: drop-shadow(0 0 6px rgba(39, 174, 96, 0.8));
    }
    50% { 
        r: 14;
        filter: drop-shadow(0 0 12px rgba(39, 174, 96, 1));
    }
}

/* Edges */
.edge-click-target {
    cursor: pointer;
    pointer-events: stroke;
    transition: all 0.2s ease;
}

.edge-click-target.valid-road-target {
    cursor: pointer;
    animation: pulse-road-target 1.2s infinite;
}

@keyframes pulse-road-target {
    0%, 100% { 
        stroke: rgba(39, 174, 96, 0.25);
        stroke-width: 25;
    }
    50% { 
        stroke: rgba(39, 174, 96, 0.5);
        stroke-width: 35;
    }
}

.edge {
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 5;
    cursor: pointer;
    stroke-linecap: round;
    transition: all 0.2s ease;
    pointer-events: stroke;
}

.edge:hover, .edge-click-target:hover + .edge {
    stroke: var(--color-primary);
    stroke-width: 7;
}

.edge.valid-placement {
    stroke: rgba(39, 174, 96, 1);
    stroke-width: 10;
    filter: drop-shadow(0 0 6px rgba(39, 174, 96, 0.8));
    animation: pulse-edge 1s infinite;
}

@keyframes pulse-edge {
    0%, 100% { 
        stroke-width: 8;
        filter: drop-shadow(0 0 4px rgba(39, 174, 96, 0.6));
    }
    50% { 
        stroke-width: 12;
        filter: drop-shadow(0 0 10px rgba(39, 174, 96, 1));
    }
}

/* Roads */
.road {
    stroke-width: 8.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Thin dark outline drawn beneath the colored road for contrast against any tile. */
.road-casing {
    stroke: #3a2a1a;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
    filter: drop-shadow(0 1px 1.5px rgba(0, 0, 0, 0.35));
}

/* Slim white sheen on top of the road for a subtle beveled/3D look. */
.road-highlight {
    stroke: rgba(255, 255, 255, 0.4);
    stroke-width: 2.5;
    stroke-linecap: round;
    pointer-events: none;
}

/* Settlements */
.settlement {
    stroke: #333;
    stroke-width: 2;
    cursor: pointer;
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.3));
}

.settlement.valid-placement {
    cursor: pointer;
    animation: pulse-settlement 1s infinite;
    filter: drop-shadow(0 0 8px var(--color-success));
}

@keyframes pulse-settlement {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.settlement-click-target {
    cursor: pointer;
}

/* Cities */
.city {
    stroke: #333;
    stroke-width: 2;
    filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.3));
}

/* Robber - rendered as an <image>, so drop-shadow grounds it on the tile */
.robber {
    pointer-events: none;
    filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.55));
}

/* Ports */
.port-group line {
    stroke: #8b7355;
    stroke-width: 2;
    stroke-dasharray: 4,3;
}

.port-marker {
    fill: #f5e6c8;
    stroke: #8b7355;
    stroke-width: 2;
}

.port-text {
    font-size: 10px;
    font-weight: 700;
    fill: #5a4e3a;
    text-anchor: middle;
    dominant-baseline: middle;
}

.port-icon {
    font-size: 12px;
}

/* ==================== MODALS ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.modal-header h3, .modal-header h2 {
    font-weight: 700;
    color: var(--color-text-dark);
}

.close-btn {
    background: none;
    border: none;
    color: var(--color-text-medium);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f5f5f5;
    color: var(--color-text-dark);
}

.modal-body {
    padding: 24px;
}

/* Trade Panel - Colonist.io Style */
.trade-panel {
    background: #e8e0d0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    width: 90%;
    max-width: 580px;
    border: 2px solid #b8a88c;
}

.trade-picker-bar {
    background: #c4b99a;
    padding: 8px 12px;
    border-bottom: 2px solid #a89a78;
    display: flex;
    justify-content: center;
}

.trade-picker-cards {
    display: flex;
    gap: 5px;
}

.trade-picker-card {
    width: 52px;
    height: 66px;
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid rgba(0,0,0,0.1);
    transition: transform 0.12s, box-shadow 0.12s;
}

.trade-picker-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    border-color: var(--color-primary);
}

.trade-picker-card .tp-header { height: 32%; }
.trade-picker-card .tp-body {
    height: 68%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
}

.trade-picker-card.wood .tp-header { background: linear-gradient(180deg, #2d9a40, #238a32); }
.trade-picker-card.wood .tp-body { background: linear-gradient(180deg, #278a38, #1d6e2a); }
.trade-picker-card.brick .tp-header { background: linear-gradient(180deg, #a0785a, #8b6548); }
.trade-picker-card.brick .tp-body { background: linear-gradient(180deg, #a0785a, #8b6548); }
.trade-picker-card.sheep .tp-header { background: linear-gradient(180deg, #5dba42, #48a832); }
.trade-picker-card.sheep .tp-body { background: linear-gradient(180deg, #5dba42, #48a832); }
.trade-picker-card.wheat .tp-header { background: linear-gradient(180deg, #d4a820, #c49515); }
.trade-picker-card.wheat .tp-body { background: linear-gradient(180deg, #c9a030, #b89020); }
.trade-picker-card.ore .tp-header { background: linear-gradient(180deg, #8899a6, #6d7f8d); }
.trade-picker-card.ore .tp-body { background: linear-gradient(180deg, #8899a6, #6d7f8d); }
.trade-picker-card.devcard .tp-header { background: linear-gradient(180deg, #2471a3, #1a5276); }
.trade-picker-card.devcard .tp-body { background: linear-gradient(180deg, #2e86c1, #2471a3); }

.trade-body {
    display: flex;
}

.trade-rows-col {
    flex: 1;
    min-width: 0;
}

.trade-row {
    display: flex;
    align-items: center;
    min-height: 80px;
    padding: 8px 12px;
    background: #f0e8d8;
    border-bottom: 1px solid #d6cbb8;
    gap: 8px;
}

.trade-row-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 50px;
}

.trade-row-icon {
    font-size: 1.6rem;
}

.trade-row-label.want .trade-row-arrow {
    color: #27ae60;
    font-size: 1rem;
    font-weight: 700;
}

.trade-row-label.give .trade-row-arrow {
    color: #e74c3c;
    font-size: 1rem;
    font-weight: 700;
}

.trade-row-cards {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    flex: 1;
    min-height: 60px;
    align-items: center;
    padding: 4px;
}

.trade-card {
    width: 48px;
    height: 62px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.1s;
}

.trade-card:hover {
    transform: scale(1.08);
}

.trade-card .tc-header { height: 32%; }
.trade-card .tc-body {
    height: 68%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.trade-card.wood .tc-header { background: linear-gradient(180deg, #2d9a40, #238a32); }
.trade-card.wood .tc-body { background: linear-gradient(180deg, #278a38, #1d6e2a); }
.trade-card.brick .tc-header { background: linear-gradient(180deg, #a0785a, #8b6548); }
.trade-card.brick .tc-body { background: linear-gradient(180deg, #a0785a, #8b6548); }
.trade-card.sheep .tc-header { background: linear-gradient(180deg, #5dba42, #48a832); }
.trade-card.sheep .tc-body { background: linear-gradient(180deg, #5dba42, #48a832); }
.trade-card.wheat .tc-header { background: linear-gradient(180deg, #d4a820, #c49515); }
.trade-card.wheat .tc-body { background: linear-gradient(180deg, #c9a030, #b89020); }
.trade-card.ore .tc-header { background: linear-gradient(180deg, #8899a6, #6d7f8d); }
.trade-card.ore .tc-body { background: linear-gradient(180deg, #8899a6, #6d7f8d); }

.trade-card-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: #27ae60;
    border-radius: 9px;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    z-index: 1;
    border: 1.5px solid rgba(255,255,255,0.5);
}

.trade-hand-row {
    display: flex;
    align-items: center;
    min-height: 70px;
    padding: 8px 12px;
    background: #ede5d5;
    gap: 5px;
    border-top: 1px solid #d6cbb8;
}

.trade-hand-cards {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    align-items: center;
}

.trade-hand-card {
    width: 48px;
    height: 62px;
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    border: 2px solid rgba(0,0,0,0.15);
    cursor: pointer;
    transition: transform 0.1s;
}

.trade-hand-card:hover {
    transform: translateY(-4px);
    border-color: #e74c3c;
}

.trade-hand-card .th-header { height: 32%; }
.trade-hand-card .th-body {
    height: 68%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.trade-hand-card.wood .th-header { background: linear-gradient(180deg, #2d9a40, #238a32); }
.trade-hand-card.wood .th-body { background: linear-gradient(180deg, #278a38, #1d6e2a); }
.trade-hand-card.brick .th-header { background: linear-gradient(180deg, #a0785a, #8b6548); }
.trade-hand-card.brick .th-body { background: linear-gradient(180deg, #a0785a, #8b6548); }
.trade-hand-card.sheep .th-header { background: linear-gradient(180deg, #5dba42, #48a832); }
.trade-hand-card.sheep .th-body { background: linear-gradient(180deg, #5dba42, #48a832); }
.trade-hand-card.wheat .th-header { background: linear-gradient(180deg, #d4a820, #c49515); }
.trade-hand-card.wheat .th-body { background: linear-gradient(180deg, #c9a030, #b89020); }
.trade-hand-card.ore .th-header { background: linear-gradient(180deg, #8899a6, #6d7f8d); }
.trade-hand-card.ore .th-body { background: linear-gradient(180deg, #8899a6, #6d7f8d); }

.trade-hand-card .th-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: #27ae60;
    border-radius: 9px;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    z-index: 1;
    border: 1.5px solid rgba(255,255,255,0.5);
}

/* Trade Action Buttons Column */
.trade-actions-col {
    display: flex;
    flex-direction: column;
    width: 80px;
    border-left: 2px solid #c4b99a;
}

.trade-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all 0.15s;
    gap: 2px;
}

.trade-action-btn.bank {
    background: linear-gradient(180deg, #7ec8e3, #5bb5d5);
    border-bottom: 2px solid #c4b99a;
}

.trade-action-btn.offer {
    background: linear-gradient(180deg, #7ec8e3, #5bb5d5);
    border-bottom: 2px solid #c4b99a;
}

.trade-action-btn.cancel {
    background: linear-gradient(180deg, #ddd, #ccc);
}

.trade-action-btn:hover {
    filter: brightness(1.1);
}

.trade-action-main {
    font-size: 1.8rem;
}

.trade-action-badge {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #27ae60;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* Discard Modal */
.discard-resources {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 20px 0;
    justify-content: center;
}

.discard-resource-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.discard-resource-item input {
    width: 50px;
    padding: 8px;
    text-align: center;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.discard-total {
    text-align: center;
    margin: 16px 0;
    font-size: 1.1rem;
    font-weight: 600;
}

/* Trade Offer Display */
.offer-display {
    display: flex;
    align-items: center;
    gap: 20px;
    margin: 20px 0;
}

.offer-side {
    flex: 1;
    text-align: center;
    padding: 16px;
    background: #f9f9f9;
    border-radius: var(--border-radius);
}

.offer-side h4 {
    margin-bottom: 12px;
    color: var(--color-text-medium);
    font-size: 0.85rem;
}

.offer-arrow {
    font-size: 2rem;
    color: var(--color-text-light);
}

.offer-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.offer-actions .btn {
    flex: 1;
}

/* Game Over Modal */
.game-over-content {
    text-align: center;
}

.game-over-content h2 {
    font-size: 1.75rem;
}

.winner-announcement {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 24px 0;
}

.final-scores {
    margin: 24px 0;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f9f9f9;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.score-row:first-child {
    background: rgba(243, 156, 18, 0.1);
    border: 2px solid var(--color-primary);
}

.score-row .player-name {
    font-weight: 600;
}

.score-row .player-score {
    font-weight: 700;
    color: var(--color-primary);
}

/* ==================== TOASTS ==================== */
#toast-container {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 24px;
    background: rgba(0,0,0,0.8);
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    animation: toastSlideUp 0.3s ease;
    backdrop-filter: blur(4px);
    white-space: nowrap;
}

.toast.success {
    background: rgba(39, 174, 96, 0.9);
}

.toast.error {
    background: rgba(192, 57, 43, 0.9);
}

.toast.info {
    background: rgba(52, 152, 219, 0.9);
}

@keyframes toastSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #b8a88c;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #8a7a60;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .right-sidebar {
        width: 260px;
    }
}

@media (max-width: 900px) {
    .game-layout {
        flex-direction: column;
    }
    
    .left-sidebar {
        flex-direction: row;
        width: 100%;
        height: 44px;
        justify-content: center;
    }
    
    .right-sidebar {
        width: 100%;
        max-height: 180px;
    }
    
    .bottom-bar {
        height: 80px;
        padding: 0 8px;
    }
    
    .resource-card {
        width: 42px;
        height: 56px;
    }
    
    .action-btn {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
}

.hidden {
    display: none !important;
}

/* ==================== ROBBER ==================== */
.hex-tile.valid-robber-target {
    cursor: pointer;
    stroke: #e74c3c !important;
    stroke-width: 4 !important;
    animation: robber-pulse 1s ease-in-out infinite;
    filter: brightness(1.1) saturate(1.2);
}

.hex-tile.valid-robber-target:hover {
    filter: brightness(1.3) saturate(1.3);
    stroke: #c0392b !important;
    stroke-width: 5 !important;
}

.hex-tile-gradient.has-robber,
.hex-tile-base.has-robber {
    filter: brightness(0.72) saturate(0.85);
}

@keyframes robber-pulse {
    0%, 100% {
        stroke: #e74c3c;
        filter: brightness(1.1) drop-shadow(0 0 8px rgba(231, 76, 60, 0.8));
    }
    50% {
        stroke: #c0392b;
        filter: brightness(1.2) drop-shadow(0 0 12px rgba(231, 76, 60, 1));
    }
}

/* Steal Dialog */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.steal-dialog {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border-radius: 16px;
    padding: 24px;
    min-width: 300px;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 2px solid #e74c3c;
}

.steal-dialog h3 {
    color: #ecf0f1;
    text-align: center;
    margin: 0 0 20px 0;
    font-size: 1.4em;
}

.steal-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.steal-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.1);
    border: 3px solid;
    border-radius: 10px;
    color: #ecf0f1;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.steal-option:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

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

.steal-cancel {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: #bdc3c7;
    cursor: pointer;
    transition: all 0.2s ease;
}

.steal-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ecf0f1;
}

/* ==================== Trade Offers ==================== */
.trade-offers-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.trade-offer-bar {
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border-radius: 12px;
    padding: 12px 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 2px solid #3498db;
    animation: slideDown 0.3s ease-out;
}

.trade-offer-bar.hidden {
    display: none;
}

.trade-offer-bar.cannot-afford {
    opacity: 0.55;
    border-color: #7f8c8d !important;
    background: linear-gradient(135deg, #1e2a36, #263545);
}

.trade-offer-bar.cannot-afford .trade-accept-btn {
    background: linear-gradient(135deg, #7f8c8d, #95a5a6);
    cursor: not-allowed;
    box-shadow: none;
}

.trade-offer-bar.cannot-afford .trade-accept-btn:hover {
    transform: none;
    box-shadow: none;
}

.trade-afford-warning {
    color: #e67e22;
    font-size: 0.8em;
    font-weight: 600;
    text-align: right;
    padding-top: 4px;
}

.trade-resource-item.resource-short {
    background: rgba(231, 76, 60, 0.3);
    border: 1px solid rgba(231, 76, 60, 0.5);
}

.trade-resource-item .resource-deficit {
    font-size: 0.75em;
    color: #e74c3c;
    font-weight: 600;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.trade-offer-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.trade-offer-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ecf0f1;
    font-weight: 600;
}

.trade-icon {
    font-size: 1.3em;
}

.trade-from-name {
    color: #3498db;
    font-weight: 700;
}

.trade-label {
    color: #bdc3c7;
    font-weight: 400;
}

.trade-offer-resources {
    display: flex;
    gap: 16px;
    padding: 0 16px;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.trade-offer-give,
.trade-offer-want {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trade-direction {
    font-size: 1.2em;
    color: #e74c3c;
    font-weight: bold;
}

.trade-direction.trade-up {
    color: #2ecc71;
}

.trade-resources-list {
    display: flex;
    gap: 6px;
    align-items: center;
}

.trade-resource-item {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.95em;
}

.trade-resource-item .resource-icon {
    font-size: 1.1em;
}

.trade-resource-item .resource-count {
    color: #ecf0f1;
    font-weight: 600;
}

.trade-offer-actions {
    display: flex;
    gap: 8px;
}

.trade-accept-btn,
.trade-reject-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 1.3em;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.trade-accept-btn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
    box-shadow: 0 3px 10px rgba(39, 174, 96, 0.4);
}

.trade-accept-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.6);
}

.trade-reject-btn {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    color: white;
    box-shadow: 0 3px 10px rgba(231, 76, 60, 0.4);
}

.trade-reject-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.6);
}

.trade-pending-indicator {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 998;
    background: rgba(52, 152, 219, 0.9);
    border-radius: 8px;
    padding: 10px 20px;
    color: white;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.trade-pending-indicator .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Trade log entry */
.log-entry.trade-log {
    background: rgba(52, 152, 219, 0.1);
    border-left: 3px solid #3498db;
    padding-left: 6px;
    margin: 3px 0;
}

.trade-log-content {
    display: inline;
}

.trade-log-content strong {
    color: #3498db;
}

/* ==================== CARD FLIGHT FX ====================
 * Full-screen overlay hosting short-lived .flying-card elements animated
 * between the board and a player's hand / player-info-card. Positioned
 * fixed above the game UI, ignores pointer events so gameplay is unaffected.
 */
#fx-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9000;
    overflow: hidden;
}

.flying-card {
    position: fixed;
    width: 48px;
    height: 64px;
    border-radius: 6px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45), 0 0 0 1.5px rgba(255,255,255,0.25) inset;
    overflow: hidden;
    transform: translate(0, 0) scale(0.6);
    opacity: 0;
    transition:
        transform 620ms cubic-bezier(0.22, 0.61, 0.36, 1),
        opacity 620ms ease-out,
        box-shadow 620ms ease-out;
    will-change: transform, opacity;
    pointer-events: none;
    background: #1c2028;
}

.flying-card img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
}

/* Generic card back for opponents (hidden hand). Diagonal gradient with a big "?" */
.flying-card.back {
    background: linear-gradient(135deg, #d24545, #7a1e1e);
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.4rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.18);
}

.flying-card.out {
    filter: saturate(0.85);
}

/* Recipient card flash: green glow pulse on the hand card that received cards. */
.resource-card.flash {
    animation: hand-card-flash 700ms ease-out;
}

@keyframes hand-card-flash {
    0%   { box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 0 rgba(46, 204, 113, 0.65); }
    35%  { box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 22px 8px rgba(46, 204, 113, 0.55); }
    100% { box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 0 rgba(46, 204, 113, 0); }
}

/* Count-badge pop when a resource count changes. */
.resource-card-count.bump {
    animation: count-bump 380ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes count-bump {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.45); background: #f1c40f; }
    100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    .flying-card,
    .resource-card.flash,
    .resource-card-count.bump {
        animation: none !important;
        transition: none !important;
    }
    #fx-layer { display: none; }
}
