:root {
  --bg: #0b0a12;
  --panel: #14111e;
  --panel-2: #1a1626;
  --panel-border: #2a2438;
  --purple: #8b5cf6;
  --purple-2: #6d3fd6;
  --purple-glow: rgba(139, 92, 246, 0.35);
  --text: #f1eef9;
  --text-dim: #9891ac;
  --text-faint: #6b6480;
  --green: #37d67a;
  --red: #ff5c7a;
  --amber: #f5b94d;
  --radius: 14px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px circle at 15% -5%, rgba(139, 92, 246, 0.16), transparent 60%),
    radial-gradient(500px circle at 90% 10%, rgba(109, 63, 214, 0.12), transparent 55%),
    var(--bg);
}

h1, h2, h3 { font-family: "Space Grotesk", "Inter", sans-serif; letter-spacing: -0.01em; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(20, 17, 30, 0.6);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.ghost-mark {
  font-size: 24px;
  display: inline-block;
  animation: float 3.2s ease-in-out infinite;
  filter: drop-shadow(0 0 10px var(--purple-glow));
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-4px) rotate(-4deg); }
}
.brand-name { font-family: "Space Grotesk", sans-serif; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
.accent { color: var(--purple); }
.tagline { color: var(--text-faint); font-size: 13px; margin-left: 10px; border-left: 1px solid var(--panel-border); padding-left: 10px; }
@media (max-width: 560px) { .tagline { display: none; } }

.auth-area, .user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: fadeIn 0.4s var(--ease);
}

input, select, button { font-family: inherit; font-size: 14px; }

input[type="text"], input[type="password"], input[type="number"], select {
  background: #1a1626;
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 13px;
  outline: none;
  width: 100%;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}
input::placeholder { color: var(--text-faint); }
input:focus, select:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
  background: #1d1830;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%), linear-gradient(135deg, var(--text-dim) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

button {
  cursor: pointer;
  border: none;
  border-radius: 9px;
  padding: 10px 18px;
  background: var(--purple);
  color: white;
  font-weight: 600;
  transition: transform 0.12s var(--ease), background 0.18s var(--ease), box-shadow 0.18s var(--ease), opacity 0.18s var(--ease);
}
button:hover { background: var(--purple-2); }
button:active { transform: scale(0.96); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .user-area { flex-wrap: wrap; justify-content: flex-end; }
  .user-area button, .user-area .username-pill { font-size: 12px; padding: 6px 10px; }
}
.ghost-btn:hover { background: #221c30; color: var(--text); border-color: #3a3250; }

.balance {
  color: var(--amber);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.username-pill {
  color: var(--text-dim);
  background: #1a1626;
  border: 1px solid var(--panel-border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
}

.hidden { display: none !important; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeSlideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeSlideIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: translateX(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 28px 60px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  animation: fadeSlideUp 0.5s var(--ease);
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 20px 50px -30px rgba(0, 0, 0, 0.6);
}

.panel h2 { margin-top: 0; font-size: 18px; }
.hint { color: var(--text-dim); font-size: 13px; line-height: 1.55; }

.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 4px; }
.conditional { margin: 4px 0 16px; animation: fadeSlideUp 0.3s var(--ease); }

.field-hint { color: var(--text-faint); font-size: 12px; line-height: 1.5; }

.primary-btn {
  padding: 12px 20px;
  font-size: 15px;
  box-shadow: 0 8px 24px -8px var(--purple-glow);
  position: relative;
}
.primary-btn.loading .btn-label { opacity: 0; }
.primary-btn.loading::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 16px; height: 16px;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-msg { margin-top: 10px; font-size: 13px; color: var(--text-dim); min-height: 18px; transition: color 0.2s var(--ease); }
.status-msg.error { color: var(--red); animation: shake 0.35s var(--ease); }
.status-msg.ok { color: var(--green); }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---- auth screen ---- */

.auth-screen {
  min-height: calc(100vh - 65px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  animation: fadeSlideUp 0.5s var(--ease);
}

.auth-panel { width: 100%; max-width: 420px; }

.auth-tabs {
  position: relative;
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: #1a1626;
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  padding: 4px;
}
.auth-tab {
  flex: 1;
  background: transparent;
  color: var(--text-dim);
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13.5px;
  position: relative;
  z-index: 1;
  transition: color 0.2s var(--ease);
}
.auth-tab.active { color: white; }
.auth-tab:hover:not(.active) { color: var(--text); }
.auth-tab-indicator {
  position: absolute;
  top: 4px; left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  background: var(--purple);
  border-radius: 8px;
  transition: transform 0.28s var(--ease);
  box-shadow: 0 4px 14px -4px var(--purple-glow);
}
.auth-tab-indicator.shift { transform: translateX(100%); }

.auth-form { animation: fadeSlideUp 0.35s var(--ease); }
.auth-form .primary-btn { width: 100%; margin-top: 6px; }

/* ---- modal ---- */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 5, 10, 0.7);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fadeIn 0.2s var(--ease);
}
.modal-box {
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 380px;
  animation: popIn 0.22s var(--ease);
}
.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }

/* ---- wizard ---- */

.wizard-head { margin-bottom: 20px; }

.explainer {
  position: relative;
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.09), rgba(139, 92, 246, 0.02));
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px 40px 16px 18px;
  margin-bottom: 22px;
  animation: fadeSlideUp 0.4s var(--ease);
}
.explainer-title {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 12px;
}
.explainer-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
@media (max-width: 720px) {
  .explainer-steps { grid-template-columns: 1fr; }
}
.explainer-step {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}
.explainer-step b { color: var(--text); }
.explainer-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--purple);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.explainer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-faint);
  border: none;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.explainer-close:hover { background: #221c30; color: var(--text); }

.steps {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 26px;
  gap: 4px;
  position: relative;
}
.steps::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 15px;
  right: 15px;
  height: 2px;
  background: var(--panel-border);
  z-index: 0;
}
.step {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  position: relative;
  z-index: 1;
}
.step-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--panel-2);
  border: 2px solid var(--panel-border);
  color: var(--text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.28s var(--ease);
}
.step-label {
  font-size: 10px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.2px;
  font-weight: 600;
  transition: color 0.28s var(--ease);
  text-align: center;
  overflow-wrap: anywhere;
  padding: 0 2px;
  line-height: 1.3;
}

@media (max-width: 480px) {
  .step-label { display: none; }
}
.step.active .step-dot {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
  box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.16);
}
.step.active .step-label { color: var(--text); }
.step.done .step-dot {
  background: rgba(55, 214, 122, 0.15);
  border-color: var(--green);
  color: var(--green);
}
.step.done .step-dot::before { content: "✓"; }
.step.done .step-label { color: var(--text-dim); }

.wizard-body { position: relative; }
.wizard-step { display: none; }
.wizard-step.active { display: block; animation: fadeSlideIn 0.32s var(--ease); }

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.segmented-3 { grid-template-columns: 1fr 1fr 1fr; }
.segment {
  background: #1a1626;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  padding: 10px 8px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.18s var(--ease);
}
.segment:hover { color: var(--text); border-color: #3a3250; }
.segment.active {
  background: var(--purple);
  border-color: var(--purple);
  color: white;
  box-shadow: 0 6px 16px -6px var(--purple-glow);
}

.toggle-field { display: flex; flex-direction: column; gap: 6px; }
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
  cursor: pointer;
}
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch-track {
  position: absolute; inset: 0;
  background: #2a2438;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  transition: background 0.2s var(--ease);
}
.switch-track::before {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: var(--text-dim);
  border-radius: 50%;
  transition: transform 0.22s var(--ease), background 0.22s var(--ease);
}
.switch input:checked ~ .switch-track { background: var(--purple); border-color: var(--purple); }
.switch input:checked ~ .switch-track::before { transform: translateX(18px); background: white; }

.review-card {
  background: #1a1626;
  border: 1px solid var(--panel-border);
  border-radius: 11px;
  padding: 16px 18px;
  font-size: 13.5px;
  line-height: 2;
  color: var(--text-dim);
}
.review-card b { color: var(--text); font-weight: 600; }
.review-card .review-title {
  color: var(--text);
  font-weight: 700;
  font-size: 14.5px;
  margin-bottom: 6px;
  display: block;
}
.review-card hr { border: none; border-top: 1px solid var(--panel-border); margin: 10px 0; }

.wizard-nav {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  justify-content: flex-end;
}
.nav-btn { min-width: 110px; }
.summon-btn { min-width: 150px; }

/* ---- market search ---- */

.market-results {
  border-radius: 9px;
  overflow: hidden;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 4px;
}
.market-result {
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-top: none;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  transition: background 0.15s var(--ease);
  animation: fadeSlideUp 0.25s var(--ease);
}
.market-result:first-child { border-top: 1px solid var(--panel-border); border-radius: 9px 9px 0 0; }
.market-result:last-child { border-radius: 0 0 9px 9px; }
.market-result:hover { background: #221c30; }
.market-result .prob { color: var(--purple); font-weight: 700; white-space: nowrap; }

.selected-market {
  border: 1px solid var(--purple-2);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.08), transparent);
  border-radius: 11px;
  padding: 14px 16px;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  animation: popIn 0.25s var(--ease);
}
.selected-market button { padding: 5px 12px; font-size: 12px; }

/* ---- ghost list ---- */

.ghost-card {
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  background: #17131f;
  transition: border-color 0.2s var(--ease), transform 0.15s var(--ease);
  animation: fadeSlideUp 0.3s var(--ease);
}
.ghost-card:hover { border-color: #3a3250; }
.ghost-card .row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.ghost-card .question { font-size: 14px; font-weight: 600; }
.ghost-card .meta { color: var(--text-dim); font-size: 12px; margin-top: 8px; line-height: 1.7; }
.ghost-card .meta b { color: var(--text); }

.state-pill {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.state-DORMANT { background: rgba(152, 145, 172, 0.15); color: var(--text-dim); }
.state-ARMED { background: rgba(245, 185, 77, 0.15); color: var(--amber); animation: pulse 1.8s ease-in-out infinite; }
.state-WOKEN { background: rgba(55, 214, 122, 0.15); color: var(--green); }
.state-EXPIRED { background: rgba(152, 145, 172, 0.1); color: var(--text-faint); }
.state-CANCELLED { background: rgba(255, 92, 122, 0.12); color: var(--red); }
.state-ERROR { background: rgba(255, 92, 122, 0.2); color: var(--red); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 185, 77, 0.35); }
  50% { box-shadow: 0 0 0 4px rgba(245, 185, 77, 0); }
}

.cancel-btn {
  background: transparent;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 5px 12px;
  font-size: 12px;
  margin-top: 10px;
}
.cancel-btn:hover { background: rgba(255, 92, 122, 0.1); }

.empty-state { color: var(--text-faint); font-size: 13px; padding: 24px 0; text-align: center; }
