/* ==========================================================================
   DESIGN SYSTEM & CUSTOM VARIABLES
   ========================================================================== */
:root {
    --bg-dark: #0a0b0e;
    --bg-card: rgba(18, 22, 33, 0.7);
    --bg-card-border: rgba(255, 255, 255, 0.07);
    
    /* Glowing accents */
    --accent-orange: #ff5e36;
    --accent-orange-glow: rgba(255, 94, 54, 0.35);
    
    --accent-cyan: #00e5ff;
    --accent-cyan-glow: rgba(0, 229, 255, 0.35);
    
    --accent-purple: #bd00ff;
    --accent-purple-glow: rgba(189, 0, 255, 0.35);
    
    --accent-red: #ff3366;
    --accent-red-glow: rgba(255, 51, 102, 0.35);
    
    --text-primary: #f0f3f8;
    --text-secondary: #8f9cae;
    --text-muted: #536275;
    
    --font-ui: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
    
    --border-radius: 12px;
    --transition-speed: 0.25s;
}

/* ==========================================================================
   RESET & SYSTEM BASICS
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: linear-gradient(rgba(10, 11, 14, 0.85), rgba(10, 11, 14, 0.85)), url('mars_colony_bg.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Weather Badges */
.weather-badge {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.status-sunny {
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid rgba(0, 229, 255, 0.4);
    color: var(--accent-cyan);
    text-shadow: 0 0 5px rgba(0, 229, 255, 0.5);
}

.status-cloudy {
    background: rgba(255, 170, 0, 0.15);
    border: 1px solid rgba(255, 170, 0, 0.4);
    color: #ffaa00;
    text-shadow: 0 0 5px rgba(255, 170, 0, 0.5);
}

.status-dusty {
    background: rgba(255, 51, 102, 0.15);
    border: 1px solid rgba(255, 51, 102, 0.4);
    color: var(--accent-red);
    text-shadow: 0 0 5px rgba(255, 51, 102, 0.5);
    animation: blink 2s infinite;
}


/* Stars Background Simulation */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background-image: 
        radial-gradient(1px 1px at 20px 30px, #ffffff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 50px 100px, rgba(255,255,255,0.7), rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 120px 240px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 250px 50px, rgba(255,255,255,0.8), rgba(0,0,0,0)),
        radial-gradient(2px 2px at 300px 350px, #fff, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 450px 150px, rgba(255,255,255,0.9), rgba(0,0,0,0));
    background-size: 550px 550px;
    opacity: 0.45;
}

/* Reddish Mars Atmosphere Dust Overlay */
.dust-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: radial-gradient(circle at 50% 120%, rgba(255, 94, 54, 0.08) 0%, rgba(10, 11, 14, 0) 70%);
    pointer-events: none;
}

a {
    color: var(--accent-orange);
    text-decoration: none;
    transition: color var(--transition-speed);
}
a:hover {
    color: #ff8466;
    text-shadow: 0 0 8px rgba(255, 132, 102, 0.4);
}

/* ==========================================================================
   APP STRUCTURE
   ========================================================================== */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 100vh;
}

/* HEADER */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.highlight {
    color: var(--accent-orange);
    text-shadow: 0 0 10px var(--accent-orange-glow);
}

.pulse-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--accent-orange);
    box-shadow: 0 0 10px var(--accent-orange);
    animation: pulse 1.8s infinite;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* LAYOUT GRID */
.game-grid {
    display: grid;
    grid-template-columns: 320px 1fr 380px;
    gap: 20px;
    align-items: start;
    flex-grow: 1;
}

/* ==========================================================================
   GLASSMORPHIC CARDS
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--border-radius);
    padding: 20px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 12px;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ==========================================================================
   STATUS & METERS
   ========================================================================== */
.sol-counter {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    background: rgba(255, 94, 54, 0.1);
    border: 1px solid rgba(255, 94, 54, 0.25);
    padding: 4px 12px;
    border-radius: 6px;
}

#lbl-sol-title {
    font-size: 0.7rem;
    color: var(--accent-orange);
    font-weight: 700;
    letter-spacing: 1px;
}

#val-sol {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    color: #fff;
    line-height: 1;
}

/* Base dome integrity progress bar */
.integrity-container {
    margin-bottom: 25px;
}

.meter-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.meter-bar-container {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.meter-bar {
    height: 100%;
    border-radius: 5px;
    transition: width 0.5s ease-out;
}

/* ==========================================================================
   RESOURCES GRID
   ========================================================================== */
.resources-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.resource-tile {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background 0.2s;
}

.resource-tile:hover {
    background: rgba(255, 255, 255, 0.04);
}

.tile-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tile-icon {
    font-size: 1.1rem;
}

.tile-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tile-value {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 600;
}

.tile-value small {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* Mini progress bar inside tiles */
.mini-bar-container {
    height: 4px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 2px;
    overflow: hidden;
}

.mini-bar {
    height: 100%;
    transition: width 0.5s ease;
}

/* Bar Colors & Glows */
.bar-cyan {
    background: var(--accent-cyan);
    box-shadow: 0 0 8px var(--accent-cyan-glow);
}
.bar-orange {
    background: var(--accent-orange);
    box-shadow: 0 0 8px var(--accent-orange-glow);
}
.bar-purple {
    background: var(--accent-purple);
    box-shadow: 0 0 8px var(--accent-purple-glow);
}
.bar-danger {
    background: var(--accent-red);
    box-shadow: 0 0 8px var(--accent-red-glow);
}

/* ==========================================================================
   EVENT CARD SYSTEM
   ========================================================================== */
.event-card {
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
    background: rgba(26, 17, 16, 0.8);
    transition: all 0.3s ease;
}

.warning-border {
    border: 1px solid rgba(255, 94, 54, 0.4);
}

.event-glow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--accent-orange), transparent);
    animation: scan-glow 2.5s infinite linear;
}

.alert-tag {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-orange);
    font-weight: 700;
    letter-spacing: 2px;
    display: inline-block;
    margin-bottom: 8px;
    padding: 2px 8px;
    background: rgba(255, 94, 54, 0.1);
    border-radius: 4px;
    border: 1px solid rgba(255, 94, 54, 0.2);
}

.event-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: #fff;
}

.event-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 20px;
    line-height: 1.6;
}

.event-choices {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Choice Buttons */
.choice-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 12px 18px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-ui);
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.choice-btn:hover {
    background: rgba(255, 94, 54, 0.08);
    border-color: rgba(255, 94, 54, 0.5);
    box-shadow: 0 0 15px rgba(255, 94, 54, 0.1);
    padding-left: 24px;
}

.choice-arrow {
    color: var(--accent-orange);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    transform: translateX(-5px);
}

.choice-btn:hover .choice-arrow {
    opacity: 1;
    transform: translateX(0);
}

/* ==========================================================================
   CREW MANAGEMENT
   ========================================================================== */
.crew-section h2 {
    font-size: 1.15rem;
    margin-bottom: 18px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 8px;
}

.crew-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.crew-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 15px;
    display: grid;
    grid-template-columns: 50px 1fr 180px;
    align-items: center;
    gap: 15px;
    transition: border-color 0.2s;
}

.crew-card:hover {
    border-color: rgba(0, 229, 255, 0.2);
}

.crew-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    box-shadow: 0 0 10px rgba(0, 229, 255, 0.15);
}

.crew-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.crew-name {
    font-weight: 600;
    font-size: 1rem;
}

.crew-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.crew-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.stat-label {
    width: 60px;
    color: var(--text-muted);
}

.stat-bar-outer {
    flex-grow: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-inner {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Crew action dropdown */
.crew-action {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.crew-action label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.styled-select {
    background: rgba(10, 11, 14, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    width: 100%;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-speed);
}

.styled-select:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.2);
}

/* ==========================================================================
   UPGRADE CARDS
   ========================================================================== */
.upgrades-section h2 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.upgrades-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 380px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar for upgrades list */
.upgrades-list::-webkit-scrollbar {
    width: 4px;
}
.upgrades-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}
.upgrades-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.upgrade-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    transition: background 0.2s;
}

.upgrade-card:hover {
    background: rgba(255, 255, 255, 0.03);
}

.upgrade-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-grow: 1;
}

.upgrade-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.upgrade-level {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-family: var(--font-mono);
}

.upgrade-cost {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.cost-item {
    background: rgba(255, 255, 255, 0.03);
    padding: 1px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.cost-red {
    color: var(--accent-red);
}

/* ==========================================================================
   AI CONSOLE TERMINAL (CRT STYLING)
   ========================================================================== */
.console-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.console-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.console-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #39ff14;
    box-shadow: 0 0 8px #39ff14;
}

.console-section h2 {
    font-size: 0.85rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}

.console-screen {
    background-color: #05070a;
    border: 1px solid #1a2536;
    border-radius: 6px;
    padding: 15px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.9);
}

/* Monospace scanline noise overlay */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        rgba(18, 16, 16, 0) 50%, 
        rgba(0, 0, 0, 0.25) 50%
    );
    background-size: 100% 4px;
    z-index: 10;
    pointer-events: none;
    opacity: 0.3;
}

.log-line {
    line-height: 1.4;
    word-break: break-word;
    animation: line-fade 0.3s ease-out;
}

.system-line {
    color: var(--text-muted);
}

.report-line {
    color: #fff;
    border-left: 2px solid var(--accent-orange);
    padding-left: 8px;
    margin-top: 5px;
    white-space: pre-line;
}

.ai-line {
    color: var(--accent-cyan);
}

.warning-line {
    color: var(--accent-red);
    font-weight: bold;
    animation: blink 1.5s infinite;
}

/* Console custom scrollbar */
.console-screen::-webkit-scrollbar {
    width: 6px;
}
.console-screen::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}
.console-screen::-webkit-scrollbar-thumb {
    background: #1a2536;
    border-radius: 3px;
}

/* ==========================================================================
   BUTTONS & CONTROLS
   ========================================================================== */
.styled-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.styled-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.btn-danger:hover {
    background: rgba(255, 51, 102, 0.15);
    border-color: rgba(255, 51, 102, 0.4);
    color: #ff668a;
    box-shadow: 0 0 10px rgba(255, 51, 102, 0.15);
}

.btn-large {
    width: 100%;
    padding: 16px 24px;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.btn-glowing {
    background: linear-gradient(135deg, var(--accent-orange) 0%, #ff8466 100%);
    border: none;
    color: #fff;
    box-shadow: 0 4px 15px var(--accent-orange-glow);
    position: relative;
    overflow: hidden;
}

.btn-glowing::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.2), transparent);
    transform: rotate(30deg);
    transition: transform 0.5s ease;
    pointer-events: none;
}

.btn-glowing:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 94, 54, 0.5);
}

.btn-glowing:hover::after {
    transform: translate(50%, 50%) rotate(30deg);
}

.btn-glowing:active {
    transform: translateY(1px);
}

/* ==========================================================================
   APP FOOTER
   ========================================================================== */
.app-footer {
    text-align: center;
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid rgba(255, 255, 255, 0.03);
    margin-top: 20px;
}

/* ==========================================================================
   UTILITIES / VISIBILITY
   ========================================================================== */
.hidden {
    display: none !important;
}

/* ==========================================================================
   ANIMATIONS KEYFRAMES
   ========================================================================== */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 94, 54, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 94, 54, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 94, 54, 0);
    }
}

@keyframes scan-glow {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

@keyframes line-fade {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ==========================================================================
   RESPONSIVE DESIGN (MEDIA QUERIES)
   ========================================================================== */
@media (max-width: 1200px) {
    .game-grid {
        grid-template-columns: 1fr 1fr;
    }
    .right-panel {
        grid-column: span 2;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
}

@media (max-width: 800px) {
    .game-grid {
        grid-template-columns: 1fr;
    }
    .right-panel {
        grid-column: span 1;
        grid-template-columns: 1fr;
    }
    .crew-card {
        grid-template-columns: 50px 1fr;
    }
    .crew-action {
        grid-column: span 2;
        margin-top: 10px;
    }
    .app-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    .header-controls {
        flex-direction: column;
        width: 100%;
    }
    .toggle-group {
        width: 100%;
        justify-content: center;
    }
    .styled-select {
        width: 150px;
    }
}
