*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --win-bg: #008080;
  --win-white: #ffffff;
  --win-black: #000000;
  --win-gray: #808080;
  --win-light: #c0c0c0;
  --win-dark: #404040;
  --win-blue: #000080;
  --win-title-active: #000080;
  --win-title-inactive: #808080;
}

body {
  font-family: 'VT323', monospace;
  overflow: hidden;
  background: #000;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Cpath d='M0 0L0 14L4 10L7 15L9 14L6 9L11 9Z' fill='white' stroke='black' stroke-width='1'/%3E%3C/svg%3E") 0 0, auto;
  user-select: none;
}

/* CRT Overlay */
.crt-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 99999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0.03) 0px,
    rgba(0,0,0,0.03) 1px,
    transparent 1px,
    transparent 2px
  );
}

.crt-screen {
  box-shadow: inset 0 0 80px rgba(0,0,0,0.3), inset 0 0 20px rgba(0,0,0,0.2);
}

/* Boot screen */
.boot-screen {
  background: #000;
  color: #00ff00;
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 40px;
  white-space: pre-wrap;
  line-height: 1.6;
}

.boot-cursor {
  display: inline-block;
  width: 10px;
  height: 18px;
  background: #00ff00;
  animation: blink 0.5s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* Window styles */
.win-window {
  position: absolute;
  background: var(--win-white);
  border: 2px solid var(--win-black);
  box-shadow: 2px 2px 0 var(--win-black);
  display: flex;
  flex-direction: column;
}

.win-titlebar {
  background: var(--win-title-inactive);
  color: var(--win-white);
  padding: 2px 4px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 22px;
  cursor: move;
  flex-shrink: 0;
}

.win-titlebar.active {
  background: var(--win-title-active);
}

.win-titlebar-text {
  flex: 1;
  text-align: center;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}

.win-btn {
  width: 18px;
  height: 16px;
  background: var(--win-light);
  border-top: 1px solid var(--win-white);
  border-left: 1px solid var(--win-white);
  border-bottom: 1px solid var(--win-dark);
  border-right: 1px solid var(--win-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  margin-left: 2px;
  color: var(--win-black);
  padding: 0;
  line-height: 1;
}

.win-btn:active {
  border-top: 1px solid var(--win-dark);
  border-left: 1px solid var(--win-dark);
  border-bottom: 1px solid var(--win-white);
  border-right: 1px solid var(--win-white);
}

.win-content {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.win-menubar {
  background: var(--win-white);
  border-bottom: 1px solid var(--win-black);
  display: flex;
  padding: 1px 0;
  flex-shrink: 0;
}

.win-menu-item {
  padding: 2px 10px;
  font-size: 14px;
  cursor: pointer;
  position: relative;
}

.win-menu-item:hover {
  background: var(--win-title-active);
  color: var(--win-white);
}

.win-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--win-white);
  border: 1px solid var(--win-black);
  z-index: 1000;
  min-width: 160px;
}

.win-dropdown-item {
  padding: 3px 16px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.win-dropdown-item:hover {
  background: var(--win-title-active);
  color: var(--win-white);
}

.win-dropdown-sep {
  border-top: 1px solid var(--win-gray);
  margin: 2px 0;
}

/* Button 3D effect */
.btn-3d {
  background: var(--win-light);
  border-top: 2px solid var(--win-white);
  border-left: 2px solid var(--win-white);
  border-bottom: 2px solid var(--win-dark);
  border-right: 2px solid var(--win-dark);
  font-family: 'VT323', monospace;
  font-size: 16px;
  cursor: pointer;
  padding: 4px 16px;
}

.btn-3d:active {
  border-top: 2px solid var(--win-dark);
  border-left: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-white);
  border-right: 2px solid var(--win-white);
}

/* Scrollbar */
.win-content::-webkit-scrollbar { width: 16px; }
.win-content::-webkit-scrollbar-track {
  background: repeating-conic-gradient(var(--win-light) 0% 25%, var(--win-white) 0% 50%) 50%/4px 4px;
  border: 1px solid var(--win-gray);
}
.win-content::-webkit-scrollbar-thumb {
  background: var(--win-light);
  border-top: 1px solid var(--win-white);
  border-left: 1px solid var(--win-white);
  border-bottom: 1px solid var(--win-dark);
  border-right: 1px solid var(--win-dark);
}

/* Desktop icons */
.desktop-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 70px;
  padding: 4px;
  cursor: pointer;
}

.desktop-icon:hover .icon-label {
  background: var(--win-title-active);
  color: var(--win-white);
}

.icon-img {
  width: 32px;
  height: 32px;
  image-rendering: pixelated;
  margin-bottom: 2px;
}

.icon-label {
  font-size: 12px;
  text-align: center;
  padding: 1px 3px;
  color: var(--win-white);
  text-shadow: 1px 1px 0 #000;
}

/* Dialog */
.win-dialog {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10000;
  background: var(--win-light);
  border: 2px solid var(--win-black);
  border-top: 2px solid var(--win-white);
  border-left: 2px solid var(--win-white);
  box-shadow: 3px 3px 0 var(--win-black);
  padding: 0;
}

.win-dialog-title {
  background: var(--win-title-active);
  color: white;
  padding: 3px 6px;
  font-size: 14px;
  text-align: center;
}

.win-dialog-body {
  padding: 16px 24px;
  text-align: center;
  font-size: 16px;
}

/* Notepad */
.notepad-textarea {
  width: 100%;
  height: 100%;
  border: none;
  resize: none;
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 4px;
  outline: none;
  background: var(--win-white);
}

/* Calculator */
.calc-display {
  background: #9EAD86;
  border-top: 2px solid var(--win-dark);
  border-left: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-white);
  border-right: 2px solid var(--win-white);
  padding: 8px 12px;
  font-size: 28px;
  text-align: right;
  margin: 8px;
  font-family: 'VT323', monospace;
  overflow: hidden;
}

.calc-btn {
  background: var(--win-light);
  border-top: 2px solid var(--win-white);
  border-left: 2px solid var(--win-white);
  border-bottom: 2px solid var(--win-dark);
  border-right: 2px solid var(--win-dark);
  font-family: 'VT323', monospace;
  font-size: 18px;
  cursor: pointer;
  width: 40px;
  height: 32px;
}

.calc-btn:active {
  border-top: 2px solid var(--win-dark);
  border-left: 2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-white);
  border-right: 2px solid var(--win-white);
}

/* Top menu bar */
.top-menubar {
  background: var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  display: flex;
  align-items: center;
  height: 24px;
  padding: 0 4px;
  z-index: 9999;
  position: relative;
}

/* Bottom taskbar */
.bottom-taskbar {
  background: var(--win-light);
  border-top: 2px solid var(--win-white);
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 14px;
}

/* Paint */
.paint-color {
  width: 16px;
  height: 16px;
  border: 1px solid var(--win-black);
  cursor: pointer;
  display: inline-block;
}

.paint-color.selected {
  border: 2px solid var(--win-white);
  outline: 2px solid var(--win-black);
}

/* File listing */
.file-item {
  display: flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 14px;
  cursor: pointer;
}

.file-item:hover {
  background: var(--win-title-active);
  color: var(--win-white);
}

/* Reversi */
.reversi-cell {
  width: 36px;
  height: 36px;
  background: #006400;
  border: 1px solid #004d00;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.reversi-piece {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid #333;
}

/* Shutdown screen */
.shutdown-screen {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #000080;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
}

.shutdown-text {
  color: #ffaa00;
  font-size: 28px;
  text-align: center;
  font-family: 'VT323', monospace;
}

/* Small screen warning */
.small-screen-warning {
  display: none;
}

@media (max-width: 500px) {
  .small-screen-warning {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #000080;
    color: #ffaa00;
    font-family: 'VT323', monospace;
    font-size: 20px;
    text-align: center;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 40px;
    flex-direction: column;
  }
  .desktop-main { display: none !important; }
}

.minimized-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 64px;
  padding: 4px;
  cursor: pointer;
  position: absolute;
}

.minimized-icon .icon-label {
  font-size: 11px;
}