@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

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

body {
  font-family: 'VT323', 'Courier New', monospace;
  font-size: 18px;
  background: #008080;
  overflow: hidden;
  user-select: none;
  cursor: default;
}

.da-desktop {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

.da-wallpaper {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, #008080 0%, #006666 50%, #004848 100%);
  z-index: 0;
}

.da-app {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 96vw);
  height: min(480px, 90vh);
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  z-index: 2;
  transition: transform 0.08s linear;
}

.da-app--shake { animation: da-shake 0.15s infinite; }
.da-app--escape { border-color: #800 #400 #400 #800; }

@keyframes da-shake {
  0%, 100% { transform: translate(calc(-50% + 0px), calc(-50% + 0px)); }
  25% { transform: translate(calc(-50% + 3px), calc(-50% - 2px)); }
  75% { transform: translate(calc(-50% - 3px), calc(-50% + 2px)); }
}

.da-titlebar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  background: linear-gradient(90deg, #000080, #1084d0);
  color: #fff;
  font-size: 16px;
  cursor: default;
}

.da-titlebar-icon { cursor: pointer; font-size: 14px; }
.da-titlebar-text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.da-titlebar-ver {
  font-size: 12px;
  opacity: 0.7;
  cursor: pointer;
  padding: 0 4px;
}
.da-titlebar-ver:hover { opacity: 1; text-decoration: underline; }

.da-titlebar-btns { display: flex; gap: 2px; }

.da-wbtn {
  width: 18px;
  height: 16px;
  font-size: 11px;
  line-height: 14px;
  padding: 0;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  color: #000;
  cursor: pointer;
}
.da-wbtn:active { border-color: #404040 #fff #fff #404040; }
.da-wbtn--close { font-weight: bold; }

.da-menubar {
  display: flex;
  gap: 2px;
  padding: 2px 4px;
  background: #c0c0c0;
  border-bottom: 1px solid #808080;
  position: relative;
}

.da-menu {
  padding: 2px 8px;
  font-family: inherit;
  font-size: 16px;
  background: transparent;
  border: none;
  cursor: pointer;
}
.da-menu:hover, .da-menu--open { background: #000080; color: #fff; }

.da-dropdown {
  position: absolute;
  top: 100%;
  left: 4px;
  min-width: 160px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  z-index: 20;
  padding: 2px 0;
}
.da-dropdown[hidden] { display: none !important; }

.da-drop-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 4px 24px;
  font-family: inherit;
  font-size: 16px;
  background: none;
  border: none;
  cursor: pointer;
}
.da-drop-item:hover { background: #000080; color: #fff; }
.da-drop-item--secret { color: #800; font-weight: bold; }
.da-drop-item[disabled] { opacity: 0.45; cursor: default; }
.da-drop-item[disabled]:hover { background: none; color: inherit; }

.da-main {
  flex: 1;
  display: grid;
  grid-template-columns: 90px 1fr 130px;
  gap: 6px;
  padding: 8px;
  min-height: 0;
  background: #d4d0c8;
}

.da-tray {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
}

.da-tray-label, .da-tray-hint {
  font-size: 13px;
  text-align: center;
  color: #404040;
  line-height: 1.2;
}

.da-item {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  background: #fff;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  cursor: grab;
}
.da-item:active { cursor: grabbing; border-color: #404040 #fff #fff #404040; }

.da-stage-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #000;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  position: relative;
  overflow: hidden;
}

#da-pet {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
}

.da-bubble {
  position: absolute;
  bottom: 8px;
  left: 8px;
  right: 8px;
  padding: 6px 8px;
  font-size: 15px;
  background: #ffffcc;
  border: 2px solid #000;
  border-radius: 8px;
  color: #000;
  line-height: 1.2;
  min-height: 2.4em;
}

.da-meters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
}

.da-meter-label {
  display: block;
  font-size: 14px;
  margin-bottom: 2px;
}
.da-meter-label--warn { color: #800; }

.da-meter-bar {
  height: 14px;
  background: #fff;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  overflow: hidden;
}

.da-meter-fill {
  height: 100%;
  width: 80%;
  background: linear-gradient(180deg, #00cc00, #008800);
  transition: width 0.3s;
}

.da-meter-fill--low { background: linear-gradient(180deg, #ffcc00, #cc8800); }
.da-meter-fill--crit { background: linear-gradient(180deg, #ff4444, #aa0000); }

.da-meter-bar--warn { border-color: #800 #faa #faa #800; }
.da-meter-fill--warn {
  width: 0%;
  background: linear-gradient(180deg, #ff0000, #880000);
}

.da-meter--hidden { display: none; }
.da-meter--hidden.da-meter--show { display: block; }

.da-cmd-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #c0c0c0;
  border-top: 1px solid #808080;
}

.da-cmd-row label { font-size: 16px; }

#da-cmd {
  flex: 1;
  font-family: inherit;
  font-size: 16px;
  padding: 3px 6px;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  background: #fff;
}

#da-cmd-go {
  font-family: inherit;
  font-size: 16px;
  padding: 3px 12px;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  cursor: pointer;
}
#da-cmd-go:active { border-color: #404040 #fff #fff #404040; }

.da-status {
  padding: 3px 8px;
  font-size: 14px;
  background: #c0c0c0;
  border-top: 1px solid #fff;
  color: #404040;
}

/* Text file pop-ups */
.da-files {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.da-notepad {
  position: absolute;
  width: 260px;
  pointer-events: all;
  background: #c0c0c0;
  border: 2px solid;
  border-color: #fff #404040 #404040 #fff;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
  animation: da-pop 0.2s ease-out;
}

@keyframes da-pop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.da-notepad-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  background: linear-gradient(90deg, #000080, #1084d0);
  color: #fff;
  font-size: 14px;
}

.da-notepad-head button {
  background: #c0c0c0;
  border: 1px solid #404040;
  width: 16px;
  height: 14px;
  font-size: 11px;
  cursor: pointer;
  color: #000;
  line-height: 12px;
}

.da-notepad-body {
  padding: 8px;
  font-size: 15px;
  line-height: 1.35;
  color: #000;
  background: #fffffe;
  min-height: 80px;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: 'VT323', monospace;
}

/* Debug console */
.da-debug {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.da-debug[hidden] { display: none !important; }

.da-debug-win {
  width: min(420px, 92vw);
  background: #1a1a1a;
  border: 2px solid #0f0;
  color: #0f0;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  box-shadow: 0 0 40px rgba(0, 255, 0, 0.2);
}

.da-debug-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #0a0a0a;
  border-bottom: 1px solid #0f0;
}
.da-debug-head button {
  background: none;
  border: 1px solid #0f0;
  color: #0f0;
  cursor: pointer;
  width: 24px;
  height: 22px;
}

.da-debug-warn, .da-debug-progress { padding: 10px; }
.da-debug-progress strong { color: #f44; }

.da-learn-list {
  list-style: none;
  padding: 0 10px 10px;
}

.da-learn-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed #063;
}
.da-learn-list li.deleted {
  opacity: 0.35;
  text-decoration: line-through;
}

.da-learn-list button {
  background: #300;
  border: 1px solid #f44;
  color: #f88;
  padding: 2px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
.da-learn-list button:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Help + overlays */
.da-help {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 80, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.da-help[hidden] { display: none !important; }

.da-help-box {
  position: relative;
  max-width: 440px;
  width: 92%;
  padding: 24px;
  background: #c0c0c0;
  border: 3px solid;
  border-color: #fff #404040 #404040 #fff;
  color: #000;
}

.da-help-box h2 {
  font-size: 22px;
  margin-bottom: 10px;
  color: #000080;
}

.da-help-box ol {
  margin: 12px 0 12px 20px;
  line-height: 1.45;
  font-size: 17px;
}

.da-help-tip {
  font-size: 15px;
  color: #404040;
  margin-bottom: 14px;
}

.da-help-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 20px;
  background: #c0c0c0;
  border: 2px solid #404040;
  cursor: pointer;
}

#da-help-start {
  width: 100%;
  padding: 8px;
  font-family: inherit;
  font-size: 18px;
  background: #000080;
  color: #fff;
  border: 2px solid #404040;
  cursor: pointer;
}

.da-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  color: #c0c0c0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.da-overlay[hidden] { display: none !important; }

.da-overlay h2 {
  font-size: 28px;
  color: #0f0;
  margin-bottom: 12px;
}

.da-overlay--scare h2 { color: #f00; }

.da-overlay button {
  margin-top: 20px;
  padding: 10px 24px;
  font-family: inherit;
  font-size: 18px;
  background: #c0c0c0;
  border: 2px solid #fff;
  cursor: pointer;
}

.da-scare-face {
  width: 200px;
  height: 200px;
  margin-bottom: 16px;
  image-rendering: pixelated;
  animation: da-scare-pulse 0.08s infinite alternate;
}

@keyframes da-scare-pulse {
  from { transform: scale(1); filter: hue-rotate(0deg); }
  to { transform: scale(1.08); filter: hue-rotate(20deg); }
}

.da-drag-ghost {
  position: fixed;
  font-size: 32px;
  pointer-events: none;
  z-index: 999;
  transform: translate(-50%, -50%);
}

.da-app.da-corrupted .da-titlebar-text::after {
  content: ' [LEARNING]';
  color: #ff0;
  animation: da-blink 0.5s infinite;
}

@keyframes da-blink {
  50% { opacity: 0.3; }
}

@media (max-width: 520px) {
  .da-main { grid-template-columns: 70px 1fr 100px; }
  .da-tray-hint { display: none; }
}
