/* =========================================================================
   I. VARIABLES & RESET
   ========================================================================= */
* {
    box-sizing: border-box;
}

body {
    background-color: #080b08;
    color: #00ffcc; /* Cyan-Green */
    text-shadow: 0 0 6px rgba(0, 255, 204, 0.7);
    font-family: 'Courier New', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
    overflow-x: hidden;
}

/* =========================================================================
   II. CRT DISPLAY THEME (SCANLINES, GLASS, ANIMATIONS)
   ========================================================================= */

/* Scanline Overlay */
.monitor-wrapper::after,
.viewport-wrapper::after,
.osc-wrapper::after {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        to bottom,
        rgba(255,255,255,.01) 0px,
        rgba(255,255,255,.01) 1px,
        rgba(0,0,0,.08) 2px,
        rgba(0,0,0,.08) 4px
    );
    pointer-events: none;
    border-radius: inherit;
    z-index: 16;
}

.monitor-wrapper::after { opacity: .7; }
.osc-wrapper::after { opacity: .35; }
.viewport-wrapper::after { opacity: .15; }

/* Convex Glass Effect & Tube Reflection */
.monitor-wrapper::before,
.viewport-wrapper::before,
.osc-wrapper::before {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 40%),
        radial-gradient(circle at center, rgba(0, 0, 0, 0) 60%, rgba(0, 0, 0, 0.5) 100%);
    z-index: 15;
    pointer-events: none;
    border-radius: inherit;
}

/* CRT Power Transitions */
.monitor-wrapper.boot .monitor {
    transform: scale(0);
    opacity: 0;
}

.monitor-wrapper.crt-off .monitor,
.viewport-wrapper.crt-off #spaceView,
.osc-wrapper.crt-off #oscilloscope {
    animation: crtPowerDown 0.5s cubic-bezier(0.25, 1, 0.20, 1) forwards;
}

.monitor-wrapper.crt-on .monitor,
.viewport-wrapper.crt-on #spaceView,
.osc-wrapper.crt-on #oscilloscope {
    animation: crtPowerUp 0.6s cubic-bezier(0.19, 1, 0.22, 1) forwards;
}

@keyframes crtPowerDown {
    0% { transform: scaleY(1) scaleX(1); filter: brightness(1); opacity: 1; }
    40% { transform: scaleY(0.01) scaleX(1); filter: brightness(3); opacity: 1; }
    80% { transform: scaleY(0.01) scaleX(0.01); filter: brightness(5); opacity: 1; background: #fff; }
    100% { transform: scaleY(0) scaleX(0); filter: brightness(0); opacity: 0; }
}

@keyframes crtPowerUp {
    0% { transform: scaleY(0) scaleX(0); filter: brightness(0); opacity: 0; }
    30% { transform: scaleY(0.01) scaleX(0.01); filter: brightness(5); opacity: 1; background: #fff; }
    60% { transform: scaleY(0.01) scaleX(1); filter: brightness(3); opacity: 1; }
    100% { transform: scaleY(1) scaleX(1); filter: brightness(1); opacity: 1; }
}

/* =========================================================================
   III. CORE LAYOUT
   ========================================================================= */

.outer-deck {
    position: relative;
    padding-top: 35px;
    width: 100%;
    max-width: 760px;
    display: flex;
    flex-direction: column;
}

.console-deck {
    display: flex;
    align-items: stretch;
    gap: 30px;
    background-color: #0d120d;
    padding: 30px;
    border: 4px solid #1f2a1f;
    border-radius: 14px;
    box-shadow:
        inset 0 2px rgba(255,255,255,.08),
        inset 0 -3px rgba(0,0,0,.3);
    width: 100%;
    position: relative;
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,.03), transparent 35%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,.02), transparent 30%),
        linear-gradient(#182018,#121712);
}

.left-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
    min-width: 0;
}

.right-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px; 
    align-items: center;
}

/* =========================================================================
   IV. MONITOR & VIEWPORT STYLING
   ========================================================================= */

.monitor-wrapper {
    background-color: #000;
    border: 5px solid #2b3a2b;
    border-radius: 24px; 
    width: 100%;
    max-width: 450px;
    height: 290px; 
    overflow: hidden;
    position: relative;
}

.monitor {
    background-color: #0f140f;
    padding: 25px;
    height: 100%;
    border-radius: 18px;
    box-shadow: inset 0 0 40px rgba(0,0,0,1);
    overflow-y: auto;
}

.header-panel {
    border-bottom: 2px dashed #2b3a2b;
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.header-panel h2 {
    margin: 0;
    font-size: 14px;
    letter-spacing: 1px;
}

.readouts p {
    margin: 6px 0;
    font-size: 11px;
    line-height: 1.3;
}

.readouts span {
    font-weight: bold;
    color: #66ff66;
}

.boot-screen {
    display:none;
    white-space:pre-line;
    font-size:12px;
    line-height:1.7;
    color:#00ffcc;
    font-weight:bold;
}

.boot-screen.active { display:block; }
.readouts.hidden { display:none; }

/* Right Side Monitors */
.viewport-wrapper {
    background: #000;
    border: 8px solid #3a4a3a;
    border-radius: 50%;
    width: 220px;
    height: 220px;
    overflow: hidden;
    align-self: center;
    box-shadow: inset 0 0 35px rgba(0,0,0,1);
    position: relative;
}

#spaceView {
    width: 100%;
    height: 100%;
    display: block;
}

.osc-wrapper {
    background-color: #000;
    border: 4px solid #2b3a2b;
    border-radius: 14px;
    width: 228px;
    height: 110px; 
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,1);
    position: relative;
}

#oscilloscope {
    width: 100%;
    height: 100%;
    display: block;
    background-color: #050805;
}

/* =========================================================================
   V. HARDWARE CONTROLS (BUTTONS, SWITCHES, LAMPS)
   ========================================================================= */

.control-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 460px;
    margin-top: 15px;
    gap: 10px;
}

.power-module {
    display:flex;
    align-items:center;
    gap:12px;
}

/* Square Toggle Switch */
.square-switch-wrapper,
.btn-wrapper {
    display:flex;
    flex-direction:column;
    align-items:center;
    gap:6px;
}

.square-switch {
    width:58px;
    height:58px;
    background:#222;
    border:3px solid #444;
    border-radius:4px;
    color:#cc3333;
    font-family:'Courier New', monospace;
    font-size:10px;
    font-weight:bold;
    display:flex;
    justify-content:center;
    align-items:center;
    cursor:pointer;
    box-shadow:
        inset 0 1px 2px rgba(255,255,255,.15),
        inset 0 -3px 4px rgba(0,0,0,.5),
        0 4px 0 #111;
    transition: color .15s, transform .08s;
}

.square-switch.off {
    color:#cc3333;
    text-shadow:0 0 3px rgba(255,0,0,.4);
}

.square-switch.on {
    color:#66ff66;
    text-shadow:0 0 5px rgba(102,255,102,.6);
}
 
.square-switch:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #111;
}

/* Physical indicator lamp housing */
.status-lamp {
    width:22px;
    height:22px;
    border-radius:50%;
    border:3px solid #333;
    background:#660000;
    box-shadow:
        inset 0 2px 4px rgba(255,255,255,.2),
        inset 0 -4px 6px rgba(0,0,0,.8),
        0 3px 5px rgba(0,0,0,.8);
    transition: background .1s, box-shadow .1s;
}

.status-lamp.red {
    background:#cc0000;
    box-shadow:
        0 0 8px rgba(255,0,0,.7),
        inset 0 2px 4px rgba(255,255,255,.25),
        inset 0 -4px 6px rgba(0,0,0,.8);
}

.status-lamp.green-idle { background:#114411; }

.status-lamp.green {
    background:#66ff66;
    box-shadow:
        0 0 15px rgba(102,255,102,.9),
        inset 0 2px 4px rgba(255,255,255,.4);
}

/* Round Buttons Area */
.button-module {
    display: flex;
    justify-content: flex-start;
    margin-top: 15px;
    width: 100%;
}

.round-button-cluster {
    display: flex;
    gap: 10px;
}

.soviet-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #394239, #242b24 70%, #191d19);
    border: 3px solid #495349;
    box-shadow:
        inset 0 1px 2px rgba(255,255,255,.12),
        inset 0 -3px 4px rgba(0,0,0,.45),
        0 4px 0 #111;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: color .15s, transform .08s;
}

.soviet-btn.deactivated {
    color: #cc3333;
    text-shadow: 0 0 3px rgba(255,0,0,.4);
}

.soviet-btn.activated {
    color: #66ff66;
    text-shadow: 0 0 5px rgba(102,255,102,.6);
}

.soviet-btn:active {
    transform: translateY(3px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,.5), 0 1px 0 #111;
}

/* =========================================================================
   VI. MISSION LOG TERMINAL (CRT THEME)
   ========================================================================= */

.log-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 5px;
    padding-bottom: 20px;
}

.log-item {
    border: 1px dashed #2b3a2b;
    padding: 10px 12px;
    cursor: pointer;
    background: rgba(0, 255, 204, 0.02);
    border-radius: 4px;
    transition: all 0.15s ease-in-out;
}

.log-item:hover {
    border-color: #00ffcc;
    background: rgba(0, 255, 204, 0.08);
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.2);
}

.log-item-header {
    font-size: 10px;
    color: #88ffcc;
    margin-bottom: 4px;
}

.log-item-title {
    font-size: 11px;
    font-weight: bold;
    color: #66ff66;
    text-transform: uppercase;
}

.log-detail {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

.soviet-back-btn {
    align-self: flex-start;
    background: #152215;
    border: 1px solid #2b3a2b;
    color: #00ffcc;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: bold;
    padding: 5px 12px;
    cursor: pointer;
    border-radius: 2px;
    text-shadow: 0 0 3px rgba(0, 255, 204, 0.5);
    transition: all 0.15s ease;
}

.soviet-back-btn:hover {
    background: #00ffcc;
    color: #080b08;
    border-color: #00ffcc;
    text-shadow: none;
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

.log-detail-header {
    border-bottom: 1px dashed #2b3a2b;
    padding-bottom: 8px;
}

.log-detail-date {
    font-size: 10px;
    color: #88ffcc;
    margin-bottom: 4px;
}

.log-detail-title {
    font-size: 13px;
    font-weight: bold;
    color: #66ff66;
    text-transform: uppercase;
    line-height: 1.2;
}

.log-detail-body {
    font-size: 11px;
    line-height: 1.4;
    color: #00ffcc;
    white-space: pre-line;
    text-shadow: 0 0 4px rgba(0, 255, 204, 0.3);
}

.log-status {
    text-align: center;
    font-size: 12px;
    padding: 20px;
    color: #88ffcc;
    animation: blink 1.5s infinite;
}

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

/* =========================================================================
   VII. CONSOLE CHASSIS & DECORATIONS
   ========================================================================= */

.metal-tag {
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(145deg, #cbd5e1, #94a3b8, #64748b);
    color: #0f172a;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 11px;
    letter-spacing: 1.5px;
    padding: 4px 14px;
    border: 2px solid #475569;
    border-radius: 2px;
    box-shadow: 
        0 2px 4px rgba(0,0,0,0.4), 
        inset 0 1px 1px rgba(255,255,255,0.6);
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
    z-index: 40;
}

.metal-tag::before, .metal-tag::after {
    content: "•";
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 8px;
    color: #334155;
}
.metal-tag::before { left: 4px; }
.metal-tag::after { right: 4px; }

/* Screws */
.console-deck::before, .console-deck::after,
.ring-nav::before, .ring-nav::after,
.screw {
    content: "";
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background:
        linear-gradient(-18deg, transparent 46%, #444 46%, #444 54%, transparent 54%),
        radial-gradient(circle at 35% 35%, #d7d7d7 0%, #a8a8a8 45%, #5b5b5b 100%);
    box-shadow: inset 0 1px 1px rgba(255,255,255,.5), inset 0 -1px 1px rgba(0,0,0,.5);
}

.console-deck::before, .ring-nav::before { top: 7px; left: 7px; }
.console-deck::after, .ring-nav::after { top: 7px; right: 7px; }
.screw-bl { bottom:7px; left:7px; }
.screw-br { bottom:7px; right:7px; }

/* Webring Physical Module */
.ring-nav {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    gap: 15px;
    z-index: 30;
    background-color: #0d120d;
    padding: 15px 20px;
    border: 3px solid #1f2a1f;
    border-radius: 4px;
    align-self: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    position: relative;
    background:
        radial-gradient(circle at 20% 20%, rgba(255,255,255,.03), transparent 35%),
        radial-gradient(circle at 80% 70%, rgba(255,255,255,.02), transparent 30%),
        linear-gradient(#182018,#121712);
}

.soviet-ring-btn {
    width: 58px;
    height: 58px;
    background: radial-gradient(circle at 35% 30%, #394239, #242b24 70%, #191d19);
    border: 3px solid #495349;
    border-radius: 3px;
    color: #66ff66;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 9px;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    box-shadow:
        inset 0 1px 2px rgba(255,255,255,.12),
        inset 0 -3px 4px rgba(0,0,0,.45),
        0 4px 0 #111;
    transition: all 0.1s ease;
    text-shadow: 0 0 3px rgba(102, 255, 102, 0.5);
}

.soviet-ring-btn:active {
    transform:translateY(3px);
    box-shadow: inset 0 2px 4px rgba(0,0,0,.6), 0 1px 0 #111;
}

/* =========================================================================
   VIII. MOBILE RESPONSIVE MEDIA QUERIES
   ========================================================================= */
@media (max-width: 768px) {
    body { padding: 10px; }
    .outer-deck { padding-top: 45px; }
    .console-deck { flex-direction: column; gap: 20px; padding: 15px; }
    .right-panel { flex-direction: row; justify-content: center; flex-wrap: wrap; gap: 15px; width: 100%; }
    .monitor-wrapper { height: 270px; }
    .control-panel { justify-content: flex-start; }
    .button-module { justify-content: center; }
}

@media (max-width: 480px) {
    .right-panel { flex-direction: column; }
    .control-panel { margin-top: 20px; }
    .ring-nav { grid-template-columns: repeat(2, 1fr); display: grid; gap: 15px; width: 100%; }
    .ring-nav .btn-wrapper { align-items: center; }
}
