:root {
  --bg-1: #eaf2ff;
  --bg-2: #d8f6ee;
  --text: #0f172a;
  --muted: #36536b;
  --panel-bg: rgba(255, 255, 255, 0.76);
  --panel-border: rgba(148, 163, 184, 0.38);
  --window-ring: rgba(99, 102, 241, 0.9);
  --window-core: rgba(30, 41, 86, 0.92);
  --answer: #eff6ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0 3.5rem;
  background: radial-gradient(circle at 14% 12%, #dbeafe, transparent 36%),
    radial-gradient(circle at 82% 86%, #ccfbf1, transparent 40%),
    radial-gradient(circle at 78% 18%, #e9d5ff, transparent 34%),
    linear-gradient(145deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  font-family: "Jost", "Segoe UI", sans-serif;
}

.page-intro,
.seo-content {
  width: min(80vw, 1200px);
  max-width: 1200px;
  text-align: center;
  padding: 1.1rem 1.35rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.13);
}

.app {
  width: min(80vw, 1200px);
  height: min(80vh, 980px);
  max-width: 1200px;
  max-height: 980px;
  min-height: 0;
  text-align: center;
  padding: 1.25rem 1.35rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.13);
  display: grid;
  grid-template-rows: auto auto auto auto auto;
}

h1 {
  font-size: clamp(2rem, 3vw, 3rem);
  margin: 0;
  letter-spacing: 0.03em;
}

.instructions {
  margin: 0.55rem auto 0;
  color: var(--muted);
  font-size: 1.03rem;
}

.seo-content h2,
.seo-content h3 {
  margin: 0.35rem 0;
}

.seo-content p {
  margin: 0.2rem 0 0.85rem;
}

.faq-expand {
  text-align: left;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: rgba(248, 250, 252, 0.78);
  margin: 0.35rem 0;
  overflow: hidden;
}

.faq-expand summary {
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: #1e293b;
  padding: 0.8rem 0.9rem;
}

.faq-expand summary::-webkit-details-marker {
  display: none;
}

.faq-expand summary::after {
  content: "+";
  float: right;
  font-weight: 700;
  color: #6366f1;
}

.faq-expand[open] summary::after {
  content: "-";
}

.faq-content {
  padding: 0 0.9rem 0.8rem;
}

.faq-content p {
  margin: 0;
  padding: 0 0 0.8rem;
}

.question-panel {
  margin-top: 1rem;
  display: grid;
  gap: 0.45rem;
  text-align: left;
}

.question-panel label {
  font-size: 0.96rem;
  color: #334155;
}

.question-panel input {
  width: 100%;
  border-radius: 10px;
  border: 1px solid #a5b4fc;
  background: #f8fbff;
  color: #0f172a;
  padding: 0.72rem 0.8rem;
  font: inherit;
}

.question-panel input:focus {
  outline: 2px solid #6366f1;
  border-color: #6366f1;
}

.orb-wrap {
  margin-top: 1.3rem;
  display: grid;
  place-items: center;
}

.decision-orb {
  --jx1: -12px;
  --jy1: -8px;
  --jr1: 22deg;
  --jx2: 15px;
  --jy2: 4px;
  --jr2: -28deg;
  --jx3: -17px;
  --jy3: -6px;
  --jr3: 33deg;
  --jx4: 12px;
  --jy4: -10px;
  --jr4: -38deg;
  --jx5: -8px;
  --jy5: 6px;
  --jr5: 24deg;
  --jx6: 5px;
  --jy6: -4px;
  --jr6: -14deg;
  --jr7: 0deg;
  --shake-duration: 920ms;
  width: clamp(240px, 48vmin, 420px);
  aspect-ratio: 1 / 1;
  border: none;
  border-radius: 50%;
  position: relative;
  cursor: grab;
  background:
    radial-gradient(circle at 24% 17%, rgba(255, 255, 255, 0.66) 1%, rgba(255, 255, 255, 0) 31%),
    radial-gradient(circle at 73% 78%, rgba(20, 184, 166, 0.34) 3%, rgba(20, 184, 166, 0) 45%),
    linear-gradient(155deg, #1f2a62, #253684 44%, #16224f 100%);
  box-shadow:
    0 28px 48px rgba(6, 22, 20, 0.4),
    0 10px 18px rgba(17, 24, 39, 0.2),
    inset -20px -30px 38px rgba(0, 0, 0, 0.36),
    inset 15px 20px 28px rgba(165, 180, 252, 0.24);
  transition: transform 70ms linear, box-shadow 160ms ease;
  will-change: transform;
}

.decision-orb::before {
  content: "";
  position: absolute;
  left: 11%;
  top: 9%;
  width: 34%;
  height: 21%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
  filter: blur(0.3px);
  opacity: 0.88;
}

.decision-orb::after {
  content: "";
  position: absolute;
  inset: 6.5%;
  border-radius: 50%;
  border: 1px solid rgba(167, 139, 250, 0.3);
  pointer-events: none;
}

.decision-orb:hover {
  box-shadow:
    0 34px 56px rgba(6, 22, 20, 0.45),
    0 12px 16px rgba(15, 23, 42, 0.16),
    inset -20px -30px 38px rgba(0, 0, 0, 0.42),
    inset 15px 20px 28px rgba(165, 180, 252, 0.28);
}

.decision-orb:active,
.decision-orb.grabbed {
  cursor: grabbing;
}

.number {
  position: absolute;
  left: 50%;
  top: 11%;
  transform: translateX(-50%);
  min-width: 54px;
  border-radius: 999px;
  padding: 0.3rem 0.6rem;
  background: rgba(191, 219, 254, 0.18);
  border: 1px solid rgba(196, 181, 253, 0.7);
  color: #e9d5ff;
  font-weight: 700;
  font-size: clamp(1rem, 2.1vw, 1.3rem);
  line-height: 1;
  display: grid;
  place-items: center;
  text-shadow: 0 0 10px rgba(196, 181, 253, 0.8);
  box-shadow: inset 0 1px 6px rgba(219, 234, 254, 0.4), 0 3px 10px rgba(15, 23, 42, 0.25);
}

.number .sigil {
  width: 1.1em;
  height: 1.1em;
  display: block;
  filter: drop-shadow(0 0 7px rgba(196, 181, 253, 0.72));
  animation: sigil-pulse 3000ms ease-in-out infinite;
}

@keyframes sigil-pulse {
  0% {
    transform: scale(0.98) rotate(-5deg);
    opacity: 0.86;
  }
  50% {
    transform: scale(1.08) rotate(5deg);
    opacity: 1;
  }
  100% {
    transform: scale(0.98) rotate(-5deg);
    opacity: 0.86;
  }
}

.window {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  width: 58%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 36% 30%, rgba(196, 181, 253, 0.95) 2%, var(--window-ring) 42%, rgba(79, 70, 229, 0.92) 100%);
  display: grid;
  place-items: center;
  padding: 0.75rem;
  overflow: hidden;
  border: 1px solid rgba(224, 231, 255, 0.85);
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.58),
    inset 0 -7px 12px rgba(3, 7, 18, 0.24),
    0 8px 16px rgba(2, 6, 23, 0.34);
}

.window::before {
  content: "";
  position: absolute;
  top: 10%;
  left: 18%;
  width: 36%;
  height: 26%;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0));
  filter: blur(0.4px);
}

.window::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, rgba(99, 102, 241, 0.58) 2%, var(--window-core) 86%);
  opacity: 0.96;
}

.answer-text {
  position: relative;
  z-index: 1;
  max-width: 80%;
  color: var(--answer);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: clamp(0.66rem, 1.45vmin, 0.92rem);
  line-height: 1.2;
  opacity: 0;
  transform: translateY(45px);
  filter: blur(1.6px);
  text-shadow: 0 0 8px rgba(196, 181, 253, 0.52);
}

.answer-text.visible {
  animation: fluid-rise 1900ms cubic-bezier(0.2, 0.75, 0.2, 1) forwards;
}

@keyframes fluid-rise {
  0% {
    opacity: 0;
    transform: translateY(48px) scale(0.9);
    filter: blur(2px);
  }
  55% {
    opacity: 0.94;
    transform: translateY(-8px) scale(1.01);
    filter: blur(0.2px);
  }
  78% {
    transform: translateY(-2px) scale(1);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

.decision-orb.shaking {
  animation: realistic-shake var(--shake-duration) cubic-bezier(0.36, 0.03, 0.22, 0.99) infinite;
}

@keyframes realistic-shake {
  0% {
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  14% {
    transform: translate(var(--jx1), var(--jy1)) rotate(var(--jr1)) scale(1.01);
  }
  28% {
    transform: translate(var(--jx2), var(--jy2)) rotate(var(--jr2)) scale(1.015);
  }
  42% {
    transform: translate(var(--jx3), var(--jy3)) rotate(var(--jr3)) scale(1.02);
  }
  58% {
    transform: translate(var(--jx4), var(--jy4)) rotate(var(--jr4)) scale(1.015);
  }
  72% {
    transform: translate(var(--jx5), var(--jy5)) rotate(var(--jr5)) scale(1);
  }
  86% {
    transform: translate(var(--jx6), var(--jy6)) rotate(var(--jr6)) scale(1.01);
  }
  100% {
    transform: translate(0, 0) rotate(var(--jr7)) scale(1);
  }
}

.status {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 1rem;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.history-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.clear-btn {
  border: 1px solid #94a3b8;
  border-radius: 8px;
  background: #f8fafc;
  color: #334155;
  font: inherit;
  font-size: 0.9rem;
  padding: 0.3rem 0.55rem;
  cursor: pointer;
}

.clear-btn:hover {
  border-color: #6366f1;
}

.history-controls {
  display: flex;
  gap: 0.5rem;
}

.history-launcher {
  position: fixed;
  right: max(1.4rem, env(safe-area-inset-right));
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border: 1px solid #a5b4fc;
  border-radius: 50%;
  background: linear-gradient(160deg, #f8fbff, #e0e7ff);
  box-shadow: 0 14px 24px rgba(15, 23, 42, 0.2);
  cursor: pointer;
  font-size: 1.3rem;
  display: grid;
  place-items: center;
  z-index: 20;
}

.history-popup {
  position: fixed;
  right: max(1.4rem, env(safe-area-inset-right));
  bottom: calc(max(1.2rem, env(safe-area-inset-bottom)) + 66px);
  width: min(92vw, 340px);
  max-height: min(68vh, 520px);
  text-align: left;
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid rgba(148, 163, 184, 0.7);
  border-radius: 14px;
  padding: 0.85rem;
  overflow: hidden;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.24);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 21;
}

.history-popup.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.history-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  max-height: calc(min(68vh, 520px) - 84px);
  overflow: auto;
  display: grid;
  gap: 0.45rem;
}

.history-item {
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  background: rgba(248, 250, 252, 0.92);
}

.history-q {
  margin: 0;
  color: #0f172a;
  font-size: 0.94rem;
}

.history-a {
  margin: 0.15rem 0 0;
  color: #0369a1;
  font-size: 0.9rem;
}

.history-time {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.history-empty {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 900px) {
  .page-intro,
  .seo-content,
  .app {
    width: 92vw;
  }

  .app {
    height: min(92vh, 920px);
    min-height: 0;
    grid-template-rows: auto auto auto auto auto;
  }

  .decision-orb {
    width: clamp(220px, 58vw, 360px);
  }

  .history-list {
    max-height: 240px;
  }
}

@media (max-height: 700px) {
  .app {
    height: 94vh;
    padding-top: 0.9rem;
    padding-bottom: 0.9rem;
  }

  .decision-orb {
    width: clamp(200px, 42vmin, 320px);
  }
}

