:root {
    --astros-navy: #002D62;
    --astros-orange: #EB6E1F;
    --text-vivid-orange: #FF8200;
    /* Vivid Orange for Winter Visibility */
    --text-dark: #000000;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--astros-navy);
    /* Navy Background */
    color: var(--text-vivid-orange);
    /* Vivid Orange text */
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Z FOLD 7 FIX: Safe Area Container */
.ui-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    box-sizing: border-box;
    padding-bottom: env(safe-area-inset-bottom, 80px) !important;
    /* Force buttons up */
}

/* --- FIELD UI LAYOUT --- */

/* Container for all HUD controls */
#settings-panel {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through to 3D model unless on a button */
    z-index: 20;
    box-sizing: border-box;
    padding: 10px;
}

/* TOP LEFT: Winter Mode */
#winter-toggle {
    position: absolute;
    top: 15px;
    left: 15px;
    pointer-events: auto;

    background: rgba(0, 45, 98, 0.6);
    backdrop-filter: blur(5px);
    border: 1px solid var(--text-vivid-orange);
    color: var(--text-vivid-orange);
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.3s;
}

#winter-toggle:hover {
    background: rgba(255, 130, 0, 0.2);
}

/* TOP RIGHT: Scale Controls */
#ar-controls-group {
    pointer-events: auto;
    /* Active zone */
    position: absolute;
    top: 15px;
    right: 15px;
}

#scale-controls {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 140px;
}

#scale-controls label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #FFF;
    display: flex;
    justify-content: space-between;
}

#scale-slider {
    width: 100%;
    cursor: pointer;
}

.preset-buttons {
    display: flex;
    justify-content: space-between;
    gap: 4px;
}

.preset-buttons button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #FFF;
    border-radius: 4px;
    padding: 4px 0;
    cursor: pointer;
    font-size: 0.75rem;
    flex: 1;
}

.preset-buttons button:hover {
    background: var(--text-vivid-orange);
    color: black;
}

/* BOTTOM CENTER: Lock Button */
/* This is inside ar-controls-group in HTML, but we want it positioned independently visually?
   Actually HTML structure groups them.
   Let's use absolute positioning relative to #settings-panel if we can, 
   OR just move the lock button out of scale-controls ID in the HTML.
   For now, strictly aiming for CSS fix:
*/

#lock-toggle {
    position: fixed;
    /* Fixed to screen bottom */
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);

    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    border: 2px solid #FFF;
    color: #FFF;
    padding: 12px 30px;
    /* Big touch target */
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1rem;
    /* Big text */
    text-transform: uppercase;
    transition: all 0.3s;
    pointer-events: auto;
    width: auto;
    min-width: 200px;

    /* Ensure it sits above AR button if showing together, 
       but AR State Logic should hide AR button. */
    z-index: 25;
}

#lock-toggle[aria-pressed="true"] {
    background: rgba(235, 110, 31, 0.8);
    /* Orange when locked */
    border-color: var(--text-vivid-orange);
}

#lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    background: transparent;
}

#toast-msg {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: var(--text-vivid-orange);
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    pointer-events: none;
    z-index: 100;
    opacity: 0;
    transition: opacity 0.5s ease;
    border: 1px solid var(--text-vivid-orange);
    text-align: center;
    backdrop-filter: blur(5px);
}

header {
    background: linear-gradient(90deg, var(--astros-navy) 0%, var(--astros-orange) 100%);
    /* Sunset gradient */
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    z-index: 10;
}

header h1 {
    margin: 0;
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #FFFFFF;
    /* Keep header title white for contrast on header bg */
}

header p {
    margin: 0.2rem 0 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

main {
    flex: 1;
    position: relative;
    width: 100%;
    background-color: #f0f0f0;
    /* Contrast for model area if needed, though model-viewer handles env */
}

model-viewer {
    width: 100%;
    height: 100%;
    background-color: var(--astros-navy);
    /* Seamless blend */
    --poster-color: var(--astros-navy);
}

/* AR Button styling - Glassmorphism */
#ar-button {
    background: rgba(0, 45, 98, 0.7);
    /* Semi-transparent Navy */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #FF8200;
    /* Orange Accents */
    border: 2px solid #FF8200;
    border-radius: 12px;
    /* Softer corners */
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
    /* Position Handling via slot but we can style slot content */
    /* The slot uses absolute positioning internally often, let's target it carefully */
    position: absolute;
    bottom: 40px;
    /* Will be buffered by container if inside? No, model-viewer slot is separate. */
    /* Wait, the ar-button slot is inside model-viewer's shadow DOM or light DOM? Light DOM. */
    /* If it is in Light DOM, we can just position it. */
    /* The prompt says wrap the UI. If AR button is inside model-viewer, it's inside Main. */
    /* I should move the AR button calculation to be safe. */
    /* But standard CSS env() works on bottom property too. */
    bottom: calc(20px + env(safe-area-inset-bottom, 50px));
    left: 50%;
    transform: translateX(-50%);
    cursor: pointer;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: all 0.3s ease;
}

#ar-button:active {
    background: rgba(0, 45, 98, 0.9);
    transform: translateX(-50%) scale(0.95);
}

#ar-button:focus {
    outline: 3px solid #FFFFFF;
    outline-offset: 2px;
}

footer {
    background-color: #001f44;
    color: #ccc;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.8rem;
}

/* Accessibility: High contrast focus rings */
*:focus-visible {
    outline: 3px solid var(--astros-orange);
    outline-offset: 2px;
}

/* Mobile responsive optimization */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.2rem;
    }
}

#lock-toggle {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(5px);
    border: 1px solid #FFF;
    color: #FFF;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    transition: background 0.3s;
    display: block;
    margin-top: 15px;
    width: 100%;
}

#lock-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    /* Above model-viewer, below UI (20) */
    background: transparent;
    /* Invisible shield */
}