@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&family=Orbitron:wght@700&display=swap');

body {
    font-family: 'Roboto', sans-serif;
    background-color: #1a1a1a;
    color: #e0e0e0;
    margin: 0;
    padding: 20px 0;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top to prevent scroll issues on long pages */
    min-height: 100vh;
    box-sizing: border-box;
    background-image: url('./background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-color: #1a1a1a; /* Fallback color */
}

#gallery-modal {
    display: none;
    position: fixed;
    z-index: 2000; /* Increased z-index */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.85);
    animation: fadeIn 0.5s;
}

#gallery-content {
    background: #202226;
    margin: 5% auto;
    padding: 25px;
    border: 1px solid #555;
    width: 80%;
    max-width: 1200px;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

#gallery-main-view h2 {
    font-family: 'Orbitron', sans-serif;
    color: #4CAF50;
    text-align: center;
    margin-top: 0;
    margin-bottom: 25px;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

#active-universe-display {
    font-family: 'Orbitron', sans-serif;
    color: #4CAF50;
    font-size: 1.1rem;
    margin-top: 8px;
    margin-bottom: 0;
    height: 20px;
}

#live-settings-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 5px;
    margin-top: 8px;
    transition: color 0.3s ease, transform 0.2s ease;
}

#live-settings-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

#live-settings-btn svg {
    width: 20px;
    height: 20px;
}

#gallery-close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
}

#gallery-close-btn:hover,
#gallery-close-btn:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 10px;
}

.gallery-item {
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
}

.gallery-item:hover {
    background-color: #3a3a3a;
    border-color: #66bb6a;
}

.gallery-item h3 {
    font-family: 'Orbitron', sans-serif;
    color: #ff4d4d;
    margin: 0 0 10px 0;
    font-size: 1.1rem;
}
.gallery-item p {
    font-size: 0.9rem;
    color: #b0b0b0;
    line-height: 1.5;
    margin: 0;
    flex-grow: 1;
}

#gallery-detail-view {
    padding: 10px;
}

#gallery-back-btn {
    background: none;
    border: 1px solid #888;
    color: #888;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    margin-bottom: 20px;
}

#gallery-back-btn:hover {
    color: #fff;
    border-color: #fff;
    background-color: rgba(255,255,255,0.1);
}

#gallery-detail-title {
    font-family: 'Orbitron', sans-serif;
    color: #ff4d4d;
    font-size: 1.8rem;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid #ff4d4d;
    padding-bottom: 10px;
}

#gallery-detail-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #e0e0e0;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px; /* For scrollbar */
}

/* Custom Scrollbar */
#gallery-detail-text::-webkit-scrollbar,
#gallery-grid::-webkit-scrollbar {
  width: 8px;
}
#gallery-detail-text::-webkit-scrollbar-track,
#gallery-grid::-webkit-scrollbar-track {
  background: transparent;
}
#gallery-detail-text::-webkit-scrollbar-thumb,
#gallery-grid::-webkit-scrollbar-thumb {
  background-color: #555;
  border-radius: 4px;
}
#gallery-detail-text::-webkit-scrollbar-thumb:hover,
#gallery-grid::-webkit-scrollbar-thumb:hover {
  background-color: #66bb6a;
}

.container {
    width: 95%;
    max-width: 1400px;
    text-align: center;
    padding: 25px;
    background: linear-gradient(135deg, rgba(26, 26, 26, 0.95), rgba(38, 38, 38, 0.9));
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid rgba(255, 77, 77, 0.2);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    position: relative;
    overflow: hidden;
}

.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 77, 77, 0.05) 50%, transparent 70%);
    pointer-events: none;
}

.header {
    position: relative;
    margin-bottom: 10px;
}

.header-controls {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    gap: 20px;
    align-items: center;
}

#view-mode-control {
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s ease, transform 0.2s ease;
}

#view-mode-control:hover {
    color: #fff;
    transform: scale(1.1);
}

h1 {
    font-family: 'Orbitron', sans-serif;
    color: #ff4d4d;
    font-size: 2.8rem;
    text-shadow: 
        0 0 5px #ff4d4d, 
        0 0 15px #ff4d4d, 
        0 0 25px #ff4d4d,
        0 0 35px rgba(255, 77, 77, 0.5);
    margin: 0;
    padding: 0;
    letter-spacing: 2px;
    animation: titleGlow 3s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 5px #ff4d4d, 0 0 15px #ff4d4d, 0 0 25px #ff4d4d; }
    to { text-shadow: 0 0 8px #ff4d4d, 0 0 20px #ff4d4d, 0 0 35px #ff4d4d, 0 0 45px rgba(255, 77, 77, 0.8); }
}

p {
    font-size: 1.1rem;
    color: #b0b0b0;
    max-width: 800px;
    margin: 0 auto 25px auto;
}

#audio-control {
    position: relative;
    top: auto;
    right: auto;
    transform: none;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s ease, transform 0.2s ease;
}

#audio-control:hover {
    color: #fff;
    transform: scale(1.1);
}

#audio-control.muted #volume-icon {
    display: none;
}
#audio-control.muted #mute-icon {
    display: block;
    color: #ff4d4d;
}

#audio-control:not(.muted) #volume-icon {
    display: block;
}
#audio-control:not(.muted) #mute-icon {
    display: none;
}

#controls {
    margin: 25px auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 25px;
    flex-wrap: wrap;
    background: linear-gradient(145deg, rgba(0,0,0,0.4), rgba(20,20,20,0.6));
    padding: 25px;
    border-radius: 12px;
    border: 1px solid rgba(85, 85, 85, 0.6);
    max-width: 1100px;
    box-shadow: 
        0 8px 25px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.1);
    backdrop-filter: blur(5px);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    min-width: 200px; /* Give groups a consistent width */
    justify-content: flex-start;
}

.control-group label {
    font-family: 'Orbitron', sans-serif;
    font-size: 0.9rem;
    color: #ccc;
}

#disaster-select, #report-style-select {
    font-size: 1rem;
    padding: 12px 20px;
    border-radius: 5px;
    border: 1px solid #555;
    background: linear-gradient(145deg, #3a3a3a, #2c2c2c);
    color: #e0e0e0;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: all 0.2s ease-in-out;
}

#disaster-select option, #report-style-select option {
    background: #333;
    color: #e0e0e0;
}

#custom-disaster-input, #custom-report-style-input, #simulate-btn {
    font-size: 1rem;
    padding: 12px 20px;
    border-radius: 5px;
    border: 1px solid #555;
    background: linear-gradient(145deg, #3a3a3a, #2c2c2c);
    color: #fff;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    transition: all 0.2s ease-in-out;
}
#custom-disaster-input, #custom-report-style-input {
     width: 180px;
     text-align: center;
}
#custom-disaster-input::placeholder, #custom-report-style-input::placeholder {
     color: #888;
}

#custom-disaster-input, #custom-report-style-input:hover {
    border-color: #777;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.main-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
    margin-bottom: 20px;
}

#simulate-btn, #gallery-btn, #pause-btn, #universe-btn {
    font-size: 1rem;
    padding: 14px 24px;
    border-radius: 8px;
    border: none;
    color: #fff;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    font-weight: bold;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
}

#simulate-btn::before, #gallery-btn::before, #pause-btn::before, #universe-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

#simulate-btn:hover::before, #gallery-btn:hover::before, #pause-btn:hover::before, #universe-btn:hover::before {
    width: 300px;
    height: 300px;
}

#simulate-btn {
    background: linear-gradient(145deg, #c62828, #d32f2f);
    box-shadow: 0 4px 15px rgba(198, 40, 40, 0.4);
}

#simulate-btn:hover {
    background: linear-gradient(145deg, #e53935, #f44336);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(229, 57, 53, 0.6);
}

#pause-btn {
    background: linear-gradient(145deg, #ff9800, #ffa726);
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.4);
}
#pause-btn:hover {
    background: linear-gradient(145deg, #ffa726, #ffb74d);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 167, 38, 0.6);
}

#gallery-btn {
    background: linear-gradient(145deg, #4CAF50, #66bb6a);
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4);
}
#gallery-btn:hover {
    background: linear-gradient(145deg, #66bb6a, #81c784);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(102, 187, 106, 0.6);
}

#universe-btn {
    background: linear-gradient(145deg, #1E88E5, #42A5F5);
    box-shadow: 0 4px 15px rgba(30, 136, 229, 0.4);
}
#universe-btn:hover {
    background: linear-gradient(145deg, #42A5F5, #64b5f6);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(66, 165, 245, 0.6);
}

#simulate-btn:active, #gallery-btn:active, #pause-btn:active, #universe-btn:active {
    transform: translateY(1px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
    border-bottom-width: 1px;
}

#simulate-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    color: #999;
    box-shadow: none;
    transform: none;
    border-bottom: none;
}

/* Toggle Switch CSS */
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #555; transition: .4s; }
.slider.round { border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #c62828; }
input:checked + .slider:before { transform: translateX(26px); }

#main-content {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    align-items: flex-start; /* Prevents items from stretching to match height */
}

#map-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
    background: linear-gradient(145deg, rgba(0,0,0,0.3), rgba(20,20,20,0.5));
    border-radius: 12px;
    border: 1px solid rgba(255, 77, 77, 0.3);
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
}

#map {
    height: 550px; /* Use fixed height */
    width: 100%;
    border: 2px solid #ff4d4d;
    border-radius: 12px;
    box-shadow: 
        0 0 30px rgba(255, 77, 77, 0.4),
        inset 0 0 20px rgba(0,0,0,0.3);
    overflow: hidden;
}

#info-panel {
    display: flex;
    justify-content: space-around;
    background: linear-gradient(145deg, rgba(0,0,0,0.5), rgba(20,20,20,0.7));
    padding: 20px;
    border-radius: 10px;
    border: 1px solid rgba(76, 175, 80, 0.3);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#map-layer-toggle {
    display: flex;
    justify-content: center;
    margin-top: 15px;
}

.layer-btn {
    font-family: 'Roboto', sans-serif;
    font-weight: bold;
    font-size: 0.9rem;
    padding: 10px 18px;
    border: 1px solid #555;
    background: linear-gradient(145deg, #333, #2a2a2a);
    color: #aaa;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.layer-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s;
}

.layer-btn:hover::before {
    left: 100%;
}

.layer-btn:first-child {
    border-top-left-radius: 5px;
    border-bottom-left-radius: 5px;
    border-right: none;
}

.layer-btn:last-child {
    border-top-right-radius: 5px;
    border-bottom-right-radius: 5px;
}

.layer-btn.active {
    background: linear-gradient(145deg, #1E88E5, #1976D2);
    color: #fff;
    border-color: #1E88E5;
    box-shadow: 0 3px 10px rgba(30, 136, 229, 0.4);
}

.layer-btn:not(.active):hover {
    background: linear-gradient(145deg, #444, #3a3a3a);
    color: #fff;
    transform: translateY(-1px);
}

.info-item {
    text-align: center;
    padding: 0 15px;
    position: relative;
}

.info-item::after {
    content: '';
    position: absolute;
    right: 0;
    top: 10%;
    height: 80%;
    width: 1px;
    background: linear-gradient(to bottom, transparent, #4CAF50, transparent);
}

.info-item:last-child::after {
    display: none;
}

.info-label {
    display: block;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    color: #aaa;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#sim-date, #sim-time, #sim-population {
    font-size: 1.3rem;
    font-weight: bold;
    color: #4CAF50;
    font-family: 'Roboto Mono', monospace;
    text-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
    transition: all 0.3s ease;
}

#results-container {
    flex: 1;
    background: linear-gradient(145deg, rgba(38, 38, 38, 0.95), rgba(26, 26, 26, 0.9));
    border: 1px solid rgba(68, 68, 68, 0.6);
    border-radius: 12px;
    padding: 25px;
    text-align: left;
    height: 613px; /* Match height of map-container (550px map + 15px gap + 48px info-panel) */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.4);
}

#results-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #ff4d4d;
    border-radius: 12px 12px 0 0;
}

#results-container h2 {
    font-family: 'Orbitron', sans-serif;
    color: #ff4d4d;
    margin-top: 0;
    border-bottom: 2px solid #ff4d4d;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
}

#report-actions {
    position: absolute;
    top: 22px;
    right: 20px;
}

#live-control-panel {
    display: none; /* managed by JS */
    gap: 10px;
    margin-top: 15px;
    padding: 10px;
    background-color: rgba(0,0,0,0.3);
    border-radius: 6px;
    border-top: 1px solid #ff9800;
}

#live-event-input {
    flex-grow: 1;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #555;
    background: #2c2c2c;
    color: #e0e0e0;
}
#live-event-input:focus {
    outline: none;
    border-color: #ff9800;
    box-shadow: 0 0 5px #ff980055;
}

#inject-event-btn {
    font-size: 0.9rem;
    padding: 8px 15px;
    border-radius: 5px;
    border: none;
    background-color: #ff9800;
    color: #000;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    border-bottom: 2px solid #b36b00;
}

#inject-event-btn:hover:not(:disabled) {
    background-color: #ffa726;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px #ffa72680;
}

#inject-event-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    color: #999;
    border-bottom: none;
    box-shadow: none;
    transform: none;
}

#share-btn, #submit-to-gallery-btn {
    background: none;
    border: 1px solid #888;
    color: #888;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s;
    margin-left: 10px;
}

#share-btn:hover, #submit-to-gallery-btn:hover:not(:disabled) {
    color: #fff;
    border-color: #fff;
    background-color: rgba(255,255,255,0.1);
}

#submit-to-gallery-btn:disabled {
    color: #4CAF50;
    border-color: #4CAF50;
    cursor: not-allowed;
    opacity: 0.7;
}

#report-content {
    color: #e0e0e0;
    line-height: 1.6;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Hide overflow of the container */
}

#report-text {
    overflow-y: auto;
    flex-grow: 1;
    padding-right: 10px; /* for scrollbar */
}

#report-text .loading-text {
    font-style: italic;
    color: #888;
    animation: pulse 1.5s infinite;
}

#report-image {
    width: 100%;
    height: 200px;
    background-color: #111;
    border-radius: 6px;
    margin-bottom: 15px;
    display: none; /* Hidden by default, shown by JS */
    overflow: hidden;
    border: 1px solid #444;
}

#report-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

#report-image.loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-text {
    font-style: italic;
    color: #888;
    animation: pulse 1.5s infinite;
}

#report-text .loading-text {
    font-style: italic;
    color: #888;
    animation: pulse 1.5s infinite;
}

/* Custom Scrollbar */
#report-text::-webkit-scrollbar {
  width: 8px;
}
#report-text::-webkit-scrollbar-track {
  background: transparent;
}
#report-text::-webkit-scrollbar-thumb {
  background-color: #555;
  border-radius: 4px;
}
#report-text::-webkit-scrollbar-thumb:hover {
  background-color: #ff4d4d;
}

/* Dark mode filter for map tiles */
.leaflet-tile-pane:not(.satellite-layer) {
    filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

#summary-container {
    margin: 30px auto 0 auto;
    background-color: #202226;
    border: 1px solid #4caf4f88;
    border-radius: 8px;
    padding: 20px;
    text-align: left;
    animation: fadeIn 1s ease;
}

#summary-container h2 {
    font-family: 'Orbitron', sans-serif;
    color: #4CAF50;
    margin-top: 0;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

#summary-content {
    color: #e0e0e0;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
}

/* Custom Scrollbar for summary */
#summary-content::-webkit-scrollbar {
  width: 8px;
}
#summary-content::-webkit-scrollbar-track {
  background: transparent;
}
#summary-content::-webkit-scrollbar-thumb {
  background-color: #555;
  border-radius: 4px;
}
#summary-content::-webkit-scrollbar-thumb:hover {
  background-color: #4CAF50;
}

.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: #333;
    color: #fff;
    border: 1px solid #ff4d4d;
}

.leaflet-popup-content {
    font-size: 14px;
}

/* --- GeoSearch Control --- */
.leaflet-control-geosearch.bar {
    border-color: #555;
    background-color: #333;
}
.leaflet-control-geosearch.bar form {
    border-color: #555;
    height: 40px;
}
.leaflet-control-geosearch.bar form input {
    background-color: #222;
    color: #fff;
    height: 40px;
    padding: 0 15px;
    border: none;
    font-family: 'Roboto', sans-serif;
}
.leaflet-control-geosearch.bar form input::placeholder {
    color: #aaa;
}
.leaflet-control-geosearch.bar .results {
    background: #262626;
    border-color: #555;
}
.leaflet-control-geosearch.bar .results > * {
    border-color: #555;
    color: #fff;
    padding: 10px;
}
.leaflet-control-geosearch.bar .results > *:hover,
.leaflet-control-geosearch.bar .results > .active {
    background: #ff4d4d;
    color: #fff;
}
.leaflet-control-geosearch-button.active {
    background-color: #c62828 !important;
    border-color: #c62828 !important;
}

#universe-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #4caf4f44;
    display: flex;
    gap: 10px;
    justify-content: center;
}

#universe-name-input {
    flex-grow: 1;
    max-width: 300px;
    font-size: 0.9rem;
    padding: 8px 12px;
    border-radius: 5px;
    border: 1px solid #555;
    background: #2c2c2c;
    color: #e0e0e0;
}

#save-universe-btn {
    font-size: 0.9rem;
    padding: 8px 15px;
    border-radius: 5px;
    border: none;
    background-color: #4CAF50;
    color: #fff;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

#save-universe-btn:hover:not(:disabled) {
    background-color: #66bb6a;
}

#save-universe-btn:disabled {
    background-color: #555;
    cursor: not-allowed;
    color: #999;
    border-bottom: none;
    box-shadow: none;
    transform: none;
}

/* Live Settings Modal */
#live-settings-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.85);
    animation: fadeIn 0.5s;
}

#live-settings-content {
    background: #202226;
    margin: 10% auto;
    padding: 25px;
    border: 1px solid #555;
    width: 90%;
    max-width: 500px;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

#live-settings-content h2 {
    font-family: 'Orbitron', sans-serif;
    color: #4CAF50;
    text-align: center;
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

#live-settings-content p {
    text-align: center;
    font-size: 0.9rem;
    color: #b0b0b0;
    margin-bottom: 25px;
}

#live-settings-close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
}

#live-settings-close-btn:hover,
#live-settings-close-btn:focus {
    color: #fff;
}

#live-settings-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#live-settings-options label {
    display: block;
    font-size: 1rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 5px;
    background-color: #2c2c2c;
    border: 1px solid #444;
    transition: all 0.2s;
}

#live-settings-options label:hover {
    background-color: #3a3a3a;
    border-color: #66bb6a;
}

#live-settings-options input[type="checkbox"] {
    margin-right: 12px;
    transform: scale(1.2);
    accent-color: #4CAF50;
}

#universe-content {
    background: #202226;
    margin: 5% auto;
    padding: 25px;
    border: 1px solid #555;
    width: 80%;
    max-width: 900px;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
}

#universe-content h2 {
    font-family: 'Orbitron', sans-serif;
    color: #4CAF50;
    text-align: center;
    margin-top: 0;
    margin-bottom: 25px;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

#universe-close-btn {
    position: absolute;
    top: 15px;
    right: 25px;
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    border: none;
    background: none;
    cursor: pointer;
}

#universe-close-btn:hover,
#universe-close-btn:focus {
    color: #fff;
}

.universe-actions-top {
    text-align: center;
    margin-bottom: 25px;
}

#start-new-universe-btn {
    font-size: 1.1rem;
    padding: 12px 25px;
    border-radius: 5px;
    border: none;
    background-color: #4CAF50;
    color: #fff;
    cursor: pointer;
    font-family: 'Roboto', sans-serif;
    font-weight: bold;
    transition: all 0.3s;
    border-bottom: 3px solid #357a38;
}

#start-new-universe-btn:hover {
    background-color: #66bb6a;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px #66bb6a80;
}

#universe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

#universe-grid::-webkit-scrollbar { width: 8px; }
#universe-grid::-webkit-scrollbar-track { background: transparent; }
#universe-grid::-webkit-scrollbar-thumb { background-color: #555; border-radius: 4px; }
#universe-grid::-webkit-scrollbar-thumb:hover { background-color: #66bb6a; }

.universe-item {
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: background-color 0.3s, border-color 0.3s;
}

.universe-item:hover {
    background-color: #3a3a3a;
    border-color: #66bb6a;
}

.universe-item h3 {
    font-family: 'Orbitron', sans-serif;
    color: #66bb6a;
    margin: 0 0 8px 0;
    font-size: 1.2rem;
}

.universe-item p {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin: 0 0 15px 0;
    line-height: 1.4;
}

.universe-item-actions {
    display: flex;
    gap: 10px;
    margin-top: auto; /* Pushes to bottom */
}

.universe-item-actions button {
    flex-grow: 1;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid;
    background: transparent;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.universe-load-btn {
    color: #66bb6a;
    border-color: #66bb6a;
}
.universe-load-btn:hover {
    background: #66bb6a;
    color: #1a1a1a;
}

.universe-delete-btn {
    color: #c62828;
    border-color: #c62828;
}
.universe-delete-btn:hover {
    background: #c62828;
    color: #fff;
}

.live-update {
    padding: 15px;
    margin-bottom: 12px;
    border-left: 4px solid #ff9800;
    background: linear-gradient(145deg, rgba(0,0,0,0.3), rgba(20,20,20,0.5));
    border-radius: 6px;
    animation: slideInLeft 0.5s ease-out;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    border: 1px solid rgba(255, 152, 0, 0.2);
}

@keyframes slideInLeft {
    from { 
        opacity: 0; 
        transform: translateX(-30px); 
    }
    to { 
        opacity: 1; 
        transform: translateX(0); 
    }
}

@media (max-width: 1024px) {
    #main-content {
        flex-direction: column;
    }
    #map, #results-container {
        min-height: 450px;
    }
}

body.mobile-view .container {
    width: 100%;
    max-width: 450px; /* A typical mobile screen width */
    padding: 15px;
    margin: 0 auto;
    border-radius: 12px;
}

body.mobile-view #main-content {
    flex-direction: column;
    align-items: stretch;
    gap: 20px;
}

body.mobile-view #map-container {
    padding: 15px;
}

body.mobile-view #map,
body.mobile-view #results-container {
    height: 400px;
}

body.mobile-view #results-container {
    height: auto;
    min-height: 400px;
}

body.mobile-view #controls {
    flex-direction: column;
    gap: 20px;
    align-items: stretch;
    padding: 20px;
}

body.mobile-view .control-group {
    width: 100%;
    min-width: auto;
}

body.mobile-view .header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

body.mobile-view .header-controls {
    position: static;
    transform: none;
    width: 100%;
    justify-content: center;
    gap: 30px;
}

body.mobile-view .main-buttons {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
}

body.mobile-view .main-buttons button {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
}

body.mobile-view .info-panel {
    padding: 15px;
    flex-direction: column;
    gap: 15px;
}

body.mobile-view .info-item {
    padding: 10px;
    border-radius: 8px;
    background: rgba(0,0,0,0.2);
}

body.mobile-view .info-item::after {
    display: none;
}

body.mobile-view #sim-date, 
body.mobile-view #sim-time, 
body.mobile-view #sim-population {
    font-size: 1.1rem;
}

#creator-ad {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1500; /* Above map, below modals */
    background: rgba(26, 26, 26, 0.9);
    backdrop-filter: blur(3px);
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    transition: transform 0.3s ease;
    animation: fadeIn 1s ease 1s forwards;
    opacity: 0;
}

#creator-ad:hover {
    transform: translateY(-3px);
}

#creator-ad a {
    color: #e0e0e0;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
}

#creator-ad a:hover {
    color: #66bb6a;
}