html, body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  user-select: none;
  background: #0b0d1a;
}

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

input, textarea {
  user-select: text;
  -webkit-user-select: text;
}

#desktop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 48px;
  overflow: hidden;
}

#boot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10000;
}

.boot-logo {
  font-size: 56px;
}

.boot-name {
  color: #ddd;
  font-size: 20px;
  letter-spacing: 2px;
}

.boot-spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #ffffff22;
  border-top-color: #4cc2ff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#boot-screen.done {
  opacity: 0;
  transition: opacity 0.6s;
  pointer-events: none;
}

.os-window {
  position: absolute;
  min-width: 260px;
  min-height: 180px;
  border-radius: 10px;
  background: #1e1f26ee;
  backdrop-filter: blur(14px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  border: 1px solid rgba(255, 255, 255, .13);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.os-window.active {
  box-shadow: 0 16px 48px rgba(0, 0, 0, .75);
  border-color: rgba(255, 255, 255, .25);
}

.os-window.maximized {
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 0;
}

.os-titlebar {
  height: 38px;
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 6px 0 12px;
  background: rgba(255, 255, 255, .06);
}

.os-title {
  flex: 1;
  font-size: 13px;
  color: #ddd;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: default;
}

.os-titlebar button {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: #ccc;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
}

.os-titlebar button:hover {
  background: rgba(255, 255, 255, .14);
}

.os-titlebar button.close:hover {
  background: #e81123;
  color: #fff;
}

.os-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
}

#taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  background: rgba(21, 22, 26, .85);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, .1);
  z-index: 5000;
}

#start-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: rgba(76, 194, 255, .14);
  color: #4cc2ff;
  font-size: 16px;
  cursor: pointer;
}

#start-btn:hover {
  background: rgba(76, 194, 255, .28);
}

#taskbar-apps {
  display: flex;
  gap: 6px;
}

.taskbar-app-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
  position: relative;
}

.taskbar-app-btn:hover {
  background: rgba(255, 255, 255, .1);
}

.taskbar-app-btn.open::after {
  content: "";
  position: absolute;
  bottom: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 2px;
  border-radius: 1px;
  background: #4cc2ff;
}

#taskbar-clock {
  margin-left: auto;
  color: #ddd;
  font-size: 13px;
  text-align: right;
  line-height: 1.25;
  padding-right: 6px;
  cursor: default;
}

#start-menu {
  position: fixed;
  bottom: 56px;
  left: 10px;
  width: 320px;
  border-radius: 12px;
  background: rgba(28, 29, 36, .95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .13);
  padding: 12px;
  z-index: 6000;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.app-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 4px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #ddd;
  font-size: 12px;
  cursor: pointer;
}

.app-grid button:hover {
  background: rgba(255, 255, 255, .1);
}

.app-grid .app-icon {
  font-size: 22px;
}

#context-menu {
  position: fixed;
  min-width: 190px;
  border-radius: 8px;
  background: rgba(28, 29, 36, .95);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .13);
  padding: 4px;
  z-index: 7000;
}

#context-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 12px;
  border: none;
  background: transparent;
  color: #ddd;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}

#context-menu button:hover {
  background: rgba(255, 255, 255, .1);
}

#context-menu .menu-sep {
  height: 1px;
  background: rgba(255, 255, 255, .13);
  margin: 4px 0;
}

.hidden {
  display: none !important;
}

#shutdown-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 11000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  color: #ccc;
  text-align: center;
}

#shutdown-screen button {
  padding: 10px 26px;
  border-radius: 8px;
  background: rgba(76, 194, 255, .14);
  color: #4cc2ff;
  border: 1px solid rgba(76, 194, 255, .35);
  font-size: 14px;
  cursor: pointer;
}

#shutdown-screen button:hover {
  background: rgba(76, 194, 255, .28);
}

#matrix-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
}

#matrix-overlay canvas {
  width: 100%;
  height: 100%;
}

.desktop-icon {
  position: absolute;
  width: 84px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.desktop-icon .di-icon {
  font-size: 34px;
}

.desktop-icon .di-label {
  font-size: 12px;
  text-align: center;
}

.desktop-icon.selected {
  background: rgba(76, 194, 255, .2);
}

/* ===== Settings app ===== */

.settings-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.settings-wrap h2 {
  margin: 0;
  padding: 16px 16px 4px;
  color: #eee;
  font-size: 16px;
}

.settings-subtitle {
  margin: 0;
  padding: 0 16px 12px;
  color: #888;
  font-size: 12px;
}

.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

.swatch-button {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.swatch {
  height: 90px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .15);
}

.swatch.selected {
  outline: 2px solid #4cc2ff;
  outline-offset: 2px;
}

.swatch-button:hover .swatch {
  filter: brightness(1.15);
}

.swatch-button:focus-visible {
  outline: 2px solid #4cc2ff;
  outline-offset: 2px;
}

.swatch-name {
  font-size: 12px;
  color: #bbb;
  text-align: center;
}

/* ===== Notes app ===== */

.notes-wrap {
  height: 100%;
  display: flex;
}

.notes-side {
  width: 170px;
  min-width: 170px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .03);
}

.notes-side-header {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}

.notes-tool-btn {
  flex: 1;
  padding: 4px 6px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, .07);
  color: #aaa;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.notes-tool-btn:hover {
  background: rgba(255, 255, 255, .14);
  color: #eee;
}

.notes-tool-btn:focus-visible {
  outline: 2px solid #4cc2ff;
  outline-offset: 2px;
}

.notes-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.note-row {
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
}

.note-row:hover {
  background: rgba(255, 255, 255, .06);
}

.note-row.selected {
  background: rgba(76, 194, 255, .18);
}

.note-row-title {
  font-size: 12px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-row-date {
  font-size: 10px;
  color: #777;
  margin-top: 2px;
}

.notes-empty {
  padding: 12px 10px;
  font-size: 12px;
  color: #666;
  text-align: center;
}

.notes-editor {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #eee;
  padding: 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: none;
}

.notes-editor:disabled {
  opacity: .5;
  cursor: default;
}

/* ===== Calculator app ===== */

.calc {
  height: 100%;
  display: flex;
  flex-direction: column;
  container-type: size;
}

.calc-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 4px;
  padding: 16px 16px 10px;
}

.calc-sub {
  font-size: 13px;
  color: #999;
  min-height: 16px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
}

.calc-value {
  width: 100%;
  text-align: right;
  font-size: 30px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  user-select: text;
  -webkit-user-select: text;
}

.calc-value.long {
  font-size: 22px;
}

.calc-keys {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 6px;
  padding: 10px;
}

.calc-key {
  min-width: 0;
  min-height: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, .07);
  color: #eee;
  font-size: 18px;
  font-family: inherit;
  cursor: pointer;
}

.calc-key:hover {
  background: rgba(255, 255, 255, .14);
}

.calc-key:active {
  background: rgba(255, 255, 255, .2);
}

.calc-key.op {
  background: rgba(76, 194, 255, .16);
  color: #9fd8ff;
  font-size: 20px;
}

.calc-key.op:hover {
  background: rgba(76, 194, 255, .3);
}

.calc-key.op:active {
  background: rgba(76, 194, 255, .4);
}

.calc-key.equals {
  background: #4cc2ff;
  color: #0b0d1a;
  font-weight: 600;
  font-size: 20px;
}

.calc-key.equals:hover {
  background: #6fd0ff;
}

.calc-key:focus-visible {
  outline: 2px solid #4cc2ff;
  outline-offset: 2px;
}

.calc-key.wide {
  grid-column: span 2;
}

@container (max-height: 280px) {
  .calc-display {
    gap: 2px;
    padding: 10px 12px 6px;
  }

  .calc-sub {
    font-size: 11px;
    min-height: 13px;
  }

  .calc-value {
    font-size: 22px;
  }

  .calc-value.long {
    font-size: 17px;
  }
}

/* ===== Tetris app ===== */

.tetris-wrap {
  height: 100%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 4px;
  overflow: hidden;
  container-type: size;
}

.tetris-board,
.tetris-next {
  max-height: 100%;
  width: auto;
  background: #14151c;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
}

.tetris-board {
  margin: auto;
}

.tetris-panel {
  width: 200px;
  min-width: 0;
  flex-shrink: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tetris-stat {
  padding: 8px 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
}

.tetris-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8a8fa3;
}

.tetris-stat-value {
  margin-top: 2px;
  font-size: 22px;
  color: #fff;
}

.tetris-hint {
  font-size: 11px;
  line-height: 1.6;
  color: #767b8f;
}

@container (max-width: 320px) {
  .tetris-hint {
    display: none;
  }

  .tetris-stat {
    padding: 5px 8px;
  }

  .tetris-stat-value {
    font-size: 16px;
  }
}

/* ===== Snake app ===== */

.snake-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow: hidden;
  container-type: size;
}

.snake-hud {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.snake-stat {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 8px;
}

.snake-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #8a8fa3;
}

.snake-stat-value {
  margin-top: 2px;
  font-size: 20px;
  color: #fff;
}

.snake-stage {
  flex: 1;
  min-height: 0;
  display: flex;
}

.snake-board {
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  background: #14151c;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
}

@container (max-height: 260px) {
  .snake-stat {
    padding: 5px 8px;
  }

  .snake-stat-value {
    font-size: 16px;
  }
}

/* ===== Flappy app ===== */

.flappy-wrap {
  height: 100%;
  display: flex;
  padding: 14px;
  overflow: hidden;
}

.flappy-board {
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  background: #14151c;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
}

/* ===== Terminal app ===== */

.term {
  height: 100%;
  display: flex;
  flex-direction: column;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #d4f7d4;
  padding: 10px;
  background: #101116;
}

.term-output {
  flex: 1;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  display: flex;
  flex-direction: column;
}

.term-prompt {
  color: #4cc2ff;
}

.term-input-line {
  flex: none;
  display: flex;
}

.term-input-line:focus-within {
  background: rgba(76, 194, 255, .06);
}

.term-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  font: inherit;
  color: #fff;
  caret-color: #4cc2ff;
}