:root {
  --text: #fff8f0;
  --text-soft: rgba(255, 248, 240, 0.75);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "Poppins", "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  /* Warm, slowly shifting Headspace-style gradient */
  background: linear-gradient(-45deg, #ff9a6c, #ff7e79, #c76ba8, #7d6bd6, #ffb26b);
  background-size: 400% 400%;
  animation: drift 28s ease infinite;
  overflow: hidden;
}

@keyframes drift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

main {
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 2; /* above the chaos layer */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8vw;
  transition: opacity 0.8s ease;
}

.hidden {
  opacity: 0;
  pointer-events: none;
}

/* --- Start screen --- */

.brand {
  font-size: clamp(3rem, 12vw, 7rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-shadow: 0 4px 30px rgba(0, 0, 0, 0.15);
}

.tagline {
  margin: 1rem 0 3rem;
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 300;
  color: var(--text-soft);
  max-width: 28ch;
}

.begin {
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 500;
  color: #6b4a8a;
  background: var(--text);
  border: none;
  border-radius: 999px;
  padding: 0.9rem 3rem;
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.begin:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.24);
}

.begin:active {
  transform: translateY(0);
}

.sound-hint {
  margin-top: 1.4rem;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--text-soft);
}

/* --- GitHub link (start screen + finale) --- */

.github-link {
  display: inline-flex;
  margin-top: 1.4rem;
  color: var(--text-soft);
  transition: color 0.2s ease;
  cursor: pointer;
}

.github-link:hover {
  color: var(--text);
}

/* --- Player --- */

.stage {
  position: relative;
  z-index: 1; /* the calm "eye of the storm", above the breathing circle */
  font-size: clamp(1.6rem, 5.5vw, 3.4rem);
  font-weight: 300;
  line-height: 1.35;
  max-width: 20ch;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.35), 0 1px 8px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(6px);
  /* fade-out: quick and gentle */
  transition: opacity 0.3s ease-in, transform 0.3s ease-in;
}

.stage.visible {
  opacity: 1;
  transform: translateY(0);
  /* fade-in: slower and softer */
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
}

/* --- Breathing circle (stays serene amid the chaos) --- */

.breathing {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(52vh, 60vw);
  height: min(52vh, 60vw);
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.28) 0%,
    rgba(255, 255, 255, 0.1) 45%,
    rgba(255, 255, 255, 0) 70%
  );
  transform: translate(-50%, -50%);
  animation: breathe 9s ease-in-out infinite;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

@keyframes breathe {
  0%,
  100% {
    transform: translate(-50%, -50%) scale(0.82);
    opacity: 0.7;
  }
  50% {
    transform: translate(-50%, -50%) scale(1.05);
    opacity: 1;
  }
}

.progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width 0.2s linear;
}

/* ======================================================================
   Chaos layer — accumulating dev-clutter around the calm centre
   ====================================================================== */

#chaos {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
  font-family: "SFMono-Regular", ui-monospace, "Menlo", monospace;
}

/* Everything that spawns fades + drifts in. */
#chaos .win,
#chaos .pill,
#chaos .bubble,
#chaos .agents,
#chaos .thinking-chip {
  position: absolute;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
#chaos .in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* --- generic dev window --- */
.win {
  width: 240px;
  background: rgba(22, 24, 34, 0.82);
  color: #d8dee9;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(3px);
  overflow: hidden;
  font-size: 11px;
}
.win.wide {
  width: 300px;
}
.win-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.win-bar .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff5f56;
}
.win-bar .dot:nth-child(2) {
  background: #ffbd2e;
}
.win-bar .dot:nth-child(3) {
  background: #27c93f;
}
.win-bar b {
  margin-left: 6px;
  font-weight: 500;
  color: #aab2c5;
  font-size: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.win-body {
  padding: 8px 10px;
  max-height: 150px;
  overflow: hidden;
}

/* --- terminal --- */
.term-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #9fe6b0;
  line-height: 1.7;
}
.term-line.warn {
  color: #ffcf6b;
}

/* --- git graph --- */
.git-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.9;
}
.git-node {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f78166;
  box-shadow: 0 0 0 2px rgba(247, 129, 102, 0.25);
  flex: none;
}
.git code {
  color: #c9d1d9;
}

/* --- dashboard grid (tiled metrics, no overlap) --- */
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.dash-tile {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  padding: 5px 7px;
}
.dash-label {
  font-size: 9px;
  color: #aab2c5;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.dash-value {
  font-size: 18px;
  font-weight: 600;
  color: #fff;
}
.metric-bar {
  margin-top: 6px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.metric-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: #59d98a;
  transition: width 0.6s ease;
}
.metric-note {
  margin-top: 6px;
  color: #ff9d9d;
  font-size: 10px;
}

/* --- pull request --- */
.pr-stat {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
}
.pr-stat span {
  font-size: 10px;
  font-weight: 400;
  color: #aab2c5;
}
.pr-diff {
  margin-top: 4px;
}
.pr-diff .add {
  color: #56d364;
}
.pr-diff .del {
  color: #f85149;
}
.pr-comment {
  margin-top: 6px;
  color: #c9d1d9;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 4px;
  line-height: 1.5;
}

/* --- browser tabs --- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.tab {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 10px;
  color: #c9d1d9;
  white-space: nowrap;
}

/* --- architecture diagram --- */
.arch {
  position: relative;
  height: 150px;
}
.arch-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.arch-lines line {
  stroke: rgba(150, 180, 255, 0.45);
  stroke-width: 0.5;
}
.arch-box {
  position: absolute;
  padding: 2px 6px;
  font-size: 9px;
  background: rgba(90, 120, 220, 0.35);
  border: 1px solid rgba(120, 150, 240, 0.6);
  border-radius: 4px;
  color: #cdd8ff;
  white-space: nowrap;
  animation: pop 0.4s ease;
}
@keyframes pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}

/* --- flamegraph --- */
.flame {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.flame-row {
  display: flex;
  gap: 1px;
  height: 11px;
}
.flame-row i {
  display: block;
  height: 100%;
  border-radius: 1px;
}

/* --- status pill --- */
.pill {
  background: rgba(255, 255, 255, 0.9);
  color: #6b4a8a;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* --- notification toasts (stack, never leave) --- */
.toast-stack {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 260px;
}
.toast {
  background: rgba(22, 24, 34, 0.9);
  color: #d8dee9;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-left: 3px solid #7d6bd6;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 11px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateX(-12px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.toast.in {
  opacity: 1;
  transform: translateX(0);
}

/* --- agent counter --- */
.agents {
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}
.agents-n {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
}
.agents-l {
  font-size: 11px;
  opacity: 0.8;
}
.agents-note {
  margin-top: 4px;
  font-size: 10px;
  color: #ffd9a0;
}

/* --- AI chat bubbles --- */
.bubble {
  max-width: 200px;
  background: rgba(255, 255, 255, 0.92);
  color: #333;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 11px;
  font-family: "Poppins", system-ui, sans-serif;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.bubble b {
  display: block;
  font-size: 10px;
  color: #7d6bd6;
  margin-bottom: 2px;
}

/* --- ambient "Thinking…" chips --- */
.thinking-chip {
  background: rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 10px;
}

/* ======================================================================
   Finale — everything fades to white, one blinking cursor remains
   ====================================================================== */

.finale {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  background: #fdfdfc;
  color: #1a1a1a;
  font-family: "SFMono-Regular", ui-monospace, "Menlo", monospace;
  opacity: 0;
  transition: opacity 1.4s ease;
}
.finale.in {
  opacity: 1;
}
.finale-cursor {
  font-size: clamp(1.2rem, 4vw, 1.8rem);
}
.finale-cursor::after {
  content: "";
  display: inline-block;
  width: 0.6ch;
  height: 1.1em;
  margin-left: 4px;
  background: #1a1a1a;
  vertical-align: -0.15em;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
.eta {
  text-align: center;
  color: #888;
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  line-height: 1.6;
  transition: opacity 0.8s ease;
}
.replay {
  margin-top: 1rem;
  font-family: inherit;
  font-size: 0.85rem;
  color: #888;
  background: none;
  border: 1px solid #ccc;
  border-radius: 999px;
  padding: 0.5rem 1.6rem;
  cursor: pointer;
}
.replay:hover {
  color: #333;
  border-color: #999;
}
.finale .github-link {
  margin-top: 0;
  color: #888;
}
.finale .github-link:hover {
  color: #333;
}

@media (prefers-reduced-motion: reduce) {
  body {
    animation: none;
  }
  .breathing {
    animation: none;
  }
  .screen,
  .stage {
    transition: opacity 0.2s ease;
  }
}
