/* NEW: Global reset to stop padding from inflating element sizes */
* {
    box-sizing: border-box;
}

body { 
    margin: 0;
    padding: 0;
    background-color: #2b0d02; 
    color: #f4a460; 
    font-family: 'Courier New', Courier, monospace;
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: flex-start; 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
    position: relative;
}

body::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        linear-gradient(rgba(43, 13, 2, 0.4), rgba(43, 13, 2, 0.4)),
        url('images/pathfind_mars_photo.png'); 
    background-size: cover;
    background-position: center;
    z-index: -1; 
}

/* --- THE BOOT SCREEN --- */
#boot-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 0 10px #f4a460;
}

.blink { animation: blinker 1.2s linear infinite; margin-top: 20px;}
@keyframes blinker { 50% { opacity: 0; } }

#sol-title {
    margin-top: 30px; 
    margin-bottom: 25px; 
    font-size: 32px; 
    text-align: center;
    text-transform: uppercase;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    padding: 0 10px;
    min-height: 40px; 
    z-index: 10;
    line-height: 1.3; 
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

#ui-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0; 
    transition: opacity 1.5s ease-in; 
    width: 100%;
}

/* --- RESPONSIVE DIAL --- */
#mars-base {
    position: relative;
    width: 80vmin;
    height: 80vmin;
    max-width: 900px;
    max-height: 900px;
    aspect-ratio: 1 / 1; /* <-- ADD THIS: Forces a perfect circle */
    flex-shrink: 0;      /* <-- ADD THIS: Stops flexbox from squishing it */
    background: radial-gradient(circle, rgba(163, 78, 44, 0.3) 10%, rgba(43, 13, 2, 0.5) 80%);
    border-radius: 50%;
    margin-bottom: 2vh;
    box-shadow: 0 0 20px rgba(244, 164, 96, 0.4);
    border: 3px solid rgba(244, 164, 96, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* FIX: Forces the ring container to break out of flex flow and overlay perfectly */
#ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 14;
}

#lander-base {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%; 
    height: auto;
    z-index: 1;
    pointer-events: none;
    -webkit-mask-image: radial-gradient(circle, rgba(0,0,0,1) 50%, rgba(0,0,0,0) 70%);
    mask-image: radial-gradient(circle, rgba(0,0,0,1) 50%, rgba(0,0,0,0) 70%);
}

#camera-sprite {
    width: 60%; 
    height: auto;
    filter: drop-shadow(0 0 10px #f4a460);
}

/* THE MARTIAN POINTER STICK */
#rover-anchor::after {
    content: '';
    position: absolute;
    bottom: 50%; 
    left: 50%;
    width: 2px; 
    height: 20vmin;
    max-height: 225px; 
    background: linear-gradient(to right, #888888, #ffffff 30%, #cccccc 70%, #777777);
    transform: translateX(-50%);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
    z-index: -1; 
}

.hex-char {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8%; 
    height: 8%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(14px, 2.5vw, 24px); 
    font-weight: bold;
    color: #ffd8a8; 
    background: rgba(43, 13, 2, 0.8); 
    border-radius: 4px;
    border: 1px solid rgba(255, 216, 168, 0.3);
    z-index: 15;
}

#status-container {
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 25px; 
    border-radius: 20px;
    border: 1px solid rgba(244, 164, 96, 0.3);
    backdrop-filter: blur(5px);
    min-height: 44px;  
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 280px;
    margin: 0 auto; 
}

#rover-anchor {
    position: absolute;
    left: 50%; 
    top: 50%;
    width: 20%;
    height: 20%;
    transform: translate(-50%, -50%); 
    transition: transform 1.2s ease-in-out;
    display: flex; 
    align-items: center; 
    justify-content: center;
    z-index: 10;
}

.controls {
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    width: 260px;
    margin-bottom: 2vh;
}

button {
    padding: 8px; 
    background: #3e1b0a; 
    color: #f4a460; 
    border: 2px solid #f4a460;
    cursor: pointer; 
    font-family: inherit; 
    font-weight: bold;
    text-transform: uppercase;
    font-size: 13px;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
}

button:active { transform: translateY(2px); }

#status {
    margin: 0;
    color: #ffd8a8;
    font-weight: bold;
    letter-spacing: 3px;
    text-align: center;
    text-shadow: 0 0 8px rgba(255, 216, 168, 0.8);
}

.glow-active {
    animation: character-pulse 0.5s ease-in-out;
}

#control-panel {
    display: flex;
    flex-direction: column;
    align-items: center; 
    width: 100%;
}

@keyframes character-pulse {
    0% { background: rgba(43, 13, 2, 0.7); border-color: rgba(255, 216, 168, 0.3); }
    50% { 
        background: rgba(163, 78, 44, 0.5); 
        border-color: rgba(244, 164, 96, 0.5); 
        box-shadow: 0 0 6px rgba(244, 164, 96, 0.4); 
    }
    100% { background: rgba(43, 13, 2, 0.7); border-color: rgba(255, 216, 168, 0.3); }
}

/* --- MOBILE TIGHTENING --- */
@media (max-width: 600px) {
    #boot-screen { font-size: 18px; }
    #sol-title { font-size: 18px; margin-top: 15px; margin-bottom: 5px; min-height: 25px; }
    
    #mars-base { width: 75vw; height: 75vw; }
     
    .hex-char { width: 26px; height: 26px; font-size: 16px; }
    #camera-sprite { width: 45px; }
    
    .controls { gap: 6px; width: 250px; margin-bottom: 10px; }
    button { padding: 8px; font-size: 12px; }
    
    #status-container {
        min-height: 38px;
        padding: 8px 20px;
    } 
    #status {
        font-size: 12px;
        line-height: 1.3;
    }
}

/* --- DESKTOP WIDE SCREEN LAYOUT --- */
@media (min-width: 900px) {
    #ui-container {
        /* 1. Use Grid to create two strict, equal-width halves */
        display: grid;
        grid-template-columns: 1fr 1fr; 
        align-items: center;
        justify-items: center; /* 2. Centers the dial and controls perfectly within their own halves */
        width: 100vw;
        height: 75vh;
        /* No gap needed here; the grid handles the spacing naturally */
    }

    #mars-base {
        margin-bottom: 0; 
        /* 3. Updated max-width constraint to 45vw so it never overlaps the right column */
        width: clamp(300px, 75vh, 45vw);
        height: clamp(300px, 75vh, 45vw);
    }

    #control-panel {
        gap: 20px;
    }

    .controls {
        margin-bottom: 0; 
    }
}

/* Hide the warning by default */
#orientation-warning {
    display: none;
}

/* Only trigger on mobile screens turned sideways, ignoring desktop monitors */
@media (orientation: landscape) and (max-width: 900px) {
    #orientation-warning {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: #000000;
        color: #f4a460;
        z-index: 99999; /* Forces it over the boot screen and UI */
        font-family: 'Courier New', Courier, monospace;
        font-size: 18px;
        font-weight: bold;
        text-align: center;
        padding: 20px;
        box-sizing: border-box;
    }
}
