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

body {
  background: #0a0012;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  font-family: 'VT323', monospace;
}

canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.back-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: rgba(10, 0, 20, 0.85);
  border: 1px solid rgba(0, 255, 200, 0.3);
  border-radius: 6px;
  color: #00ffcc;
  text-decoration: none;
  font-size: 16px;
  transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.back-link:hover {
  color: #ff00ff;
  border-color: rgba(255, 0, 255, 0.5);
  box-shadow: 0 2px 12px rgba(255, 0, 255, 0.3);
}

.hidden { display: none !important; }

#compiler-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 0, 25, 0.88);
  backdrop-filter: blur(6px);
  animation: overlay-in 0.25s ease-out;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.terminal {
  width: 90%;
  max-width: 740px;
  background: #0d0018;
  border: 2px solid rgba(0, 255, 200, 0.3);
  border-radius: 12px;
  box-shadow: 0 14px 42px rgba(0, 255, 200, 0.08), 0 0 60px rgba(255, 0, 255, 0.06);
  overflow: hidden;
  font-family: 'Share Tech Mono', monospace;
}

.terminal-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #1a0030, #0d0018);
  border-bottom: 1px solid rgba(0, 255, 200, 0.2);
}

.term-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.term-dot.red { background: #ff4466; }
.term-dot.yellow { background: #ffcc00; }
.term-dot.green { background: #00ff88; }

.term-title {
  margin-left: 8px;
  font-size: 12px;
  color: #00ffcc;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

#compile-player-label { color: #ff88cc; }

.terminal-body {
  padding: 18px;
  max-height: 400px;
  overflow-y: auto;
}

.term-line {
  font-size: 14px;
  color: #ccbbdd;
  line-height: 1.65;
  margin-bottom: 8px;
}

.term-system { color: #ff00ff; font-weight: bold; }
.term-highlight { color: #ffcc00; font-weight: bold; }

.term-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 14px 0 6px;
}

.term-caret {
  color: #00ffcc;
  font-size: 18px;
  font-weight: bold;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

#compile-input {
  flex: 1;
  font-family: 'Share Tech Mono', monospace;
  font-size: 16px;
  padding: 10px 12px;
  background: #150025;
  border: 1px solid rgba(0, 255, 200, 0.25);
  border-radius: 8px;
  color: #eeddff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#compile-input:focus {
  border-color: #ff00ff;
  box-shadow: 0 0 0 3px rgba(255, 0, 255, 0.15), 0 0 20px rgba(255, 0, 255, 0.08);
}

#compile-input::placeholder { color: #665577; }

.term-hint {
  font-size: 12px;
  color: #886699;
  margin-top: 4px;
}

#compile-output {
  margin-top: 14px;
  padding: 12px;
  background: #0a0015;
  border: 1px solid rgba(255, 0, 255, 0.2);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.7;
  color: #ccbbdd;
}

#compile-output.compile-reveal {
  animation: reveal-pulse 0.55s ease-out;
}

@keyframes reveal-pulse {
  0% { transform: scale(0.98); opacity: 0.7; }
  55% { transform: scale(1.01); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.compile-mod-name {
  color: #00ffcc;
  font-size: 18px;
  font-weight: bold;
  text-shadow: 0 0 10px rgba(0, 255, 200, 0.3);
}

.compile-mod-quip {
  color: #cc99ff;
  font-style: italic;
}

.compile-mod-tradeoff {
  color: #ff6699;
  font-size: 13px;
}

.compile-preview-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.compile-pixel-card {
  flex: 1;
  min-width: 0;
  background: #150025;
  border: 1px solid rgba(0, 255, 200, 0.15);
  border-radius: 8px;
  padding: 8px;
}

.compile-pixel-title {
  font-size: 11px;
  color: #88aacc;
  margin-bottom: 6px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.compile-pixel-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  width: 100%;
  max-width: 96px;
  aspect-ratio: 1 / 1;
  background: #0a0015;
  padding: 4px;
  border-radius: 6px;
}

.compile-pixel-cell {
  border-radius: 1px;
}

.compile-trait-row {
  margin-top: 9px;
}

.compile-trait-tag,
.compile-trait-empty {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.45;
}

.compile-trait-tag {
  color: #00ffcc;
  background: rgba(0, 255, 200, 0.08);
  border: 1px solid rgba(0, 255, 200, 0.25);
}

.compile-trait-empty {
  color: #886699;
  background: rgba(128, 0, 255, 0.08);
  border: 1px solid rgba(128, 0, 255, 0.2);
}

#compile-mods-display {
  font-size: 12px;
  color: #aa88cc;
  margin-bottom: 4px;
}

.existing-mod-tag {
  display: inline-block;
  padding: 2px 7px;
  margin: 2px;
  background: rgba(255, 0, 255, 0.08);
  border: 1px solid rgba(255, 0, 255, 0.2);
  border-radius: 8px;
  color: #cc88ff;
  font-size: 11px;
}

.compiling-bar {
  width: 100%;
  height: 7px;
  background: #150025;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 10px;
  border: 1px solid rgba(0, 255, 200, 0.15);
}

.compiling-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff00ff, #00ffcc, #ffcc00);
  width: 0%;
  animation: compile-progress 3s ease-in-out forwards;
  border-radius: 999px;
}

@keyframes compile-progress {
  0% { width: 0%; }
  70% { width: 84%; }
  100% { width: 100%; }
}

#codex-overlay {
  position: fixed;
  inset: 0;
  z-index: 140;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 0, 15, 0.75);
  backdrop-filter: blur(4px);
}

.codex-panel {
  width: min(760px, 92vw);
  max-height: 82vh;
  overflow: auto;
  background: #0d0018;
  border: 2px solid rgba(0, 255, 200, 0.25);
  border-radius: 12px;
  box-shadow: 0 16px 42px rgba(0, 255, 200, 0.06), 0 0 80px rgba(255, 0, 255, 0.04);
  padding: 14px;
  font-family: 'Share Tech Mono', monospace;
}

.codex-title {
  color: #ff00ff;
  font-size: 22px;
  letter-spacing: 1px;
  margin-bottom: 10px;
  text-shadow: 0 0 10px rgba(255, 0, 255, 0.3);
}

.codex-stats {
  font-size: 13px;
  color: #aa88cc;
  line-height: 1.6;
  margin-bottom: 10px;
}

.codex-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.codex-card {
  border: 1px solid rgba(0, 255, 200, 0.12);
  border-radius: 8px;
  padding: 8px;
  background: #150025;
}

.codex-card-name {
  font-size: 14px;
  color: #00ffcc;
  margin-bottom: 3px;
}

.codex-card-meta {
  font-size: 11px;
  color: #886699;
  line-height: 1.5;
}

.codex-hint {
  margin-top: 12px;
  color: #665577;
  font-size: 12px;
}
