*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #f8f7f4;
  --bg-soft: #f2eff9;
  --surface: #ffffff;
  --border: #e8e2f4;
  --border-strong: #ddd6f0;
  --violet: #4c1d95;
  --violet-mid: #6d28d9;
  --violet-bright: #7c3aed;
  --violet-soft: #ede9fe;
  --fire: #c2410c;
  --fire-mid: #ea580c;
  --muted: #6b6880;
  --muted-light: #9d9ab0;
  --text: #18161f;
  --text-soft: #3d3852;
  --blue: #38bdf8;
  --radius: 12px;
  --radius-lg: 16px;
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

.app {
  min-height: 100dvh;
}

.input-screen {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  min-height: 100dvh;
  animation: fade-in 360ms ease both;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100dvh;
  padding: 52px 32px 40px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: linear-gradient(170deg, #f0ebff 0%, #eae3ff 40%, #f8f7f4 100%);
}

.brand {
  text-align: center;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--violet-mid);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.36em;
  text-transform: uppercase;
}

.participants-panel {
  flex: 1;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.counter {
  min-width: 34px;
  padding: 3px 10px;
  border: 1px solid rgba(109, 40, 217, 0.15);
  border-radius: 999px;
  color: var(--violet-mid);
  background: var(--violet-soft);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.participants {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.participants li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  animation: fade-up 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.participant-name {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 600;
}

.participant-name span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.participant-index {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: var(--violet-mid);
  background: var(--violet-soft);
  font-size: 11px;
  font-weight: 800;
}

.remove-button {
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--muted-light);
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.remove-button:hover {
  color: var(--fire-mid);
  background: #fee2e2;
}

.empty-state {
  margin: 0;
  padding: 28px 0;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  color: var(--muted-light);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.compose {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 80px;
}

.compose-inner {
  width: min(100%, 460px);
}

.title {
  margin: 0 0 12px;
  color: var(--text);
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(42px, 6vw, 58px);
  font-weight: 400;
  line-height: 1.05;
}

.title em {
  color: var(--violet-bright);
}

.subtitle {
  margin: 0 0 36px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.name-form {
  display: grid;
  gap: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.field {
  width: 100%;
  min-width: 0;
  padding: 13px 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  font-size: 15px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field:focus {
  border-color: var(--violet-bright);
  box-shadow: 0 0 0 4px rgba(109, 40, 217, 0.09);
}

.field::placeholder {
  color: var(--muted-light);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button-add {
  padding: 13px 20px;
  color: #fff;
  background: linear-gradient(180deg, #7c3aed 0%, #5b21b6 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 4px 16px rgba(91, 33, 182, 0.38);
  white-space: nowrap;
}

.quick-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 40px;
}

.chip {
  padding: 5px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.chip:hover {
  border-color: #a78bfa;
  color: var(--violet-mid);
  background: var(--violet-soft);
}

.divider {
  height: 1px;
  margin-bottom: 28px;
  background: var(--border);
}

.button-fire {
  width: 100%;
  padding: 16px 28px;
  border-radius: var(--radius-lg);
  color: #fff;
  background: linear-gradient(180deg, #f97316 0%, #c2410c 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 6px 28px rgba(194, 65, 12, 0.42);
}

.button-fire:not(:disabled):hover {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 10px 36px rgba(194, 65, 12, 0.52);
}

.button-ghost {
  padding: 13px 24px;
  border: 1.5px solid var(--border-strong);
  color: var(--muted);
  background: transparent;
}

.button-ghost:hover {
  color: var(--violet-mid);
  background: var(--violet-soft);
}

.hint,
.status {
  margin: 10px 0 0;
  color: var(--muted-light);
  font-size: 12px;
  text-align: center;
}

.status {
  min-height: 18px;
  color: var(--fire);
}

.goblet-svg {
  display: block;
  overflow: visible;
  margin: 0 auto;
  filter: drop-shadow(0 4px 18px rgba(30, 27, 75, 0.35));
  animation: bob 4s ease-in-out infinite;
  transition: filter 700ms ease;
}

.goblet-svg.is-glowing {
  filter: drop-shadow(0 0 20px rgba(56, 189, 248, 0.72)) drop-shadow(0 0 48px rgba(37, 99, 235, 0.32));
}

.goblet-svg.is-intense {
  filter: drop-shadow(0 0 32px rgba(56, 189, 248, 0.9)) drop-shadow(0 0 72px rgba(37, 99, 235, 0.5));
}

.flame-group {
  transform-origin: 100px 84px;
}

.goblet-svg.is-glowing .flame-group {
  animation: flame-live 2s ease-in-out infinite;
}

.generating-screen,
.result-screen {
  position: relative;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: fade-in 360ms ease both;
}

.generating-screen {
  background: linear-gradient(170deg, #f0ebff 0%, var(--bg) 70%);
}

.result-screen {
  padding: 60px 40px;
  background: linear-gradient(170deg, #f8f7f4 0%, #f2ebf9 100%);
  text-align: center;
}

.rings span {
  position: absolute;
  top: 50%;
  left: 50%;
  border: 1px solid rgba(109, 40, 217, 0.07);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.rings span:nth-child(1) {
  width: 560px;
  height: 560px;
}

.rings span:nth-child(2) {
  width: 840px;
  height: 840px;
  opacity: 0.72;
}

.rings span:nth-child(3) {
  width: 1120px;
  height: 1120px;
  opacity: 0.48;
}

.orbit-stage {
  position: relative;
  width: min(560px, 90vw);
  height: min(560px, 90vw);
}

.orbiter {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 150px;
  padding: 6px 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--violet);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 12px rgba(91, 33, 182, 0.12);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
  animation: orbit var(--duration) linear infinite;
}

.orbiter.is-outer {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  font-weight: 500;
  opacity: 0.75;
}

.center-goblet {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 2;
  transform: translate(-50%, -52%);
}

.progress {
  width: 280px;
  margin-top: 52px;
}

.progress-bar {
  height: 2px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border);
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--violet-bright), var(--fire-mid));
  transition: width 80ms linear;
}

.particle {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: var(--color);
  pointer-events: none;
  animation: particle-rise var(--duration) ease-out var(--delay) infinite;
}

.result-label {
  position: relative;
  z-index: 2;
  margin-bottom: 28px;
  color: #3b82f6;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.44em;
  text-transform: uppercase;
}

.winner-title {
  position: relative;
  z-index: 2;
  margin: 10px 0 16px;
  color: var(--text);
  font-family: "DM Serif Display", Georgia, serif;
  font-size: clamp(54px, 10vw, 104px);
  font-weight: 400;
  line-height: 1;
  overflow-wrap: anywhere;
  animation: name-reveal 850ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.decor-line {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.decor-line::before,
.decor-line::after {
  width: 60px;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--blue));
}

.decor-line::after {
  background: linear-gradient(90deg, var(--blue), transparent);
}

.decor-line span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--blue);
}

.rest-list {
  max-width: 720px;
  margin: 0 0 44px;
  color: var(--muted-light);
  font-size: 12px;
  line-height: 1.5;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.result-actions .button-fire {
  width: auto;
  padding: 14px 36px;
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 500px;
  height: 500px;
  border: 1.5px solid rgba(56, 189, 248, 0.2);
  border-radius: 50%;
  pointer-events: none;
  animation: ring-out 2.8s ease-out both;
}

.pulse-ring:nth-child(2) {
  animation-delay: 350ms;
  border-color: rgba(56, 189, 248, 0.16);
}

.pulse-ring:nth-child(3) {
  animation-delay: 700ms;
  border-color: rgba(59, 130, 246, 0.12);
}

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

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

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes flame-live {
  0%, 100% { transform: scaleY(1) scaleX(1) rotate(-1deg); }
  25% { transform: scaleY(1.07) scaleX(0.95) rotate(1deg); }
  50% { transform: scaleY(0.97) scaleX(1.03) rotate(-2deg); }
  75% { transform: scaleY(1.05) scaleX(0.97) rotate(1.5deg); }
}

@keyframes orbit {
  from {
    transform: rotate(var(--angle)) translateX(var(--radius)) rotate(calc(-1 * var(--angle))) translate(-50%, -50%);
  }
  to {
    transform: rotate(calc(var(--angle) + 360deg)) translateX(var(--radius)) rotate(calc(-1 * (var(--angle) + 360deg))) translate(-50%, -50%);
  }
}

@keyframes particle-rise {
  from { opacity: 1; transform: translate(0, 0) scale(1); }
  to { opacity: 0; transform: translate(var(--px), var(--py)) scale(0); }
}

@keyframes name-reveal {
  0% { opacity: 0; transform: translateY(30px) scale(0.9); filter: blur(10px); }
  60% { filter: blur(0); }
  100% { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}

@keyframes ring-out {
  from { opacity: 0.7; transform: translate(-50%, -50%) scale(0.4); }
  to { opacity: 0; transform: translate(-50%, -50%) scale(2.6); }
}

@media (max-width: 860px) {
  .input-screen {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    min-height: 0;
  }

  .compose {
    padding: 42px 24px 56px;
  }

  .orbit-stage {
    width: min(460px, 92vw);
    height: min(460px, 92vw);
  }
}

@media (max-width: 520px) {
  .input-row,
  .result-actions {
    flex-direction: column;
  }

  .button-add {
    width: 100%;
  }

  .sidebar {
    padding: 34px 20px 28px;
  }

  .compose {
    padding-inline: 18px;
  }
}
