:root {
  --calc-neon: #78d6df;
  --calc-gold: #f3c653;
  --calc-ember: #bb8cff;
}

body {
  background:
    radial-gradient(circle at 12% 16%, rgba(85, 33, 152, 0.3), transparent 32rem),
    radial-gradient(circle at 92% 4%, rgba(243, 198, 83, 0.1), transparent 25rem),
    linear-gradient(145deg, #0b071c, #080616 62%, #0b0a1b) !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.024) 0 1px, transparent 1px 7rem),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 6rem),
    radial-gradient(circle at 18% 22%, rgba(187, 140, 255, 0.2), transparent 28%),
    radial-gradient(circle at 76% 18%, rgba(245, 217, 145, 0.16), transparent 25%),
    radial-gradient(circle at 56% 88%, rgba(120, 214, 223, 0.12), transparent 30%),
    conic-gradient(from 215deg at 50% 48%, rgba(187, 140, 255, 0.08), rgba(245, 217, 145, 0.12), rgba(120, 214, 223, 0.08), rgba(187, 140, 255, 0.08)),
    linear-gradient(110deg, rgba(187, 140, 255, 0.04), transparent 40%, rgba(245, 217, 145, 0.04));
  mix-blend-mode: screen;
}

.app-shell {
  position: relative;
  isolation: isolate;
}

.stage-area {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 42% 42%, rgba(187, 140, 255, 0.13), transparent 33%),
    rgba(8, 6, 22, 0.68) !important;
}

.stage-area::before,
.stage-area::after {
  content: "";
  position: absolute;
  inset: 4%;
  z-index: 0;
  border: 1px solid rgba(245, 217, 145, 0.14);
  border-radius: 50%;
  pointer-events: none;
  transform: rotate(-8deg);
  filter: drop-shadow(0 0 28px rgba(245, 217, 145, 0.16));
}

.stage-area::after {
  inset: 14% 10%;
  border-color: rgba(24, 247, 210, 0.18);
  transform: rotate(8deg);
}

.stage-toolbar,
.scene-frame,
.control-shell {
  position: relative;
  z-index: 1;
}

.brand {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stage-toolbar {
  min-height: 76px;
  padding-left: 8.5rem !important;
  background: rgba(10, 7, 27, 0.72);
  backdrop-filter: blur(18px);
}

.calc-mystic-back {
  position: absolute;
  left: 1.4rem;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: rgba(255, 247, 221, 0.78);
  font-size: 0.78rem;
  text-decoration: none;
}

.calc-mystic-back::before {
  content: "←";
  margin-right: 0.45rem;
  color: var(--calc-gold);
}

.calc-ritual-intro {
  position: absolute;
  top: 7.5rem;
  left: clamp(1.4rem, 4vw, 4rem);
  z-index: 3;
  display: grid;
  gap: 0.75rem;
  width: min(25rem, calc(100% - 3rem));
  padding: 1.45rem;
  border: 1px solid rgba(243, 198, 83, 0.25);
  border-radius: 24px;
  background:
    radial-gradient(circle at 90% 8%, rgba(187, 140, 255, 0.2), transparent 30%),
    rgba(14, 9, 34, 0.82);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(18px);
  pointer-events: none;
}

.calc-ritual-intro p {
  margin: 0;
  color: var(--calc-gold);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.calc-ritual-intro h1 {
  max-width: 9ch;
  margin: 0;
  color: #fff7dd;
  font: 500 clamp(2.1rem, 3.6vw, 4.4rem)/0.98 "Noto Serif SC", "Songti SC", Georgia, serif;
  letter-spacing: -0.07em;
}

.calc-ritual-intro > span {
  max-width: 22rem;
  color: #c8bdd2;
  font-size: 0.88rem;
  line-height: 1.7;
}

.calc-ritual-intro ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
}

.calc-ritual-intro li {
  display: grid;
  gap: 0.2rem;
  padding-top: 0.55rem;
  border-top: 1px solid rgba(255, 247, 221, 0.15);
  color: #8f849c;
  font-size: 0.72rem;
}

.calc-ritual-intro li b {
  color: inherit;
  font-size: 0.62rem;
}

body[data-calc-phase="start"] [data-calc-step="start"],
body[data-calc-phase="cast"] [data-calc-step="cast"],
body[data-calc-phase="result"] [data-calc-step="result"] {
  border-color: var(--calc-gold);
  color: #fff7dd;
}

.mode-switch,
.primary-action {
  position: relative;
}

.mode-switch button,
.primary-action,
.panel,
input,
select,
textarea {
  border-radius: 16px;
}

.mode-switch button,
.primary-action {
  overflow: hidden;
}

.mode-switch button::before,
.primary-action::before {
  content: "";
  position: absolute;
  inset: -80% -30%;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.46) 50%, transparent 58%);
  transform: translateX(-70%);
  transition: transform 520ms ease;
}

.mode-switch button:hover::before,
.mode-switch button:focus-visible::before,
.primary-action:hover::before,
.primary-action:focus-visible::before {
  transform: translateX(72%);
}

.panel {
  position: relative;
  border-color: rgba(245, 217, 145, 0.18);
  background:
    linear-gradient(180deg, rgba(20, 12, 42, 0.92), rgba(8, 7, 24, 0.92)),
    radial-gradient(circle at 82% 12%, rgba(187, 140, 255, 0.1), transparent 28%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 18px 56px rgba(0, 0, 0, 0.24),
    0 0 52px rgba(24, 247, 210, 0.05);
}

.panel::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background:
    linear-gradient(120deg, rgba(24, 247, 210, 0.32), transparent 30%, transparent 68%, rgba(245, 217, 145, 0.28)),
    radial-gradient(circle at 82% 12%, rgba(255, 94, 47, 0.16), transparent 28%);
  mask: linear-gradient(#000, #000) content-box, linear-gradient(#000, #000);
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.5;
}

.scene-frame canvas {
  filter: saturate(1.18) contrast(1.06);
}

.control-shell,
.control-area {
  background: rgba(8, 6, 22, 0.66) !important;
}

.calc-anime-shards {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  mix-blend-mode: screen;
}

.calc-anime-shard {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: clamp(6px, 0.74vw, 12px);
  aspect-ratio: 1;
  border-radius: 30% 70% 28% 72%;
  background:
    radial-gradient(circle at 28% 24%, rgba(255, 255, 255, 0.9), transparent 24%),
    hsl(var(--hue) 95% 58% / 0.7);
  box-shadow:
    0 0 24px hsl(var(--hue) 95% 58% / 0.4),
    0 0 72px hsl(var(--hue) 95% 58% / 0.16);
  opacity: 0;
}

.calc-anime-scanner,
.calc-anime-paths {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
  mix-blend-mode: screen;
}

.calc-anime-scan {
  position: absolute;
  top: -16%;
  bottom: -16%;
  width: min(12rem, 12vw);
  rotate: 14deg;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent);
  filter: blur(20px);
  opacity: 0;
}

.calc-anime-scan-b {
  width: min(25rem, 25vw);
  background: linear-gradient(90deg, transparent, rgba(24, 247, 210, 0.16), rgba(245, 217, 145, 0.12), transparent);
  filter: blur(38px);
}

.calc-anime-paths {
  width: 100%;
  height: 100%;
  opacity: 0.66;
}

.calc-anime-arc {
  fill: none;
  stroke: rgba(245, 217, 145, 0.58);
  stroke-width: 1.5;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 16px rgba(245, 217, 145, 0.32));
}

.calc-anime-orb {
  position: fixed;
  z-index: 2;
  width: clamp(7px, 0.8vw, 13px);
  aspect-ratio: 1;
  border-radius: 999px;
  pointer-events: none;
  background:
    radial-gradient(circle at 34% 32%, #ffffff 0 18%, rgba(255, 255, 255, 0.1) 28%, transparent 58%),
    var(--calc-neon);
  box-shadow:
    0 0 20px rgba(24, 247, 210, 0.8),
    0 0 70px rgba(245, 217, 145, 0.38),
    0 0 120px rgba(255, 94, 47, 0.24);
  mix-blend-mode: screen;
}

@media (max-width: 920px) {
  .stage-toolbar {
    padding-left: 1rem !important;
    padding-top: 4rem !important;
  }

  .calc-mystic-back {
    top: 0.75rem;
    left: 1rem;
  }

  .calc-ritual-intro {
    position: relative;
    top: auto;
    left: auto;
    width: auto;
    margin: 1rem;
    pointer-events: auto;
  }

  .scene-frame {
    min-height: 430px;
  }

  .stage-area::before,
  .stage-area::after,
  .calc-anime-shards,
  .calc-anime-scanner,
  .calc-anime-paths,
  .calc-anime-orb {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mode-switch button::before,
  .primary-action::before,
  .panel::before {
    display: none;
  }
}
