/* CSS Variables for Accessibility & Aesthetics */
:root {
    --bg-color: #0d0d12;
    --text-color: #e2e8f0;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --accent-color: #3b82f6;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body.high-contrast {
    --bg-color: #000;
    --text-color: #ffff00;
    --accent-color: #ffff00;
    --glass-bg: #000;
    --glass-border: #ffff00;
}

body.dyslexic-font {
    --font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
}

#canvasContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#uiLayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#portfolioTitle {
    position: absolute;
    top: 30px;
    left: 30px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 4px 12px rgba(0,0,0,0.5);
    background: linear-gradient(90deg, #fff, #a5b4fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Crosshair */
#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    mix-blend-mode: difference;
    transition: transform 0.2s ease, background 0.2s ease;
}
#crosshair.active {
    transform: translate(-50%, -50%) scale(2);
    background: var(--accent-color);
}

/* Glassmorphism Modal */
.glass-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    pointer-events: auto;
    transition: opacity 0.3s ease, transform 0.3s ease;
    min-width: 300px;
}
.glass-modal.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -45%);
}

.glass-modal h2 {
    margin-top: 0;
    font-size: 2rem;
    margin-bottom: 10px;
}
.glass-modal p {
    font-size: 1.1rem;
    line-height: 1.5;
    color: #cbd5e1;
    margin-bottom: 30px;
}

.glass-btn {
    display: inline-block;
    padding: 12px 24px;
    background: var(--accent-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.1s ease;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
}
.glass-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
}
.glass-btn.outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: #fff;
    margin-left: 10px;
}
.glass-btn.outline:hover {
    background: rgba(255,255,255,0.1);
}

/* Loading Screen */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0d0d12;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    transition: opacity 0.5s ease;
}
.glow-text {
    font-size: 2em;
    font-weight: 300;
    letter-spacing: 4px;
    text-transform: uppercase;
    animation: pulse 2s infinite ease-in-out;
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; text-shadow: 0 0 20px var(--accent-color); }
}

/* Paint Palette UI */
#paintPalette {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(13, 13, 18, 0.85);
    padding: 10px 15px;
    border-radius: 12px;
    backdrop-filter: blur(8px);
    z-index: 10;
    transition: opacity 0.3s;
    pointer-events: auto;
}
#paintPalette.hidden {
    opacity: 0;
    pointer-events: none;
}
.palette-colors {
    display: flex;
    gap: 8px;
}
.color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}
.color-swatch:hover {
    transform: scale(1.1);
}
.color-swatch.active {
    border: 2px solid white;
    transform: scale(1.1);
}
.palette-size {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-family: var(--font-primary);
    font-size: 0.8rem;
}
.palette-size input[type=range] {
    flex-grow: 1;
}

/* Orientation Lock */
#orientationLock {
    display: none;
    background: rgba(13, 13, 18, 0.95);
    backdrop-filter: blur(10px);
}
@media screen and (max-width: 768px) and (orientation: portrait) {
    #orientationLock {
        display: flex;
    }
}

/* Mobile Controls */
.mobile-only {
    display: none;
}
.is-mobile .mobile-only {
    display: block;
}

#mobileControls {
    position: absolute;
    bottom: 30px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    z-index: 100;
}
#mobileControls.hidden {
    display: none;
}
#joystick-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: auto;
}
#joystick-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}
.strafe-row {
    display: flex;
    gap: 10px;
}
#joystick-left .glass-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    user-select: none;
}

.icon-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}
.icon-btn:active {
    background: rgba(59, 130, 246, 0.8);
    transform: scale(0.95);
}

/* Inventory UI */
#inventoryUI {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    pointer-events: auto;
    z-index: 20;
}
.inv-slot {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(5px);
    padding: 10px 15px;
    border-radius: 8px;
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}
.inv-slot.active {
    background: var(--accent-color);
    box-shadow: 0 0 15px var(--accent-color);
}
.inv-slot:hover {
    transform: translateY(-2px);
}
@media screen and (max-width: 768px) {
    #inventoryUI {
        bottom: 80px; /* Above mobile controls */
        transform: translateX(-50%) scale(0.85);
    }
}
