/* Basic Reset & Body Styling */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Share Tech Mono', monospace; background-color: #0a0f1f; color: #e0e0e0; line-height: 1.6; display: flex; justify-content: center; align-items: flex-start; min-height: 100vh; padding: 20px; }
.container { width: 100%; max-width: 900px; background-color: #1a1f2f; border: 2px solid #4a4f6f; border-radius: 8px; padding: 20px; box-shadow: 0 0 15px rgba(74, 79, 111, 0.5); }

/* Header Section */
#top-section { border-bottom: 1px solid #4a4f6f; padding-bottom: 15px; margin-bottom: 20px; text-align: center; }
#top-section h1 { font-family: 'Orbitron', sans-serif; color: #ffffff; margin-bottom: 15px; font-size: 2em; text-shadow: 0 0 5px #6a9ff3; }
#status-indicators { display: flex; justify-content: space-around; align-items: center; flex-wrap: wrap; gap: 15px; font-size: 1.1em; }
.indicator span:first-child { color: #aaa; margin-right: 5px; }
.indicator span:last-child { color: #6a9ff3; font-weight: bold; }

/* Distance Bar Styles */
#distance-container { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 220px; }
.distance-emoji { font-size: 1.5em; line-height: 1; }
.progress-bar-wrapper { flex-grow: 1; position: relative; height: 20px; background-color: #333; border: 1px solid #4a4f6f; border-radius: 5px; overflow: hidden; }
progress#distance-bar { width: 100%; height: 100%; appearance: none; background-color: transparent; border: none; position: absolute; top: 0; left: 0; z-index: 1; }
progress#distance-bar::-webkit-progress-value { background-color: #4caf50; border-radius: 0; transition: background-color 0.3s ease; }
progress#distance-bar::-moz-progress-bar { background-color: #4caf50; border-radius: 0; transition: background-color 0.3s ease; }
#spaceship-icon { position: absolute; top: 50%; left: 0%; transform: translate(-50%, -50%); font-size: 1.4em; z-index: 2; transition: left 0.5s linear; pointer-events: none; }
.flash-red progress#distance-bar::-webkit-progress-value,
.flash-red progress#distance-bar::-moz-progress-bar { animation: flashRedBg 1s infinite; }
.flash-red #spaceship-icon { animation: flashRedText 1s infinite; }
@keyframes flashRedBg { 0%, 100% { background-color: #d9534f; } 50% { background-color: #f0ad4e; } }
@keyframes flashRedText { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Middle Section */
#middle-section { margin-bottom: 20px; }
#middle-section h2 { text-align: center; margin-bottom: 15px; color: #bbb; font-size: 1.5em; }
#system-list { max-height: 40vh; overflow-y: auto; padding: 10px; background-color: #101525; border: 1px dashed #4a4f6f; border-radius: 4px; display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }
#system-list::-webkit-scrollbar { width: 8px; }
#system-list::-webkit-scrollbar-track { background: #1a1f2f; }
#system-list::-webkit-scrollbar-thumb { background-color: #4a4f6f; border-radius: 4px; }
.system-module { background-color: #2a2f4f; border: 1px solid #5a5f7f; border-radius: 5px; padding: 12px; display: flex; flex-direction: column; justify-content: space-between; transition: background-color 0.3s ease; }
.system-module h3 { font-size: 1.1em; color: #ffffff; margin-bottom: 8px; }
.system-details p { font-size: 0.9em; margin-bottom: 3px; color: #ccc; }
.system-details span { font-weight: bold; color: #e0e0e0; }
.system-module button { padding: 8px 12px; margin-top: 10px; font-family: 'Share Tech Mono', monospace; font-size: 0.9em; border: none; border-radius: 4px; cursor: pointer; background-color: #5cb85c; color: white; transition: background-color 0.2s ease; font-weight: bold; }
.system-module button:hover { opacity: 0.9; }
.system-module button.active { background-color: #d9534f; }
.system-module button:disabled { background-color: #555; cursor: not-allowed; }

/* Bottom Section */
#bottom-section { border-top: 1px solid #4a4f6f; padding-top: 15px; }
#summary { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 15px; margin-bottom: 20px; font-size: 1.1em; text-align: center; align-items: center; } /* Added align-items */
.summary-item span { font-weight: bold; color: #6a9ff3; }
.summary-item .warning { color: #f8d7da; background-color: #dc3545; padding: 2px 5px; border-radius: 3px; font-weight: bold; animation: blinkWarning 1s infinite; }

/* --- Power Meter Styles --- */
.power-meter-container {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 200px; /* Adjust as needed */
}
.power-meter-container > span:first-child { /* Label */
    color: #aaa;
    flex-shrink: 0; /* Prevent label from shrinking */
}
.power-bar-wrapper {
    flex-grow: 1; /* Allow bar to take space */
    position: relative; /* For potential text overlay */
    height: 18px; /* Bar height */
    background-color: #333; /* Track background */
    border: 1px solid #4a4f6f;
    border-radius: 4px;
    overflow: hidden; /* Clip progress bar */
}
progress#power-meter-bar {
    width: 100%;
    height: 100%;
    appearance: none;
    border: none;
    background-color: transparent; /* Track is handled by wrapper */
    /* transition for smooth value change (optional) */
    /* transition: background-color 0.3s ease; */
}
/* Default color (OK) */
progress#power-meter-bar::-webkit-progress-value { background-color: #5cb85c; transition: background-color 0.3s ease;}
progress#power-meter-bar::-moz-progress-bar { background-color: #5cb85c; transition: background-color 0.3s ease;}
/* Warning color (>80%) */
progress#power-meter-bar.power-warning::-webkit-progress-value { background-color: #f0ad4e; }
progress#power-meter-bar.power-warning::-moz-progress-bar { background-color: #f0ad4e; }
/* Critical color (>100%) */
progress#power-meter-bar.power-critical::-webkit-progress-value { background-color: #d9534f; animation: blinkWarningBg 1s infinite; }
progress#power-meter-bar.power-critical::-moz-progress-bar { background-color: #d9534f; animation: blinkWarningBg 1s infinite; }

#power-meter-text {
    /* Optional: Position text over the bar */
    /* position: absolute; */
    /* top: 50%; left: 50%; transform: translate(-50%, -50%); */
    /* font-size: 0.8em; color: white; text-shadow: 1px 1px 1px black; */

    /* Or display next to the bar */
    font-size: 0.9em;
    color: #ccc;
    margin-left: 8px; /* Space if text is next to bar */
    flex-shrink: 0;
}
/* Animation for critical power bar */
@keyframes blinkWarningBg { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
/* --- End Power Meter Styles --- */


#start-reentry { display: block; width: 50%; margin: 0 auto 20px auto; padding: 12px 20px; font-size: 1.2em; font-family: 'Orbitron', sans-serif; background-color: #f0ad4e; color: #1a1f2f; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.3s ease, transform 0.1s ease; font-weight: bold; }
#start-reentry:hover:not(:disabled) { background-color: #ec971f; transform: scale(1.02); }
#start-reentry:disabled { background-color: #555; color: #aaa; cursor: not-allowed; transform: none; }
#log-panel-container { margin-top: 15px; background-color: #101525; padding: 10px; border: 1px solid #4a4f6f; border-radius: 4px; }
#log-panel-container h3 { text-align: center; margin-bottom: 10px; color: #bbb; }
#log-panel { max-height: 100px; overflow-y: auto; font-size: 0.9em; padding-right: 5px; }
#log-panel p { margin-bottom: 5px; border-bottom: 1px dashed #333; padding-bottom: 3px; }
#log-panel p:last-child { border-bottom: none; }
@keyframes blinkWarning { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

/* Modal Styling */
.modal { display: none; position: fixed; z-index: 10; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.7); }
.modal-content { background-color: #1a1f2f; color: #e0e0e0; margin: 15% auto; padding: 30px; border: 2px solid #6a9ff3; border-radius: 8px; width: 80%; max-width: 500px; text-align: center; box-shadow: 0 5px 15px rgba(106, 159, 243, 0.4); }
#modal-title { font-family: 'Orbitron', sans-serif; font-size: 1.8em; margin-bottom: 15px; }
#modal-image { display: block; max-width: 80%; max-height: 150px; height: auto; margin: 0 auto 15px auto; border-radius: 4px; object-fit: contain; }
#modal-message { font-size: 1.2em; margin-bottom: 20px; }
#modal-stats p { margin-bottom: 8px; font-size: 1.1em; }
#modal-stats span { font-weight: bold; color: #6a9ff3; }
#play-again-button { padding: 10px 20px; font-size: 1.1em; font-family: 'Share Tech Mono', monospace; margin-top: 20px; background-color: #5cb85c; color: white; border: none; border-radius: 5px; cursor: pointer; transition: background-color 0.2s ease; }
#play-again-button:hover { background-color: #4cae4c; }

/* Responsive Adjustments */
@media (max-width: 768px) { /* Adjusted breakpoint for summary layout */
    #summary {
        flex-direction: column; /* Stack summary items */
        align-items: center; /* Center items vertically */
    }
    .power-meter-container {
        width: 80%; /* Make power meter wider when stacked */
        max-width: 300px;
    }
}
@media (max-width: 700px) {
     #status-indicators { flex-direction: column; align-items: center; }
    #distance-container { width: 90%; max-width: 300px; margin-top: 10px; }
}
@media (max-width: 600px) {
    .container { padding: 15px; }
    #top-section h1 { font-size: 1.5em; }
    #status-indicators { font-size: 1em; }
    #system-list { grid-template-columns: 1fr; max-height: 35vh; }
    #summary { font-size: 1em; } /* Already column via 768px breakpoint */
    #start-reentry { width: 80%; font-size: 1.1em; }
    .modal-content { width: 90%; margin: 25% auto; }
    #modal-image { max-height: 120px; }
}