:root {
  --bg-1: #090913;
  --bg-2: #110b1d;
  --bg-3: #170f24;
  --ball-size-scale: 1.5;
  --text-main: #edf0ff;
  --text-soft: #b9bfd9;
  --accent-1: #9d60ff;
  --accent-2: #e68bff;
  --accent-3: #6ce3ff;
  --glass-border: rgba(180, 163, 255, 0.35);
  --glass-fill: rgba(18, 14, 35, 0.65);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 15% 18%, rgba(169, 92, 255, 0.18), transparent 35%),
    radial-gradient(circle at 82% 22%, rgba(76, 142, 255, 0.17), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(204, 105, 255, 0.2), transparent 50%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2) 40%, var(--bg-3));
  overflow-x: hidden;
}

.bg-veil,
.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.bg-veil {
  background:
    radial-gradient(circle at 30% 20%, rgba(201, 130, 255, 0.08), transparent 42%),
    radial-gradient(circle at 70% 65%, rgba(100, 220, 255, 0.06), transparent 35%);
  filter: blur(6px);
}

.bg-grid {
  background-image:
    linear-gradient(rgba(164, 149, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(164, 149, 255, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(circle at center, black 15%, transparent 78%);
  opacity: 0.38;
}

.site-header {
  position: fixed;
  top: 18px;
  left: 24px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  width: min(430px, calc(100vw - 38px));
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(190, 169, 255, 0.35);
  background: rgba(12, 8, 24, 0.65);
  backdrop-filter: blur(8px);
}

.logo-icon {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  object-fit: contain;
  box-shadow:
    0 0 10px rgba(132, 98, 255, 0.5),
    0 0 18px rgba(108, 227, 255, 0.2);
}

.logo-text {
  font-family: "Orbitron", sans-serif;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.main-stage {
  min-height: 80vh;
  display: grid;
  place-items: center;
  padding: 24px 20px 48px;
}

.oracle-zone {
  width: min(920px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.control-panel {
  position: relative;
  width: min(560px, 100%);
  min-height: 100px;
  display: grid;
  place-items: center;
  z-index: 16;
}

.btn-primary,
.btn-secondary {
  position: relative;
  z-index: 20;
  border: 0;
  border-radius: 14px;
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.06em;
  font-size: 0.95rem;
  color: #fff;
  cursor: pointer;
  transition:
    transform 0.24s ease,
    box-shadow 0.24s ease,
    filter 0.24s ease;
}

.btn-primary {
  padding: 16px 34px;
  background: linear-gradient(120deg, var(--accent-1), var(--accent-2) 55%, #f0a7ff);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18) inset,
    0 12px 32px rgba(166, 92, 255, 0.35);
}

.btn-secondary {
  margin-top: 8px;
  padding: 13px 24px;
  background: linear-gradient(130deg, #5879ff, #9b61ff 55%, #ec91ff);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.16) inset,
    0 10px 24px rgba(120, 103, 255, 0.32);
}

.btn-primary:hover,
.btn-secondary:hover {
  transform: translateY(-2px) scale(1.01);
  filter: brightness(1.07);
}

.btn-primary:active,
.btn-secondary:active {
  transform: translateY(1px) scale(0.995);
}

.question-form {
  width: min(560px, 100%);
  display: grid;
  gap: 8px;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 16;
  border: 1px solid var(--glass-border);
  background: var(--glass-fill);
  backdrop-filter: blur(10px);
  border-radius: 22px;
  padding: 22px;
  box-shadow:
    0 24px 60px rgba(8, 8, 18, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  animation: form-fade 320ms ease;
}

.question-form label {
  font-size: 0.9rem;
  color: #d9deff;
}

.select-wrap {
  position: relative;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid #d0c5ff;
  border-bottom: 2px solid #d0c5ff;
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.question-form select,
.question-form input {
  width: 100%;
  border: 1px solid rgba(203, 188, 255, 0.42);
  border-radius: 12px;
  padding: 12px 14px;
  color: #f4f5ff;
  background: rgba(19, 16, 34, 0.8);
  font: inherit;
  outline: none;
  transition:
    border-color 200ms ease,
    box-shadow 200ms ease;
}

.question-form select {
  appearance: none;
  cursor: pointer;
  padding-right: 38px;
}

.question-form input::placeholder {
  color: #9da2c0;
}

.question-form select:focus,
.question-form input:focus {
  border-color: rgba(200, 151, 255, 0.95);
  box-shadow: 0 0 0 3px rgba(166, 99, 255, 0.22);
}

.field-note {
  margin: 2px 0 8px;
  font-size: 0.76rem;
  color: var(--text-soft);
  line-height: 1.35;
}

.countdown {
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 800;
  color: #f3dcff;
  text-shadow:
    0 0 24px rgba(230, 139, 255, 0.9),
    0 0 54px rgba(130, 100, 255, 0.75);
  animation: pulse-counter 920ms ease-in-out infinite;
  z-index: 12;
}

.countdown.is-waiting {
  font-size: clamp(1rem, 2.4vw, 1.45rem);
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.04em;
  text-align: center;
  animation-duration: 1.25s;
}

.crystal-ball {
  position: relative;
  width: min(100vw, calc(68vw * var(--ball-size-scale)), calc(420px * var(--ball-size-scale)));
  aspect-ratio: 1 / 1;
  margin-top: -60px;
  display: grid;
  place-items: center;
  z-index: 3;
}

@media (hover: hover) and (pointer: fine) {
  .ball-core,
  .ball-core * {
    cursor:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 28 28'%3E%3Ccircle cx='14' cy='14' r='12' fill='%23140f25' stroke='%23dfc1ff' stroke-width='1.6'/%3E%3Ctext x='14' y='19' text-anchor='middle' font-family='Arial, sans-serif' font-size='16' fill='%23f4e6ff'%3E%3F%3C/text%3E%3C/svg%3E")
        14 14,
      help;
  }
}

.ball-core {
  position: absolute;
  width: 50%;
  height: 50%;
  left: 25%;
  top: 25%;
  transform: translateY(-60px);
  z-index: 6;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
}

.ball-result {
  position: absolute;
  width: 60vw;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -110px);
  z-index: 10;
  display: grid;
  place-items: center;
  text-align: center;
  pointer-events: auto;
  cursor: default;
  padding: 0;
}

.ball-result-logo {
  margin: 0 auto 12px;
}

.ball-result p {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.6em 0.84em;
  border-radius: 14px;
  border: 1px solid rgba(210, 182, 255, 0.56);
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 237, 255, 0.18), transparent 55%),
    linear-gradient(150deg, rgba(31, 21, 50, 0.78), rgba(13, 10, 26, 0.78));
  backdrop-filter: blur(6px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 14px 30px rgba(8, 5, 20, 0.34);
  font-family: "Orbitron", sans-serif;
  letter-spacing: 0.04em;
  font-size: clamp(1.05rem, 2.1vw, 1.5rem);
  line-height: 1.3;
  color: #f7e5ff;
  text-shadow:
    0 0 14px rgba(230, 139, 255, 0.78),
    0 0 30px rgba(130, 100, 255, 0.55);
  cursor: default;
}

.ball-shell {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 8;
  pointer-events: none;
  user-select: none;
  filter:
    drop-shadow(0 30px 52px rgba(7, 5, 18, 0.52))
    drop-shadow(0 0 34px rgba(168, 112, 255, 0.3));
}

.smoke-layer,
.sparkle-layer {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.smoke {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--size);
  height: calc(var(--size) * 0.7);
  border-radius: 58% 42% 51% 49%;
  transform:
    translate(-50%, -50%)
    rotate(0deg)
    translateX(var(--orbit))
    translateY(var(--drift))
    translate(var(--flow-x, 0px), var(--flow-y, 0px))
    scale(var(--shape-x, 1), var(--shape-y, 1));
  background: radial-gradient(
    circle at 35% 35%,
    rgba(234, 192, 255, 0.54) 0%,
    rgba(179, 124, 248, 0.24) 48%,
    rgba(139, 95, 210, 0.1) 72%,
    transparent 85%
  );
  filter: blur(9px);
  mix-blend-mode: screen;
  opacity: 0.68;
  will-change: transform, filter, opacity;
  transition:
    border-radius 560ms ease,
    opacity 420ms ease;
  animation:
    smoke-flow var(--duration) linear infinite,
    smoke-breath calc(var(--duration) * 0.45) ease-in-out infinite;
  animation-delay: var(--delay);
}

.sparkle {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  transform:
    translate(-50%, -50%)
    rotate(0deg)
    translateX(var(--orbit))
    translate(var(--flow-x, 0px), var(--flow-y, 0px));
  background: radial-gradient(
    circle at center,
    rgba(255, 255, 255, 1) 0%,
    rgba(223, 194, 255, 0.85) 35%,
    rgba(161, 116, 255, 0.24) 72%,
    transparent 92%
  );
  box-shadow:
    0 0 10px rgba(228, 196, 255, 0.72),
    0 0 20px rgba(108, 227, 255, 0.3);
  opacity: 0.6;
  animation:
    sparkle-drift var(--duration) linear infinite,
    sparkle-pulse calc(var(--duration) * 0.3) ease-in-out infinite;
  animation-delay: var(--delay);
}

.crystal-ball.is-thinking .smoke {
  opacity: 0.86;
}

.crystal-ball.is-thinking .sparkle {
  opacity: 0.98;
}

.crystal-ball.is-thinking .ball-shell {
  animation:
    sphere-shift 2.6s cubic-bezier(0.42, 0, 0.2, 1) infinite,
    sphere-shimmer 2.6s cubic-bezier(0.42, 0, 0.2, 1) infinite;
}

.oracle-text {
  margin: 0;
  max-width: 100%;
  line-height: 1.42;
  color: rgba(214, 216, 234, 0.56);
  font-size: clamp(0.74rem, 1.15vw, 0.92rem);
  letter-spacing: 0.01em;
  text-wrap: balance;
}

.hidden {
  display: none !important;
}

@keyframes smoke-flow {
  from {
    transform:
      translate(-50%, -50%)
      rotate(0deg)
      translateX(var(--orbit))
      translateY(var(--drift))
      translate(var(--flow-x, 0px), var(--flow-y, 0px))
      scale(var(--shape-x, 1), var(--shape-y, 1));
  }
  to {
    transform:
      translate(-50%, -50%)
      rotate(360deg)
      translateX(var(--orbit))
      translateY(var(--drift))
      translate(var(--flow-x, 0px), var(--flow-y, 0px))
      scale(var(--shape-x, 1), var(--shape-y, 1));
  }
}

@keyframes smoke-breath {
  0%,
  100% {
    opacity: 0.24;
    filter: blur(12px);
  }
  50% {
    opacity: 0.74;
    filter: blur(7px);
  }
}

@keyframes sparkle-drift {
  from {
    transform:
      translate(-50%, -50%)
      rotate(0deg)
      translateX(var(--orbit))
      translate(var(--flow-x, 0px), var(--flow-y, 0px));
  }
  to {
    transform:
      translate(-50%, -50%)
      rotate(360deg)
      translateX(var(--orbit))
      translate(var(--flow-x, 0px), var(--flow-y, 0px));
  }
}

@keyframes sparkle-pulse {
  0%,
  100% {
    opacity: 0.25;
    filter: blur(0.5px);
  }
  50% {
    opacity: 0.92;
    filter: blur(0px);
  }
}

@keyframes pulse-counter {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

@keyframes sphere-shift {
  0%,
  100% {
    opacity: 0.95;
    transform: none;
  }
  50% {
    opacity: 0.985;
    transform: none;
  }
}

@keyframes sphere-shimmer {
  0%,
  100% {
    filter:
      drop-shadow(0 30px 52px rgba(7, 5, 18, 0.52))
      drop-shadow(0 0 46px rgba(178, 118, 255, 0.46))
      hue-rotate(0deg)
      saturate(1.2)
      brightness(1.06);
  }
  50% {
    filter:
      drop-shadow(0 30px 52px rgba(7, 5, 18, 0.52))
      drop-shadow(0 0 64px rgba(230, 162, 255, 0.62))
      hue-rotate(14deg)
      saturate(1.34)
      brightness(1.14);
  }
}

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

@keyframes form-fade {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

@media (max-width: 860px) {
  .main-stage {
    min-height: calc(100svh - 18px);
    align-items: start;
    padding: 6px 14px 20px;
  }

  .oracle-zone {
    gap: 14px;
  }

  .site-header {
    position: static;
    top: auto;
    left: auto;
    width: 100%;
    max-width: 420px;
    margin: 10px auto 0;
    gap: 10px;
    padding: 0 4px;
  }

  .logo {
    gap: 7px;
    padding: 7px 10px;
  }

  .logo-text {
    font-size: 0.82rem;
    letter-spacing: 0.06em;
  }

  .oracle-text {
    color: rgba(214, 216, 234, 0.48);
    font-size: 0.72rem;
    line-height: 1.36;
  }

  .control-panel {
    min-height: 104px;
    width: 100%;
  }

  .btn-primary {
    padding: 13px 24px;
    font-size: 0.85rem;
  }

  .countdown {
    font-size: clamp(1.9rem, 11vw, 3rem);
  }

  .countdown.is-waiting {
    font-size: clamp(0.95rem, 4.2vw, 1.25rem);
  }

  .question-form {
    width: min(100%, 520px);
    border-radius: 16px;
    padding: 14px;
    gap: 6px;
  }

  .question-form label {
    font-size: 0.84rem;
  }

  .field-note {
    font-size: 0.72rem;
  }

  .crystal-ball {
    width: min(100vw, calc(84vw * var(--ball-size-scale)), calc(360px * var(--ball-size-scale)));
  }

  .ball-result p {
    font-size: clamp(0.96rem, 2.7vw, 1.3rem);
  }
}

@media (max-width: 560px) {
  .main-stage {
    padding-top: 4px;
  }

  .site-header {
    margin-top: 6px;
  }

  .oracle-text {
    font-size: 0.68rem;
  }

  .crystal-ball {
    width: min(100vw, calc(90vw * var(--ball-size-scale)), calc(332px * var(--ball-size-scale)));
  }

  .btn-secondary {
    padding: 12px 18px;
    font-size: 0.79rem;
  }

  .ball-result p {
    font-size: clamp(0.86rem, 3.7vw, 1.08rem);
  }
}

@media (max-height: 760px) and (max-width: 860px) {
  .site-header {
    gap: 8px;
  }

  .oracle-zone {
    gap: 10px;
  }

  .control-panel {
    min-height: 104px;
  }

  .crystal-ball {
    width: min(100vw, calc(74vw * var(--ball-size-scale)), calc(300px * var(--ball-size-scale)));
  }
}
