/* ============================================================
   CEK KHODAM — Mystic Summoning design system
   ============================================================ */

:root {
  --ink: #0a0713;
  --ink-deep: #050309;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-border: rgba(167, 139, 250, 0.22);
  --violet: #a78bfa;
  --violet-deep: #7c3aed;
  --ecto: #6ee7b7;
  --ecto-soft: #a7f3d0;
  --text: #f5f3ff;
  --text-muted: #b4a9d6;
  --danger: #f87171;
  --gold: #fbbf24;
}

* {
  -webkit-tap-highlight-color: transparent;
}

body {
  background: var(--ink);
  color: var(--text);
  position: relative;
  overflow-x: hidden;
}

/* ---------- Ambient background ---------- */

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(
      60% 50% at 50% 8%,
      rgba(124, 58, 237, 0.28),
      transparent 60%
    ),
    radial-gradient(
      45% 40% at 85% 85%,
      rgba(110, 231, 183, 0.1),
      transparent 60%
    ),
    radial-gradient(
      45% 40% at 10% 90%,
      rgba(124, 58, 237, 0.14),
      transparent 60%
    ),
    var(--ink);
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.star {
  position: absolute;
  width: 2px;
  height: 2px;
  border-radius: 9999px;
  background: var(--text);
  opacity: 0.25;
  animation: twinkle linear infinite;
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.1;
  }
  50% {
    opacity: 0.85;
  }
}

.orb {
  position: absolute;
  border-radius: 9999px;
  filter: blur(60px);
  opacity: 0.35;
  animation: drift 18s ease-in-out infinite;
}

@keyframes drift {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(18px, -24px) scale(1.08);
  }
}

/* ---------- Type ---------- */

.font-type {
  font-family: "Urbanist", sans-serif;
}
.font-type-creepy {
  font-family: "Creepster", system-ui;
  letter-spacing: 0.02em;
}

.title-glow {
  color: var(--ecto-soft);
  text-shadow:
    0 0 12px rgba(110, 231, 183, 0.65),
    0 0 34px rgba(110, 231, 183, 0.35);
}

/* ---------- Layout shell ---------- */

.stage {
  position: relative;
  z-index: 10;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.02) inset,
    0 20px 60px -20px rgba(0, 0, 0, 0.6);
  border-radius: 1.25rem;
}

.fade-up {
  animation: fadeUp 0.7s ease both;
}
.fade-up-delay-1 {
  animation-delay: 0.08s;
}
.fade-up-delay-2 {
  animation-delay: 0.16s;
}
.fade-up-delay-3 {
  animation-delay: 0.24s;
}

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

/* ---------- Summoning circle (signature element) ---------- */

.summon-wrap {
  position: relative;
  width: 176px;
  height: 176px;
  margin: 0 auto;
}

.summon-ring {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  border: 1px dashed rgba(167, 139, 250, 0.45);
  animation: spin-slow 22s linear infinite;
}

.summon-ring.reverse {
  inset: 14px;
  border: 1px solid rgba(110, 231, 183, 0.35);
  animation: spin-slow-reverse 16s linear infinite;
}

.summon-ring.dotted {
  inset: 28px;
  border: 1.5px dotted rgba(167, 139, 250, 0.4);
  animation: spin-slow 30s linear infinite;
}

.summon-core {
  position: absolute;
  inset: 40px;
  border-radius: 9999px;
  background: radial-gradient(
    circle at 50% 40%,
    rgba(167, 139, 250, 0.35),
    rgba(10, 7, 19, 0) 70%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-core 3.2s ease-in-out infinite;
}

@keyframes spin-slow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
@keyframes spin-slow-reverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}
@keyframes pulse-core {
  0%,
  100% {
    filter: drop-shadow(0 0 6px rgba(167, 139, 250, 0.5));
  }
  50% {
    filter: drop-shadow(0 0 18px rgba(110, 231, 183, 0.55));
  }
}

.summon-wrap.summoning .summon-ring {
  animation-duration: 3.2s;
}
.summon-wrap.summoning .summon-ring.reverse {
  animation-duration: 2.1s;
}
.summon-wrap.summoning .summon-ring.dotted {
  animation-duration: 4s;
}
.summon-wrap.summoning .summon-core {
  animation-duration: 0.9s;
}

/* ---------- Inputs ---------- */

.input-mystic {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(167, 139, 250, 0.25);
  color: var(--text);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.2s;
}
.input-mystic::placeholder {
  color: var(--text-muted);
}
.input-mystic:focus {
  border-color: var(--violet);
  background: rgba(167, 139, 250, 0.08);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.18);
}
.input-mystic.input-error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16);
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.75rem;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  transition:
    transform 0.15s ease,
    box-shadow 0.2s ease,
    background 0.2s ease,
    opacity 0.2s ease;
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--violet-deep), #5b21b6);
  color: #fff;
  box-shadow: 0 8px 24px -8px rgba(124, 58, 237, 0.7);
}
.btn-primary:hover {
  box-shadow: 0 10px 30px -6px rgba(124, 58, 237, 0.85);
}
.btn-primary:disabled {
  opacity: 0.5;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(167, 139, 250, 0.3);
  color: var(--text-muted);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: var(--violet);
}

/* ---------- Spirit result card ---------- */

.spirit-card {
  perspective: 1200px;
}

.spirit-card-inner {
  transform-style: preserve-3d;
  animation: cardReveal 0.6s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes cardReveal {
  0% {
    transform: rotateY(-90deg) scale(0.9);
    opacity: 0;
  }
  60% {
    opacity: 1;
  }
  100% {
    transform: rotateY(0deg) scale(1);
    opacity: 1;
  }
}

.spirit-name {
  background: linear-gradient(90deg, var(--ecto-soft), var(--violet) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Rules page ---------- */

.rule-row {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}
.rule-icon {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ecto);
}

/* ---------- Utility ---------- */

.shake {
  animation: shake 0.4s ease;
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  75% {
    transform: translateX(6px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
