:root {
  --bg: #0b0d12;
  --panel: #14171f;
  --panel-edge: #232734;
  --text: #f2f3f6;
  --muted: #8b90a0;
  --faint: #5c6172;
  --blue: #2f5bd6;
  --blue-deep: #1c3a94;
  --blue-edge: #4f7cff;
  --pill: #1c2029;
  --pill-hover: #242936;
  --ball-size: clamp(200px, 54vw, 260px);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.card {
  width: min(760px, 100%);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 20px;
  padding: 22px 28px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.wordmark {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.menu {
  background: none;
  border: 0;
  color: var(--faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 6px;
}

h1 {
  margin: 10px 0 8px;
  font-size: clamp(28px, 5vw, 36px);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
}

.tagline {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  transition: opacity 0.35s ease;
}

.tagline.is-swapping { opacity: 0; }

/* The ball */

.ball-button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  outline-offset: 8px;
}

.ball-button:focus-visible { outline: 2px solid var(--blue-edge); }

.ball {
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  position: relative;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,0.10), transparent 38%),
    radial-gradient(circle at 50% 60%, #1c1f29 0%, #0e1016 70%, #080a0e 100%);
  box-shadow:
    inset 0 -14px 30px rgba(0,0,0,0.6),
    inset 0 10px 24px rgba(255,255,255,0.03),
    0 20px 50px rgba(0,0,0,0.55),
    0 0 0 1px rgba(255,255,255,0.04);
}

.window {
  width: 56%;
  height: 56%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, #142252 0%, #0b1330 60%, #080d22 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(79,124,255,0.55),
    inset 0 6px 18px rgba(0,0,0,0.6),
    0 0 18px rgba(47,91,214,0.18);
  overflow: hidden;
}

.triangle {
  width: 72%;
  aspect-ratio: 1 / 0.92;
  clip-path: polygon(50% 4%, 97% 92%, 3% 92%);
  background: linear-gradient(180deg, var(--blue-edge) 0%, var(--blue) 45%, var(--blue-deep) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding-bottom: 14%;
  color: #fff;
  transform-origin: 50% 60%;
}

.triangle .num {
  font-size: calc(var(--ball-size) * 0.13);
  font-weight: 700;
  line-height: 1;
}

.triangle .word {
  font-size: calc(var(--ball-size) * 0.04);
  letter-spacing: 0.08em;
  margin-top: 4px;
}

/* Shake animation */

.ball.is-shaking { animation: wobble 0.7s cubic-bezier(.36,.07,.19,.97) both; }

.ball.is-shaking .triangle { animation: resurface 0.7s ease-out both; }

@keyframes wobble {
  10%, 90% { transform: translate3d(-1px, 0, 0) rotate(-1deg); }
  20%, 80% { transform: translate3d(2px, 0, 0) rotate(2deg); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0) rotate(-3deg); }
  40%, 60% { transform: translate3d(4px, 0, 0) rotate(3deg); }
}

@keyframes resurface {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  35% { opacity: 0; transform: translateY(18%) scale(0.85); }
  65% { opacity: 0; transform: translateY(18%) scale(0.85); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .ball.is-shaking, .ball.is-shaking .triangle { animation: none; }
}

/* The spark */

.spark {
  margin-top: 28px;
  text-align: center;
  min-height: 92px;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.spark.is-swapping { opacity: 0; transform: translateY(4px); }

.spark-title {
  margin: 0 0 8px;
  font-size: clamp(24px, 4.4vw, 30px);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.spark-body {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  max-width: 56ch;
  margin-inline: auto;
}

.spark[data-kind="experiment"] .spark-body,
.spark[data-kind="escape"] .spark-body,
.spark[data-kind="breather"] .spark-body { color: #a9aebb; }

/* The two choices */

.choices {
  margin-top: 22px;
  width: 100%;
  display: flex;
  gap: 10px;
}

.choice {
  flex: 1 1 0;
  border: 0;
  border-radius: 999px;
  background: var(--pill);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  padding: 14px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: background 0.15s ease;
}

.choice:hover { background: var(--pill-hover); }
.choice:focus-visible { outline: 2px solid var(--blue-edge); outline-offset: 2px; }
.choice svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.choice[hidden] { display: none; }

/* Explore panel (Stage 2 shell) */

.explore-panel {
  width: 100%;
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.explore-panel[hidden] { display: none; }

.explore-panel textarea {
  width: 100%;
  resize: none;
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  padding: 12px 14px;
}

.explore-panel textarea:focus { outline: 2px solid var(--blue-edge); outline-offset: 0; border-color: transparent; }
.explore-panel textarea::placeholder { color: var(--faint); }

.send {
  border: 0;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font: inherit;
  font-size: 15px;
  padding: 12px 18px;
  cursor: pointer;
  align-self: stretch;
}

.send:hover { background: var(--blue-edge); }

.reply {
  grid-column: 1 / -1;
  margin: 4px 4px 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.send:disabled { opacity: 0.6; cursor: default; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Footer */

.divider {
  width: 100%;
  height: 1px;
  background: var(--panel-edge);
  margin: 34px 0 26px;
}

.beyond {
  display: flex;
  gap: 24px;
  justify-content: center;
  flex-wrap: wrap;
}

.beyond a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.beyond a:hover { color: var(--text); }
.beyond svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.beyond-caption {
  margin: 14px 0 0;
  color: var(--faint);
  font-size: 13px;
  text-align: center;
}

@media (max-width: 480px) {
  .card { padding: 18px 18px 22px; border-radius: 16px; }
  .choices { flex-direction: column; }
}
