* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Consolas, "Courier New", monospace;
  background: #ffffff;
  color: #111111;
}

main {
  padding: 12px;
}

h1 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
}

.top-controls {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#open-world-preview,
#close-world-preview {
  font-family: inherit;
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 10px;
  border: 1px solid #777777;
  background: #f5f5f5;
  color: #111111;
  cursor: pointer;
}

.nav-link {
  display: inline-block;
  text-decoration: none;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 10px;
  border: 1px solid #777777;
  background: #f5f5f5;
  color: #111111;
}

#open-world-preview:hover,
#close-world-preview:hover,
.nav-link:hover {
  background: #ebebeb;
}

#generator-lab {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.generator-panel {
  border: 1px solid #d0d0d0;
  padding: 10px;
  background: #fcfcfc;
}

.generator-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
}

#nextgen-meta {
  margin: 0 0 10px;
  font-size: 12px;
}

#nextgen-canvas {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  border: 1px solid #222222;
  background: #ffffff;
  image-rendering: pixelated;
}

#nextgen-report {
  margin: 10px 0 0;
  padding: 8px;
  border: 1px solid #d0d0d0;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

#corridor-tiles {
  margin-top: 14px;
}

#corridor-tiles-title {
  margin: 0 0 6px;
  font-size: 16px;
}

#corridor-tiles-meta {
  margin: 0 0 8px;
  font-size: 12px;
}

#corridor-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.corridor-tile-card {
  border: 1px solid #d0d0d0;
  padding: 8px;
  background: #fafafa;
}

.corridor-tile-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
}

.corridor-tile-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #999999;
  background: #ffffff;
  image-rendering: pixelated;
}

.corridor-tile-sockets {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.2;
  color: #333333;
}

#access-corridor-tiles {
  margin-top: 14px;
}

#access-corridor-tiles-title {
  margin: 0 0 6px;
  font-size: 16px;
}

#access-corridor-tiles-meta {
  margin: 0 0 8px;
  font-size: 12px;
}

#access-corridor-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.access-corridor-tile-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #999999;
  background: #ffffff;
  image-rendering: pixelated;
}

#room-prefabs {
  margin-top: 14px;
}

#room-prefabs-title {
  margin: 0 0 6px;
  font-size: 16px;
}

#room-prefabs-meta {
  margin: 0 0 8px;
  font-size: 12px;
}

#room-prefab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.room-prefab-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #999999;
  background: #ffffff;
  image-rendering: pixelated;
}

.world-preview-screen {
  min-height: 100vh;
  padding: 12px;
  background: #ffffff;
}

.world-preview-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  flex-wrap: wrap;
}

.world-preview-title {
  margin: 0;
  font-size: 16px;
}

#world-preview-meta {
  margin: 0 0 8px;
  font-size: 12px;
}

#world-preview-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #222222;
  background: #ffffff;
  image-rendering: pixelated;
}

.game-runtime-page {
  margin: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-root {
  position: fixed;
  inset: 0;
  background: #101015;
  overflow: hidden;
}

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

#runtime-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(80vw, 920px);
  pointer-events: none;
}

#runtime-overlay[hidden] {
  display: none !important;
}

#runtime-overlay .nav-link {
  width: fit-content;
  pointer-events: auto;
}

#runtime-debug-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.runtime-toggle-button {
  font-family: inherit;
  font-size: 12px;
  line-height: 1.2;
  padding: 6px 10px;
  border: 1px solid #777777;
  background: #f5f5f5;
  color: #111111;
  cursor: pointer;
}

.runtime-toggle-button:hover:enabled {
  background: #ebebeb;
}

.runtime-toggle-button:disabled {
  opacity: 0.65;
  cursor: default;
}

#game-meta {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  padding: 8px 10px;
  border: 1px solid #777777;
  background: rgba(245, 245, 245, 0.95);
  color: #111111;
}

#first-contact-diagnostics {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  white-space: pre;
  padding: 8px 10px;
  border: 1px solid #777777;
  background: rgba(245, 245, 245, 0.95);
  color: #111111;
}

#game-over-overlay {
  position: absolute;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 8, 12, 0.66);
  pointer-events: none;
}

#game-over-overlay[hidden] {
  display: none !important;
}

.game-over-card {
  width: min(520px, 90vw);
  padding: 20px 24px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 10, 15, 0.92);
  color: #f4f4f4;
  text-align: center;
}

.game-over-title {
  margin: 0 0 8px;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
  letter-spacing: 0.08em;
}

.game-over-subtitle {
  margin: 0;
  font-size: 14px;
  opacity: 0.95;
}

.game-over-hint {
  margin: 8px 0 0;
  font-size: 12px;
  opacity: 0.78;
}
