body {
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    font-family: Arial, sans-serif;
    background-color: black;
    /* Disable text selection and dragging */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    /* Disable drag ghost images */
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    /* Disable text selection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
#background-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Disable drag and selection */
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}
#background-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Disable drag and selection */
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}
#darkness-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50; /* Above background (0) but below tokens (100) and fog (150) */
    opacity: 0;
    transition: opacity 0.3s ease;
}
#darkness-overlay.active {
    opacity: 1;
}
#background-image.darkness-mode,
#background-video.darkness-mode {
    filter: grayscale(100%);
    transition: filter 0.3s ease;
}
#svg-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.wall {
    stroke: #ff0000;
    stroke-width: 4;
    transition: opacity 0.3s ease;
}
.hidden {
    display: none;
}
.wall.hidden {
    opacity: 0;
}
.temp-wall {
    stroke: #0000ff;
    stroke-width: 2;
    stroke-dasharray: 5,5;
}
.door-boundary {
    stroke: #8B5A00;
    stroke-width: 3;
    fill: rgba(139, 90, 0, 0.2);
    transition: opacity 0.3s ease;
    cursor: pointer;
}
.door-boundary.hidden {
    opacity: 0;
}
.door-boundary:hover {
    stroke: #CD853F;
    fill: rgba(205, 133, 63, 0.3);
}
.temp-door {
    stroke: #8B5A00;
    stroke-width: 2;
    stroke-dasharray: 8,4;
    fill: rgba(139, 90, 0, 0.1);
}
.door-line {
    stroke: #8B5A00;
    stroke-width: 3;
    cursor: pointer;
}
.temp-door-line {
    stroke: #8B5A00;
    stroke-width: 2;
    stroke-dasharray: 8,4;
}
.door-token {
    position: absolute;
    cursor: pointer;
    z-index: 140; /* Below fog of war (150) but above most tokens (100) */
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
    transition: all 0.3s ease;
    user-select: none;
}
.door-token:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 0 10px rgba(139, 90, 0, 0.6);
}
.player-token {
    position: absolute;
    border-radius: 50%;
    cursor: move;
    z-index: 10;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    border: 3px solid #0000ff
}

/* Hide border and background when avatar is present */
.player-token.has-avatar {
    border: none;
    background-color: transparent;
}

/* Highlight for assigned player token (non-DM view) */
.player-token.assigned-to-user {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8), 
                0 0 20px 5px rgba(59, 130, 246, 0.4);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.8), 
                    0 0 20px 5px rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 1), 
                    0 0 25px 8px rgba(59, 130, 246, 0.6);
    }
}

.enemy-token {
    position: absolute;
    border-radius: 50%;
    cursor: move;
    z-index: 0;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    border: 3px solid #ff0000;
}

/* Hide border and background when avatar is present */
.enemy-token.has-avatar {
    border: none;
    background-color: transparent;
}
.enemy-token-dmmode {
    /* DM mode styling - removed z-index override to allow proper layering */
}

.npc-token {
    position: absolute;
    border-radius: 50%;
    cursor: move;
    z-index: 0;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: white;
    border: 3px solid #ffaa00;
}

/* Hide border and background when avatar is present */
.npc-token.has-avatar {
    border: none;
    background-color: transparent;
}
.npc-token-dmmode {
    /* DM mode styling - removed z-index override to allow proper layering */
}
#lights-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 145; /* Above tokens (140), below fog (150) */
}

#fog-of-war {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 1;
    z-index: 150; /* Always above tokens - opacity changes based on DM mode */
}

/* DM Mode - Keep same z-index, only change opacity */
#fog-of-war.dm-mode {
    /* z-index stays at 150 - fog is always above tokens */
    /* opacity is controlled by JavaScript (0.5 in DM mode, 1.0 in player mode) */
}
.wall-mode #svg-container {
    cursor: crosshair;
}
#spell-effects-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
.spell-effect {
    position: absolute;
    pointer-events: none;
}
.spell-path {
    position: absolute;
    pointer-events: none;
    border: 2px dashed red;
    opacity: 0.7;
}
.fireball {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: radial-gradient(circle, yellow, orange, red);
    box-shadow: 0 0 10px red;
    pointer-events: none;
}
#grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
#measure-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200; /* Above fog of war (150) so measurements are always visible */
}

/* Context Menu Styles - maintained at constant 175px visual width */
#layer-context-menu {
    position: absolute;
    background-color: #2d3748;
    border: 2px solid #4a5568;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    min-width: 175px;
    padding: 16px 0;
    font-size: 28px;
}

.context-menu-item {
    padding: 16px 32px;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}

.context-menu-item:hover {
    background-color: #4a5568;
}

.context-menu-separator {
    border-top: 2px solid #4a5568;
    margin: 8px 0;
}

.context-menu-red {
    color: #fc8181;
}

.context-menu-red:hover {
    color: #feb2b2;
}

.context-menu-green {
    color: #68d391;
}

.context-menu-green:hover {
    color: #9ae6b4;
}

.context-menu-blue {
    color: #63b3ed;
}

.context-menu-blue:hover {
    color: #90cdf4;
}

.context-menu-yellow {
    color: #f6e05e;
}

.context-menu-yellow:hover {
    color: #faf089;
}

.context-menu-orange {
    color: #f6ad55;
}

.context-menu-orange:hover {
    color: #fbd38d;
}

/* Asset Lock Controls - Now centered and double size */
#asset-lock-controls {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: #2d3748;
    border: 2px solid #4a5568;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
    padding: 24px;
    z-index: 1000;
    font-size: 24px;
    min-width: 400px;
    text-align: center;
}

.lock-button {
    padding: 16px 24px;
    border-radius: 8px;
    border: none;
    font-size: 24px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    min-width: 200px;
}

.lock-button-unlock {
    background-color: #e53e3e;
    color: white;
}

.lock-button-unlock:hover {
    background-color: #c53030;
}

.lock-button-lock {
    background-color: #3182ce;
    color: white;
}

.lock-button-lock:hover {
    background-color: #2c5282;
}

.lock-control-label {
    color: white;
    font-size: 20px;
    margin-bottom: 16px;
    font-weight: bold;
}

/* Lock Indicators - Removed asset lock indicators, keeping only token indicators */

/* Token lock indicator styles removed - no longer showing lock icons on tokens */

/* Attach Instructions */
#attach-instructions {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    padding: 16px 24px;
    color: white;
    font-size: 14px;
    z-index: 1000;
    text-align: center;
}

/* Board Asset Selection */
.board-asset.selected {
    border: 2px solid #3182ce !important;
    box-shadow: 0 0 10px rgba(49, 130, 206, 0.5) !important;
}

/* Locked Board Assets */
.board-asset.locked {
    pointer-events: none !important; /* Allow clicks to pass through to underlying assets */
    /* Removed opacity to prevent transparency - locked assets should remain fully visible */
}

.board-asset.locked:hover {
    /* No opacity change on hover - locked assets remain fully visible */
}

/* Inverse Zoom CSS Rules for Iframe - maintains constant visual size */
:root {
    --dropdown-zoom: 1; /* Will be set to 1/actualZoom to maintain constant 175px visual size */
}

.dropdown-zoomed {
    transform: scale(var(--dropdown-zoom)) !important;
    transform-origin: top left !important;
    z-index: 9999 !important;
}

.dropdown-font-scaled {
    font-size: calc(1rem * var(--dropdown-zoom)) !important;
}

.dropdown-font-scaled * {
    font-size: inherit !important;
}

/* Specific high-priority transform rules for context menu in iframe */
#layer-context-menu.dropdown-zoomed {
    transform: scale(var(--dropdown-zoom)) !important;
    transform-origin: top left !important;
    font-size: calc(28px * var(--dropdown-zoom)) !important;
    z-index: 9999 !important;
}

#layer-context-menu.dropdown-font-scaled {
    font-size: calc(28px * var(--dropdown-zoom)) !important;
}
