:root {
  --win98-gray: #c0c0c0;
  --win98-dark: #808080;
  --win98-light: #e0e0e0;
  --win98-green: #0a9e0a;
  --win98-blue: #000080;
  --win98-text: #000000;
  --wallpaper: linear-gradient(135deg, #0c75c1 0%, #0a538c 40%, #07305c 100%);
  --icon-size: 64px;
  font-family: "MS Sans Serif", Tahoma, sans-serif;
}

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

body {
  margin: 0;
  background: var(--wallpaper);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  color: var(--win98-text);
}

#main-ui {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.desktop {
  position: relative;
  flex: 1;
  width: 100%;
  padding: 12px;
  overflow: hidden;
}

.icon {
  width: 96px;
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  color: white;
  text-shadow: 1px 1px 0px #000;
  gap: 6px;
  padding: 8px;
  z-index: 5;
}

.icon .art {
  width: var(--icon-size);
  height: var(--icon-size);
  background: var(--win98-light);
  border: 2px solid #fff;
  box-shadow: 2px 2px 0 var(--win98-dark);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.icon:hover .art {
  outline: 2px solid #fff;
}

.icon .art img {
  width: 26px;
  height: 26px;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.window {
  position: absolute;
  top: 80px;
  left: 120px;
  width: 420px;
  min-width: 320px;
  min-height: 220px;
  background: var(--win98-gray);
  border: 2px solid #000;
  box-shadow: 4px 4px 0 #000;
  display: none;
  flex-direction: column;
  z-index: 10;
}

.window.active {
  box-shadow: 6px 6px 0 #000;
}

.titlebar {
  height: 28px;
  background: linear-gradient(90deg, #000080, #1084d0);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  cursor: move;
}

.titlebar .title {
  font-weight: bold;
  letter-spacing: 0.5px;
}

.titlebar .actions {
  display: flex;
  gap: 4px;
}

.titlebar button {
  width: 24px;
  height: 20px;
  background: var(--win98-gray);
  border: 2px solid #000;
  box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #000;
  cursor: pointer;
  font-weight: bold;
  padding: 0;
}

.titlebar button:active {
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #000;
}

.window .content {
  background: #fff;
  margin: 6px;
  border: 2px solid #000;
  padding: 12px;
  flex: 1;
  overflow: auto;
  color: #000;
  user-select: text;
}

.win-resizer {
  position: absolute;
  z-index: 5;
}

.win-resizer.n {
  top: -2px;
  left: 0;
  right: 0;
  height: 5px;
  cursor: n-resize;
}

.win-resizer.s {
  bottom: -2px;
  left: 0;
  right: 0;
  height: 5px;
  cursor: s-resize;
}

.win-resizer.e {
  top: 0;
  bottom: 0;
  right: -2px;
  width: 5px;
  cursor: e-resize;
}

.win-resizer.w {
  top: 0;
  bottom: 0;
  left: -2px;
  width: 5px;
  cursor: w-resize;
}

.win-resizer.nw {
  top: -2px;
  left: -2px;
  width: 8px;
  height: 8px;
  cursor: nw-resize;
}

.win-resizer.ne {
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  cursor: ne-resize;
}

.win-resizer.sw {
  bottom: -2px;
  left: -2px;
  width: 8px;
  height: 8px;
  cursor: sw-resize;
}

.win-resizer.se {
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  cursor: se-resize;
  background: repeating-linear-gradient(45deg,
      #808080,
      #808080 2px,
      #c0c0c0 2px,
      #c0c0c0 4px);
}

.start-menu {
  position: fixed;
  bottom: 32px;
  left: 2px;
  width: 220px;
  background: var(--win98-gray);
  border: 2px solid #000;
  box-shadow: inset 1.5px 1.5px 0 #fff, 2px 2px 0 #000;
  display: none;
  z-index: 10000;
  flex-direction: row;
}

.start-menu.open {
  display: flex;
}

/* Submenu & Categories */
.menu-items li.menu-category {
  position: relative;
}

.menu-items li.menu-category::after {
  content: '▶';
  position: absolute;
  right: 5px;
  font-size: 8px;
}

.submenu {
  display: none;
  position: absolute;
  left: 100%;
  top: -2px;
  background: var(--win98-gray);
  border: 2px solid #fff;
  border-left: 2px solid var(--win98-light);
  border-top: 2px solid var(--win98-light);
  box-shadow: 2px 2px 0 #000;
  width: 170px;
  padding: 2px;
  list-style: none;
  z-index: 1000;
}

.menu-items li:hover>.submenu {
  display: block;
}

.submenu li {
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.submenu li:hover {
  background: var(--win98-blue);
  color: white;
}

.submenu li img {
  width: 16px;
  height: 16px;
}

.start-menu .sidebar {
  width: 26px;
  background: linear-gradient(to bottom, #000080, #1084d0);
  display: flex;
  align-items: flex-end;
  padding: 8px 4px;
}

.start-menu .sidebar-text {
  color: #c0c0c0;
  font-weight: bold;
  font-size: 16px;
  transform: rotate(-90deg);
  transform-origin: bottom left;
  white-space: nowrap;
  display: block;
  margin-bottom: 2px;
  margin-left: 18px;
}

.start-menu .sidebar-text span {
  color: #fff;
}

.start-menu .menu-items {
  flex: 1;
  list-style: none;
  margin: 0;
  padding: 4px;
}

.start-menu .menu-items li {
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
}

.start-menu .menu-items li:hover {
  background: var(--win98-blue);
  color: #fff;
}

.start-menu .menu-items li img {
  width: 22px;
  height: 22px;
}

.start-menu .menu-items hr {
  margin: 4px 0;
  border: 0;
  border-bottom: 1px solid #808080;
  border-top: 1px solid #fff;
}

.taskbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 32px;
  background: var(--win98-gray);
  border-top: 2px solid #fff;
  box-shadow: inset 0 2px 0 #808080;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  padding: 2px 4px;
  gap: 6px;
  z-index: 10001;
}

.start-btn {
  background: #c0c0c0;
  border: 2px solid #000;
  box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #000;
  font-weight: bold;
  padding: 4px 10px;
  cursor: pointer;
}

.taskbar .clock {
  margin-left: auto;
  padding: 4px 10px;
  border: 2px solid #000;
  background: #e0e0e0;
  font-family: monospace;
}

.task-buttons {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 0 4px;
}

.task-btn {
  min-width: 110px;
  padding: 6px 10px;
  background: #dcdcdc;
  border: 2px solid #000;
  box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #000;
  cursor: pointer;
  text-align: left;
  white-space: nowrap;
}

.task-btn.active {
  background: #b0d2ff;
  box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 #000;
}

.module-section {
  display: grid;
  gap: 10px;
}

/* Boiler Module */
.boiler-module {
  padding: 10px;
}

.status-panel,
.action-panel,
.config-panel {
  border: 1px inset #ccc;
  padding: 8px;
  background: #eee;
  margin-bottom: 10px;
}

.status-row {
  margin-bottom: 4px;
}

.boiler-module h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.btn-group button {
  padding: 4px 8px;
}

.config-panel .field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 11px;
}

.config-panel .field span {
  flex: 1;
  padding-right: 5px;
  white-space: nowrap;
}

.config-panel .field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 15px;
}

.config-panel input {
  font-family: inherit;
  width: 60px;
  text-align: right;
  padding: 1px 3px;
}


.module-section h3 {
  margin: 0;
  font-size: 16px;
}

.about-list {
  margin: 0;
  padding-left: 18px;
}

/* Status Badges */
.badge {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid #000;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  min-width: 30px;
  background: #fff;
  box-shadow: inset 1px 1px 0 #000;
}

.badge.ok {
  background: #00ff00;
  color: #000;
}

.badge.err {
  background: #ff0000;
  color: #fff;
}

.badge.warn {
  background: #ffff00;
  color: #000;
}

.badge.ghost {
  background: #ccc;
  color: #888;
}

/* Card layout for Burner */
.card-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.card-item {
  background: #fff;
  border: 2px solid #808080;
  box-shadow: inset -1px -1px 0 #fff, inset 1px 1px 0 #000;
  padding: 6px;
  flex: 1;
  min-width: 140px;
}

.card-item h4 {
  margin: 0 0 6px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-box {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 8px;
  height: 100%;
}

.chat-messages {
  border: 1px solid #000;
  padding: 8px;
  background: #f4f4f4;
  overflow-y: auto;
  max-height: 220px;
}

.chat-messages .msg {
  margin-bottom: 6px;
  padding: 6px 8px;
  background: #fff;
  border: 1px solid #000;
  box-shadow: 2px 2px 0 #808080;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.chat-form input {
  padding: 6px;
  border: 2px solid #000;
}

.chat-form button {
  padding: 6px 12px;
  border: 2px solid #000;
  background: #e0e0e0;
  cursor: pointer;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.fake-photo {
  border: 2px solid #000;
  height: 120px;
  background-size: cover;
  background-position: center;
  position: relative;
  box-shadow: 3px 3px 0 #808080;
}

.fake-photo::after {
  content: attr(data-label);
  position: absolute;
  bottom: 6px;
  left: 6px;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid #000;
  font-size: 12px;
}

.browser {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  height: 100%;
}

.browser-bar {
  display: flex;
  gap: 6px;
}

.browser-bar input {
  flex: 1;
  padding: 6px;
  border: 2px solid #000;
}

.browser-bar button {
  padding: 6px 12px;
  border: 2px solid #000;
  background: #e0e0e0;
  cursor: pointer;
}

.browser-display {
  border: 2px inset #808080;
  background: #fdfdfd;
  overflow: hidden;
  min-height: 220px;
}

.browser-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.browser-page {
  padding: 12px;
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 640px) {
  .desktop {
    padding: 8px;
  }

  .window {
    width: 90vw;
    left: 5vw;
    right: 5vw;
  }
}

/* Snake Window Override */
.window[data-window="snake"] {
  width: 495px !important;
  height: 560px !important;
}

/* Boulder Dash Window Override (Updated for 25x24 grid) */
.window[data-window="boulderdash"] {
  /* Dimensions handled by inline style to allow resizing */
}