body {
    margin: 0;
    padding: 0;
    background: #2a2a2a;
    color: white;
    font-family: Arial, sans-serif;
    overflow: hidden;
    height: 100vh;
}

/* Map Container - Now Full Screen */
#mapContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a1a1a;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.canvas-container {
    position: relative;
    transform-origin: center center;
    transition: transform 0.3s ease;
    display: inline-block;
    min-width: 100px;
    min-height: 100px;
    background: #1a1a1a;
}

.canvas-container canvas {
    display: block;
}

#mapCanvas, #gridCanvas, #fogCanvas, #tokenCanvas {
    position: absolute;
    top: 0;
    left: 0;
}

#mapCanvas {
    z-index: 1;
}

#gridCanvas {
    z-index: 2;
    pointer-events: none;
}

#fogCanvas {
    z-index: 3;
    pointer-events: none;
}

#tokenCanvas {
    z-index: 4;
    cursor: pointer;
    touch-action: manipulation;
}

/* Tabbed Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: rgba(42, 42, 42, 0.95);
    backdrop-filter: blur(10px);
    border-left: 1px solid #666;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.3);
}

.sidebar.collapsed {
    transform: translateX(320px);
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    left: -40px;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 60px;
    background: rgba(42, 42, 42, 0.95);
    border: 1px solid #666;
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.sidebar-toggle:hover {
    background: rgba(74, 144, 226, 0.8);
}

.sidebar.collapsed .sidebar-toggle span {
    transform: rotate(180deg);
}

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid #666;
}

.tab-button {
    flex: 1;
    padding: 15px 10px;
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    border-right: 1px solid #666;
}

.tab-button:last-child {
    border-right: none;
}

.tab-button:hover {
    background: rgba(74, 144, 226, 0.1);
    color: #4a90e2;
}

.tab-button.active {
    background: rgba(74, 144, 226, 0.2);
    color: #4a90e2;
    border-bottom: 2px solid #4a90e2;
}

.tab-icon {
    font-size: 18px;
}

.tab-label {
    font-size: 12px;
    font-weight: bold;
}

/* Sidebar Content */
.sidebar-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.tab-content {
    display: none;
    padding: 20px;
    height: 100%;
    box-sizing: border-box;
}

.tab-content.active {
    display: block;
}

.tab-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #666;
}

.tab-header h3 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #4a90e2;
}

.tab-description {
    margin: 0;
    font-size: 12px;
    color: #aaa;
    line-height: 1.4;
}

.tab-footer {
    margin-top: 30px;
    padding-top: 15px;
    padding-bottom: 20px; /* Extra bottom padding for tablets */
    border-top: 1px solid #666;
    /* Ensure footer content is always accessible */
    min-height: 60px;
}

.tip {
    font-size: 11px;
    color: #aaa;
    text-align: center;
    line-height: 1.4;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

/* Control Sections */
.control-section {
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid #555;
}

.control-section h4 {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: #4a90e2;
    font-weight: bold;
}

.control-group {
    margin-bottom: 15px;
}

.control-group:last-child {
    margin-bottom: 0;
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
}

.range-input {
    display: flex;
    align-items: center;
    gap: 10px;
}

.range-input input[type="range"] {
    flex: 1;
    height: 6px;
    background: #555;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.range-input input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    background: #4a90e2;
    border-radius: 50%;
    cursor: pointer;
}

.range-input input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: #4a90e2;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.range-input span {
    min-width: 50px;
    font-size: 11px;
    color: #4a90e2;
    font-weight: bold;
}

input[type="file"] {
    width: 100%;
    padding: 8px;
    background: #444;
    color: white;
    border: 1px solid #666;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
}

input[type="color"] {
    width: 40px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background: transparent;
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

button {
    padding: 10px 15px;
    background: #4a90e2;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

button:hover {
    background: #357abd;
    transform: translateY(-1px);
}

button:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.config-link {
    display: block;
    padding: 10px 15px;
    background: #666;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.2s ease;
    text-align: center;
}

.config-link:hover {
    background: #555;
    transform: translateY(-1px);
}

/* Player Items */
.player-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.player-item.selected {
    background: rgba(74, 144, 226, 0.3) !important;
    border: 2px solid #4a90e2 !important;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
    transform: scale(1.02);
}

.player-item:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.player-item.on-map {
    pointer-events: none;
    opacity: 0.5;
    background: rgba(100, 100, 100, 0.2) !important;
    border: 1px solid #666 !important;
}

.token-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 8px;
}

.token-color-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid white;
    flex-shrink: 0;
}

.token-name {
    flex: 1;
    background: transparent;
    border: 1px solid #666;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.token-controls {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.token-color-picker {
    width: 25px;
    height: 25px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.delete-token {
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 10px;
}

.delete-token:hover {
    background: #cc3333;
}

/* Token hover tooltip */
.token-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
    border: 1px solid #666;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    transform: translate(-50%, -100%);
    margin-top: -10px;
}

.token-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* Placement mode animations */
@keyframes placementPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4);
        background: rgba(74, 144, 226, 0.1);
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(74, 144, 226, 0);
        background: rgba(74, 144, 226, 0.2);
    }
}

@keyframes placementCue {
    0%, 100% { 
        border-color: rgba(74, 144, 226, 0.3); 
        background: rgba(74, 144, 226, 0.05); 
    }
    50% { 
        border-color: rgba(74, 144, 226, 0.6); 
        background: rgba(74, 144, 226, 0.15); 
    }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(74, 144, 226, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(74, 144, 226, 0); }
    100% { box-shadow: 0 0 0 0 rgba(74, 144, 226, 0); }
}

#placementOverlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(74, 144, 226, 0.1);
    pointer-events: none;
    z-index: 5;
    border: 3px dashed rgba(74, 144, 226, 0.5);
    border-radius: 8px;
    animation: placementCue 2s infinite;
}

/* iPad and tablet specific fixes */
@media (min-width: 768px) and (max-width: 1024px) {
    .tab-content {
        height: calc(100vh - 120px);
        padding-bottom: 80px; /* Extra space for iPad scrolling */
    }
    
    .tab-footer {
        padding-bottom: 40px;
        margin-bottom: 20px;
    }
    
    .tip {
        margin-bottom: 20px;
        padding: 15px;
        /* Ensure tip text is easily readable on tablets */
        font-size: 12px;
        line-height: 1.5;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        width: 100vw;
        max-width: 350px;
    }
    
    .sidebar.collapsed {
        transform: translateX(100%);
    }
    
    .tab-button {
        padding: 12px 8px;
    }
    
    .tab-icon {
        font-size: 16px;
    }
    
    .tab-label {
        font-size: 10px;
    }
    
    .control-section {
        padding: 12px;
        margin-bottom: 20px;
    }
    
    .sidebar-toggle {
        left: -35px;
        width: 35px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100vw;
    }
    
    .sidebar-toggle {
        display: none;
    }
}



/* Monster token items */
.monster-item {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.monster-item.selected {
    background: rgba(255, 107, 107, 0.3) !important;
    border: 2px solid #ff6b6b !important;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    transform: scale(1.02);
}

.monster-item:active {
    transform: scale(0.98);
    opacity: 0.8;
}

.monster-item:hover {
    background: rgba(255, 107, 107, 0.15);
    transform: translateX(3px);
}

/* Monster placement cue animation */
@keyframes monsterPlacementCue {
    0%, 100% { 
        border-color: rgba(255, 107, 107, 0.3); 
        background: rgba(255, 107, 107, 0.05); 
    }
    50% { 
        border-color: rgba(255, 107, 107, 0.6); 
        background: rgba(255, 107, 107, 0.15); 
    }
}

/* Monster visibility indicators */
.monster-visibility-indicator {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.monster-visibility-indicator.visible {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
}

.monster-visibility-indicator.hidden {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

/* Token tooltips for monsters */
.token-tooltip.monster-tooltip {
    background: rgba(255, 107, 107, 0.9);
    border-color: #ff6b6b;
}

.token-tooltip.monster-tooltip::after {
    border-top-color: rgba(255, 107, 107, 0.9);
}