/* Force full screen and hide scrollbars */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #020204; /* Deep space dark backdrop */
    font-family: 'Arial Black', sans-serif;
}

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

/* Subtle overlay to give it a high-stakes, secure feel */
#vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 100px rgba(0,0,0,0.8);
    z-index: 2;
    pointer-events: none;
}

/* --- WELCOME MESSAGING TYPOGRAPHY --- */
.welcome-container {
    position: absolute;
    top: 18%; /* Frames the top third of the globe */
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
    pointer-events: none;
    user-select: none;
    width: 100%;
}

.welcome-title {
    font-size: 54px;
    font-weight: 900;
    letter-spacing: 6px;
    margin: 0;
    /* Sleek metallic gradient text */
    background: linear-gradient(to bottom, #ffffff 30%, #a3a3a3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.9));
}

.welcome-subtitle {
    font-size: 13px;
    color: #ffd014; /* Matches button safety-yellow */
    font-weight: bold;
    letter-spacing: 5px;
    margin-top: 12px;
    text-transform: uppercase;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
    opacity: 0.9;
}

/* --- INDUSTRIAL BUTTONS SYSTEM --- */

/* Center container for primary LOGIN */
.ui-container-center {
    position: absolute;
    top: 66%; /* Places the main button exactly 2/3 down */
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Bottom right container for NEW PLAYER secondary route */
.ui-container-right {
    position: absolute;
    bottom: 5%;
    right: 5%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Bottom-left container for ABOUT — mirrors NEW PLAYER */
.ui-container-left {
    position: absolute;
    bottom: 5%;
    left: 5%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Version label, bottom-centre */
.version-label {
    position: absolute;
    bottom: 5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    color: #ffd014;
    font-size: 12px;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: bold;
    opacity: 0.75;
    text-shadow: 0 2px 4px rgba(0,0,0,0.9);
    pointer-events: none;
    user-select: none;
}

/* ABOUT panel overlay */
.about-overlay {
    position: absolute;
    inset: 0;
    z-index: 50;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 2, 4, 0.82);
    backdrop-filter: blur(4px);
    padding: 20px;
}
.about-overlay.show { display: flex; }
.about-panel {
    width: min(460px, 100%);
    max-height: 80vh;
    background: linear-gradient(180deg, #1d1810, #14110d);
    border: 2px solid #2b0c00;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
    padding: 26px 24px 22px;
    position: relative;
    color: #e8e2d4;
    font-family: 'Trebuchet MS', sans-serif;
}
.about-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    color: #9b9484;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.15s;
}
.about-close:hover { color: #ffd014; }
.about-title {
    font-family: 'Arial Black', sans-serif;
    font-size: 22px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0 0 4px;
    background: linear-gradient(to bottom, #fff 30%, #a3a3a3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.about-tagline {
    color: #ffd014;
    font-size: 12px;
    font-style: italic;
    letter-spacing: 1px;
    margin: 0 0 14px;
    opacity: 0.9;
}
.about-scroll {
    max-height: 48vh;
    overflow-y: auto;
    padding-right: 8px;
    font-size: 14px;
    line-height: 1.6;
}
.about-scroll p { margin: 0 0 12px; }
.about-scroll h3 {
    color: #d64700;
    font-size: 13px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 16px 0 8px;
}
.about-scroll ol { margin: 0 0 12px; padding-left: 20px; }
.about-scroll ol li { margin-bottom: 6px; }
.about-foot {
    font-size: 12px;
    color: #9b9484;
    font-style: italic;
    border-top: 1px solid #3a2f20;
    padding-top: 10px;
    margin-top: 4px !important;
}
.about-scroll::-webkit-scrollbar { width: 8px; }
.about-scroll::-webkit-scrollbar-thumb { background: #521800; border-radius: 4px; }

/* Outer Heavily Weathered Rusted Frame */
.industrial-frame {
    background: radial-gradient(circle at 50% 20%, #e65c19 0%, #a63605 40%, #521800 90%);
    padding: 10px 14px;
    border-radius: 80px;
    border: 5px solid #2b0c00;
    box-shadow: 
        0 15px 30px rgba(0, 0, 0, 0.7),
        inset 0 4px 6px rgba(255, 255, 255, 0.3),
        inset 0 -10px 20px rgba(0, 0, 0, 0.6);
    position: relative;
}

/* Simulated Rust Patches via pseudo-element */
.industrial-frame::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 75px;
    background-image: 
        radial-gradient(ellipse at 20% 30%, rgba(66, 20, 1, 0.8) 0%, transparent 20%),
        radial-gradient(circle at 85% 70%, rgba(41, 13, 1, 0.9) 0%, transparent 25%);
    pointer-events: none;
}

/* Inner Clean Construction Orange Socket Rim */
.orange-rim {
    background: linear-gradient(to bottom, #d64700, #802b00);
    padding: 6px;
    border-radius: 65px;
    border: 3px solid #1a0600;
    box-shadow: inset 0 8px 12px rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
}

/* The Animated Safety-Yellow Core Button */
.yellow-core {
    background: linear-gradient(to bottom, #ffd014 0%, #f0ab00 60%, #c28600 100%);
    border: 3px solid #3d2f00;
    border-radius: 50px;
    padding: 18px 75px;
    color: #2b2b2b;
    font-size: 32px;
    font-weight: 900;
    letter-spacing: 3px;
    cursor: pointer;
    outline: none;
    position: relative;
    user-select: none;
    
    /* High-fidelity cartoony shadow mechanics */
    box-shadow: 
        0 8px 0 #8a6000, 
        inset 0 4px 4px rgba(255, 255, 255, 0.6),
        inset 0 -4px 8px rgba(0, 0, 0, 0.2);
    
    transition: transform 0.05s ease, box-shadow 0.05s ease;
}

/* 3D Depress Animation Mechanics on Click */
.yellow-core:active {
    transform: translateY(6px);
    box-shadow: 
        0 2px 0 #8a6000, 
        inset 0 6px 10px rgba(0, 0, 0, 0.6),
        inset 0 -2px 4px rgba(255, 255, 255, 0.2);
    color: #121212;
}

.yellow-core:hover {
    filter: brightness(1.05);
}

/* --- SMALL MODIFIER VARIANT (For New Player Experience) --- */
.industrial-frame.small {
    padding: 6px 10px;
    border-radius: 50px;
    border: 3px solid #2b0c00;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.6);
}

.industrial-frame.small::before {
    border-radius: 45px;
}

.orange-rim.small {
    padding: 4px;
    border-radius: 40px;
    border: 2px solid #1a0600;
}

.yellow-core.small {
    padding: 10px 24px;
    font-size: 14px;
    letter-spacing: 1px;
    box-shadow: 
        0 4px 0 #8a6000, 
        inset 0 2px 2px rgba(255, 255, 255, 0.6),
        inset 0 -2px 4px rgba(0, 0, 0, 0.2);
}

.yellow-core.small:active {
    transform: translateY(4px); /* Scaled down travel distance */
    box-shadow: 
        0 1px 0 #8a6000, 
        inset 0 4px 6px rgba(0, 0, 0, 0.6),
        inset 0 -1px 2px rgba(255, 255, 255, 0.2);
}

/* --- AUTH VIEWS (login / signup) --- */
.auth-overlay {
    position: absolute;
    inset: 0;
    z-index: 60;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(2, 2, 4, 0.78);
    backdrop-filter: blur(4px);
    padding: 20px;
}
.auth-overlay.show { display: flex; }

.auth-panel {
    width: min(360px, 100%);
    background: linear-gradient(180deg, #1d1810, #14110d);
    border: 2px solid #2b0c00;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.8), inset 0 1px 0 rgba(255,255,255,0.05);
    padding: 30px 26px 26px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #9b9484;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}
.auth-close:hover { color: #ffd014; }

.auth-title {
    font-family: 'Arial Black', sans-serif;
    font-size: 22px;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin: 0 0 6px;
    text-align: center;
    background: linear-gradient(to bottom, #fff 30%, #a3a3a3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    background: #0d0b08;
    border: 1px solid #3a2f20;
    border-radius: 6px;
    color: #e8e2d4;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 15px;
    outline: none;
}
.auth-input:focus { border-color: #ffd014; }

.auth-submit {
    margin-top: 6px;
    padding: 13px;
    background: linear-gradient(180deg, #ffd014, #d68a00);
    border: none;
    border-radius: 6px;
    color: #1a1206;
    font-family: 'Arial Black', sans-serif;
    font-size: 16px;
    letter-spacing: 2px;
    cursor: pointer;
    transition: filter 0.15s;
}
.auth-submit:hover { filter: brightness(1.1); }

.auth-message {
    min-height: 18px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 13px;
    color: #ffd014;
    text-align: center;
}

/* --- MAIN GAME MAP VIEW --- */
#mapView {
    position: absolute;
    inset: 0;
    z-index: 70;
    display: none;
    flex-direction: column;
    background: radial-gradient(circle at 50% 30%, #161512, #070706);
}
#mapView.show { display: flex; }

#mapHeader {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px 8px;
    background: linear-gradient(180deg, #1d1810, #14110d);
    border-bottom: 2px solid #2b0c00;
    gap: 8px;
}
.mapbar-brand {
    font-family: 'Arial Black', sans-serif;
    letter-spacing: 4px;
    font-size: 24px;
    text-align: center;
    background: linear-gradient(to bottom, #ffd014, #d68a00);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
#mapStatsRow {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    width: 100%;
}
.stat { display: flex; flex-direction: column; align-items: center; }
.stat-label {
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #9b8f6e;
}
.stat-val {
    font-family: 'Arial Black', sans-serif;
    font-size: 18px;
    color: #ffd014;
}
#mapLogout {
    background: #0d0b08;
    border: 1px solid #3a2f20;
    color: #c9bfa6;
    padding: 8px 14px;
    border-radius: 6px;
    font-family: 'Trebuchet MS', sans-serif;
    cursor: pointer;
}
#mapLogout:hover { border-color: #ffd014; color: #ffd014; }

#mapWrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 20px;
}
#mapGrid {
    display: grid;
    gap: 2px;
    width: min(90vmin, 680px);
    aspect-ratio: 1 / 1;
}
.cell {
    background: #2a2620;
    border: 1px solid #1c1915;
    border-radius: 2px;
}
.cell.owned { background: #4a6340; border-color: #6f8a5a; }
.cell.origin { background: #ffd014; border-color: #ffe57a; }

#mapInfo {
    padding: 12px 20px;
    text-align: center;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 13px;
    color: #c9bfa6;
    border-top: 1px solid #2b0c00;
    background: #100d09;
}

/* --- DIG PANEL + FATIGUE BAR --- */
#digPanel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 16px 20px 24px;
    background: #100d09;
    border-top: 1px solid #2b0c00;
}
#fatigueWrap {
    width: min(90vw, 420px);
    height: 14px;
    background: #0d0b08;
    border: 1px solid #3a2f20;
    border-radius: 8px;
    overflow: hidden;
}
#fatigueBar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #1d9e75, #ffd014);
    transition: width 0.12s linear;
}
#digButton {
    padding: 16px 60px;
    background: linear-gradient(180deg, #ffd014, #d68a00);
    border: none;
    border-radius: 10px;
    color: #1a1206;
    font-family: 'Arial Black', sans-serif;
    font-size: 22px;
    letter-spacing: 3px;
    cursor: pointer;
    user-select: none;
    transition: filter 0.1s, transform 0.05s;
}
#digButton:hover { filter: brightness(1.08); }
#digButton:active { transform: scale(0.97); }
#digButton:disabled {
    background: #3a322500;
    background-color: #2a2620;
    color: #7a7060;
    cursor: not-allowed;
}

/* --- CASH COUNTER (above fatigue bar) --- */
#cashCounter {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-bottom: 4px;
}
.cash-label {
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 10px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #9b8f6e;
}
#mapBalance {
    font-family: 'Arial Black', monospace;
    font-size: 26px;
    color: #ffd014;
    letter-spacing: 1px;
    text-shadow: 0 0 12px rgba(255, 208, 20, 0.35);
}

/* --- AD BANNER PLACEHOLDER (bottom) --- */
#adBanner {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(45deg, #15120d, #15120d 12px, #1a160f 12px, #1a160f 24px);
    background: #141109;
    border-top: 2px dashed #3a2f20;
    color: #5f5848;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 12px;
    letter-spacing: 4px;
    text-transform: uppercase;
}

/* --- RIVAL-OWNED BLOCK --- */
.cell.rival { background: #6b3a2a; border-color: #8a4a35; }
.cell { cursor: pointer; }
.cell:hover { outline: 1px solid #ffd01480; }

/* --- CLAIMS OFFICE BUTTON --- */
#officeButton {
    position: absolute;
    bottom: 90px;
    left: 16px;
    z-index: 75;
    background: linear-gradient(180deg, #2a2620, #1a160f);
    border: 1px solid #6f8a5a;
    color: #cfe0b8;
    padding: 10px 16px;
    border-radius: 8px;
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 14px;
    cursor: pointer;
}
#officeButton:hover { border-color: #ffd014; color: #ffd014; }

/* --- CLAIMS OFFICE DRAWER (slides from left, 1/3 width) --- */
#officeBackdrop {
    position: absolute;
    inset: 0;
    z-index: 80;
    background: rgba(0,0,0,0.45);
    display: none;
}
#officeBackdrop.show { display: block; }
#officeDrawer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 33%;
    min-width: 280px;
    max-width: 460px;
    z-index: 85;
    background: linear-gradient(180deg, #1d1810, #100d09);
    border-right: 2px solid #2b0c00;
    box-shadow: 6px 0 30px rgba(0,0,0,0.6);
    transform: translateX(-105%);
    transition: transform 0.28s ease;
    padding: 24px 22px;
    overflow-y: auto;
}
#officeDrawer.show { transform: translateX(0); }
#officeClose {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    color: #9b9484;
    font-size: 28px;
    cursor: pointer;
}
#officeClose:hover { color: #ffd014; }
.office-title {
    font-family: 'Arial Black', sans-serif;
    letter-spacing: 2px;
    font-size: 20px;
    color: #ffd014;
    margin: 0 0 18px;
}
.office-coord {
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 13px;
    letter-spacing: 1px;
    color: #9b8f6e;
    margin: 0 0 4px;
}
.office-status { font-family: 'Arial Black', sans-serif; font-size: 16px; margin: 6px 0; }
.office-status.free { color: #8fce6a; }
.office-status.owned { color: #ffd014; }
.office-status.rival { color: #d98b6a; }
.office-price {
    font-family: 'Arial Black', sans-serif;
    font-size: 34px;
    color: #ffd014;
    margin: 10px 0;
}
.office-hint, .office-msg {
    font-family: 'Trebuchet MS', sans-serif;
    font-size: 12px;
    color: #9b8f6e;
}
#buyBlockBtn {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    background: linear-gradient(180deg, #ffd014, #d68a00);
    border: none;
    border-radius: 8px;
    color: #1a1206;
    font-family: 'Arial Black', sans-serif;
    letter-spacing: 2px;
    font-size: 15px;
    cursor: pointer;
}
#buyBlockBtn:hover { filter: brightness(1.08); }
#buyBlockBtn:disabled { opacity: 0.6; cursor: not-allowed; }