/* DefragWar-Yo - 90s Retro Windows 95/98 OS & CRT Styling */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    background-color: #008080; /* Windows 95/98 Desktop Teal */
    background-image: radial-gradient(rgba(0, 0, 0, 0.15) 15%, transparent 16%);
    background-size: 8px 8px;
    font-family: "MS Sans Serif", Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    color: #000000;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 16px;
    overflow-x: hidden;
}

/* --- WINDOWS 95/98 WINDOW CHASSIS --- */
.win95-window {
    background: #c0c0c0;
    border: 2px solid #ffffff;
    border-right-color: #000000;
    border-bottom-color: #000000;
    box-shadow: 1px 1px 0px #808080 inset, -1px -1px 0px #dfdfdf inset, 4px 4px 15px rgba(0,0,0,0.6);
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
}

/* Title Bar */
.win95-titlebar {
    background: linear-gradient(90deg, #000080, #1084d0);
    color: #ffffff;
    padding: 3px 4px 3px 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.titlebar-icon {
    margin-right: 6px;
}

.titlebar-controls {
    display: flex;
    gap: 2px;
}

.win95-title-btn {
    background: #c0c0c0;
    border: 1px solid #ffffff;
    border-right-color: #000000;
    border-bottom-color: #000000;
    box-shadow: 1px 1px 0px #dfdfdf inset, -1px -1px 0px #808080 inset;
    width: 16px;
    height: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 9px;
    font-family: monospace;
    cursor: pointer;
}

.win95-title-btn:active {
    border: 1px solid #000000;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
}

/* Menu Bar */
.win95-menubar {
    display: flex;
    gap: 12px;
    padding: 3px 8px;
    border-bottom: 1px solid #808080;
    background: #c0c0c0;
}

.menu-item {
    cursor: pointer;
    padding: 1px 4px;
}

.menu-item:hover {
    background: #000080;
    color: #ffffff;
}

.menu-item span {
    text-decoration: underline;
}

/* Toolbar Controls */
.win95-toolbar {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 1px solid #808080;
    background: #d4d0c8;
    align-items: center;
    flex-wrap: wrap;
}

.win95-btn {
    background: #c0c0c0;
    border: 2px solid #ffffff;
    border-right-color: #000000;
    border-bottom-color: #000000;
    box-shadow: 1px 1px 0px #dfdfdf inset, -1px -1px 0px #808080 inset;
    padding: 3px 10px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.win95-btn:active {
    border: 2px solid #000000;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    box-shadow: 1px 1px 0px #808080 inset;
    padding: 4px 9px 2px 11px;
}

.win95-btn.primary {
    font-weight: bold;
}

/* Telemetry Dashboard Panels */
.telemetry-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 6px;
    padding: 6px 8px;
    background: #c0c0c0;
    border-bottom: 1px solid #808080;
}

.telemetry-panel {
    border: 1px solid #808080;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    padding: 4px 6px;
    background: #d4d0c8;
    font-size: 10px;
}

.telemetry-label {
    font-weight: bold;
    color: #404040;
    margin-bottom: 2px;
    display: flex;
    justify-content: space-between;
}

.telemetry-bar-bg {
    background: #101820;
    height: 12px;
    border: 1px solid #808080;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    overflow: hidden;
    position: relative;
}

.telemetry-bar-fill {
    height: 100%;
    width: 0%;
    transition: width 0.15s ease-out;
}

.buffer-dots {
    display: flex;
    gap: 3px;
    height: 12px;
    align-items: center;
}

.buffer-dot {
    width: 8px;
    height: 8px;
    background: #333333;
    border: 1px solid #666666;
}

.buffer-dot.filled {
    background: #ffd600;
    border-color: #ffffff;
    box-shadow: 0 0 4px #ffd600;
}

/* --- CRT CANVAS SCREEN FRAME --- */
.screen-container {
    position: relative;
    background: #000000;
    margin: 6px 8px;
    border: 2px solid #808080;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: 580px;
    cursor: crosshair;
}

/* CRT Shader & Scanlines Overlay */
.crt-overlay {
    pointer-events: none;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
}

.crt-active .crt-overlay {
    display: block;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.4) 50%),
                radial-gradient(ellipse at center, rgba(0,0,0,0) 65%, rgba(0,0,0,0.7) 100%);
    background-size: 100% 4px, 100% 100%;
    box-shadow: inset 0 0 40px rgba(0, 255, 200, 0.1);
}

/* Cluster Legend */
.cluster-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 6px 10px;
    background: #c0c0c0;
    border-top: 1px solid #ffffff;
    font-size: 10px;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border: 1px solid #404040;
}

/* Status Bar */
.win95-statusbar {
    display: flex;
    gap: 6px;
    padding: 2px 6px;
    background: #c0c0c0;
    border-top: 1px solid #808080;
    font-size: 10px;
}

.status-panel {
    border: 1px solid #808080;
    border-right-color: #ffffff;
    border-bottom-color: #ffffff;
    padding: 2px 6px;
    flex: 1;
}

.status-panel.fixed {
    flex: none;
    width: 120px;
}

/* --- OVERLAY MODALS --- */
.game-modal-backdrop {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.game-dialog {
    background: #c0c0c0;
    border: 2px solid #ffffff;
    border-right-color: #000000;
    border-bottom-color: #000000;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.8);
    width: 90%;
    max-width: 440px;
    padding: 3px;
}

.dialog-body {
    padding: 16px;
    font-size: 12px;
    line-height: 1.4;
}

/* --- BSOD (BLUE SCREEN OF DEATH) CRASH OVERLAY --- */
.bsod-screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #0000aa;
    color: #ffffff;
    font-family: "Courier New", monospace;
    font-size: 13px;
    padding: 24px;
    display: none;
    z-index: 30;
    overflow: hidden;
    line-height: 1.5;
}

.bsod-header {
    background: #c0c0c0;
    color: #0000aa;
    font-weight: bold;
    display: inline-block;
    padding: 2px 10px;
    margin-bottom: 16px;
}

.bsod-reboot-box {
    margin-top: 20px;
    border: 2px dashed #ffff00;
    padding: 12px;
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
}

.bsod-progress-bar {
    width: 100%;
    height: 16px;
    background: #000055;
    border: 1px solid #ffffff;
    margin: 10px 0;
}

.bsod-progress-fill {
    height: 100%;
    width: 0%;
    background: #00ff66;
}
