:root {
  --bg: #0b1622;
  --ink: #eaf3fb;
  --muted: #9fb4c7;
  --accent: #19b3d6;
  --accent-2: #0e7fb0;
  --win: #34d399;
  --lose: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 70% -10%, #143247 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.stage {
  max-width: 920px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.scene {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 18px;
  overflow: hidden;
  background: #0d1a26;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.pool {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.pool.loaded { opacity: 1; }

.result {
  position: absolute;
  left: 50%;
  bottom: 0;
  height: 82%;
  transform: translateX(-50%) translateY(12%);
  opacity: 0;
  filter: drop-shadow(0 18px 22px rgba(0, 0, 0, 0.6));
  pointer-events: none;
  user-select: none;
  transition: opacity 0.45s ease, transform 0.55s cubic-bezier(0.2, 0.9, 0.25, 1.3);
}
.result.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 22px 16px;
  text-align: center;
  font-weight: 900;
  font-size: clamp(26px, 6vw, 56px);
  letter-spacing: 0.01em;
  line-height: 1.05;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.45), 0 0 24px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(-12px) scale(0.96);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.banner.show { opacity: 1; transform: translateY(0) scale(1); }
.banner .name { display: block; font-size: 0.62em; opacity: 0.95; }
.banner.win { color: #eafff6; }
.banner.win .verdict { color: var(--win); }
.banner.lose .verdict { color: var(--lose); }

.pool-label {
  position: absolute;
  left: 14px;
  bottom: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: clamp(13px, 2.2vw, 16px);
  font-weight: 700;
  color: #eaf3fb;
  background: rgba(4, 12, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(4px);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease 0.15s, transform 0.35s ease 0.15s;
  pointer-events: none;
}
.pool-label.show { opacity: 1; transform: translateY(0); }

.loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
  background: #0d1a26;
  transition: opacity 0.3s ease;
}
.loader.hidden { opacity: 0; pointer-events: none; }

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.controls { text-align: center; }

.title {
  margin: 0;
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #7fe3ff, #19b3d6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle { margin: 6px 0 18px; color: var(--muted); min-height: 1.2em; }

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

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  padding: 14px 26px;
  border-radius: 999px;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.5; cursor: default; }

.btn-primary {
  color: #03131b;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(25, 179, 214, 0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 30px rgba(25, 179, 214, 0.5); }

.btn-ghost {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.btn-ghost:hover { background: rgba(255, 255, 255, 0.12); }

.stats { margin: 16px 0 0; min-height: 1em; font-size: 13px; color: var(--muted); }
.stats b { color: var(--ink); }

.credit { margin: 8px 0 0; min-height: 1em; font-size: 12px; color: var(--muted); }
.credit a { color: var(--accent); text-decoration: none; }
.credit a:hover { text-decoration: underline; }

/* ---- Name modal ---- */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 10, 16, 0.78);
  backdrop-filter: blur(6px);
  z-index: 10;
  transition: opacity 0.3s ease;
}
.modal.hidden { opacity: 0; pointer-events: none; }

.card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #13283a, #0e2030);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 28px 24px;
  text-align: center;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55);
}
.card-title { margin: 0 0 6px; font-size: 22px; }
.card-sub { margin: 0 0 18px; color: var(--muted); font-size: 14px; }

/* Two-step wizard: steps share one grid cell and slide across it. */
.steps { display: grid; overflow: hidden; }
.step {
  grid-area: 1 / 1;
  transition: transform 0.42s cubic-bezier(0.22, 0.8, 0.26, 1), opacity 0.34s ease;
}
.step.is-active { transform: translateX(0); opacity: 1; }
.step.is-out-left { transform: translateX(-70px); opacity: 0; pointer-events: none; }
.step.is-out-right { transform: translateX(70px); opacity: 0; pointer-events: none; }

.step-actions { display: flex; gap: 10px; }
.step-actions .start-btn { flex: 1; }
.step-actions .back-btn { flex: 0 0 auto; padding-left: 18px; padding-right: 18px; }

.name-input.error { border-color: var(--lose); animation: shake 0.3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.name-input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  outline: none;
  margin-bottom: 14px;
}
.name-input:focus { border-color: var(--accent); }
.card-btn { width: 100%; }

.card-q { margin: 4px 0 10px; color: var(--muted); font-size: 14px; }

/* Step 2: stacked choice buttons + subtle back link */
.pool-choice { display: flex; flex-direction: column; gap: 10px; }
.back-link {
  width: 100%;
  margin-top: 12px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-weight: 600;
}
.back-link:hover { color: var(--ink); background: transparent; }

.choice {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}
.choice-btn {
  flex: 1;
  cursor: pointer;
  padding: 12px 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.choice-btn:hover { background: rgba(255, 255, 255, 0.1); }
.choice-btn:active { transform: translateY(1px); }
.choice-btn.is-selected {
  border-color: var(--accent);
  background: rgba(25, 179, 214, 0.16);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.upload-row[hidden] { display: none; }
.upload-row {
  display: block;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
}
.upload-row input[type="file"] {
  display: block;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
}
#fileHint { display: block; margin-top: 8px; font-size: 12px; color: var(--muted); }
#fileHint.error { color: var(--lose); }
#fileHint.ok { color: var(--win); }
