:root {
  --bg-deep: #020611;
  --bg-midnight: #081325;
  --bg-haze: #0f1d33;
  --text-main: #d9e0ee;
  --text-soft: #98a8bf;
  --text-dim: #71839e;
  --silver: #c8d0dd;
  --silver-soft: rgba(200, 208, 221, 0.7);
  --line: rgba(200, 208, 221, 0.34);
  --line-bright: rgba(223, 232, 247, 0.72);
  --star: #edf3ff;
  --star-soft: rgba(237, 243, 255, 0.52);
  --danger: #c78b9a;
  --danger-soft: rgba(199, 139, 154, 0.16);
  --overlay: rgba(2, 7, 16, 0.42);
  --transition: 320ms cubic-bezier(0.2, 0.8, 0.2, 1);
  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-ui: "Inter", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-ui);
}

body {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: none;
  background: none;
  color: inherit;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

#app {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

/* SKY */

.sky-world {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
  isolation: isolate;
}

.sky-gradient,
.sky-vignette,
.sky-noise,
.star-field,
.sparkle-layer,
.shooting-star-layer,
.constellation-layer,
.foreground-layer {
  position: absolute;
  inset: 0;
}

.sky-gradient {
  background: linear-gradient(
    180deg,
    #000000 0%,
    #01030a 10%,
    #020611 24%,
    #081325 54%,
    #1a4679 100%
  );
  z-index: 0;
}

.sky-vignette {
  background: radial-gradient(
    circle at center,
    rgba(2, 6, 17, 0) 48%,
    rgba(2, 6, 17, 0.08) 70%,
    rgba(2, 6, 17, 0.26) 100%
  );
  z-index: 1;
  pointer-events: none;
}

.sky-noise {
  opacity: 0.05;
  z-index: 2;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.8) 0.5px, transparent 0.8px),
    radial-gradient(circle at 80% 40%, rgba(255,255,255,0.55) 0.5px, transparent 0.8px),
    radial-gradient(circle at 40% 80%, rgba(255,255,255,0.38) 0.4px, transparent 0.7px);
  background-size: 170px 170px, 210px 210px, 150px 150px;
}

/* RANDOM BACKGROUND STARS */

.star-field {
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}

.bg-star {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
}

.bg-star.far {
  width: 1px;
  height: 1px;
  opacity: 0.32;
}

.bg-star.mid {
  width: 1.6px;
  height: 1.6px;
  opacity: 0.56;
}

.bg-star.near {
  width: 2.2px;
  height: 2.2px;
  opacity: 0.82;
  box-shadow: 0 0 7px rgba(255,255,255,0.42);
}

.bg-star.pulse-soft {
  animation: starPulseSoft 6s ease-in-out infinite;
}

.bg-star.pulse-bright {
  animation: starPulseBright 4.2s ease-in-out infinite;
}

@keyframes starPulseSoft {
  0%, 100% {
    opacity: 0.45;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.35);
  }
}

@keyframes starPulseBright {
  0%, 100% {
    opacity: 0.55;
    transform: scale(1);
    box-shadow: 0 0 4px rgba(255,255,255,0.22);
  }
  50% {
    opacity: 1;
    transform: scale(2);
    box-shadow: 0 0 14px rgba(255,255,255,0.82);
  }
}

.sparkle-layer,
.shooting-star-layer {
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
}

.sparkle-star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 0 12px rgba(255,255,255,0.9);
  animation: sparklePulse 2.8s ease-in-out infinite;
}

@keyframes sparklePulse {
  0%, 100% {
    opacity: 0.2;
    transform: scale(1);
    box-shadow: 0 0 6px rgba(255,255,255,0.25);
  }
  50% {
    opacity: 1;
    transform: scale(2.2);
    box-shadow: 0 0 16px rgba(255,255,255,0.95);
  }
}

.shooting-star {
  position: absolute;
  width: 120px;
  height: 2px;
  opacity: 0;
  background: linear-gradient(
    90deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0.15) 15%,
    rgba(255,255,255,0.95) 55%,
    rgba(255,255,255,0) 100%
  );
  transform-origin: left center;
  box-shadow: 0 0 10px rgba(255,255,255,0.45);
  animation: shootingStar 1.25s linear forwards;
}

@keyframes shootingStar {
  0% {
    opacity: 0;
    transform: rotate(var(--angle)) translate3d(0, 0, 0) scaleX(0.5);
  }
  8% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: rotate(var(--angle)) translate3d(var(--dx), var(--dy), 0) scaleX(1);
  }
}

/* CONSTELLATIONS */

.constellation-layer {
  z-index: 4;
  pointer-events: none;
}

.sky-node {
  position: absolute;
  width: 8px;
  height: 8px;
  margin-left: -4px;
  margin-top: -4px;
  border-radius: 50%;
  background: var(--star);
  box-shadow: 0 0 14px rgba(237, 243, 255, 0.8);
  transition: opacity var(--transition), transform var(--transition);
}

.sky-node.ghost {
  opacity: 0.12;
  box-shadow: 0 0 6px rgba(237, 243, 255, 0.08);
}

.sky-node.in-progress {
  opacity: 1;
  transform: scale(1.2);
  box-shadow: 0 0 18px rgba(237, 243, 255, 0.9);
}

.sky-node.completed {
  opacity: 0.7;
}

.sky-line {
  position: absolute;
  height: 1px;
  transform-origin: left center;
  background: var(--line);
}

.sky-line.in-progress {
  background: var(--line-bright);
  box-shadow: 0 0 8px rgba(223, 232, 247, 0.5);
}

.sky-line.completed {
  background: rgba(200, 208, 221, 0.3);
}

.sky-label {
  position: absolute;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  color: var(--text-soft);
  text-transform: uppercase;
  white-space: nowrap;
}

.sky-label.active {
  color: var(--silver);
}

/* FOREGROUND TREES */

.foreground-layer {
  z-index: 6;
  pointer-events: none;
}

.tree {
  position: absolute;
  bottom: 0;
  height: 45vh;
  max-height: 420px;
  object-fit: contain;
  opacity: 0.88;
  filter: brightness(0.62) saturate(0.82) contrast(1.08);
}

.tree-left {
  left: 0;
}

.tree-right {
  right: 0;
}

/* HEADER */

.site-header {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 70;
  text-align: center;
  pointer-events: none;
  transition:
    top 1.2s cubic-bezier(0.2, 0.8, 0.2, 1),
    transform 1.2s cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 600ms ease,
    z-index 0ms linear 1.2s;
}

.brand-lockup h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(5rem, 11vw, 9.25rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #fff;
  white-space: nowrap;
  line-height: 1;
  transition:
    font-size 1.2s cubic-bezier(0.2, 0.8, 0.2, 1),
    color 600ms ease;
}

body.intro-started .site-header,
body.intro-complete .site-header {
  top: 36px;
  transform: translateX(-50%);
}

body.intro-started .brand-lockup h1,
body.intro-complete .brand-lockup h1 {
  font-size: clamp(2rem, 3.5vw, 3.5rem);
  color: var(--silver);
}

body.intro-complete .site-header {
  z-index: 10;
}

/* INTRO */

.intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: #000;
  cursor: pointer;
  overflow: hidden;
  transition: opacity 900ms ease, visibility 900ms ease;
}

.intro-copy {
  position: absolute;
  left: 50%;
  top: calc(50% + 116px);
  transform: translateX(-50%);
  text-align: center;
  width: min(88vw, 900px);
  pointer-events: none;
}

.intro-subtitle {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.35rem);
  color: rgba(255, 255, 255, 0.88);
  letter-spacing: 0.03em;
  transition: opacity 700ms ease;
}

.intro-prompt {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  transition: opacity 700ms ease;
}

.intro-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.intro-star {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 0 10px rgba(255,255,255,0.9);
  animation: introSparkle 2.8s ease-in-out infinite;
}

.intro-star.tiny {
  width: 2px;
  height: 2px;
  opacity: 0.55;
}

.intro-star.small {
  width: 3px;
  height: 3px;
  opacity: 0.72;
}

.intro-star.bright {
  width: 4px;
  height: 4px;
  opacity: 0.95;
  box-shadow: 0 0 14px rgba(255,255,255,1);
}

@keyframes introSparkle {
  0%, 100% {
    opacity: 0.18;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(2.2);
  }
}

body.intro-started .intro-subtitle,
body.intro-started .intro-prompt,
body.intro-started .intro-stars {
  opacity: 0;
}

body.intro-started .intro-overlay {
  opacity: 0;
}

body.intro-complete .intro-overlay {
  visibility: hidden;
  pointer-events: none;
}

/* OVERLAYS */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 11;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
}

.overlay-active {
  opacity: 1;
  pointer-events: auto;
}

/* MAIN UI */

.main-ui {
  position: absolute;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
  width: min(480px, calc(100vw - 84px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}

.task-label {
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.task-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 10px 0 14px;
  color: var(--silver);
  font-size: 1.1rem;
  outline: none;
  text-align: center;
}

.task-input::placeholder {
  color: rgba(152, 168, 191, 0.5);
}

.main-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* BUTTONS */

.primary-action,
.secondary-action,
.danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 22px;
  border-radius: 999px;
  transition: transform var(--transition), opacity var(--transition), border-color var(--transition), background-color var(--transition);
}

.primary-action {
  color: var(--bg-deep);
  background: var(--silver);
  font-weight: 600;
}

.primary-action:hover {
  transform: translateY(-1px);
}

.secondary-action {
  color: var(--silver);
  border: 1px solid rgba(200, 208, 221, 0.28);
  background: rgba(255,255,255,0.04);
}

.secondary-action:hover {
  border-color: rgba(220, 228, 245, 0.46);
  background: rgba(255,255,255,0.07);
}

.complete-task-btn {
  min-height: 54px;
  padding: 15px 28px;
  font-size: 1.02rem;
}

.danger-action {
  color: #eedbe0;
  border: 1px solid rgba(199, 139, 154, 0.25);
  background: var(--danger-soft);
}

.text-btn {
  color: var(--text-soft);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.text-btn:hover {
  color: var(--silver);
  border-color: rgba(200, 208, 221, 0.4);
}

/* MESSAGES */

.inline-message {
  min-height: 20px;
  margin: 0;
  font-size: 0.95rem;
}

.error-message {
  color: #d7a2b0;
}

/* SESSION UI */

.session-ui {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 34px 42px 42px;
}

.session-top-row {
  display: flex;
  justify-content: flex-end;
}

.session-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: auto;
  margin-bottom: auto;
  text-align: center;
  gap: 10px;
  transform: translateY(-2.5vh);
}

.session-kicker {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.76rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.session-task-title {
  margin: 0;
  max-width: 18ch;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 5vw, 5.4rem);
  font-weight: 600;
  color: var(--silver);
  line-height: 0.96;
  letter-spacing: 0.01em;
}

.active-progress {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--text-soft);
  font-size: 0.98rem;
  margin-top: 4px;
}

.active-constellation-name {
  color: var(--silver);
}

.session-bottom-row {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  width: min(720px, calc(100vw - 84px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.minimal-metrics {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  justify-content: center;
}

.metric {
  color: var(--text-soft);
  font-size: 0.96rem;
}

/* STATUS */

.status-shell {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 44px;
  margin: 0 auto;
  width: min(600px, calc(100vw - 84px));
  text-align: center;
}

.status-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 4vw, 4.2rem);
  font-weight: 600;
  color: var(--silver);
}

.status-message {
  margin: 0 auto 14px;
  max-width: 46ch;
  text-align: center;
}

.status-btn {
  margin-top: 4px;
}

/* COMPLETION */

.completion-page,
.processing-screen {
  position: absolute;
  inset: 0;
  z-index: 25;
}

.completion-page {
  display: grid;
  place-items: center;
  padding: 36px;
  background: rgba(2, 7, 16, 0.94);
}

.completion-background {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 20%, rgba(57, 82, 121, 0.18), transparent 26%),
    linear-gradient(180deg, #071121 0%, #030915 100%);
}

.completion-shell {
  position: relative;
  width: min(720px, 100%);
  z-index: 1;
}

.completion-header h2 {
  margin: 4px 0 18px;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4vw, 4.4rem);
  font-weight: 600;
  color: var(--silver);
}

.method-toggle {
  display: inline-flex;
  gap: 10px;
  margin-bottom: 24px;
  border-bottom: 1px solid rgba(200, 208, 221, 0.18);
  padding-bottom: 10px;
}

.toggle-btn {
  color: var(--text-dim);
  padding: 0 0 6px;
  border-bottom: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.toggle-btn.active {
  color: var(--silver);
  border-color: rgba(200, 208, 221, 0.45);
}

.method-panel {
  display: none;
  max-width: 620px;
}

.method-panel.active {
  display: block;
}

.method-panel label {
  display: block;
  margin: 12px 0 8px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

input[type="file"],
textarea {
  width: 100%;
  background: transparent;
  color: var(--silver);
  border: none;
  border-bottom: 1px solid rgba(200, 208, 221, 0.28);
  padding: 10px 0 12px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 110px;
}

textarea::placeholder {
  color: rgba(152, 168, 191, 0.48);
}

.char-count {
  margin: 8px 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.full-width-btn {
  margin-top: 26px;
}

/* PROCESSING */

.processing-screen {
  display: grid;
  place-items: center;
  background: rgba(2, 7, 16, 0.94);
}

.processing-shell {
  text-align: center;
}

.processing-orbit {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1px solid rgba(200, 208, 221, 0.16);
  border-top-color: rgba(223, 232, 247, 0.68);
  animation: spin 1.2s linear infinite;
}

#processing-title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 2.3rem;
  font-weight: 600;
  color: var(--silver);
}

#processing-text {
  margin: 0;
  color: var(--text-soft);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* MODAL */

.modal {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 7, 16, 0.7);
}

.modal-shell {
  position: relative;
  width: min(500px, 100%);
  background: rgba(4, 10, 21, 0.92);
  border: 1px solid rgba(200, 208, 221, 0.12);
  padding: 28px;
}

.modal-shell h3 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--silver);
}

.modal-shell p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.65;
}

.modal-actions {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

/* SESSION ATMOSPHERE */

body.session-active .site-header {
  opacity: 0.64;
}

body.session-active .sky-vignette {
  background:
    radial-gradient(circle at center, transparent 34%, rgba(2, 6, 17, 0.14) 64%, rgba(2, 6, 17, 0.36) 100%);
}

/* MOBILE */

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .site-header {
    left: 50%;
  }

  body.intro-started .site-header,
  body.intro-complete .site-header {
    top: 24px;
  }

  .brand-lockup h1 {
    font-size: clamp(4rem, 12vw, 7rem);
  }

  body.intro-started .brand-lockup h1,
  body.intro-complete .brand-lockup h1 {
    font-size: 2.4rem;
  }

  .intro-copy {
    top: calc(50% + 94px);
    width: min(92vw, 640px);
  }

  .main-ui,
  .status-shell {
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    width: min(90vw, 480px);
  }

  .session-ui {
    padding: 24px 24px 28px;
  }

  .session-center {
    gap: 14px;
  }

  .session-task-title {
    max-width: 12ch;
    font-size: clamp(2.6rem, 8vw, 4.4rem);
  }

  .session-bottom-row {
    width: calc(100vw - 48px);
    bottom: 28px;
  }

  .completion-page {
    padding: 24px;
  }

  .tree {
    height: 34vh;
    max-height: 280px;
  }
}

@media (max-width: 640px) {
  .main-ui {
    width: calc(100vw - 48px);
  }

  .intro-subtitle {
    font-size: 1rem;
  }

  .intro-prompt {
    font-size: 0.82rem;
    bottom: 28px;
  }

  .minimal-metrics {
    gap: 12px;
    flex-direction: column;
  }

  .modal-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .method-toggle {
    display: flex;
    width: 100%;
  }

  .complete-task-btn {
    width: 100%;
    max-width: 320px;
  }

  .tree {
    height: 28vh;
    max-height: 220px;
  }
}