* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  image-rendering: pixelated;
}

body {
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  font-family: 'VT323', monospace;
  cursor: default;
  user-select: none;
}

@font-face {
  font-family: 'Chicago';
  src: local('VT323');
}

.font-chicago {
  font-family: 'VT323', monospace;
}

.font-terminal {
  font-family: 'VT323', monospace;
}

.font-pixel {
  font-family: 'Press Start 2P', cursive;
}

/* Boot screen */
.boot-screen {
  position: fixed;
  inset: 0;
  background: #F5F0E1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.boot-progress {
  width: 200px;
  height: 12px;
  border: 2px solid #000;
  background: #fff;
  margin-top: 16px;
}

.boot-progress-fill {
  height: 100%;
  background: #000;
  transition: width 2s linear;
}

/* Shutdown screen */
.shutdown-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  color: #F5F0E1;
}

/* Menu bar */
.menu-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 24px;
  background: #E8E8E8;
  border-bottom: 2px solid #000;
  display: flex;
  align-items: center;
  z-index: 10000;
  font-size: 16px;
  padding: 0 8px;
}

.menu-item {
  padding: 2px 12px;
  cursor: default;
  position: relative;
  font-family: 'VT323', monospace;
  font-size: 16px;
  line-height: 20px;
}

.menu-item:hover, .menu-item.active {
  background: #000;
  color: #fff;
}

.menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: #fff;
  border: 2px solid #000;
  z-index: 10001;
  box-shadow: 2px 2px 0px #000;
}

.menu-dropdown-item {
  padding: 4px 16px;
  cursor: default;
  font-family: 'VT323', monospace;
  font-size: 16px;
  white-space: nowrap;
}

.menu-dropdown-item:hover {
  background: #000;
  color: #fff;
}

.menu-separator {
  border-top: 1px dotted #888;
  margin: 2px 4px;
}

/* Desktop */
.desktop {
  position: fixed;
  top: 24px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* Desktop patterns */
.pattern-strawberry {
  background-color: #8B5E83;
  background-image:
    radial-gradient(circle 4px at 16px 16px, #C41E3A 3px, transparent 4px),
    radial-gradient(circle 4px at 48px 48px, #C41E3A 3px, transparent 4px);
  background-size: 64px 64px;
}

.pattern-blueberry {
  background-color: #4F5D99;
  background-image:
    radial-gradient(circle 3px at 12px 12px, #7B8EC9 2px, transparent 3px),
    radial-gradient(circle 3px at 36px 36px, #7B8EC9 2px, transparent 3px);
  background-size: 48px 48px;
}

.pattern-raspberry {
  background-color: #6B2D5B;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 6px, #8B4D7B 6px, #8B4D7B 8px);
}

.pattern-blackberry {
  background-color: #3A2040;
  background-image:
    linear-gradient(45deg, #4A3050 25%, transparent 25%),
    linear-gradient(-45deg, #4A3050 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #4A3050 75%),
    linear-gradient(-45deg, transparent 75%, #4A3050 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

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

.desktop-icon:hover .icon-label {
  background: #000;
  color: #fff;
}

.icon-image {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin-bottom: 2px;
}

.icon-label {
  font-family: 'VT323', monospace;
  font-size: 14px;
  text-align: center;
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  padding: 1px 4px;
}

/* Window */
.mac-window {
  position: absolute;
  background: #fff;
  border: 2px solid #000;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  min-width: 200px;
  min-height: 100px;
}

.window-titlebar {
  height: 22px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  cursor: grab;
  flex-shrink: 0;
  position: relative;
  border-bottom: 2px solid #000;
}

.window-titlebar.active {
  background: repeating-linear-gradient(
    to right,
    #000 0px, #000 1px,
    #fff 1px, #fff 3px
  );
}

.window-titlebar.inactive {
  background: repeating-linear-gradient(
    to right,
    #aaa 0px, #aaa 1px,
    #ddd 1px, #ddd 3px
  );
}

.window-close {
  width: 14px;
  height: 14px;
  border: 2px solid #000;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
  z-index: 1;
}

.window-close:active {
  background: #000;
}

.window-title {
  flex: 1;
  text-align: center;
  font-family: 'VT323', monospace;
  font-size: 14px;
  font-weight: bold;
  background: #fff;
  padding: 0 8px;
  z-index: 1;
  white-space: nowrap;
  border: 1px solid #000;
  margin: 0 4px;
  line-height: 16px;
}

.window-body {
  flex: 1;
  overflow: hidden;
  background: #fff;
  position: relative;
}

.window-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  z-index: 2;
}

.window-resize::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: linear-gradient(135deg,
    transparent 30%,
    #888 30%, #888 40%,
    transparent 40%, transparent 60%,
    #888 60%, #888 70%,
    transparent 70%
  );
}

/* Mac button */
.mac-btn {
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 4px 16px;
  background: #E8E8E8;
  border: 2px solid #000;
  border-top-color: #fff;
  border-left-color: #fff;
  cursor: pointer;
  outline: none;
}

.mac-btn:active {
  border-top-color: #000;
  border-left-color: #000;
  border-bottom-color: #fff;
  border-right-color: #fff;
  background: #ccc;
}

.mac-btn-primary {
  border: 3px solid #000;
  border-radius: 6px;
  padding: 4px 20px;
}

/* Dialog overlay */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
}

.dialog-box {
  background: #E8E8E8;
  border: 3px solid #000;
  box-shadow: 3px 3px 0px #000;
  padding: 16px;
  max-width: 400px;
  font-family: 'VT323', monospace;
}

/* Calculator */
.calc-display {
  background: #C8D8C0;
  border: 2px inset #888;
  font-family: 'VT323', monospace;
  font-size: 28px;
  text-align: right;
  padding: 4px 8px;
  margin: 4px;
  height: 40px;
  line-height: 36px;
  overflow: hidden;
}

.calc-btn {
  font-family: 'VT323', monospace;
  font-size: 20px;
  background: #E8E8E8;
  border: 2px solid #000;
  border-top-color: #fff;
  border-left-color: #fff;
  cursor: pointer;
  outline: none;
  width: 100%;
  height: 36px;
}

.calc-btn:active {
  border-top-color: #000;
  border-left-color: #000;
  border-bottom-color: #fff;
  border-right-color: #fff;
}

/* Terminal */
.terminal-body {
  background: #000;
  color: #33FF33;
  font-family: 'VT323', monospace;
  font-size: 16px;
  padding: 8px;
  height: 100%;
  overflow-y: auto;
  cursor: text;
}

.terminal-input {
  background: transparent;
  border: none;
  color: #33FF33;
  font-family: 'VT323', monospace;
  font-size: 16px;
  outline: none;
  width: calc(100% - 100px);
  caret-color: #33FF33;
}

/* Scrollbar classic mac style */
.mac-scrollbar::-webkit-scrollbar {
  width: 16px;
}
.mac-scrollbar::-webkit-scrollbar-track {
  background: #E8E8E8;
  border-left: 1px solid #000;
}
.mac-scrollbar::-webkit-scrollbar-thumb {
  background: #C0C0C0;
  border: 1px solid #000;
}
.mac-scrollbar::-webkit-scrollbar-button {
  background: #E8E8E8;
  border: 1px solid #000;
  height: 16px;
}

/* Paint */
.paint-tool {
  width: 28px;
  height: 28px;
  border: 2px solid #000;
  border-top-color: #fff;
  border-left-color: #fff;
  background: #E8E8E8;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  margin: 2px;
}

.paint-tool.active {
  border-top-color: #000;
  border-left-color: #000;
  border-bottom-color: #fff;
  border-right-color: #fff;
  background: #aaa;
}

.paint-color {
  width: 20px;
  height: 20px;
  border: 2px solid #000;
  cursor: pointer;
  margin: 1px;
}

.paint-color.active {
  border: 3px solid #fff;
  outline: 2px solid #000;
}

/* Control panel */
.control-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 80px;
  padding: 8px;
  cursor: pointer;
  border: 2px solid transparent;
}

.control-item:hover {
  border: 2px solid #000;
  background: #ddd;
}

/* Mobile warning */
.mobile-warning {
  display: none;
  position: fixed;
  inset: 0;
  background: #F5F0E1;
  z-index: 100000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  font-family: 'VT323', monospace;
}

@media (max-width: 768px) {
  .mobile-warning {
    display: flex !important;
  }
  #desktop-app {
    display: none !important;
  }
}

/* Blinking cursor */
@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

.blink-cursor {
  animation: blink 1s infinite;
}

/* Writer */
.writer-textarea {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  font-family: 'VT323', monospace;
  font-size: 18px;
  padding: 8px;
  background: #fff;
}

/* Pattern preview */
.pattern-swatch {
  width: 48px;
  height: 48px;
  border: 2px solid #000;
  cursor: pointer;
  margin: 4px;
}

.pattern-swatch.active {
  border: 3px solid #C41E3A;
  outline: 2px solid #000;
}