/* ── Keyframes ─────────────────────────────────────────── */

@keyframes rise-in {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes splash-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(0.95); }
}

@keyframes btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,168,76,0); }
  50%       { box-shadow: 0 0 28px 6px rgba(201,168,76,0.22); }
}

@keyframes particle-float {
  0%   { opacity: 0;   transform: translateY(0)     scale(1);   }
  15%  { opacity: 0.7; }
  80%  { opacity: 0.2; }
  100% { opacity: 0;   transform: translateY(-140px) scale(0.4); }
}

@keyframes ring-appear {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes circle-pop {
  0%   { opacity: 0; transform: scale(0.15); }
  60%  { opacity: 1; transform: scale(1.1); }
  78%  { transform: scale(0.94); }
  90%  { transform: scale(1.04); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes circle-breathe {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.045); }
}

@keyframes burst {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.16); }
  65%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}

@keyframes conn-flow {
  from { stroke-dashoffset: 28; }
  to   { stroke-dashoffset: 0; }
}

@keyframes conn-appear {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes enter-appear {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes enter-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(201,168,76,0.3), 0 0 40px rgba(201,168,76,0.1); }
  50%       { box-shadow: 0 0 40px rgba(201,168,76,0.55), 0 0 80px rgba(201,168,76,0.2); }
}

@keyframes sheet-in {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

@keyframes sheet-out {
  from { transform: translateY(0); }
  to   { transform: translateY(102%); }
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes backdrop-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@keyframes welcome-in {
  from { opacity: 0; transform: scale(1.04); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pillar-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes crest-glow {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(201,168,76,0.4)); }
  50%       { filter: drop-shadow(0 0 16px rgba(201,168,76,0.8)); }
}

@keyframes complete-ring-pulse {
  0%, 100% { opacity: 0.35; }
  50%       { opacity: 0.75; }
}

/* ── Root ──────────────────────────────────────────────── */

.join-root {
  min-height: 100dvh;
  background: #0A0806;
  overflow: hidden;
  position: relative;
}

/* ── Splash ────────────────────────────────────────────── */

.splash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash--out {
  animation: splash-out 0.55s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.splash-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 65% at 50% 38%, #1C1610 0%, #0A0806 65%);
  pointer-events: none;
}

.splash-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 50%;
  background: rgba(201,168,76,0.55);
  animation: particle-float calc(5s + var(--i) * 0.4s) ease-in-out calc(var(--i) * 0.45s) infinite;
  left: calc(8% + var(--i) * 7.2%);
  bottom: 15%;
}

.splash-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  user-select: none;
}

.crest-wrap {
  color: #C9A84C;
  margin-bottom: 1.4rem;
  animation: rise-in 0.9s ease 0.05s both, crest-glow 3s ease-in-out 1.2s infinite;
}

.wordmark {
  font-family: 'Playfair Display', serif;
  font-weight: 500;
  font-size: clamp(2.6rem, 10vw, 3.4rem);
  letter-spacing: 0.16em;
  color: #EDE8E0;
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 0.25rem;
  animation: rise-in 0.9s ease 0.22s both;
}

.flourish {
  width: 200px;
  height: auto;
  margin-bottom: 1.4rem;
  animation: rise-in 0.9s ease 0.34s both;
}

.splash-sub {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 300;
  letter-spacing: 0.1em;
  color: rgba(201,168,76,0.65);
  margin-bottom: 2.8rem;
  animation: rise-in 0.9s ease 0.46s both;
}

.begin-btn {
  font-family: 'Playfair Display', serif;
  font-size: 0.88rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #C9A84C;
  background: transparent;
  border: 1px solid rgba(201,168,76,0.45);
  padding: 0.8rem 2.6rem;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  animation: rise-in 0.9s ease 0.62s both, btn-pulse 2.8s ease-in-out 1.6s infinite;
}

.begin-btn:hover {
  background: rgba(201,168,76,0.07);
  border-color: rgba(201,168,76,0.85);
}

.begin-btn:active {
  transform: scale(0.97);
}

/* ── Ring Screen ───────────────────────────────────────── */

.ring-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 1.5rem 1rem calc(env(safe-area-inset-bottom) + 1.5rem);
  background: radial-gradient(ellipse 90% 70% at 50% 35%, #1A130C 0%, #0A0806 60%);
  opacity: 0;
}

.ring-screen--in {
  animation: ring-appear 0.5s ease 0.05s both;
  opacity: 1;
}

.ring-hint {
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.55);
  margin-bottom: 1.8rem;
  text-align: center;
  min-height: 1.2em;
  transition: opacity 0.3s;
}

.ring-container {
  position: relative;
  width: min(360px, calc(100vw - 1.5rem));
  aspect-ratio: 360 / 340;
  margin: 0 auto;
}

/* Connection lines SVG */
.conn-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.conn-line {
  stroke: rgba(201,168,76,0.1);
  stroke-width: 1;
  stroke-dasharray: 6 9;
  transition: stroke 0.6s, stroke-width 0.6s, opacity 0.6s;
}

.ring-screen--in .conn-line {
  animation: conn-appear 0.8s ease 0.6s both;
}

.conn-line--active {
  stroke: rgba(201,168,76,0.4);
  stroke-width: 1.5;
  animation: conn-flow 2.5s linear infinite !important;
}

.ring-screen--complete .conn-line {
  stroke: rgba(201,168,76,0.55);
  stroke-width: 1.5;
  animation: conn-flow 1.8s linear infinite, complete-ring-pulse 2s ease-in-out infinite !important;
}

/* ── Circle Nodes ──────────────────────────────────────── */

.circle-node {
  position: absolute;
  width: 27.8%;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.1s;
  padding: 0;
  border: none;
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}

.circle-node--you    { top: 0.8%;  left: 36.1%; }
.circle-node--palace { top: 55.8%; left: 6.1%;  }
.circle-node--butler { top: 55.8%; left: 66.1%; }

.ring-screen--in .circle-node {
  animation: circle-pop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both;
}

.ring-screen--in .circle-node.circle-node--not-filled {
  animation:
    circle-pop 0.65s cubic-bezier(0.34, 1.56, 0.64, 1) var(--delay) both,
    circle-breathe 4.5s ease-in-out calc(var(--delay) + 0.9s) infinite;
}

.circle-body {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  border: 1.5px solid rgba(255,255,255,0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: background 0.4s, border-color 0.4s, box-shadow 0.4s;
  color: rgba(255,255,255,0.4);
  position: relative;
  overflow: hidden;
}

.circle-body::after {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: linear-gradient(140deg, rgba(255,255,255,0.06) 0%, transparent 55%);
  pointer-events: none;
}

.circle-node:hover .circle-body {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 20px var(--glow, rgba(201,168,76,0.2));
}

.circle-node:active .circle-body {
  transform: scale(0.94);
  transition: transform 0.1s;
}

.circle-node--filled .circle-body {
  border-color: var(--color);
  background: rgba(255,255,255,0.05);
  box-shadow:
    0 0 0 1px var(--color),
    0 0 20px var(--glow),
    inset 0 0 16px rgba(0,0,0,0.2);
  color: rgba(255,255,255,0.85);
}

.ring-screen--complete .circle-node .circle-body {
  animation: burst 0.4s ease both;
}

.ring-screen--complete .circle-node--you    .circle-body { animation-delay: 0.0s; }
.ring-screen--complete .circle-node--palace .circle-body { animation-delay: 0.08s; }
.ring-screen--complete .circle-node--butler .circle-body { animation-delay: 0.16s; }

.circle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.circle-node:hover .circle-icon {
  transform: scale(1.08);
}

.circle-display-name {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--color);
  text-align: center;
  max-width: 72%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

.circle-label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.35);
  white-space: nowrap;
  transition: color 0.3s;
}

.circle-node--filled .circle-label {
  color: rgba(255,255,255,0.6);
}

/* ── Enter Zone ────────────────────────────────────────── */

.enter-zone {
  margin-top: 3.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s;
}

.enter-zone--in {
  animation: enter-appear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
  pointer-events: auto;
}

.enter-btn {
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #0A0806;
  background: linear-gradient(135deg, #D4A840, #C9A84C 50%, #B8943E);
  border: none;
  padding: 0.9rem 2.8rem;
  border-radius: 100px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.2s, box-shadow 0.2s;
  animation: enter-glow 2.5s ease-in-out 0.4s infinite;
}

.enter-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(201,168,76,0.4);
}

.enter-btn:active {
  transform: scale(0.97) translateY(0);
}

/* ── Edit Sheet ────────────────────────────────────────── */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0);
  display: flex;
  align-items: flex-end;
  animation: backdrop-in 0.3s ease forwards;
}

.sheet-backdrop--in {
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.sheet {
  width: 100%;
  max-height: 85dvh;
  background: #131010;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  overflow-y: auto;
  overscroll-behavior: contain;
  transform: translateY(100%);
  position: relative;
  padding-bottom: calc(env(safe-area-inset-bottom) + 1rem);
}

.sheet--in {
  animation: sheet-in 0.42s cubic-bezier(0.34, 1.26, 0.64, 1) forwards;
}

.sheet--out {
  animation: sheet-out 0.32s cubic-bezier(0.4, 0, 0.6, 1) forwards;
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 2px;
  margin: 12px auto 0;
}

.sheet-close {
  position: absolute;
  top: 10px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.07);
  border: none;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.sheet-close:hover {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8);
}

.sheet-accent {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color, #C9A84C), transparent);
  margin: 16px 0 0;
  opacity: 0.6;
}

/* ── Form Body ─────────────────────────────────────────── */

.form-body {
  padding: 1.2rem 1.5rem 1.8rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.form-icon {
  margin-bottom: 0.8rem;
  opacity: 0.9;
}

.form-title {
  font-family: 'Playfair Display', serif;
  font-weight: 500;
  font-size: 1.35rem;
  color: #EDE8E0;
  letter-spacing: 0.02em;
  margin-bottom: 0.3rem;
  text-align: center;
}

.form-sub {
  font-size: 0.78rem;
  font-weight: 300;
  color: rgba(237,232,224,0.45);
  letter-spacing: 0.04em;
  margin-bottom: 1.8rem;
  text-align: center;
}

.form-fields {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  margin-bottom: 1.8rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(237,232,224,0.4);
}

.field-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: #EDE8E0;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  -webkit-appearance: none;
}

.field-input::placeholder {
  color: rgba(237,232,224,0.2);
}

.field-input:focus {
  border-color: var(--focus-color, rgba(201,168,76,0.6));
  background: rgba(255,255,255,0.07);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-color, #C9A84C) 15%, transparent);
}

/* ── Pill group ────────────────────────────────────────── */

.pill-group {
  display: flex;
  gap: 0.5rem;
}

.pill {
  flex: 1;
  padding: 0.55rem 0.5rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  font-weight: 400;
  color: rgba(237,232,224,0.5);
  cursor: pointer;
  transition: all 0.18s;
  text-align: center;
}

.pill:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(237,232,224,0.8);
}

.pill--active {
  border-color: var(--color, #C9A84C);
  background: color-mix(in srgb, var(--color, #C9A84C) 14%, transparent);
  color: var(--color, #C9A84C);
}

.tone-desc {
  font-size: 0.72rem;
  font-weight: 300;
  color: rgba(237,232,224,0.35);
  letter-spacing: 0.02em;
  margin-top: 0.5rem;
  text-align: center;
  min-height: 1em;
  transition: opacity 0.2s;
}

/* ── Save button ───────────────────────────────────────── */

.save-btn {
  width: 100%;
  padding: 0.9rem;
  border-radius: 12px;
  border: none;
  background: var(--color, #C9A84C);
  color: #0A0806;
  font-family: 'Playfair Display', serif;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
}

.save-btn:hover:not(:disabled) {
  box-shadow: 0 4px 20px color-mix(in srgb, var(--color, #C9A84C) 45%, transparent);
  transform: translateY(-1px);
}

.save-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.save-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Welcome Screen ────────────────────────────────────── */

.welcome {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0A0806;
  opacity: 0;
  z-index: 100;
}

.welcome--in {
  animation: welcome-in 0.7s ease forwards;
}

.welcome-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 85% 70% at 50% 40%, #1E1610 0%, #0A0806 65%);
}

.welcome-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 2rem 1.5rem;
  gap: 0;
}

.crest-wrap--big {
  color: #C9A84C;
  margin-bottom: 1.6rem;
  animation: rise-in 0.8s ease 0.15s both, crest-glow 3s ease-in-out 1s infinite;
}

.welcome-label {
  font-size: 0.72rem;
  font-weight: 300;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.6);
  margin-bottom: 0.9rem;
  animation: rise-in 0.8s ease 0.3s both;
}

.welcome-name {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 8vw, 2.8rem);
  font-weight: 500;
  color: #EDE8E0;
  letter-spacing: 0.04em;
  margin-bottom: 0.3rem;
  animation: rise-in 0.8s ease 0.42s both;
}

.welcome-palace {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 1rem;
  color: rgba(201,168,76,0.7);
  letter-spacing: 0.06em;
  margin-bottom: 2.2rem;
  animation: rise-in 0.8s ease 0.52s both;
}

.welcome-pillars {
  display: flex;
  gap: 1rem;
  margin-bottom: 2.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

.welcome-pillar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.7rem 1.1rem;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--pc) 30%, transparent);
  background: color-mix(in srgb, var(--pc) 8%, transparent);
  animation: pillar-rise 0.7s ease both;
  min-width: 80px;
}

.welcome-pillar:nth-child(1) { animation-delay: 0.62s; }
.welcome-pillar:nth-child(2) { animation-delay: 0.72s; }
.welcome-pillar:nth-child(3) { animation-delay: 0.82s; }

.pillar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
  opacity: 0.85;
}

.pillar-label {
  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--pc);
  opacity: 0.75;
}

.pillar-name {
  font-size: 0.85rem;
  font-weight: 400;
  color: rgba(237,232,224,0.85);
}

.enter-btn--gold {
  animation: rise-in 0.8s ease 0.95s both, enter-glow 2.5s ease-in-out 1.5s infinite;
}
