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

body {
  background: #0d0d0d;
  color: #33ff33;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: row;
  overflow: hidden;
}

#terminal {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow: hidden;
  min-width: 0;
}

#gallery {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #1a2e1a;
  background: #0a0f0a;
  padding: 12px;
}

#gallery.hidden { display: none; }

#gallery-img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gallery-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
}

#gallery-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid #1a2e1a;
  margin-top: 8px;
}

#gallery-controls button {
  background: transparent;
  border: 1px solid #33ff33;
  color: #33ff33;
  font-family: inherit;
  font-size: 18px;
  padding: 2px 10px;
  cursor: pointer;
}

#gallery-controls button:hover { background: #1a2e1a; }

#gallery-label {
  color: #33ff33;
  font-size: 13px;
}

#scene {
  height: min(52vh, 520px);
  min-height: 260px;
  border: 1px solid #1a2e1a;
  background: #090b0d;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

#scene.hidden { display: none; }

#scene-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

#output {
  flex: 1;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.7;
  padding-bottom: 8px;
  scrollbar-width: thin;
  scrollbar-color: #1a4d1a #0d0d0d;
}

#output::-webkit-scrollbar       { width: 6px; }
#output::-webkit-scrollbar-track { background: #0d0d0d; }
#output::-webkit-scrollbar-thumb { background: #1a4d1a; border-radius: 3px; }

.line { margin-bottom: 2px; }

.line.input  { color: #aaffaa; }
.line.system { color: #555; font-style: italic; }
.line.server { color: #33ff33; }

.line.server + .line.server { margin-top: 0; }

#input-line {
  display: flex;
  align-items: center;
  border-top: 1px solid #1a2e1a;
  padding-top: 10px;
  margin-top: 8px;
  flex-shrink: 0;
}

#prompt {
  color: #33ff33;
  margin-right: 8px;
  user-select: none;
}

#cmd {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #33ff33;
  font-family: inherit;
  font-size: inherit;
  caret-color: #33ff33;
}

/* Gallery toggle — hidden on desktop, shown on mobile */
#gallery-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #1a4d1a;
  font-size: 20px;
  padding: 0 8px 0 0;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}
#gallery-toggle.has-images { color: #33ff33; }

/* Mobile: stack gallery above terminal, hidden by default */
@media (max-width: 640px) {
  #app { flex-direction: column; }

  #gallery {
    width: 100%;
    height: 42vh;
    max-height: 42vh;
    border-left: none;
    border-bottom: 1px solid #1a2e1a;
    order: -1;
    flex-shrink: 0;
  }

  #terminal { min-height: 0; order: 0; }

  #scene {
    height: 34vh;
    min-height: 180px;
  }

  #gallery-toggle { display: block; }
}
