:root {
    --sidebar-width: 280px;
    --text-color: #eee;
    --border-color: rgba(255, 255, 255, 0.1);
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: 
        radial-gradient(ellipse at top left, rgba(5, 20, 12, 0.8) 0%, transparent 50%),
        radial-gradient(ellipse at top right, rgba(8, 25, 15, 0.6) 0%, transparent 50%),
        radial-gradient(ellipse at bottom center, rgba(3, 15, 8, 0.9) 0%, transparent 60%),
        linear-gradient(135deg, #030a07 0%, #05140a 25%, #06180d 50%, #05140a 75%, #030a07 100%);
    background-color: #030a07;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-color);
}

.main-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Mobile portrait layout */
@media (max-width: 768px) and (orientation: portrait) {
    .main-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100vw !important;
        max-width: 100vw !important;
        max-height: 50vh;
        border-right: none;
        border-top: 1px solid var(--border-color);
        border-image: none;
        overflow-y: auto;
        padding: 15px;
        box-sizing: border-box;
        margin: 0;
        left: 0;
        right: 0;
    }
    
    .sidebar.hidden {
        transform: translateY(calc(100% - 50px));
        width: 100vw !important;
    }
    
    /* Adjust close button position in mobile */
    .sidebar .sidebar-close-btn {
        position: absolute;
        bottom: 20px;
        left: 20px;
        top: auto;
    }
    
    .sidebar-toggle {
        position: fixed;
        bottom: 20px;
        left: 20px;
        top: auto;
        right: auto;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        border-radius: 0;
    }
    
    /* Show toggle button when sidebar is hidden in mobile */
    .main-container:hover .sidebar.hidden ~ .sidebar-toggle {
        opacity: 1;
        pointer-events: all;
        transform: translateX(0);
    }
    
    .canvas-container {
        flex: 1;
        min-height: 50vh;
        order: -1; /* Canvas appears first */
        width: 100vw;
    }
    
    .header {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
    
    .controls {
        max-height: calc(50vh - 200px);
    }
}

/* Mobile landscape layout - keep original behavior */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: var(--sidebar-width);
    }
}

/* Sidebar Styling - Pure Glass Effect */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border-right: 1px solid;
    border-image: linear-gradient(
        to bottom,
        #d4af37 0%,
        #f4d03f 20%,
        #d4af37 40%,
        #b8860b 60%,
        #8b6914 80%,
        #6b4e1f 100%
    ) 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    z-index: 10;
    flex-shrink: 0;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), 
                opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    box-shadow: 2px 0 8px rgba(212, 175, 55, 0.2);
}

.sidebar.hidden {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    width: 0 !important;
    padding: 0 !important;
    border-right: none !important;
    box-shadow: none !important;
    background: transparent !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    overflow: hidden;
}

.sidebar.hidden * {
    pointer-events: none;
}

.sidebar-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px) saturate(180%);
    -webkit-backdrop-filter: blur(30px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 11;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100%);
}

/* Show toggle when sidebar is hidden and hovering near left edge */
.sidebar.hidden ~ .sidebar-toggle {
    opacity: 0;
    pointer-events: none;
}

.main-container:hover .sidebar.hidden ~ .sidebar-toggle {
    opacity: 1;
    pointer-events: all;
    transform: translateX(0);
}

.main-container:hover .sidebar.hidden ~ .sidebar-toggle:hover {
    transform: translateX(4px);
}

/* Show toggle button inside sidebar when visible (for closing) */
.sidebar:not(.hidden) .sidebar-close-btn {
    display: flex;
}

.sidebar.hidden .sidebar-close-btn {
    display: none;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 4px 2px 16px rgba(0, 0, 0, 0.4);
}

.sidebar-close-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.8;
    padding: 0;
}

.sidebar-close-btn:hover {
    opacity: 1;
    color: rgba(255, 255, 255, 1);
    transform: translateX(-2px);
}

.sidebar-close-btn:active {
    transform: scale(0.95);
}

.sidebar-toggle:active {
    transform: translateX(2px);
}

.sidebar:not(.hidden) .sidebar-toggle {
    opacity: 0;
    pointer-events: none;
}

.header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    text-align: center;
}

.header h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 1.5px;
}

.header p {
    margin: 4px 0 0;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
}

/* Sidebar header elements */
.sidebar-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
}

.sidebar-header .wikipedia-link {
    text-align: right;
    margin-bottom: 10px;
}

.sidebar-header .wikipedia-link a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: rgba(144, 238, 144, 0.8);
    text-decoration: none;
    font-size: 0.55rem;
    letter-spacing: 0.5px;
    text-transform: lowercase;
    transition: color 0.2s;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.sidebar-header .wikipedia-link a:hover {
    color: rgba(144, 238, 144, 1);
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-header .wikipedia-link a svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.sidebar-header .tribute {
    text-align: center;
    margin-bottom: 12px;
}

.sidebar-header .tribute p {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
    line-height: 1.4;
    padding: 0;
    font-weight: 400;
}


.sidebar-header .action-buttons-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.sidebar-header .action-btn-small {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.sidebar-header .action-btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.controls {
    flex: 1;
    overflow-y: auto;
}

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

.control-group label {
    display: block;
    font-size: 0.65rem;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.slider-value-display {
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    font-family: 'Courier New', monospace;
    margin-left: 4px;
}

.slider-value {
    text-align: center;
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 4px;
    font-family: 'Courier New', monospace;
}

.slider-wrapper {
    position: relative;
    width: 100%;
    max-width: 200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 0;
}

input[type=range] {
    width: 100%;
    background: transparent;
    -webkit-appearance: none;
    cursor: pointer;
    position: relative;
    z-index: 2;
    outline: none;
}

.slider-center-marker {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 1px;
    height: 10px;
    background: rgba(255, 255, 255, 0.2);
    pointer-events: none;
    z-index: 1;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0;
    transition: background 0.2s;
}

input[type=range]:hover::-webkit-slider-runnable-track {
    background: rgba(255, 255, 255, 0.3);
}

input[type=range]::-webkit-slider-thumb {
    height: 12px;
    width: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    -webkit-appearance: none;
    margin-top: -5.5px;
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
    cursor: grab;
    border: none;
}

input[type=range]::-webkit-slider-thumb:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    transform: scale(1.15);
}

input[type=range]::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.1);
}

/* Firefox */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 1px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0;
}

input[type=range]::-moz-range-thumb {
    height: 12px;
    width: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    box-shadow: 
        0 1px 3px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.2);
    cursor: grab;
}

input[type=range]::-moz-range-thumb:hover {
    background: rgba(255, 255, 255, 1);
    box-shadow: 
        0 2px 4px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.3);
    transform: scale(1.15);
}

.actions {
    margin-top: 15px;
}

.action-buttons-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.action-btn-small {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.2s;
    min-width: 50px;
    height: auto;
    flex: 1;
    max-width: 60px;
}

.action-btn-small:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.action-btn-small:active {
    transform: scale(0.95);
}

.action-btn-small:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.action-btn-small .btn-label {
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1;
    margin-top: 1px;
    font-weight: 500;
    letter-spacing: 0.2px;
}


.footer {
    margin-top: 12px;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
}

#fps {
    margin-bottom: 8px;
}

.credits {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.credit-line {
    margin-bottom: 4px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
}

.credit-line strong {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
}

.credit-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.6rem;
}

.credit-links a {
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    transition: color 0.2s;
}

.credit-links a:hover {
    color: rgba(255, 255, 255, 0.8);
}

.credit-links .separator {
    color: rgba(255, 255, 255, 0.3);
}

/* Canvas Container */
.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: 
        radial-gradient(ellipse at center, rgba(5, 20, 12, 0.4) 0%, transparent 70%),
        radial-gradient(ellipse at top right, rgba(8, 25, 15, 0.3) 0%, transparent 50%),
        linear-gradient(180deg, #030a07 0%, #05140a 30%, #06180d 60%, #05140a 90%, #030a07 100%);
    background-color: #030a07;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: grab;
    filter: brightness(1.2) contrast(1.3) saturate(1.4);
    transition: filter 0.3s ease;
}

#canvas:active {
    cursor: grabbing;
}

#canvas-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.8);
    font-size: 1rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.6s ease;
}
