body {
    background: #1a1a1a;
    font-family: "Courier New", monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    color: #e6e6d6;
    margin: 0;
    padding: 0 160px;
    overflow-x: hidden;
    transition: background 0.5s ease;
}

h1 {
    text-align: center;
    color: #d8d2b0;
    letter-spacing: 2px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

h2 {
    color: #c9c3a5;
    font-size: 16px;
    margin-top: 0;
    text-align: center;
    width: 100%;
}

.subtitle {
    font-size: 11px;
    color: #888;
    letter-spacing: 1px;
}

.hidden {
    display: none !important;
}

.app-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.main-layout {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.right-stack {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
}

.footer {
    margin-top: 20px;
}

.panel {
    position: relative;
    width: 680px;
    background: linear-gradient(145deg, #2b2b2b, #1c1c1c);
    border: 3px solid #555;
    padding: 20px;
    box-shadow: inset 0 0 10px #000, 0 0 15px rgba(0, 0, 0, 0.6);
    z-index: 10;
}

.valve-panel,
.status-panel,
.reactor-info-panel {
    background: #111;
    border: 2px solid #444;
    padding: 15px;
    margin-top: 80px;
}

.valve-panel {
    width: 150px;
}

.status-panel,
.reactor-info-panel {
    width: 180px;
}

.config-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    background: #111;
    border: 2px solid #444;
    padding: 15px;
    color: #c9c3a5;
    width: 200px;
}

.config-hidden {
    display: none;
}

.config-panel label {
    display: block;
    font-size: 12px;
    margin-bottom: 5px;
}

.config-panel input,
input[type="range"] {
    width: 100%;
    background: #222;
    border: 1px solid #444;
    color: #fff;
}

.config-panel input {
    margin-bottom: 15px;
    padding: 4px;
}

input[type="range"] {
    cursor: pointer;
    accent-color: #c9c3a5;
}

button {
    background: linear-gradient(#3a3a3a, #2a2a2a);
    border: 2px solid #666;
    color: #e6e6d6;
    padding: 8px 12px;
    cursor: pointer;
    font-family: inherit;
    box-shadow: inset 0 1px 0 #777, 0 2px 0 #111;
}

button:hover {
    background: #444;
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
    box-shadow: none;
    border-color: #333;
}

.scram-btn {
    background: linear-gradient(#7a0000, #4a0000);
    border-color: #a33;
    color: #fff;
    font-weight: bold;
    min-width: 120px;
}

#simToggle {
    z-index: 1001;
    position: relative;
}

.top-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.metric-box,
#tempDisplay,
#fuelDisplay,
#waterDisplay,
#rodDisplay {
    background: #000;
    border: 1px solid #444;
    padding: 8px;
    color: #c2b71e;
    font-size: 1.1em;
    box-shadow: inset 0 0 8px rgba(0, 255, 0, 0.1);
}

#tempRate {
    font-size: 0.8em;
    margin-left: 10px;
}

.section {
    background: #222;
    border: 1px solid #444;
    margin: 10px 0;
    padding: 15px;
    box-shadow: inset 0 0 5px #000;
}

.info-line {
    padding: 6px;
    border-bottom: 1px solid #222;
}

.reactor-info-panel {
    font-size: 12px;
    color: #c9c3a5;
}

.reactor-info-panel h2 {
    margin-bottom: 10px;
    font-size: 14px;
}

.rod-layout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 25px;
}

.rod-info {
    flex: 1;
}

.rod-system {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #050505;
    border: 2px solid #555;
    box-shadow: inset 0 0 12px #000, 0 0 8px rgba(0, 0, 0, 0.8);
    padding: 20px 30px;
    min-height: 220px;
    box-sizing: border-box;
}

.rod-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.rod-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    height: 180px;
}

.rod-scale {
    position: relative;
    width: 45px;
    height: 180px;
}

.rod-tick {
    position: absolute;
    right: 0;
    width: 28px;
    height: 1px;
    background: #aaa;
}

.rod-tick span {
    position: absolute;
    right: 34px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 9px;
    font-family: "Courier New", monospace;
    line-height: 1;
}

.tick-0 {
    top: 0%;
    width: 32px;
}

.tick-10 {
    top: 10%;
}

.tick-20 {
    top: 20%;
}

.tick-30 {
    top: 30%;
}

.tick-40 {
    top: 40%;
}

.tick-50 {
    top: 50%;
    width: 32px;
}

.tick-60 {
    top: 60%;
}

.tick-70 {
    top: 70%;
}

.tick-80 {
    top: 80%;
}

.tick-90 {
    top: 90%;
}

.tick-100 {
    top: 100%;
    width: 32px;
}

.rod-housing {
    position: relative;
    width: 52px;
    height: 180px;
    background: #267ebc;
    border: 3px solid #000;
    overflow: hidden;
    box-shadow: inset 0 0 12px #000, 0 0 0 1px #555;
    box-sizing: border-box;
}

.rod-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: auto;
    width: 100%;
    height: 0%;
    background: linear-gradient(
        90deg,
        #bdbdbd 0%,
        #d7d7d7 50%,
        #bdbdbd 100%
    );
    border-bottom: 2px solid #fff;
    box-shadow:
        inset 0 0 8px rgba(255, 255, 255, 0.7),
        0 0 5px rgba(255, 255, 255, 0.25);
    transition: height 0.2s linear;
    transform: none !important;
}

.system-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    width: 100%;
}

.system-item {
    background: #1b1b1b;
    border: 1px solid #444;
    padding: 12px;
    text-align: center;
    box-sizing: border-box;
}

.system-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #400;
    box-shadow: inset 0 0 3px #000;
    transition: all 0.3s;
    flex-shrink: 0;
}

.light.on {
    background: #0f0;
    box-shadow: 0 0 10px #0f0, inset 0 0 3px #fff;
}

.status-item {
    padding: 8px;
    margin: 6px 0;
    text-align: center;
    background: #1a1a1a;
    color: #444;
    border: 1px solid #333;
    font-size: 13px;
}

.status-active {
    background: #004400;
    color: #0f0;
    border-color: #0f0;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.status-meltdown {
    background: #440000;
    color: #f00;
    border-color: #f00;
    animation: dangerPulse 0.5s infinite;
}

.status-scram {
    background: #002244;
    color: #09f;
    border-color: #09f;
}

.status-inactive {
    background: #440000;
    color: #f00;
    border-color: #f00;
}

.status-stalled {
    background: #222;
    color: #fff;
    animation: stalledBlink 1s infinite;
}

.valves-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.valve-group {
    background: #1a1a1a;
    padding: 8px;
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.valve-led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-bottom: 5px;
    background: #444;
}

.led-ready {
    background: #f00 !important;
    box-shadow: 0 0 8px #f00;
}

.led-active {
    background: #0f0 !important;
    box-shadow: 0 0 8px #0f0;
}

.led-cooldown {
    background: #444 !important;
}

.meltdown-timer {
    position: absolute;
    top: 15px;
    left: 49%;
    transform: translateX(-50%);
    background: #000;
    border: 3px solid #f00;
    color: #f00;
    padding: 10px 25px;
    font-size: 20px;
    font-weight: bold;
    z-index: 1000;
    white-space: nowrap;
}

.panel.warning-mode {
    border-color: #f80;
    box-shadow: 0 0 20px rgba(255, 136, 0, 0.4);
}

.panel.meltdown-mode {
    border-color: #f00;
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.6);
    animation: meltdownPulse 0.5s infinite;
}

.panel.safe-mode {
    border-color: #0f6;
    box-shadow: 0 0 25px rgba(0, 255, 102, 0.6);
    animation: safePulse 1s infinite;
}

body.meltdown-safe-mode {
    background: radial-gradient(circle, rgb(0, 42, 18), #1a1a1a);
}

.scram-ready {
    background: #f00 !important;
    color: #fff !important;
    animation: dangerPulse 0.4s infinite;
}

.scram-used {
    background: #333 !important;
    color: #666 !important;
    border-color: #444 !important;
}

@keyframes safePulse {
    0%, 100% {
        box-shadow: 0 0 15px #0f6;
    }

    50% {
        box-shadow: 0 0 40px #0f6;
    }
}

@keyframes dangerPulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes meltdownPulse {
    0%, 100% {
        box-shadow: 0 0 15px #f00;
    }

    50% {
        box-shadow: 0 0 40px #f00;
    }
}

@keyframes stalledBlink {
    0%, 100% {
        border-color: #333;
    }

    50% {
        border-color: #09f;
    }
}

.audio-panel {
    margin-top: 15px;
    font-size: 12px;
}

@media (max-width: 900px) {
    body {
        padding: 0;
        min-height: 100vh;
        display: block;
    }

    html,
    body {
        overflow-x: hidden;
    }

    .app-container,
    .panel,
    .system-item,
    button {
        width: 100%;
    }

    .main-layout {
        flex-direction: column;
        gap: 0;
        width: 100%;
        display: flex;
        min-height: 100vh;
        align-items: stretch;
    }

    .panel {
        max-width: 100%;
        min-height: 100vh;
        border: none;
        box-shadow: none;
        padding: 12px;
        border-radius: 0;
        order: 1 !important;
        box-sizing: border-box;
    }

    .valve-panel,
    .status-panel,
    .reactor-info-panel {
        width: 100%;
        margin: 0;
        border-radius: 0;
        border: none;
        max-width: 100%;
        box-sizing: border-box;
    }

    .config-panel {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100%;
        margin-bottom: 10px;
        order: 0 !important;
        box-sizing: border-box;
    }

    .meltdown-timer {
        position: fixed !important;
        top: 0;
        left: 0;
        transform: none !important;
        width: 100%;
        text-align: center;
        font-size: 14px;
        z-index: 3000;
        border-left: none;
        border-right: none;
        box-sizing: border-box;
    }

    button {
        font-size: 14px;
    }

    .top-controls,
    .rod-layout {
        flex-direction: column;
        gap: 8px;
    }

    .system-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .valves-vertical {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        justify-items: center;
        align-items: stretch;
        background: transparent;
    }

    .valve-group {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        max-width: none;
        padding: 10px;
        gap: 10px;
        border: none !important;
        background: transparent;
        box-shadow: none !important;
    }

    .valve-group button {
        flex: 1;
        font-size: 12px;
        padding: 6px;
    }

    .valve-group .valve-led {
        flex-shrink: 0;
    }

    #valve1::before,
    #valve2::before,
    #valve3::before,
    #valve4::before {
        color: #888;
        font-size: 11px;
    }

    .rod-layout {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .rod-info {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .rod-system {
        flex: 1;
        display: flex;
        justify-content: center;
    }

    .rod-buttons {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }

    .rod-container {
        transform: scale(0.9);
    }

    .reactor-info-panel {
        font-size: 14px;
        order: 5 !important;
    }

    .reactor-info-panel h2 {
        font-size: 16px;
    }

    .info-line {
        font-size: 13px;
    }

    .valve-panel {
        order: 2 !important;
    }

    .right-stack {
        order: 3 !important;
    }

    .status-panel {
        order: 4 !important;
    }
}

.turbine-layout {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 30px;
    margin-top: 20px;
    width: 100%;
    max-width: 900px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

.data-screen {
    background: #000;
    border: 1px solid #1f9d34;
    padding: 15px;
    font-family: "VT323", "Courier New", monospace;
    color: #1f9d34;
    text-align: left;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.synchroscope-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.synchro-info {
    display: flex;
    justify-content: space-between;
    width: 100%;
    font-size: 18px;
    color: #1f9d34;
    border-bottom: 1px dashed #135c1f;
    padding-bottom: 10px;
    margin-bottom: 25px;
}

.status-box {
    padding: 10px;
    text-align: center;
    font-weight: bold;
    border: 1px solid #0f4d1a;
    margin-top: 10px;
    font-size: 18px;
    width: 100%;
    box-sizing: border-box;
}

.status-offline {
    color: #888;
    border-color: #555;
    background: #000;
}

.status-synced {
    background: #1f9d34;
    color: #000;
    border-color: #1f9d34;
}

.status-failed {
    background: #b81414;
    color: #000;
    border-color: #b81414;
}

.level-displays {
    display: flex;
    gap: 10px;
    width: 100%;
}

.level-displays #waterDisplay,
.level-displays #fuelDisplay {
    flex: 1;
    margin: 0;
    box-sizing: border-box;
}

.simulation-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}