:root {
  --bg: #0D1B3E;
  --card: #1A2B52;
  --grad-start: #1B2F5E;
  --grad-mid: #6B3FA0;
  --grad-end: #D94F6B;
  --gold: #F5C842;
  --cream: #F0EDE8;
  --error: #D94F6B;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  font-family: 'Nunito', sans-serif;
  overflow: hidden;
}

#app { position: relative; width: 100vw; height: 100vh; }

#scene-container {
  position: absolute;
  inset: 0;
}

#cell-scene {
  width: 100%;
  height: 100%;
  display: block;
}

.particle-layer { pointer-events: none; }

.bg-creature[data-role="polymerase"] {
  cursor: grab;
  touch-action: none;
}
.bg-creature[data-role="polymerase"]:active { cursor: grabbing; }

.chip-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 22px;
  fill: #ffffff;
  pointer-events: none;
  user-select: none;
}

.poly-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 15px;
  fill: var(--cream);
  pointer-events: none;
  user-select: none;
}

.bg-life-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 11px;
  fill: #9aa6c4;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

.highlight-ring {
  pointer-events: none;
}

.promoter-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 13px;
  fill: #C9A9EE;
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px;
}

#brand-tag {
  position: absolute;
  top: 16px;
  left: 20px;
  font-weight: 900;
  color: var(--cream);
  font-size: 15px;
  letter-spacing: 0.5px;
}
#brand-tag span {
  font-weight: 400;
  color: #9aa6c4;
  font-size: 12px;
  margin-left: 6px;
}

#instruction-bar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 640px;
  background: var(--card);
  border: 1px solid rgba(217, 79, 107, 0.0);
  border-image: linear-gradient(90deg, var(--grad-start), var(--grad-mid), var(--grad-end)) 1;
  border-radius: 14px;
  padding: 14px 22px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

#instruction-text {
  margin: 0;
  color: var(--cream);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
}

#feedback-toast {
  align-self: center;
  margin: 0 auto;
  max-width: 560px;
  padding: 10px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
  background: var(--card);
  border: 2px solid var(--gold);
  color: var(--cream);
  transition: opacity 0.25s ease, transform 0.25s ease;
  opacity: 1;
  transform: translateY(0);
}
#feedback-toast.hidden {
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
}
#feedback-toast.error {
  border-color: var(--error);
}
#feedback-toast.success {
  border-color: var(--gold);
}

#picker-tray {
  align-self: center;
  display: flex;
  gap: 14px;
  margin-bottom: 10px;
  pointer-events: auto;
}
#picker-tray.hidden { display: none; }

#skip-btn {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 20;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--cream);
  background: rgba(26, 43, 82, 0.85);
  border: 1px solid rgba(240, 237, 232, 0.25);
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.15s ease, border-color 0.15s ease;
}
#skip-btn:hover {
  background: rgba(107, 63, 160, 0.9);
  border-color: var(--gold);
}
#skip-btn.hidden { display: none; }

#credits {
  position: absolute;
  left: 20px;
  bottom: 16px;
  z-index: 20;
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  line-height: 1.55;
  color: #9aa6c4;
  pointer-events: none;
}
#credits a {
  color: var(--gold);
  text-decoration: none;
  font-weight: 700;
  pointer-events: auto;
}
#credits a:hover { text-decoration: underline; }

#pairing-guide {
  position: absolute;
  right: 20px;
  bottom: 20px;
  background: var(--card);
  border: 1px solid rgba(240,237,232,0.15);
  border-radius: 12px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  pointer-events: none;
}
#pairing-guide.hidden { display: none; }

.pairing-guide-title {
  color: var(--cream);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 6px;
  text-align: center;
}

.pairing-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.pairing-row + .pairing-row { margin-top: 6px; }

.pg-base {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 13px;
  color: var(--cream);
}

.pg-arrow {
  color: #9aa6c4;
  font-size: 13px;
}

/* Toggled via backgroundLife.setTypeVisible() — e.g. ribosomes stay out
   of sight during nuclear transcription, then reappear for translation. */
.bg-creature.creature-hidden {
  visibility: hidden;
}

.chip {
  user-select: none;
  cursor: grab;
  touch-action: none;
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 26px;
  color: var(--cream);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
  border: 2px solid rgba(255,255,255,0.15);
  transition: transform 0.15s ease;
}
.chip:active { cursor: grabbing; transform: scale(1.08); }

.aa-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 12px;
  fill: #3A2E00;
  pointer-events: none;
  user-select: none;
}

/* Finished protein spotlight — pulsing gold glow once translation ends. */
.polypeptide-spotlight {
  animation: pp-glow 1.7s ease-in-out infinite;
}
@keyframes pp-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(245, 200, 66, 0.65)); }
  50% { filter: drop-shadow(0 0 22px rgba(245, 200, 66, 1)); }
}

.trna-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 9px 13px;
  background: #243A63;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  cursor: grab;
  user-select: none;
  touch-action: none;
  transition: transform 0.15s ease;
}
.trna-chip:active { cursor: grabbing; transform: scale(1.06); }
.trna-anticodon { display: flex; gap: 3px; }
.trna-anticodon span {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 14px;
  color: #fff;
}
.trna-aa {
  font-weight: 800;
  font-size: 13px;
  color: var(--cream);
}

.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%);
  opacity: 0.92;
}

/* .chip is applied alongside .drag-ghost for nucleotide drags, so the
   ghost is the same 64px rounded-square chip it was picked up from. */

.drag-ghost-molecule {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.ghost-molecule-shape {
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.55);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.ghost-molecule-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 12px;
  color: var(--cream);
  background: rgba(13,27,62,0.75);
  padding: 2px 8px;
  border-radius: 8px;
  white-space: nowrap;
}
