* { box-sizing: border-box; }

:root {
  --red: #e63946;
  --red-dark: #b71c2b;
  --navy: #1b2230;
  --navy-light: #262f42;
  --gold: #f1c40f;
  --green: #2ecc71;
  --text: #f4f4f4;
  --row-height: 88px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, #2a3346 0%, #12161f 70%);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 32px 16px 64px;
}

.app {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

header {
  text-align: center;
  margin-bottom: 8px;
  padding-top: 8px;
}

header h1 {
  margin: 0;
  font-size: 2.4rem;
  letter-spacing: 0.5px;
}

.subtitle {
  margin: 6px 0 0;
  color: #9aa4b8;
  font-size: 1rem;
}

.reset-footer {
  display: flex;
  justify-content: center;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hidden {
  display: none !important;
}

/* Stepper */

.stepper {
  position: relative;
  display: flex;
  gap: 20px;
  margin: 28px auto 8px;
}

.stepper::before {
  content: "";
  position: absolute;
  top: 19px;
  left: 16.667%;
  right: 16.667%;
  height: 2px;
  background: rgba(255, 255, 255, 0.14);
  z-index: 0;
}

.stepper-progress {
  position: absolute;
  top: 19px;
  left: 16.667%;
  height: 2px;
  background: var(--green);
  z-index: 0;
  width: 0;
  transition: width 0.4s ease;
}

.step {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  background: var(--navy-light);
  border: 2px solid rgba(255, 255, 255, 0.18);
  color: #9aa4b8;
  z-index: 1;
  transition: all 0.3s ease;
}

.step.active .step-circle {
  border-color: var(--gold);
  background: var(--gold);
  color: #1b2230;
  animation: pulse-gold 1.6s ease-in-out infinite;
}

.step.done .step-circle {
  border-color: var(--green);
  background: var(--green);
  color: white;
}

@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 8px rgba(241, 196, 15, 0.5); }
  50% { box-shadow: 0 0 22px rgba(241, 196, 15, 0.9); }
}

.step-label {
  margin-top: 8px;
  font-size: 0.78rem;
  color: #6b7385;
  transition: color 0.3s ease;
}

.step.active .step-label {
  color: var(--gold);
  font-weight: 700;
}

.step.done .step-label {
  color: var(--green);
}

/* Stage / reel */

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin: 28px 0 8px;
}

.stage::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 640px;
  height: 640px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(230, 57, 70, 0.22) 0%, transparent 65%);
  animation: ambient-pulse 4.5s ease-in-out infinite;
  pointer-events: none;
  z-index: -1;
}

@keyframes ambient-pulse {
  0%, 100% { opacity: 0.6; transform: translate(-50%, -50%) scale(0.95); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
}

.reel-frame {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: calc(var(--row-height) * 3);
  overflow: hidden;
  border-radius: 20px;
  border: 3px solid var(--gold);
  background: #0d1017;
  box-shadow: 0 0 50px rgba(230, 57, 70, 0.35), inset 0 0 30px rgba(0, 0, 0, 0.6);
}

.reel-frame::before,
.reel-frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 40%;
  pointer-events: none;
  z-index: 2;
}

.reel-frame::before {
  top: 0;
  background: linear-gradient(to bottom, #0d1017, transparent);
}

.reel-frame::after {
  bottom: 0;
  background: linear-gradient(to top, #0d1017, transparent);
}

.reel-highlight {
  position: absolute;
  top: var(--row-height);
  left: 0;
  right: 0;
  height: var(--row-height);
  border-top: 2px solid rgba(241, 196, 15, 0.6);
  border-bottom: 2px solid rgba(241, 196, 15, 0.6);
  background: rgba(241, 196, 15, 0.08);
  z-index: 1;
  pointer-events: none;
  transition: background 0.3s ease;
}

.reel-highlight.landed {
  background: rgba(241, 196, 15, 0.25);
}

.reel-track {
  will-change: transform;
}

.reel-row {
  height: var(--row-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  padding: 0 16px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.reel-icon {
  width: 54px;
  height: 54px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.5));
}

.reel-caption {
  margin: 0;
  min-height: 1.4em;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--gold);
  text-align: center;
}

.remaining-count {
  color: #9aa4b8;
  font-size: 0.9rem;
  margin: 0;
}

/* Cards */

.card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 22px 24px;
  backdrop-filter: blur(6px);
  margin-top: 24px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.welcome-card {
  text-align: center;
  border-color: rgba(241, 196, 15, 0.35);
  background: linear-gradient(160deg, rgba(230, 57, 70, 0.08), rgba(255, 255, 255, 0.03));
}

.welcome-kicker {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold);
}

.welcome-card h2 {
  font-size: 1.6rem;
  margin: 0 0 16px;
}

.welcome-card p {
  color: #cfd6e4;
  line-height: 1.55;
  margin: 0 0 14px;
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}

.welcome-fineprint {
  font-size: 0.8rem;
  color: #6b7385;
  font-style: italic;
}

.welcome-card .save-names-btn {
  max-width: 260px;
  margin-left: auto;
  margin-right: auto;
}

.setup-card label {
  display: block;
  font-size: 0.85rem;
  color: #9aa4b8;
  margin-bottom: 8px;
}

#namesInput {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  resize: vertical;
}

#namesInput:focus {
  outline: 2px solid var(--red);
}

.hint {
  margin: 8px 0 0;
  font-size: 0.8rem;
  color: #6b7385;
}

.save-names-btn {
  margin-top: 14px;
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: none;
  font-size: 1.05rem;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(230, 57, 70, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.save-names-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(230, 57, 70, 0.55);
}

.save-names-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.reset-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #cfd6e4;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: background 0.15s ease;
}

.reset-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Timeline */

.timeline {
  display: flex;
  gap: 16px;
}

.timeline-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#eliminatedRow {
  margin-bottom: 8px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  animation: timeline-in 0.35s ease both;
}

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

.timeline-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
}

.timeline-icon-img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.timeline-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.timeline-text strong {
  font-size: 0.98rem;
  font-weight: 700;
}

.timeline-text span {
  font-size: 0.78rem;
  color: #9aa4b8;
}

.timeline-item.tone-in {
  background: rgba(46, 204, 113, 0.14);
  border-color: rgba(46, 204, 113, 0.4);
}
.timeline-item.tone-in .timeline-icon { background: rgba(46, 204, 113, 0.25); }

.timeline-item.tone-out {
  background: rgba(107, 115, 133, 0.1);
  border-color: rgba(107, 115, 133, 0.25);
  opacity: 0.75;
}
.timeline-item.tone-out .timeline-text strong { text-decoration: line-through; color: #9aa4b8; }

.timeline-item.tone-order {
  background: rgba(241, 196, 15, 0.14);
  border-color: rgba(241, 196, 15, 0.4);
}
.timeline-item.tone-order .timeline-icon { background: rgba(241, 196, 15, 0.25); }

.timeline-item.tone-final {
  background: linear-gradient(135deg, rgba(230, 57, 70, 0.28), rgba(230, 57, 70, 0.1));
  border-color: rgba(230, 57, 70, 0.55);
}
.timeline-item.tone-final .timeline-icon { background: rgba(230, 57, 70, 0.3); }
.timeline-item.tone-final .timeline-text strong { color: var(--gold); }

/* Results */

.results-card {
  border-color: rgba(241, 196, 15, 0.35);
}

.results-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.result-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
}

.result-position {
  flex: 1;
  font-weight: 600;
  color: #cfd6e4;
}

.result-name {
  font-weight: 700;
  color: var(--gold);
}

.result-row.result-open {
  opacity: 0.5;
}

.result-row.result-open .result-name {
  color: #6b7385;
  font-weight: 500;
}
