/* ─── Custom properties ─────────────────────────────────────── */
:root {
  --bg:       #070712;
  --bg2:      #0d0d1f;
  --gold:     #c8a96e;
  --gold-dim: #8a6f3e;
  --ivory:    #e8dcc8;
  --purple:   #7b6fa0;
  --glow:     rgba(200, 169, 110, 0.18);
  --header-h: 90px;
  --footer-h: 128px;
  --font-title: 'Cinzel', 'Palatino Linotype', serif;
  --font-body:  'Crimson Text', 'Georgia', serif;
}

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ivory);
  font-family: var(--font-body);
}

/* ─── Stars canvas ───────────────────────────────────────────── */
#stars-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* ─── Dreamy wavy background ─────────────────────────────────── */
.dream-bg {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(62vw, 62vh);
  height: min(62vw, 62vh);
  transform: translate(-50%, -50%);
  z-index: 1;
  pointer-events: none;
}

.dream-blob {
  position: absolute;
  inset: 0;
}

.dream-blob--a {
  background: radial-gradient(ellipse at 50% 50%, rgba(60,110,200,0.28) 0%, rgba(40,80,160,0.12) 40%, transparent 70%);
  animation: morph-a 13s ease-in-out infinite, spin-a 45s linear infinite;
}

.dream-blob--b {
  background: radial-gradient(ellipse at 52% 52%, rgba(80,140,220,0.18) 0%, transparent 65%);
  animation: morph-b 19s ease-in-out infinite, spin-b 60s linear infinite reverse;
}

.dream-blob--c {
  background: radial-gradient(ellipse at 48% 46%, rgba(100,160,255,0.13) 0%, transparent 60%);
  animation: morph-c 24s ease-in-out infinite, spin-c 38s linear infinite;
}

.dream-blob--d {
  background: radial-gradient(ellipse at 50% 50%, rgba(140,180,255,0.07) 0%, transparent 55%);
  animation: morph-a 30s ease-in-out infinite reverse, spin-a 75s linear infinite reverse;
}

@keyframes morph-a {
  0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; transform: scale(1); }
  25%       { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; transform: scale(1.08); }
  50%       { border-radius: 50% 40% 60% 40% / 30% 60% 40% 70%; transform: scale(0.94); }
  75%       { border-radius: 40% 60% 40% 60% / 70% 30% 60% 40%; transform: scale(1.04); }
}

@keyframes morph-b {
  0%, 100% { border-radius: 40% 60% 60% 40% / 70% 30% 50% 60%; transform: scale(0.88); }
  33%       { border-radius: 60% 40% 40% 60% / 40% 70% 60% 30%; transform: scale(0.98); }
  66%       { border-radius: 30% 70% 50% 50% / 50% 50% 40% 70%; transform: scale(0.82); }
}

@keyframes morph-c {
  0%, 100% { border-radius: 70% 30% 50% 50% / 30% 50% 70% 40%; transform: scale(1.15); }
  40%       { border-radius: 40% 60% 30% 70% / 60% 40% 50% 60%; transform: scale(1.05); }
  80%       { border-radius: 50% 50% 60% 40% / 40% 60% 30% 70%; transform: scale(1.2); }
}

@keyframes spin-a {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes spin-b {
  from { transform: rotate(0deg) scale(0.88); }
  to   { transform: rotate(360deg) scale(0.88); }
}

@keyframes spin-c {
  from { transform: rotate(0deg) scale(1.15); }
  to   { transform: rotate(360deg) scale(1.15); }
}

/* ─── Top sparkle (fired when a wish reaches infinity) ───────── */
.top-sparkle {
  position: absolute;
  left: 50%;
  top: 10%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: none;
  width: 0; height: 0;
}

.sparkle-core {
  position: absolute;
  width: 8px; height: 8px;
  background: var(--gold);
  border-radius: 50%;
  top: -4px; left: -4px;
  box-shadow: 0 0 10px 4px rgba(200,169,110,0.9), 0 0 28px rgba(200,169,110,0.5);
  animation: sparkle-core 1.3s ease-out forwards;
}

.sparkle-ray {
  position: absolute;
  width: 3px; height: 3px;
  background: var(--gold);
  border-radius: 50%;
  top: -1.5px; left: -1.5px;
  animation: sparkle-ray 1s ease-out forwards;
  animation-delay: var(--d, 0ms);
}

@keyframes sparkle-core {
  0%   { opacity: 0;   transform: scale(0); }
  18%  { opacity: 1;   transform: scale(3); }
  55%  { opacity: 0.7; transform: scale(2); }
  100% { opacity: 0;   transform: scale(0.4); }
}

@keyframes sparkle-ray {
  0%   { opacity: 1; transform: translate(0, 0) scale(1.2); }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(0); }
}

/* ─── Header ─────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  z-index: 30;
  background: linear-gradient(to bottom, var(--bg) 60%, transparent);
  padding-top: 12px;
}

.header-yy {
  font-size: 1rem;
  color: var(--gold-dim);
  letter-spacing: 0.3em;
  opacity: 0.6;
}

.header-title {
  font-family: var(--font-title);
  font-size: clamp(1.1rem, 3vw, 1.7rem);
  font-weight: 600;
  letter-spacing: 0.45em;
  color: var(--gold);
  text-shadow: 0 0 30px rgba(200,169,110,0.45), 0 0 60px rgba(200,169,110,0.2);
}

.header-sub {
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  color: var(--gold-dim);
  text-transform: uppercase;
  opacity: 0.7;
}

/* ─── Crawl stage ────────────────────────────────────────────── */
.crawl-stage {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  bottom: var(--footer-h);
  overflow: hidden;
  z-index: 10;
}

/* Fade into infinity at top — kept shallow so 10 wishes stay visible */
.crawl-stage::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 22%;
  background: linear-gradient(to bottom, var(--bg) 15%, transparent);
  z-index: 20;
  pointer-events: none;
}

/* Fade into footer at bottom */
.crawl-stage::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 18%;
  background: linear-gradient(to top, var(--bg) 0%, transparent);
  z-index: 20;
  pointer-events: none;
}

/* ─── Idle state ─────────────────────────────────────────────── */
.idle-state {
  position: absolute;
  top: 50%; left: 50%;
  /* Base translate; animation adds scale on top */
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 15;
  opacity: 0.65;
  transition: opacity 0.7s ease;
  animation: idle-pulse 5s ease-in-out infinite;
}

/* Stop the animation and fade out; since animation only drives scale
   (not opacity) the transition on opacity wins cleanly. */
.idle-state.hidden {
  opacity: 0 !important;
  pointer-events: none;
  animation-play-state: paused;
}

.idle-symbol {
  font-size: 2.5rem;
  color: var(--gold);
  opacity: 0.7;
  margin-bottom: 16px;
  display: block;
  animation: star-spin 20s linear infinite;
}

@keyframes star-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.idle-text {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--gold-dim);
  letter-spacing: 0.15em;
  line-height: 1.9;
  opacity: 0.8;
}

/* Only scale, never touch opacity — lets the transition own opacity */
@keyframes idle-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.97); }
  50%       { transform: translate(-50%, -50%) scale(1.04); }
}

/* ─── Active wish crawl ──────────────────────────────────────── */
/*
 * Two-element structure so perspective + clipping work correctly:
 *   .wish-crawl  — full-width, animates `bottom` (2-D scroll)
 *   .wish-inner  — width-constrained, applies rotateX (3-D tilt)
 */
.wish-crawl {
  position: absolute;
  left: 0; right: 0;
  bottom: -15%;
  z-index: 15;
  animation: wish-up var(--dur, 30000ms) linear forwards;
}

.wish-inner {
  width: clamp(280px, 60%, 700px);
  margin: 0 auto;
  transform: perspective(700px) rotateX(22deg);
  transform-origin: 50% 100%;
  text-align: center;
}

@keyframes wish-up {
  from { bottom: -12%; }
  to   { bottom: 125%; }
}

/* Stream mode: compact single-line cards, ~10 visible at once */
.wish-text {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 1.9vw, 1.3rem);
  font-weight: 400;
  line-height: 1.65;
  color: #f0e8d8;
  text-shadow: 0 0 22px rgba(200,169,110,0.6), 0 0 50px rgba(200,169,110,0.25);
  letter-spacing: 0.05em;
  padding: 10px 18px;
  margin: 0;
}

.wish-star {
  color: var(--gold);
  opacity: 0.6;
  font-size: 0.7em;
  margin-right: 0.45em;
  vertical-align: middle;
}

/* ─── Philosopher panel ──────────────────────────────────────── */
.philosopher-panel {
  position: fixed;
  left: calc(50% - 500px);
  right: calc(50% + min(30vw, 350px));
  top: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  padding: 24px 20px 20px 20px;
  pointer-events: none;
  background: linear-gradient(
    to right,
    rgba(7, 7, 18, 0.82) 0%,
    rgba(7, 7, 18, 0.60) 60%,
    rgba(7, 7, 18, 0.25) 85%,
    transparent 100%
  );
  overflow: hidden;
}

/* Soft fade at the top so oldest quotes dissolve upward */
.philosopher-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 100px;
  background: linear-gradient(to bottom, rgba(7,7,18,0.95) 0%, transparent 100%);
  z-index: 1;
  pointer-events: none;
}

.philosopher-header {
  font-family: var(--font-title);
  font-size: 0.58rem;
  letter-spacing: 0.4em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.philosopher-icon {
  font-size: 0.52rem;
  color: var(--gold);
  opacity: 0.7;
}

.quotes-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 20px;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.philosopher-quote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.8rem;
  line-height: 1.75;
  color: #ccc0a8;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: quote-appear 2s ease-out forwards;
  padding-left: 10px;
  border-left: 1px solid rgba(200, 169, 110, 0.18);
  flex-shrink: 0;
}

.philosopher-quote.removing {
  animation: quote-vanish 1.2s ease-in forwards !important;
  overflow: hidden;
}

@keyframes quote-appear {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 0.8; transform: translateY(0); }
}

@keyframes quote-vanish {
  0%   { opacity: 0.8; max-height: 140px; margin-bottom: 0; }
  100% { opacity: 0;   max-height: 0;     margin-bottom: -20px; }
}

/* ─── Cosmos right panel ─────────────────────────────────────── */
.cosmos-panel {
  position: fixed;
  left: calc(50% + min(30vw, 350px));
  right: calc(50% - 500px);
  top: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 24px 20px 20px 20px;
  pointer-events: none;
  background: linear-gradient(
    to left,
    rgba(7, 7, 18, 0.82) 0%,
    rgba(7, 7, 18, 0.60) 60%,
    rgba(7, 7, 18, 0.25) 85%,
    transparent 100%
  );
  overflow: hidden;
}

.cosmos-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 100px;
  background: linear-gradient(to bottom, rgba(7,7,18,0.95) 0%, transparent 100%);
  z-index: 1;
  pointer-events: none;
}

.cosmos-header {
  font-family: var(--font-title);
  font-size: 0.58rem;
  letter-spacing: 0.4em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.5;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.cosmos-title { font-family: var(--font-title); }

.cosmos-moon {
  margin-bottom: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.moon-emoji {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 3px;
}

.moon-name {
  font-family: var(--font-title);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.75;
  display: block;
  margin-bottom: 4px;
}

.moon-meaning {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.7rem;
  line-height: 1.55;
  color: #b8a88a;
  margin: 0;
  opacity: 0.8;
}

.cosmic-weather-text {
  font-family: var(--font-body);
  font-size: 0.68rem;
  line-height: 1.65;
  color: #a099b8;
  font-style: italic;
  margin: 0 0 12px 0;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(200, 169, 110, 0.10);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  opacity: 0.85;
}

.cosmos-stargazer {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(200, 169, 110, 0.10);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  transition: opacity 0.8s ease;
}

.stargazer-name {
  font-family: var(--font-title);
  font-size: 0.5rem;
  letter-spacing: 0.25em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.65;
  margin-bottom: 5px;
}

.stargazer-map {
  font-family: monospace;
  font-size: 0.62rem;
  color: rgba(200, 169, 110, 0.45);
  line-height: 1.4;
  margin: 0 0 5px 0;
  letter-spacing: 0.05em;
  white-space: pre;
}

.stargazer-myth {
  font-family: var(--font-body);
  font-size: 0.67rem;
  line-height: 1.6;
  color: #b8a88a;
  font-style: italic;
  margin: 0;
  opacity: 0.72;
}

.cosmos-sky {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(200, 169, 110, 0.10);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.sky-season {
  font-family: var(--font-title);
  font-size: 0.48rem;
  letter-spacing: 0.3em;
  color: var(--gold);
  text-transform: uppercase;
  opacity: 0.45;
  margin-bottom: 7px;
}

.sky-item {
  display: flex;
  gap: 6px;
  margin-bottom: 5px;
  align-items: flex-start;
}

.sky-item-icon {
  color: var(--gold);
  opacity: 0.55;
  font-size: 0.6rem;
  flex-shrink: 0;
  padding-top: 2px;
}

.sky-item-text {
  font-family: var(--font-body);
  font-size: 0.65rem;
  line-height: 1.5;
  color: #b0a090;
  opacity: 0.75;
}

.sky-item-name {
  color: #ccc0a8;
  opacity: 1;
  font-style: normal;
}

/* Oracle messages — mirror of philosopher quotes */
.oracle-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 16px;
  overflow: hidden;
  position: relative;
  z-index: 2;
}

.oracle-quote {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 0.75rem;
  line-height: 1.75;
  color: #a8b0cc;
  letter-spacing: 0.02em;
  opacity: 0;
  animation: oracle-appear 2s ease-out forwards;
  padding-right: 10px;
  border-right: 1px solid rgba(150, 140, 200, 0.20);
  flex-shrink: 0;
}

.oracle-quote.removing {
  animation: oracle-vanish 1.2s ease-in forwards !important;
  overflow: hidden;
}

@keyframes oracle-appear {
  0%   { opacity: 0; transform: translateY(10px); }
  100% { opacity: 0.8; transform: translateY(0); }
}

@keyframes oracle-vanish {
  0%   { opacity: 0.8; max-height: 140px; margin-bottom: 0; }
  100% { opacity: 0;   max-height: 0;     margin-bottom: -16px; }
}

/* ─── Bottom panel ───────────────────────────────────────────── */
.bottom-panel {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--footer-h);
  z-index: 30;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 0 0 14px;
}

/* Queue status bar */
.queue-bar {
  text-align: center;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  color: var(--gold-dim);
  text-transform: uppercase;
  min-height: 20px;
  padding: 0 20px 6px;
  opacity: 0.8;
  transition: opacity 0.4s;
}

.queue-bar:empty { opacity: 0; }

.queue-bar .your-turn { color: var(--gold); font-weight: 600; }

.divider {
  width: min(600px, 80%);
  margin: 0 auto 12px;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold-dim), transparent);
  opacity: 0.3;
}

/* Input row */
.input-row {
  display: flex;
  justify-content: center;
  padding: 0 20px;
}

.input-wrap {
  position: relative;
  width: min(640px, 100%);
}

#wish-input {
  width: 100%;
  background: rgba(13, 13, 31, 0.7);
  border: 1px solid rgba(200, 169, 110, 0.25);
  border-radius: 4px;
  padding: 13px 52px 13px 20px;
  font-family: var(--font-body);
  font-size: 1.05rem;
  font-style: italic;
  color: var(--ivory);
  letter-spacing: 0.06em;
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  caret-color: var(--gold);
}

#wish-input::placeholder {
  color: var(--gold-dim);
  opacity: 0.45;
  letter-spacing: 0.12em;
}

#wish-input:focus {
  border-color: rgba(200, 169, 110, 0.55);
  box-shadow: 0 0 0 1px rgba(200,169,110,0.15), 0 0 20px rgba(200,169,110,0.08);
}

#wish-input.blocked {
  border-color: rgba(200, 80, 80, 0.5);
  box-shadow: 0 0 0 1px rgba(200,80,80,0.2), 0 0 16px rgba(200,80,80,0.08);
}

#wish-input:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.char-count {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.72rem;
  color: var(--gold-dim);
  opacity: 0.5;
  font-family: var(--font-title);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.char-count.low { color: #c87a6e; opacity: 0.9; }

.input-hint {
  text-align: center;
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  color: var(--gold-dim);
  opacity: 0.38;
  text-transform: uppercase;
  margin-top: 7px;
}

.input-hint kbd {
  font-family: var(--font-title);
  font-size: 0.62rem;
  background: rgba(200,169,110,0.1);
  border: 1px solid rgba(200,169,110,0.2);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { display: none; }
