* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: 'VT323', monospace;
  background: linear-gradient(160deg, #1a0a3d 0%, #3a1c71 35%, #5f2c82 60%, #d76d77 100%);
}

/* twinkling starfield background */
.starfield {
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff, transparent),
    radial-gradient(2px 2px at 120px 80px, #fff, transparent),
    radial-gradient(1px 1px at 90px 150px, #ffd6ff, transparent),
    radial-gradient(2px 2px at 200px 220px, #fff, transparent),
    radial-gradient(1px 1px at 250px 60px, #9be7ff, transparent),
    radial-gradient(2px 2px at 300px 180px, #fff, transparent),
    radial-gradient(1px 1px at 350px 40px, #fff, transparent);
  background-repeat: repeat;
  background-size: 400px 300px;
  animation: twinkle 3s infinite alternate;
  z-index: 0;
}
@keyframes twinkle {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

.desktop {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  z-index: 1;
}

/* ===== WINDOW CHROME ===== */
.window {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: min(480px, 90vw);
  background: #c0c0c0;
  border-radius: 2px;
  box-shadow:
    inset -1px -1px 0 #0a0a0a,
    inset 1px 1px 0 #fff,
    inset -2px -2px 0 #6b6b6b,
    inset 2px 2px 0 #dfdfdf,
    4px 4px 12px rgba(0,0,0,0.5);
  user-select: none;
  animation: popIn 0.35s cubic-bezier(.2,1.4,.4,1);
}

@keyframes popIn {
  0% { transform: translateX(-50%) scale(0.6); opacity: 0; }
  70% { transform: translateX(-50%) scale(1.05); opacity: 1; }
  100% { transform: translateX(-50%) scale(1); }
}

.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3px 4px;
  background: linear-gradient(90deg, #0a246a, #3a6ea5 60%, #a6caf0);
  color: #fff;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  cursor: grab;
  border-bottom: 1px solid #000;
}
.title-bar:active { cursor: grabbing; }

.title-bar-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
}

.title-bar-controls { display: flex; gap: 3px; }

.tb-btn {
  width: 20px;
  height: 18px;
  background: #c0c0c0;
  border: none;
  box-shadow:
    inset -1px -1px 0 #0a0a0a,
    inset 1px 1px 0 #fff,
    inset -2px -2px 0 #6b6b6b,
    inset 2px 2px 0 #dfdfdf;
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  color: #000;
  cursor: pointer;
  line-height: 1;
}
.tb-btn:active {
  box-shadow:
    inset 1px 1px 0 #0a0a0a,
    inset -1px -1px 0 #fff;
}
.tb-close { font-weight: bold; }

.menu-bar {
  display: flex;
  gap: 14px;
  padding: 3px 10px;
  background: #c0c0c0;
  border-bottom: 1px solid #808080;
  font-size: 16px;
  color: #000;
}

.window-body {
  background: #c0c0c0;
  padding: 14px;
  text-align: center;
}

.trash-stage {
  position: relative;
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trash-spinner {
  width: 90px;
  height: 108px;
  perspective: 600px;
}
.trash-svg {
  width: 100%;
  height: 100%;
  animation: spin3d 3.5s linear infinite;
  transform-style: preserve-3d;
  filter: drop-shadow(0 0 10px #ff7ff0) drop-shadow(0 0 4px #7ffcff);
}
@keyframes spin3d {
  from { transform: rotateY(0deg); }
  to { transform: rotateY(360deg); }
}

.sparkle {
  position: absolute;
  font-size: 22px;
  color: #fff59d;
  text-shadow: 0 0 8px #fff, 0 0 14px #ff7ff0;
  animation: sparkleFloat 2.4s ease-in-out infinite;
}
.s1 { top: 10px; left: 20px; animation-delay: 0s; }
.s2 { top: 20px; right: 20px; animation-delay: 0.6s; color: #7ffcff; }
.s3 { bottom: 10px; left: 40px; animation-delay: 1.2s; }
.s4 { bottom: 20px; right: 30px; animation-delay: 1.8s; color: #ff9ff2; }
@keyframes sparkleFloat {
  0%, 100% { transform: translateY(0) scale(1); opacity: 0.6; }
  50% { transform: translateY(-10px) scale(1.3); opacity: 1; }
}

.blurb {
  margin: 6px 0 12px;
  font-size: 20px;
  color: #000;
  line-height: 1.3;
}

.rainbow {
  font-weight: bold;
  background: linear-gradient(90deg, #ff004c, #ff9800, #ffee00, #4dff00, #00e5ff, #7c4dff, #ff004c);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: rainbowMove 4s linear infinite;
}
@keyframes rainbowMove {
  from { background-position: 0% 0; }
  to { background-position: 300% 0; }
}

.marquee-wrap {
  overflow: hidden;
  background: #000;
  border: 2px inset #808080;
  padding: 4px 0;
}
.marquee-track {
  display: inline-block;
  white-space: nowrap;
  color: #00ff6a;
  font-size: 18px;
  padding-left: 100%;
  animation: marquee 14s linear infinite;
}
@keyframes marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 3px 8px;
  background: #c0c0c0;
  border-top: 1px solid #fff;
  box-shadow: inset 0 1px 0 #808080;
  font-size: 14px;
  color: #000;
}

/* ===== TASKBAR ===== */
.taskbar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 34px;
  background: #c0c0c0;
  border-top: 2px solid #fff;
  display: flex;
  align-items: center;
  padding: 0 4px;
  gap: 8px;
  z-index: 5;
}
.start-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  padding: 6px 10px;
  background: #c0c0c0;
  box-shadow:
    inset -1px -1px 0 #0a0a0a,
    inset 1px 1px 0 #fff,
    inset -2px -2px 0 #6b6b6b,
    inset 2px 2px 0 #dfdfdf;
  border: none;
  cursor: pointer;
}
.taskbar-items { flex: 1; display: flex; gap: 4px; }
.taskbar-item {
  font-size: 14px;
  padding: 3px 10px;
  background: #dcdcdc;
  box-shadow:
    inset -1px -1px 0 #0a0a0a,
    inset 1px 1px 0 #fff;
  cursor: pointer;
}
.clock {
  font-size: 14px;
  padding: 4px 10px;
  background: #c0c0c0;
  box-shadow: inset 1px 1px 0 #808080;
  color: #000;
}

/* ===== START MENU ===== */
.start-menu {
  position: absolute;
  bottom: 34px;
  left: 0;
  display: none;
  flex-direction: column;
  min-width: 180px;
  background: #c0c0c0;
  padding: 3px;
  box-shadow:
    inset -1px -1px 0 #0a0a0a,
    inset 1px 1px 0 #fff,
    inset -2px -2px 0 #6b6b6b,
    inset 2px 2px 0 #dfdfdf;
  z-index: 15;
}
.start-menu.show { display: flex; }
.start-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 16px;
  color: #000;
  cursor: pointer;
}
.start-menu-item:hover {
  background: #0a246a;
  color: #fff;
}
.start-menu-icon { font-size: 18px; }

/* ===== FAKE MESSAGE BOX ===== */
.msgbox-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.msgbox-overlay.show { display: flex; }

.msgbox {
  position: relative;
  top: auto; left: auto; transform: none;
  width: min(340px, 85vw);
  animation: popIn 0.25s cubic-bezier(.2,1.4,.4,1);
}

.msgbox-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  background: #c0c0c0;
}
.msgbox-icon {
  font-size: 34px;
  flex-shrink: 0;
}
#msgText {
  margin: 0;
  font-size: 19px;
  color: #000;
  line-height: 1.3;
}

.msgbox-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 0 0 14px;
  background: #c0c0c0;
}
.win-btn {
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 4px 20px;
  background: #c0c0c0;
  box-shadow:
    inset -1px -1px 0 #0a0a0a,
    inset 1px 1px 0 #fff,
    inset -2px -2px 0 #6b6b6b,
    inset 2px 2px 0 #dfdfdf;
  border: none;
  cursor: pointer;
}
.win-btn:active {
  box-shadow:
    inset 1px 1px 0 #0a0a0a,
    inset -1px -1px 0 #fff;
}

/* ===== WASHEDUP LOGIN WINDOW ===== */
.washedup-window {
  top: 20%;
  width: min(340px, 88vw);
  z-index: 12;
}
.washedup-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px 20px;
}
.washedup-icon {
  font-size: 40px;
  margin-bottom: 8px;
}
#washedUpForm {
  width: 100%;
  display: flex;
  flex-direction: column;
}
.washedup-label {
  font-size: 17px;
  color: #000;
  margin: 6px 0 3px;
  text-align: left;
}
.washedup-input {
  font-family: 'VT323', monospace;
  font-size: 17px;
  padding: 3px 6px;
  background: #fff;
  border: none;
  box-shadow:
    inset 1px 1px 0 #6b6b6b,
    inset -1px -1px 0 #fff,
    inset 2px 2px 0 #0a0a0a;
  color: #000;
}
.washedup-error {
  min-height: 22px;
  margin-top: 10px;
  font-size: 18px;
  color: #b00000;
  font-weight: bold;
  text-align: center;
}
.washedup-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 6px;
}

.washedup-window.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(-50%); }
  20% { transform: translateX(-50%) translateX(-10px); }
  40% { transform: translateX(-50%) translateX(8px); }
  60% { transform: translateX(-50%) translateX(-6px); }
  80% { transform: translateX(-50%) translateX(4px); }
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 46px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #000;
  color: #00ff6a;
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 8px 18px;
  border: 2px solid #00ff6a;
  border-radius: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 30;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.window.closing {
  animation: closeOut 0.4s ease-in forwards;
}
@keyframes closeOut {
  to { transform: translateX(-50%) scale(0.2); opacity: 0; }
}
.window.hidden { display: none; }

/* ===== CURSOR SPARKLE TRAIL ===== */
.cursor-sparkle {
  position: fixed;
  top: 0;
  left: 0;
  font-size: 16px;
  color: #fff59d;
  text-shadow: 0 0 6px #fff, 0 0 10px #ff7ff0;
  pointer-events: none;
  z-index: 40;
  animation: cursorSparkleFade 0.7s ease-out forwards;
}
@keyframes cursorSparkleFade {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) translateY(-16px); }
}

/* ===== KONAMI MODE ===== */
.konami-mode .desktop {
  animation: konamiHue 2s linear infinite;
}
@keyframes konamiHue {
  from { filter: hue-rotate(0deg) saturate(1.6); }
  to { filter: hue-rotate(360deg) saturate(1.6); }
}
.konami-mode .trash-svg {
  animation-duration: 0.3s !important;
}

.confetti-piece {
  position: fixed;
  top: -30px;
  font-size: 24px;
  z-index: 41;
  pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(360deg); opacity: 0.9; }
}

/* ===== IDLE SCREENSAVER (PIPES) ===== */
.screensaver {
  position: fixed;
  inset: 0;
  display: none;
  background: #000;
  z-index: 50;
  cursor: none;
}
.screensaver.show { display: block; }

/* ===== BLUE SCREEN OF DEATH ===== */
.bsod {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  background: #0000aa;
  color: #fff;
  z-index: 100;
  padding: 8vh 6vw;
  font-family: 'VT323', monospace;
}
.bsod.show { display: flex; }
.bsod-text {
  white-space: pre-wrap;
  font-size: 22px;
  line-height: 1.4;
  max-width: 800px;
}
#bsodStatus { animation: bsodBlink 1s step-start infinite; }
@keyframes bsodBlink {
  50% { opacity: 0; }
}

@media (max-width: 480px) {
  .bsod-text { font-size: 16px; }

  .window {
    width: 94vw;
  }
  .washedup-window { top: 14%; }

  .title-bar { padding: 4px 5px; }
  .title-bar-text { font-size: 9px; }
  .title-bar-controls { gap: 5px; }
  .tb-btn {
    width: 30px;
    height: 26px;
    font-size: 10px;
  }

  .menu-bar {
    gap: 8px;
    padding: 3px 6px;
    font-size: 13px;
  }

  .window-body { padding: 10px; }
  .trash-stage { height: 130px; }
  .trash-spinner { width: 72px; height: 86px; }
  .sparkle { font-size: 18px; }

  .blurb { font-size: 17px; }
  .marquee-track { font-size: 15px; }
  .status-bar { font-size: 12px; padding: 3px 6px; }

  .taskbar { height: 40px; }
  .start-btn { font-size: 11px; padding: 8px 12px; }
  .clock, .taskbar-item { font-size: 13px; }
  .start-menu { min-width: 200px; bottom: 40px; }
  .start-menu-item { padding: 10px 12px; font-size: 17px; }

  .msgbox-body { padding: 16px 14px; gap: 10px; }
  .msgbox-icon { font-size: 28px; }
  #msgText { font-size: 17px; }
  .win-btn { padding: 6px 18px; font-size: 16px; }

  .washedup-icon { font-size: 34px; }
  .washedup-label { font-size: 16px; }
  .washedup-input { font-size: 16px; padding: 6px; }
}
