html,body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background: #0f172a; /* dark slate background outside the map */
    color: #e5e7eb;
}

:root {
    /* Default occupant bubble scale; JS will update this once per zoom change */
    --occ-scale: 1.3;
    /* Global size multiplier to make bubble and avatars larger */
    --occ-size-multiplier: 3.6;
}

#gameContainer {
    width: 100%;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

#gameArea {
    width: 18000px;
    height: 18000px;
    /* light map background with subtle grid */
    background-color: #f3f4f6;
    background-image: linear-gradient(#e5e7eb 1px, transparent 1px), linear-gradient(90deg, #e5e7eb 1px, transparent 1px);
    background-size: 32px 32px;
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    /* Transición quitada para evitar blur en movimiento del personaje */
    /* transition: transform 0.08s linear; */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

#gameUI {
    position: fixed;
    top: 10px;
/* Zombie styles removed */
}

.occ-tail {
    position: absolute;
    left: 50%;
    bottom: calc(-6px * var(--occ-size-multiplier));
    width: calc(10px * var(--occ-size-multiplier));
    height: calc(10px * var(--occ-size-multiplier));
    background: rgba(15,23,42,0.82);
    border-left: 1px solid rgba(255,255,255,0.16);
    border-bottom: 1px solid rgba(255,255,255,0.16);
    transform: translateX(-50%) rotate(45deg);
    box-shadow: 2px 2px 8px rgba(0,0,0,0.25);
}

.occ-chip {
    width: calc(24px * var(--occ-size-multiplier));
    height: calc(24px * var(--occ-size-multiplier));
    border-radius: 4px; /* no circle */
    overflow: hidden;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(12px * var(--occ-size-multiplier));
    font-weight: 600;
    color: #fff;
    /* no border */
    box-shadow: none;
    border: none;
}

.occ-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* improve smoothing to avoid pixelation */
    image-rendering: auto;
    -ms-interpolation-mode: bicubic; /* legacy IE */
}

.occ-more {
    font-size: calc(11px * var(--occ-size-multiplier));
    padding: calc(2px * var(--occ-size-multiplier)) calc(4px * var(--occ-size-multiplier));
    color: #fff;
    opacity: 0.85;
}

/* Floating Media Controls */
#mediaControls {
        position: fixed;
        right: 16px;
        bottom: 16px;
        z-index: 1001; /* Above stamina/health */
        display: flex;
        gap: 10px;
        padding: 8px;
        background: rgba(18, 18, 18, 0.6);
        border: 1px solid rgba(255,255,255,0.12);
        border-radius: 12px;
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        box-shadow: 0 4px 18px rgba(0,0,0,0.25);
}

.mc-btn {
        width: 44px;
        height: 44px;
        border-radius: 12px;
        border: 1px solid rgba(255,255,255,0.2);
        background: rgba(255,255,255,0.08);
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.2s, transform 0.1s, border-color 0.2s;
}

.mc-btn:hover { background: rgba(255,255,255,0.18); }
.mc-btn:active { transform: scale(0.96); }

.mc-btn.on { border-color: rgba(46, 204, 113, 0.8); }
.mc-btn.off { border-color: rgba(231, 76, 60, 0.8); background: rgba(231, 76, 60, 0.15); }

.mc-icon { font-size: 20px; line-height: 1; }

/* Media Settings Panel */
#mediaSettingsPanel {
    position: absolute;
    bottom: 60px;
    right: 0;
    min-width: 260px;
    padding: 10px 12px;
    background: rgba(18,18,18,0.92);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    color: #fff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    display: none;
    z-index: 1002;
}

#mediaSettingsPanel[aria-hidden="false"] { display: block; }

#mediaSettingsPanel .msp-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

#mediaSettingsPanel label {
    font-size: 12px;
    opacity: 0.9;
}

#mediaSettingsPanel select {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 6px 8px;
    outline: none;
}

@media (max-width: 768px) {
    #mediaControls {
        right: 10px; bottom: 10px; gap: 8px; padding: 6px; border-radius: 10px;
    }
    .mc-btn { width: 40px; height: 40px; border-radius: 10px; }
    .mc-icon { font-size: 18px; }
}

.character {
    width: 128px; /* Reducido a la mitad para mejor precisión */
    height: 128px; /* Reducido a la mitad */
  position: absolute;
  z-index: 10;
    /* Keep pixel-art crisp for 2D sprites; the 3D canvas is separate and unaffected */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
  will-change: transform;
    contain: paint;
  backface-visibility: hidden;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  /* Remove any background gradients or colors */
  background-color: transparent;
    /* Centrar el sprite en las coordenadas y escalar al doble porque el contenedor es la mitad */
    transform: translate(-50%, -50%) scale(2);
}

/* 3D actor canvas layered inside .character */
.character .three-actor { position:absolute; inset:0; pointer-events:none; z-index:2; }
.character .three-actor-canvas { width:100%; height:100%; display:block; }

/* Character animation frames */
.character.animated {
  animation-duration: 0.8s;
  animation-iteration-count: infinite;
  animation-timing-function: steps(8, end);
}

.character.idle {
  animation-name: idle-animation;
}

.character.walking {
  animation-name: walking-animation;
}

.character.greeting {
  animation-name: greeting-animation;
  animation-iteration-count: 1;
  animation-duration: 1.2s;
}


/* Animation states for pixel art characters */
.character.idle {
    /* Disable idle bobbing to avoid transform conflicts with JS animator */
    animation: none;
}

.character.moving {
    animation: pixelWalk 0.6s ease-in-out infinite;
}

@keyframes pixelIdle {
    0%, 100% { 
        transform: translateY(0px); 
    }
    50% { 
        transform: translateY(-3px); 
    }
}

@keyframes pixelWalk {
    0% { 
        transform: translateY(0px); 
    }
    25% { 
        transform: translateY(-4px); 
    }
    50% { 
        transform: translateY(-1px); 
    }
    75% { 
        transform: translateY(-4px); 
    }
    100% { 
        transform: translateY(0px); 
    }
}

/* Arm movement animations */
@keyframes armSwingLeft {
    0% { 
        transform: rotate(0deg); 
    }
    25% { 
        transform: rotate(-15deg); 
    }
    50% { 
        transform: rotate(0deg); 
    }
    75% { 
        transform: rotate(15deg); 
    }
    100% { 
        transform: rotate(0deg); 
    }
}

@keyframes armSwingRight {
    0% { 
        transform: rotate(0deg); 
    }
    25% { 
        transform: rotate(15deg); 
    }
    50% { 
        transform: rotate(0deg); 
    }
    75% { 
        transform: rotate(-15deg); 
    }
    100% { 
        transform: rotate(0deg); 
    }
}

/* Leg movement animations */
@keyframes legWalkLeft {
    0% { 
        transform: translateX(0px) translateY(0px); 
    }
    25% { 
        transform: translateX(-2px) translateY(-4px); 
    }
    50% { 
        transform: translateX(0px) translateY(0px); 
    }
    75% { 
        transform: translateX(2px) translateY(-2px); 
    }
    100% { 
        transform: translateX(0px) translateY(0px); 
    }
}

@keyframes legWalkRight {
    0% { 
        transform: translateX(0px) translateY(0px); 
    }
    25% { 
        transform: translateX(2px) translateY(-2px); 
    }
    50% { 
        transform: translateX(0px) translateY(0px); 
    }
    75% { 
        transform: translateX(-2px) translateY(-4px); 
    }
    100% { 
        transform: translateX(0px) translateY(0px); 
    }
}

/* Apply animations to moving characters */
.character.moving::before {
    animation: armSwingLeft 0.6s ease-in-out infinite;
    transform-origin: center bottom;
}

.character.moving::after {
    animation: legWalkLeft 0.6s ease-in-out infinite;
}

.character.left.moving::before {
    animation: armSwingLeft 0.6s ease-in-out infinite;
    transform-origin: center bottom;
}

.character.left.moving::after {
    animation: legWalkLeft 0.6s ease-in-out infinite;
}

.character.right.moving::before {
    animation: armSwingRight 0.6s ease-in-out infinite;
    transform-origin: center bottom;
}

.character.right.moving::after {
    animation: legWalkRight 0.6s ease-in-out infinite;
}

.character.left {
    transform: scaleX(-1);
}

.character.right {
    transform: scaleX(1);
}

.character.left.moving {
    animation: pixelWalkLeft 0.6s ease-in-out infinite;
    transform: scaleX(-1);
}

.character.right.moving {
    animation: pixelWalkRight 0.6s ease-in-out infinite;
    transform: scaleX(1);
}

.character.up.moving {
    animation: pixelWalkUp 0.6s ease-in-out infinite;
}

.character.down.moving {
    animation: pixelWalkDown 0.6s ease-in-out infinite;
}

@keyframes pixelWalkLeft {
    0% { 
        transform: scaleX(-1) translateY(0px); 
    }
    25% { 
        transform: scaleX(-1) translateY(-6px); 
    }
    50% { 
        transform: scaleX(-1) translateY(-2px); 
    }
    75% { 
        transform: scaleX(-1) translateY(-6px); 
    }
    100% { 
        transform: scaleX(-1) translateY(0px); 
    }
}

@keyframes pixelWalkRight {
    0% { 
        transform: scaleX(1) translateY(0px); 
    }
    25% { 
        transform: scaleX(1) translateY(-6px); 
    }
    50% { 
        transform: scaleX(1) translateY(-2px); 
    }
    75% { 
        transform: scaleX(1) translateY(-6px); 
    }
    100% { 
        transform: scaleX(1) translateY(0px); 
    }
}

@keyframes pixelWalkUp {
    0% { 
        transform: translateY(0px); 
        filter: brightness(1.2); 
    }
    25% { 
        transform: translateY(-5px); 
        filter: brightness(1.3); 
    }
    50% { 
        transform: translateY(-1px); 
        filter: brightness(1.2); 
    }
    75% { 
        transform: translateY(-5px); 
        filter: brightness(1.3); 
    }
    100% { 
        transform: translateY(0px); 
        filter: brightness(1.2); 
    }
}

@keyframes pixelWalkDown {
    0% { 
        transform: translateY(0px); 
        filter: brightness(0.8); 
    }
    25% { 
        transform: translateY(-4px); 
        filter: brightness(0.7); 
    }
    50% { 
        transform: translateY(-1px); 
        filter: brightness(0.8); 
    }
    75% { 
        transform: translateY(-4px); 
        filter: brightness(0.7); 
    }
    100% { 
        transform: translateY(0px); 
        filter: brightness(0.8); 
    }
}

.character.up {
    filter: brightness(1.1);
}

.character.down {
    filter: brightness(0.9);
}


/* Character container should allow overflow for name tags */
.character {
    overflow: visible !important;
    position: relative;
}

/* Etiquetas de nombre de personaje */
.character-name {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 2px;
    margin-left: 40px;
    margin-right: 40px;
    border-radius: 4px;
    font-size: 10px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 2500;
}

/* Estilos básicos para los elementos del template (murallas, escritorios, alfombras, piso) */
.map-element {
    position: absolute;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Elementos básicos existentes */
.map-element.wall {
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 50%, #8B4513 100%);
    border: none; /* Removed border */
    box-shadow: none; /* Removed shadow */
}

.map-element.desk {
    background: #8B4513;
    border: 1px solid #654321;
}

.map-element.carpet {
    background: #CD853F;
    border: 1px solid #A0522D;
}

.map-element.floor {
    background: #F5F5DC;
}

/* Nuevos elementos urbanos */
.map-element.road {
    background: linear-gradient(45deg, #696969 25%, #808080 25%, #808080 50%, #696969 50%, #696969 75%, #808080 75%);
    background-size: 8px 8px;
    border: 1px solid #555;
}

.map-element.park {
    background: linear-gradient(135deg, #228B22 0%, #32CD32 50%, #228B22 100%);
    border: 2px solid #006400;
    box-shadow: inset 0 0 20px rgba(0,100,0,0.3);
}

.map-element.plaza {
    background: linear-gradient(45deg, #DDD 25%, #EEE 25%, #EEE 50%, #DDD 50%, #DDD 75%, #EEE 75%);
    background-size: 16px 16px;
    border: 2px solid #CCC;
}

.map-element.plot {
    background: rgba(255, 255, 0, 0.2);
    border: 1px solid #FFD700; /* Kept minimal border for visibility */
    box-shadow: none; /* Removed shadow */
}

/* Espacios comunitarios especiales */
.map-element.townhall {
    background: linear-gradient(135deg, #DC143C 0%, #B22222 50%, #DC143C 100%);
    border: none; /* Removed border */
    box-shadow: none; /* Removed shadow */
}

.map-element.library {
    background: linear-gradient(135deg, #4169E1 0%, #0000CD 50%, #4169E1 100%);
    border: none; /* Removed border */
    box-shadow: none; /* Removed shadow */
}

.map-element.market {
    background: linear-gradient(135deg, #FF6347 0%, #FF4500 50%, #FF6347 100%);
    border: none; /* Removed border */
    box-shadow: none; /* Removed shadow */
}

.map-element.church {
    background: linear-gradient(135deg, #DDA0DD 0%, #9370DB 50%, #DDA0DD 100%);
    border: none; /* Removed border */
    box-shadow: none; /* Removed shadow */
}

.map-element.school {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FFD700 100%);
    border: none; /* Removed border */
    box-shadow: none; /* Removed shadow */
}

.map-element.hospital {
    background: linear-gradient(135deg, #FFFFFF 0%, #F0F8FF 50%, #FFFFFF 100%);
    border: none; /* Removed border */
    box-shadow: none; /* Removed shadow */
}

/* Elementos decorativos */
.map-element.fountain {
    background: radial-gradient(circle, #87CEEB 0%, #4682B4 70%, #2F4F4F 100%);
    border: none; /* Removed border */
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.map-element.tree {
    background: radial-gradient(circle, #228B22 0%, #006400 100%);
    border: 2px solid #2F4F2F;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.map-element.bench {
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
    border: 1px solid #654321;
    border-radius: 4px;
}

.map-element.lamppost {
    background: radial-gradient(circle, #FFD700 0%, #FFA500 50%, #FF8C00 100%);
    border: 1px solid #B8860B;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
}

/* Efectos especiales para edificios comunitarios */
.map-element.townhall::before {
    content: '🏛️';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
}

.map-element.library::before {
    content: '📚';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

.map-element.market::before {
    content: '🏪';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

.map-element.church::before {
    content: '⛪';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

.map-element.school::before {
    content: '🏫';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

.map-element.hospital::before {
    content: '🏥';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
}

/* Animaciones para elementos dinámicos */
.map-element.fountain {
    animation: fountainFlow 3s ease-in-out infinite;
}

@keyframes fountainFlow {
    0%, 100% { 
        box-shadow: 0 2px 6px rgba(0,0,0,0.3), 0 0 15px rgba(135, 206, 235, 0.4);
    }
    50% { 
        box-shadow: 0 2px 6px rgba(0,0,0,0.3), 0 0 25px rgba(135, 206, 235, 0.7);
    }
}

.map-element.lamppost {
    animation: lampGlow 4s ease-in-out infinite;
}

@keyframes lampGlow {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.6);
    }
    50% { 
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.9);
    }
}

/* Hover effects removed for cleaner appearance */

/* Estilos para elementos con assets de imagen */
.map-element.has-image {
    border-radius: 0px; /* Sin bordes redondeados para pixel art */
    box-shadow: none; /* Sin sombras para mantener el estilo pixel art */
    overflow: hidden;
    border: none; /* Sin bordes para árboles y elementos naturales */
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Estilos específicos para árboles */
.map-element.has-image.tree {
    border: none;
    box-shadow: none;
    background-size: contain !important; /* Mantener proporciones del sprite */
    background-position: center !important;
    background-repeat: no-repeat !important;
}

/* Estilos para nuevos elementos de la ciudad */

/* Edificios decorativos */
.map-element.building {
    border: none;
    box-shadow: none; /* Removed shadow */
    background-size: contain !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* NPCs */
.map-element.npc {
    border: none;
    box-shadow: none; /* Removed shadow */
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    border-radius: 50%;
    cursor: pointer;
    z-index: 15;
}

/* Elementos decorativos */
.map-element.decor {
    border: none;
    box-shadow: none;
    background-size: contain !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Elementos de camino */
.map-element.road_element {
    border: none;
    box-shadow: none;
    background-size: cover !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    opacity: 0.8;
}

/* Postes de luz */
.map-element.lamppost {
    background: linear-gradient(to bottom, #8B4513 0%, #8B4513 70%, #FFD700 70%, #FFD700 100%);
    border-radius: 4px;
    box-shadow: none; /* Removed glow effect */
}

/* Clase especial para el jugador local - transición suave para movimiento del servidor */
.character.local-player {
    /* Enlarge local player's container to fit the bigger 3D model */
    width: 256px;
    height: 256px;
    /* Never show 2D sprite behind/in front of 3D canvas */
    background-image: none !important;
  transition: transform 0.08s linear !important;
}

/* Hide any pseudo-elements used by 2D animation on the local player */
.character.local-player::before,
.character.local-player::after {
    content: none !important;
    display: none !important;
}

/* Plot and road specific styles */
.map-element.plot {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    color: white;
    border: 1px solid #00FF00; /* Minimal border for editor visibility */
}

.map-element.road {
    background-size: cover !important;
    background-repeat: no-repeat !important;
    border: none; /* No border for roads */
}

.map-element.special-building {
    position: relative;
    border: none; /* No border for special buildings */
}

.plot-label, .building-label {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    pointer-events: none;
}

.building-label {
    position: absolute;
    bottom: 5px;
    left: 5px;
}

/* Enhanced properties panel */
.property-group {
    margin-bottom: 15px;
}

.property-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.property-group input,
.property-group select {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.property-group input[type="checkbox"] {
    width: auto;
    margin-right: 5px;
}

.type-specific-panel {
    border-top: 1px solid #ddd;
    padding-top: 10px;
    margin-top: 10px;
}

.type-specific-panel h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 14px;
}

/* Coordinate display */
#coordinatesDisplay {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 14px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 200px;
}

#coordinatesDisplay span {
    display: block;
}

/* Zombie styles removed */

/* Player health bar */
.player-health {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    padding: 6px;
    border-radius: 5px;
    color: white;
    font-weight: bold;
    z-index: 1000;
    font-size: 12px;
}

.health-bar {
    width: 120px;
    height: 10px;
    background: #333;
    border-radius: 5px;
    overflow: hidden;
    margin-top: 3px;
}

.health-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    transition: width 0.3s;
    border-radius: 10px;
}

.health-fill.low {
    background: linear-gradient(90deg, #f44336, #ff9800);
}

/* Zombie wave notification removed */

/* Plot overlay styles */
.plot-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
    z-index: 10;
    border: 1px solid #ccc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transform-origin: top left;
    /* Ensure overlay is readable at all zoom levels */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.plot-status {
    font-weight: bold;
    margin-bottom: 4px;
    font-size: 15px;
}

.plot-status.empty {
    color: #2E7D32;
}

.plot-status.public_space {
    color: #1565C0;
}

.plot-status.private_club {
    color: #E65100;
}

.plot-status.private_house {
    color: #AD1457;
}

.plot-name {
    font-size: 13px;
    color: #424242;
    margin-bottom: 2px;
    font-weight: 600;
}

.plot-owner {
    font-size: 11px;
    color: #666666;
    font-weight: normal;
}

/* Plot modal styles */
.plot-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.plot-modal {
    background: white;
    padding: 25px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.plot-modal h3 {
    margin-top: 0;
    color: #333;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

.plot-info {
    margin: 15px 0;
    padding: 15px;
    background: #f5f5f5;
    border-radius: 5px;
}

.plot-info p {
    margin: 5px 0;
    color: #555;
}

.plot-actions {
    margin: 20px 0;
}

.plot-actions h4 {
    color: #333;
    margin-bottom: 15px;
}

.plot-actions button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 15px;
    margin: 5px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.plot-actions button:hover {
    background: #45a049;
}

.plot-actions button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.input-group {
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
}

.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #333;
}

.input-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

.plot-type-change {
    margin: 15px 0;
    padding: 15px;
    background: #f0f8ff;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

.plot-type-change label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
}

.plot-type-change select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

/* Building indicator styling */
.building-indicator {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 3px;
    padding: 2px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Responsive overlay scaling */
@media (max-width: 768px) {
    .plot-overlay {
        font-size: 12px;
        padding: 6px 8px;
        min-height: 50px;
    }
    
    .plot-status {
        font-size: 13px;
    }
    
    .plot-name {
        font-size: 11px;
    }
    
    .plot-owner {
        font-size: 9px;
    }
}

/* Enhanced modal styles */
.enter-building-btn {
    background: #2196F3 !important;
    font-size: 16px !important;
    padding: 12px 20px !important;
    font-weight: bold;
}

.enter-building-btn:hover {
    background: #1976D2 !important;
}

/* Building name sign styling */
.building-sign {
    position: absolute !important;
    top: -30px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    background: rgba(139, 69, 19, 0.9) !important;
    color: white !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    font-size: 12px !important;
    font-weight: bold !important;
    white-space: nowrap !important;
    border: 2px solid #8B4513 !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
    z-index: 20 !important;
    pointer-events: none !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5) !important;
    min-width: 80px !important;
    text-align: center !important;
}

/* Responsive building sign for smaller buildings */
.building-sign.small {
    font-size: 10px !important;
    padding: 2px 4px !important;
    top: -25px !important;
}

/* Video call window styles */
#videoCallWindow {
    position: fixed;
    top: 80px;
    left: auto;
    right: 20px;
    transform: none;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(76, 175, 80, 0.4);
    border-radius: 12px;
    padding: 12px;
    z-index: 2000;
    display: none;
    width: 320px;
    max-width: 95vw;
    max-height: 70vh;
    overflow: hidden;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}

#videoCallWindow.active {
    display: block;
}

#videoCallHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    color: white;
    cursor: move;
    user-select: none;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 8px;
}

#videoCallHeader:hover {
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    padding-left: 4px;
    padding-right: 4px;
}

#fullscreenVideoCall {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 6px;
    margin-left: 4px;
    margin-right: 4px;
    border-radius: 4px;
    transition: all 0.2s;
}
#fullscreenVideoCall:hover {
    background: rgba(76, 175, 80, 0.3);
    color: #4CAF50;
}

#videoCallTitle {
    font-size: 14px;
    font-weight: 600;
    opacity: 0.9;
}

#closeVideoCall {
    background: rgba(255, 68, 68, 0.8);
    border: none;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

#closeVideoCall:hover {
    background: rgba(204, 0, 0, 0.9);
}

#videoCallContent {
    display: block;
    width: 100%;
}

#videoStage {
    display: none;
}

.stage-placeholder {
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 48px;
}

.stage-placeholder p {
    font-size: 16px;
    margin-top: 10px;
}

#videoSidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

#layoutControls {
    display: none;
}

.layout-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: #fff;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

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

.layout-btn.active {
    background: #4CAF50;
    border-color: #4CAF50;
}

.resize-handle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 18px;
    cursor: col-resize;
    padding: 4px;
    margin-left: auto;
}

.resize-handle:hover {
    color: #fff;
}

#videoGrid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 60vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    padding-right: 4px;
}

/* Scrollbar personalizado para el grid */
#videoGrid::-webkit-scrollbar {
    width: 6px;
}

#videoGrid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

#videoGrid::-webkit-scrollbar-thumb {
    background: rgba(76, 175, 80, 0.4);
    border-radius: 3px;
}

#videoGrid::-webkit-scrollbar-thumb:hover {
    background: rgba(76, 175, 80, 0.6);
}

#localVideo {
    width: 100%;
    height: auto;
    aspect-ratio: 4/3;
    max-height: 120px;
    border: 1px solid #4CAF50;
    border-radius: 6px;
    background-color: #000;
    object-fit: cover;
}

.video-container {
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    width: 100%;
}

.video-container:hover {
    background: rgba(0, 0, 0, 0.4);
}

.video-container.self {
    border: 1px solid rgba(76, 175, 80, 0.6);
    order: -1; /* Siempre primero en el grid */
}

.video-container.self .video-label {
    background: rgba(76, 175, 80, 0.7);
    font-weight: 600;
}

.video-container.self video {
    border-color: rgba(76, 175, 80, 0.5);
}

/* Usuarios remotos */
/* Indicador de pantalla compartida (Feedback para el que comparte) */
.sharing-indicator {
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #f59e0b;
    color: #000;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: none;
    align-items: center;
    gap: 8px;
    animation: pulse-share 2s infinite;
}

.sharing-indicator.active {
    display: flex;
}

@keyframes pulse-share {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Controles de video (Expandir, Focus) */
.video-controls {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 20;
}

.video-container:hover .video-controls {
    opacity: 1;
}

.video-btn {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.video-btn:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Estados de Mute y Video Off */
.status-indicator {
    position: absolute;
    bottom: 30px;
    right: 8px;
    display: flex;
    gap: 4px;
    z-index: 10;
}

.status-icon {
    background: rgba(220, 38, 38, 0.9); /* Rojo para alertas */
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    display: none; /* Oculto por defecto */
}

.video-container.muted .status-icon.icon-mute {
    display: flex;
}

.video-container.video-off .status-icon.icon-no-video {
    display: flex;
}

.video-container.video-off video {
    opacity: 0;
}

.video-container.video-off .video-placeholder {
    display: flex;
}

/* Placeholder de conexión en progreso */
.video-container.connecting .video-placeholder {
    display: flex;
}

.connecting-placeholder {
    background: linear-gradient(135deg, #1e3a5f 0%, #1f2937 100%);
}

.connecting-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(59, 130, 246, 0.3);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

.connecting-text {
    color: #93c5fd;
    font-size: 12px;
    font-weight: 500;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1f2937;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #9ca3af;
    z-index: 2;
}

.video-placeholder .avatar-circle {
    width: 48px;
    height: 48px;
    background: #374151;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 8px;
    color: #e5e7eb;
}

/* Layout Focus */
.layout-focus #videoGrid {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: 1fr;
    gap: 10px;
    height: 100%;
}

.layout-focus .video-container.focused {
    grid-column: 2;
    grid-row: 1;
    height: 100%;
    max-height: none;
}

.layout-focus .video-container:not(.focused) {
    grid-column: 1;
    max-height: 150px;
}

/* Fullscreen individual */
.video-container.expanded {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    background: #000;
    max-height: none !important;
    border: none;
    border-radius: 0;
}

.video-container.expanded video {
    height: 100%;
    max-height: none;
    object-fit: contain;
}

.video-container.remote-user {
    border: 1px solid rgba(33, 150, 243, 0.6);
    display: block !important;
    visibility: visible !important;
}

.video-container.remote-user .video-label {
    background: rgba(33, 150, 243, 0.7);
}

.video-container.remote-user video {
    border-color: rgba(33, 150, 243, 0.5);
}

.video-container.screen-share {
    border: 2px solid #f59e0b;
    border-radius: 8px;
    min-width: 320px; /* Más ancho que los videos normales */
    max-width: 480px;
    flex-shrink: 0;
}

.video-container.screen-share video {
    object-fit: contain;
    background: #000;
}

.video-container.screen-share .video-label {
    background: rgba(245, 158, 11, 0.8);
    font-weight: bold;
}

.video-container video {
    width: 100%;
    height: auto;
    aspect-ratio: 4/3;
    max-height: 120px;
    border: 1px solid rgba(33, 150, 243, 0.5);
    border-radius: 6px;
    background-color: #000;
    object-fit: cover;
    display: block;
    position: relative;
    z-index: 5;
}

.video-container video[style*="display: none"],
.video-container video[style*="display:none"] {
    display: none !important;
    z-index: 1;
}

.video-label {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    backdrop-filter: blur(4px);
    max-width: calc(100% - 8px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.video-label-avatar {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.5);
    flex-shrink: 0;
}

.fullscreen-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.video-container:hover .fullscreen-btn {
    opacity: 1;
}

.fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.85);
}

/* Spotlight target */
.spotlight {
    outline: 3px solid #f59e0b;
    outline-offset: 0;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.25);
}

/* Annotation ping */
.annotation-ping {
    position: absolute;
    width: 16px; height: 16px;
    border-radius: 999px;
    background: rgba(59,130,246,0.9);
    box-shadow: 0 0 0 6px rgba(59,130,246,0.25), 0 0 0 10px rgba(59,130,246,0.15);
    transform: translate(-50%, -50%);
    pointer-events: none;
    animation: ping-fade 1.2s ease-out forwards;
}

@keyframes ping-fade {
    0% { opacity: 1; transform: translate(-50%, -50%) scale(0.8); }
    60% { opacity: 0.9; transform: translate(-50%, -50%) scale(1.15); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
}

/* Animación para nuevos participantes */
@keyframes slideInVideo {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.video-container {
    animation: slideInVideo 0.4s ease-out;
}

/* Indicador de conexión activa - solo en hover */
.video-container::before {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 6px;
    height: 6px;
    background: #4CAF50;
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(76, 175, 80, 0.8);
    z-index: 15;
}

/* Video status overlay for when camera is off */
.video-status-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    border: 2px solid #2196F3;
    border-radius: 8px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.video-status-overlay[style*="display: flex"],
.video-status-overlay[style*="display:flex"] {
    display: flex !important;
}

.video-status-overlay .status-icon {
    font-size: 32px;
    margin-bottom: 6px;
    opacity: 0.6;
}

.video-status-overlay .status-text {
    color: white;
    font-size: 11px;
    text-align: center;
    opacity: 0.8;
    font-weight: 400;
}

/* Legacy video styles for backward compatibility */
#videos {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: none; /* Hidden by default, using video call window instead */
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

div[id^="video-container-"] {
    position: relative;
    pointer-events: all;
}

video[id^="video-"] {
    width: 200px;
    height: 150px;
    border: 2px solid #2196F3;
    border-radius: 8px;
    background-color: #000;
}

/* =========================================
   NEW VIDEO UI STYLES
   ========================================= */

/* Top Remote Feeds Bar */
#topRemoteFeeds {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 180px;
    z-index: 1000;
    pointer-events: none; /* Allow clicking through empty space */
    display: flex;
    justify-content: center;
    padding: 10px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.6) 0%, rgba(0,0,0,0) 100%);
}

#remoteFeedsContainer {
    display: flex;
    gap: 12px;
    pointer-events: auto;
    overflow-x: auto;
    max-width: 95%;
    padding: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.3) transparent;
}

#remoteFeedsContainer::-webkit-scrollbar {
    height: 6px;
}

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

#remoteFeedsContainer::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 3px;
}

#remoteFeedsContainer .video-container {
    min-width: 200px;
    max-width: 280px;
    height: 140px;
    flex-shrink: 0;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.2);
    background: rgba(0,0,0,0.7);
    transition: all 0.2s;
    cursor: pointer;
}

#remoteFeedsContainer .video-container:hover {
    border-color: #3b82f6;
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

#remoteFeedsContainer .video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

#remoteFeedsContainer .video-container .video-label {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0,0,0,0.8);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#remoteFeedsContainer .video-container .video-controls {
    position: absolute;
    top: 6px;
    right: 6px;
    opacity: 0;
    transition: opacity 0.2s;
}

#remoteFeedsContainer .video-container:hover .video-controls {
    opacity: 1;
}

#remoteFeedsContainer .video-container .video-btn {
    background: rgba(59, 130, 246, 0.9);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 16px;
}

#remoteFeedsContainer .video-container .video-btn:hover {
    background: rgba(59, 130, 246, 1);
    transform: scale(1.1);
}

/* Screen share specific styles in top bar */
#remoteFeedsContainer .video-container.screen-share {
    min-width: 280px;
    max-width: 400px;
    border-color: #f59e0b;
}

#remoteFeedsContainer .video-container.screen-share:hover {
    border-color: #fbbf24;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

/* Local Screen Preview (when sharing screen) */
#local-screen-preview {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 320px;
    height: 180px;
    z-index: 1200;
    border-radius: 12px;
    border: 3px solid #f59e0b;
    background: #000;
    box-shadow: 0 8px 32px rgba(245, 158, 11, 0.4);
    overflow: hidden;
}

#local-screen-preview video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#local-screen-preview .video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(245, 158, 11, 0.9);
    color: #000;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
}

#local-screen-preview .video-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#local-screen-preview .video-btn:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

/* Local Feed Window (Draggable) */
#localFeedWindow {
    position: fixed;
    bottom: 80px;
    left: 20px;
    width: 240px;
    height: 180px;
    background: rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    transition: transform 0.1s;
}

#localFeedWindow.draggable-window {
    /* Styles for draggable state handled by JS mostly */
}

.window-header {
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
    cursor: grab;
    font-size: 12px;
    color: #ccc;
    user-select: none;
}

.window-header:active {
    cursor: grabbing;
}

.window-controls button {
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
    font-size: 14px;
    padding: 0 4px;
}

.window-content {
    flex: 1;
    position: relative;
    background: #000;
}

#localVideoMain {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    cursor: se-resize;
    background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.5) 50%);
}

/* Bottom Control Bar */
#bottomControlBar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 30, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 2000;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.control-group {
    display: flex;
    gap: 8px;
}

.control-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
}

.control-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
    position: relative;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.control-btn.active {
    background: #ef4444; /* Red for active mute/off state if needed, or green */
}

.control-btn.secondary {
    width: 32px;
    height: 32px;
    font-size: 14px;
    background: transparent;
}

/* Settings Popup */
.settings-popup {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: rgba(30, 30, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    width: 250px;
    display: none;
    flex-direction: column;
    gap: 10px;
    color: white;
}

.settings-popup[aria-hidden="false"] {
    display: flex;
}

.msp-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.msp-row select {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 4px;
    border-radius: 4px;
}

/* Video Containers in Top Bar */
#remoteFeedsContainer .video-container {
    width: 200px;
    height: 150px;
    flex-shrink: 0;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

#remoteFeedsContainer .video-container.screen-share {
    width: 266px; /* 16:9 aspect ratio relative to height */
    border-color: #f59e0b;
}

#remoteFeedsContainer .video-container:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

/* Character UI Styles */
.status-bar {
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-bar:hover {
    background: rgba(0, 0, 0, 0.9) !important;
}

#characterSheet, #inventoryModal {
    backdrop-filter: blur(10px);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.inventory-slot {
    transition: all 0.2s ease;
}

.inventory-slot:hover {
    border-color: #9b59b6 !important;
    box-shadow: 0 0 10px rgba(155, 89, 182, 0.5);
}

#keyboardHints {
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Character Sheet Equipment Slots */
#equipmentSlots > div:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.02);
    transition: all 0.2s ease;
}

/* Health and Stamina Bar Animations */
#healthBar, #staminaBar {
    transition: width 0.3s ease, background 0.2s ease;
}

/* Modal close buttons */
button[id^="close"] {
    transition: background 0.2s ease;
}

button[id^="close"]:hover {
    background: #c0392b !important;
    transform: scale(1.1);
}

/* Scrollbar styles for modals */
#characterSheet::-webkit-scrollbar,
#inventoryModal::-webkit-scrollbar {
    width: 8px;
}

#characterSheet::-webkit-scrollbar-track,
#inventoryModal::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#characterSheet::-webkit-scrollbar-thumb,
#inventoryModal::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

#characterSheet::-webkit-scrollbar-thumb:hover,
#inventoryModal::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Inventory grid responsiveness */
#inventoryGrid {
    max-width: 100%;
}

@media (max-width: 600px) {
    #characterSheet, #inventoryModal {
        width: 90%;
        max-width: 400px;
    }
    
    #inventoryGrid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .inventory-slot {
        width: 50px;
        height: 50px;
        font-size: 18px;
    }
}

/* Model Selector Modal */
.modal {
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1e293b;
    padding: 20px;
    border: 1px solid #334155;
    border-radius: 12px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    color: #fff;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

.model-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.model-item {
    background: #0f172a;
    border: 2px solid #334155;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.model-item:hover {
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.model-item.selected {
    border-color: #22c55e;
    background: #14532d;
}

.model-icon {
    font-size: 24px;
    margin-bottom: 5px;
    display: block;
}

.model-name {
    font-size: 12px;
    font-weight: 600;
}

.btn-secondary {
    background: #475569;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-secondary:hover {
    background: #64748b;
}

/* ===== VIDEO GRID OVERLAY ===== */
.video-grid-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

.video-grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(0, 0, 0, 0.8);
    border-bottom: 2px solid #334155;
}

.video-grid-header h2 {
    color: white;
    margin: 0;
    font-size: 24px;
}

.close-grid-btn {
    background: rgba(239, 68, 68, 0.8);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-grid-btn:hover {
    background: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}

.video-grid-container {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    align-content: start;
}

/* Responsive grid for different screen sizes */
@media (min-width: 1200px) {
    .video-grid-container {
        grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    }
}

@media (max-width: 768px) {
    .video-grid-container {
        grid-template-columns: 1fr;
        padding: 15px;
        gap: 15px;
    }
}

.video-grid-item {
    position: relative;
    background: #1e293b;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #334155;
    transition: all 0.3s;
    cursor: pointer;
    aspect-ratio: 16/9;
}

.video-grid-item:hover {
    border-color: #3b82f6;
    transform: scale(1.02);
}

.video-grid-item.focused {
    grid-column: 1 / -1;
    aspect-ratio: 16/9;
    max-height: 80vh;
    border-color: #22c55e;
}

.video-grid-item video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.video-grid-item .video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    z-index: 10;
}

.video-grid-item .video-status {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 6px;
    z-index: 10;
}

.video-grid-item .status-badge {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.video-grid-item .focus-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(59, 130, 246, 0.9);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.video-grid-item:hover .focus-btn {
    opacity: 1;
}

.video-grid-item.focused .focus-btn {
    background: rgba(239, 68, 68, 0.9);
}

.video-grid-item .video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    color: #94a3b8;
}

.video-grid-item .video-placeholder .placeholder-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.video-grid-item .video-placeholder .placeholder-text {
    font-size: 14px;
}