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

body {
  background: #0a0a0a;
  overflow: hidden;
  font-family: 'IBM Plex Mono', monospace;
  color: #e8e0d4;
  width: 100vw;
  height: 100vh;
  position: relative;
}

#canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

/* ── Entry Screen ────────────────────────────────── */
#entry-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: opacity 1.2s ease;
}
#entry-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}
#entry-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  padding: 40px;
}
#entry-title {
  font-family: 'Special Elite', 'IBM Plex Mono', monospace;
  font-size: clamp(18px, 4vw, 36px);
  letter-spacing: 8px;
  color: #e8e0d4;
  text-shadow: 0 0 30px rgba(232,224,212,0.15);
  opacity: 0.85;
  animation: title-breathe 4s ease-in-out infinite;
}
@keyframes title-breathe {
  0%,100% { opacity: 0.7; text-shadow: 0 0 20px rgba(232,224,212,0.1); }
  50% { opacity: 0.95; text-shadow: 0 0 40px rgba(232,224,212,0.25); }
}

#input-wrap {
  position: relative;
  width: min(520px, 85vw);
}
#memory-input {
  width: 100%;
  background: rgba(20,20,20,0.7);
  border: 1px solid rgba(232,224,212,0.12);
  border-radius: 2px;
  color: #e8e0d4;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 300;
  padding: 16px 20px;
  outline: none;
  transition: border-color 0.4s, box-shadow 0.4s;
  letter-spacing: 0.5px;
}
#memory-input::placeholder {
  color: rgba(232,224,212,0.25);
  font-style: italic;
}
#memory-input:focus {
  border-color: rgba(232,224,212,0.3);
  box-shadow: 0 0 30px rgba(232,224,212,0.06), inset 0 0 20px rgba(232,224,212,0.02);
}
#cursor-glow {
  position: absolute;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 22px;
  background: #e8e0d4;
  opacity: 0;
  animation: cursor-pulse 1.1s ease-in-out infinite;
  pointer-events: none;
}
#memory-input:focus ~ #cursor-glow { display: none; }
@keyframes cursor-pulse {
  0%,100% { opacity: 0; }
  50% { opacity: 0.6; }
}

#commit-btn {
  background: transparent;
  border: 1px solid rgba(232,224,212,0.2);
  color: rgba(232,224,212,0.6);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 3px;
  padding: 12px 32px;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}
#commit-btn:hover {
  color: rgba(232,224,212,0.9);
  border-color: rgba(232,224,212,0.4);
  text-shadow: 0 0 10px rgba(232,224,212,0.2);
  animation: btn-glitch 0.15s steps(2) infinite;
}
@keyframes btn-glitch {
  0% { transform: translate(0); }
  25% { transform: translate(-1px, 1px); }
  50% { transform: translate(1px, -1px); }
  75% { transform: translate(-1px, -1px); }
  100% { transform: translate(0); }
}
#commit-btn:hover::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(232,224,212,0.02) 2px,
    rgba(232,224,212,0.02) 4px
  );
}

/* ── Controls ────────────────────────────────────── */
#controls {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: linear-gradient(to bottom, rgba(10,10,10,0.85), transparent);
  gap: 12px;
  flex-wrap: wrap;
  transition: opacity 0.5s;
}
#controls.hidden { display: none; }

#controls-left, #controls-right {
  display: flex;
  gap: 10px;
  align-items: center;
}
#controls-center { flex: 1; text-align: center; }

.ctrl-btn {
  background: rgba(232,224,212,0.06);
  border: 1px solid rgba(232,224,212,0.15);
  color: rgba(232,224,212,0.5);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  padding: 7px 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}
.ctrl-btn:hover {
  color: rgba(232,224,212,0.85);
  border-color: rgba(232,224,212,0.3);
  background: rgba(232,224,212,0.1);
}
.ctrl-btn.active {
  color: #ff6090;
  border-color: rgba(255,96,144,0.4);
}

#age-display {
  font-size: 12px;
  color: rgba(232,224,212,0.3);
  letter-spacing: 1px;
  transition: opacity 2s;
}

.ctrl-label {
  font-size: 10px;
  color: rgba(232,224,212,0.35);
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
#speed-slider {
  width: 80px;
  accent-color: #e8e0d4;
  opacity: 0.5;
}
.ctrl-select {
  background: rgba(10,10,10,0.8);
  border: 1px solid rgba(232,224,212,0.15);
  color: rgba(232,224,212,0.5);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
  outline: none;
}
.ctrl-select option {
  background: #0a0a0a;
  color: #e8e0d4;
}

/* ── Archive ─────────────────────────────────────── */
#archive {
  position: fixed;
  bottom: 30px;
  left: 0; right: 0;
  z-index: 20;
  display: flex;
  justify-content: center;
  padding: 0 20px;
  transition: opacity 0.5s;
}
#archive.hidden { display: none; }
#archive-inner {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 8px 4px;
  max-width: 100%;
  scrollbar-width: thin;
  scrollbar-color: rgba(232,224,212,0.1) transparent;
}
#archive-inner::-webkit-scrollbar { height: 4px; }
#archive-inner::-webkit-scrollbar-thumb { background: rgba(232,224,212,0.1); }

.archive-thumb {
  width: 80px;
  height: 54px;
  border: 1px solid rgba(232,224,212,0.1);
  cursor: pointer;
  flex-shrink: 0;
  image-rendering: pixelated;
  transition: border-color 0.2s, transform 0.2s;
  opacity: 0.6;
  object-fit: cover;
}
.archive-thumb:hover {
  border-color: rgba(232,224,212,0.35);
  transform: scale(1.08);
  opacity: 1;
}

/* ── Footer ──────────────────────────────────────── */
#footer-wrap {
  position: fixed;
  bottom: 6px;
  left: 0; right: 0;
  z-index: 25;
  text-align: center;
}
#footer-link {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  color: rgba(232,224,212,0.18);
  text-decoration: none;
  letter-spacing: 2px;
  transition: color 0.3s;
}
#footer-link:hover {
  color: rgba(232,224,212,0.5);
}

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  #controls {
    padding: 8px 12px;
    flex-direction: column;
    gap: 8px;
  }
  #controls-left, #controls-right {
    width: 100%;
    justify-content: center;
  }
  #archive { bottom: 26px; }
  .archive-thumb { width: 60px; height: 40px; }
}