:root {
  --black: #000000;
  --blue: #0000AA;
  --green: #00AA00;
  --cyan: #00AAAA;
  --red: #AA0000;
  --purple: #AA00AA;
  --brown: #AA5500;
  --ltgray: #AAAAAA;
  --dkgray: #555555;
  --ltblue: #5555FF;
  --ltgreen: #55FF55;
  --ltcyan: #55FFFF;
  --ltred: #FF5555;
  --ltpurple: #FF55FF;
  --yellow: #FFFF55;
  --white: #FFFFFF;
}

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

input, textarea, select, [contenteditable="true"], .term-input {
  user-select: text !important;
  -webkit-user-select: text !important;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  background-color: #121216;
  background-image: radial-gradient(circle at 50% 50%, #1e1e24 0%, #0d0d10 100%);
  color: #fff;
  font-family: "Courier New", Courier, monospace;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#page {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px;
  gap: 10px;
}

/* Outer CRT-like Shell & Bezel */
#temple-shell {
  width: min(96vw, 960px);
  aspect-ratio: 4 / 3;
  max-height: 88vh;
  position: relative;
  background: #2b2b36;
  border-radius: 12px;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.9),
    inset 0 2px 4px rgba(255, 255, 255, 0.15),
    inset 0 -4px 10px rgba(0, 0, 0, 0.8);
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Virtual 640x480 Scaled Screen */
#temple-screen {
  width: 640px;
  height: 480px;
  background-color: var(--white);
  color: var(--black);
  position: absolute;
  transform-origin: center center;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.4);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

/* CRT Phosphor Scanline Shader Overlay */
#temple-screen.crt-active::after {
  content: " ";
  display: block;
  position: absolute;
  top: 0; left: 0; bottom: 0; right: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.22) 50%);
  background-size: 100% 4px;
  z-index: 999999;
  pointer-events: none;
  opacity: 0.6;
}

/* Top System Status Bar */
#top-bar {
  height: 22px;
  background-color: var(--blue);
  color: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6px;
  font-size: 12px;
  font-weight: bold;
  border-bottom: 1px solid var(--black);
  z-index: 1000;
  flex-shrink: 0;
}

.info-left {
  display: flex;
  gap: 12px;
}

.info-right {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-down {
  background-color: var(--cyan);
  color: var(--black);
  padding: 1px 4px;
  border: 1px solid var(--black);
  cursor: pointer;
  font-size: 11px;
}

.btn-down:hover {
  background-color: var(--ltcyan);
}

/* Desktop Canvas Area */
#desktop {
  flex: 1;
  position: relative;
  background-color: var(--white);
  background-image: url('../images/solana-msdos-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  overflow: hidden;
  height: 436px;
}

/* Bottom Adam Line */
#bottom-bar {
  height: 22px;
  background-color: var(--white);
  color: var(--blue);
  font-size: 9px;
  line-height: 10px;
  padding: 1px 4px;
  border-top: 1px solid var(--blue);
  overflow: hidden;
  white-space: nowrap;
  font-family: monospace;
  z-index: 1000;
  flex-shrink: 0;
}

/* Windows Subsystem */
.temple-window {
  position: absolute;
  background-color: var(--white);
  border: 2px solid var(--blue);
  box-shadow: 2px 2px 0px var(--black);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-size: 12px;
}

.temple-window.active {
  border-color: var(--purple);
  box-shadow: 3px 3px 0px var(--black);
}

.temple-window.active .win-header {
  background-color: var(--purple);
  color: var(--white);
}

.win-header {
  height: 20px;
  background-color: var(--blue);
  color: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  font-weight: bold;
  font-size: 11px;
  cursor: grab;
  flex-shrink: 0;
}

.win-header:active {
  cursor: grabbing;
}

.win-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-controls {
  display: flex;
  gap: 2px;
}

.win-btn {
  background: transparent;
  border: none;
  color: var(--white);
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}

.win-btn:hover {
  background-color: var(--red);
  color: var(--white);
}

.win-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--white);
  color: var(--black);
  padding: 2px;
  position: relative;
}

.win-status {
  height: 14px;
  background-color: var(--blue);
  color: var(--yellow);
  font-size: 10px;
  display: flex;
  justify-content: space-between;
  padding: 0 4px;
  align-items: center;
  flex-shrink: 0;
}

/* DolDoc Elements */
.dd-link {
  color: var(--red);
  text-decoration: underline;
  cursor: pointer;
  font-weight: bold;
}

.dd-link:hover {
  background-color: var(--yellow);
  color: var(--blue);
}

.dd-btn {
  background-color: var(--ltgray);
  color: var(--black);
  border: 1px solid var(--black);
  box-shadow: 1px 1px 0px var(--black);
  padding: 2px 6px;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
}

.dd-btn:hover {
  background-color: var(--yellow);
}

.dd-btn:active {
  box-shadow: inset 1px 1px 0px var(--black);
}

.dd-heading {
  font-weight: bold;
  color: var(--purple);
  margin: 4px 0 2px 0;
}

/* Terminal Styles */
.term-output {
  display: flex;
  flex-direction: column;
  gap: 1px;
  word-break: break-all;
}

.term-line {
  display: flex;
  align-items: center;
  width: 100%;
}

.term-prompt {
  color: var(--blue);
  font-weight: bold;
  white-space: nowrap;
  margin-right: 4px;
}

.term-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--black);
  padding: 0;
  margin: 0;
}

/* Desktop Icon Grid */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 4px;
}

.icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  padding: 2px;
}

.icon-item:hover {
  background-color: var(--ltcyan);
}

.icon-label {
  font-size: 10px;
  margin-top: 2px;
  word-break: break-word;
  line-height: 11px;
  color: var(--blue);
  font-weight: bold;
}

/* Boot Sequence Overlay */
#boot-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--black);
  color: var(--ltgreen);
  padding: 12px;
  font-family: "Courier New", monospace;
  font-size: 12px;
  line-height: 15px;
  white-space: pre-wrap;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  cursor: pointer;
}

#boot-screen.hidden {
  display: none;
}

.boot-skip-hint {
  position: absolute;
  bottom: 12px;
  right: 12px;
  color: var(--yellow);
  font-size: 11px;
}

/* Mobile Virtual Dock */
#mobile-dock {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: min(96vw, 960px);
  background: #1e1e24;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #333;
}

.dock-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
}

.mob-key {
  background: #2b2b36;
  color: #fff;
  border: 1px solid #444;
  padding: 4px 8px;
  font-family: "Courier New", monospace;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  flex: 1 1 auto;
  text-align: center;
  min-width: 60px;
}

.mob-key:hover, .mob-key:active {
  background: var(--blue);
  color: var(--white);
}

/* Outside Container & Attribution */
.outside-container {
  width: min(96vw, 960px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #888;
  padding: 4px 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.outside-container a {
  color: #aaa;
  text-decoration: underline;
}

.outside-container a:hover {
  color: var(--yellow);
}

/* Piano Keys */
.piano-keys {
  display: flex;
  gap: 2px;
}

.piano-key {
  flex: 1;
  background: var(--white);
  color: var(--black);
  border: 1px solid var(--black);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 11px;
}

.piano-key:active {
  background: var(--yellow);
}

/* Responsive Mobile Rules */
@media (max-width: 600px) {
  #temple-shell {
    width: 100vw;
    height: 75vw; /* 4:3 exact aspect ratio */
    max-height: 60vh;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    border: 2px solid #333;
  }

  .outside-container {
    flex-direction: column;
    text-align: center;
  }
}
