@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --bg-0: #060915;
  --bg-1: #0b1230;
  --bg-2: #172a5b;
  --bgNebula1: rgba(124, 153, 255, 0.14);
  --bgNebula2: rgba(164, 111, 255, 0.16);
  --accentA: #7be2ff;
  --accentB: #f6a7ff;
  --accentC: #8effd0;
  --cardBg: linear-gradient(166deg, rgba(15, 34, 72, 0.8), rgba(8, 16, 35, 0.82));
  --cardBorder: rgba(255, 255, 255, 0.22);
  --textPrimary: #e8eeff;
  --textSecondary: #afbee8;
  --line: rgba(255, 255, 255, 0.16);
  --orbGlow: 0 0 36px rgba(124, 223, 255, 0.52), 0 0 92px rgba(196, 127, 255, 0.28);
  --good: #8effd0;
  --bad: #ffc0d0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: calc(var(--vh, 1vh) * 100);
  display: block;
  padding:
    max(10px, env(safe-area-inset-top, 0px))
    max(10px, env(safe-area-inset-right, 0px))
    max(10px, env(safe-area-inset-bottom, 0px))
    max(10px, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(1000px 760px at 12% 10%, var(--bgNebula1), transparent 60%),
    radial-gradient(920px 680px at 88% 12%, rgba(120, 208, 255, 0.12), transparent 62%),
    radial-gradient(720px 520px at 56% 96%, var(--bgNebula2), transparent 65%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  color: var(--textPrimary);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
  position: relative;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
}

html,
body {
  width: 100%;
  height: 100%;
  background: #060915;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body::before {
  content: "";
  position: fixed;
  inset: -2px;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 760px at 12% 10%, var(--bgNebula1), transparent 60%),
    radial-gradient(920px 680px at 88% 12%, rgba(120, 208, 255, 0.12), transparent 62%),
    radial-gradient(720px 520px at 56% 96%, var(--bgNebula2), transparent 65%),
    linear-gradient(160deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
}

#galaxyCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.bg-video {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  filter: saturate(1.08) contrast(1.02) brightness(0.66);
  transform: translateZ(0);
  backface-visibility: hidden;
  opacity: var(--video-visible-opacity, 0.45);
  transition: opacity 260ms ease;
}

.oracle-bg-video {
  z-index: 2;
  --video-visible-opacity: 0.1;
}

.stage {
  width: 92vw;
  max-width: min(92vw, 520px);
  margin: 0 auto;
  padding: 26px;
  border-radius: 30px;
  background: transparent;
  border: none;
  box-shadow: none;
  position: relative;
  overflow: hidden;
  z-index: 3;
  isolation: isolate;
}

/* v1.4.3 GLASS CLAMP PATCH */
.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  background: rgba(10, 14, 24, 0.6);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.stage > * {
  position: relative;
  z-index: 1;
}

.reveal-fx-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  mix-blend-mode: screen;
  filter: saturate(1.25) brightness(1.05);
  transition: opacity 180ms ease;
}

.reveal-fx-video.active {
  opacity: 0.88;
}

#flash,
#mist,
#sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#flash {
  opacity: 0;
  background: radial-gradient(circle at 50% 38%, rgba(255, 255, 255, 0.92), transparent 60%);
}

#mist {
  opacity: 0;
  background: radial-gradient(circle at 50% 66%, rgba(160, 211, 255, 0.3), transparent 74%);
}

#flash.active {
  animation: flashPop 0.46s ease-out;
}

#flash.answer-hit {
  opacity: 0;
  background: radial-gradient(circle at 50% 52%, rgba(205, 126, 255, 0.95), rgba(145, 88, 255, 0.65) 32%, transparent 68%);
  animation: answerHitFlash 0.3s ease-out;
}

#mist.active {
  animation: mistRise 1.05s ease-out;
}

body.is-revealing #flash {
  opacity: 0.25;
}

body.is-revealing .orb {
  animation: ritualPulse 0.9s ease-in-out infinite;
}

body.is-revealing .primary {
  opacity: 0.8;
}

.stage.pre-reveal-shake {
  animation: preRevealShake 0.22s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.title-wrap {
  position: relative;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 3.8vw, 2.75rem);
  font-family: ui-sans-serif, system-ui, -apple-system, "SF Pro Display", "SF Pro Text", "Segoe UI", Inter, Roboto, Arial, sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  position: relative;
  z-index: 1;
}

.tagline {
  margin: 4px 0 0;
  color: rgba(214, 227, 255, 0.9);
  font-weight: 500;
}

.title-sweep {
  position: absolute;
  top: 4px;
  left: -8px;
  right: -8px;
  height: 56px;
  border-radius: 999px;
  background: linear-gradient(115deg, transparent 10%, rgba(255, 255, 255, 0.34) 46%, transparent 78%);
  filter: blur(5px);
  mix-blend-mode: screen;
  opacity: 0.4;
  transform: translateX(-46%);
  animation: titleSweep 7.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}

.title-sparkles {
  position: absolute;
  inset: -8px -10px auto -10px;
  height: 66px;
  pointer-events: none;
  z-index: 2;
}

.title-sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.62) 0%, rgba(138, 227, 255, 0.42) 56%, rgba(255, 255, 255, 0) 82%);
  box-shadow: 0 0 8px rgba(164, 231, 255, 0.38);
  animation: titleSparklePop 1.25s ease-out forwards;
}

.gear-btn {
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  color: var(--textPrimary);
  cursor: pointer;
}

.gear-btn svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.hint {
  position: fixed;
  top: 78px;
  right: 24px;
  z-index: 4;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(14, 24, 48, 0.84);
  box-shadow: 0 10px 26px rgba(2, 8, 20, 0.45);
  font-size: 0.88rem;
  pointer-events: none;
}

.hint.show {
  animation: hintInOut 2.2s ease forwards;
}

.hint.hidden {
  display: none;
}

.orb-shell {
  margin-top: 16px;
  display: grid;
  justify-items: center;
}

.orb {
  width: clamp(180px, 52vw, 320px);
  aspect-ratio: 1;
  border-radius: 999px;
  clip-path: circle(50%);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  background:
    radial-gradient(circle at 30% 26%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 44%),
    radial-gradient(circle at 63% 66%, rgba(158, 231, 255, 0.9), rgba(194, 131, 255, 0.4) 58%, rgba(64, 40, 114, 0.9) 100%);
  box-shadow: var(--orbGlow), inset 0 0 30px rgba(255, 255, 255, 0.68);
  animation: orbFloat 6.3s ease-in-out infinite;
}

.orb::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.35) 38%, transparent 72%);
  filter: blur(2px);
  opacity: 0.7;
  transform: translateX(-120%) rotate(14deg);
  animation: orbSpecSweep 8.8s ease-in-out infinite;
  -webkit-mask-image: radial-gradient(circle at center, #000 66%, transparent 76%);
  mask-image: radial-gradient(circle at center, #000 66%, transparent 76%);
}

.orb::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 0 32px rgba(255, 255, 255, 0.11);
}

.stage.intent .orb {
  transform: scale(1.03);
}

.orb.reveal {
  animation: orbReveal 0.88s cubic-bezier(0.2, 0.95, 0.35, 1.02);
}

.controls {
  margin-top: 14px;
}

.prompt {
  display: block;
  margin: 10px 0 8px;
  font-size: 0.92rem;
  color: var(--textSecondary);
}

input,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(8, 16, 38, 0.72);
  color: var(--textPrimary);
  padding: 12px;
  font-size: 1rem;
}

#question {
  box-shadow: inset 0 0 18px rgba(117, 167, 255, 0.14);
}

#question.shake {
  animation: inputShake 0.28s ease;
}

.actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 16px;
  color: var(--textPrimary);
  background: rgba(255, 255, 255, 0.07);
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary {
  background: linear-gradient(125deg, var(--accentA), var(--accentB));
  color: #10162f;
  min-width: 130px;
}

.primary.loading::after {
  content: "...";
  margin-left: 4px;
}

.ghost {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
}

.danger {
  border-color: rgba(255, 138, 172, 0.5);
}

.small {
  padding: 8px 12px;
  font-size: 0.84rem;
}

.answer {
  margin-top: 16px;
}

.answer-card {
  border: 1px solid var(--cardBorder);
  background: var(--cardBg);
  border-radius: 22px;
  padding: 16px;
  box-shadow: 0 16px 38px rgba(3, 8, 20, 0.56);
  transform: translateY(12px);
  opacity: 0;
}

.answer-card.reveal {
  animation: cardPull 0.82s cubic-bezier(0.22, 0.85, 0.25, 1) forwards;
}

.answer-simple {
  font-size: clamp(1.04rem, 1.6vw + 0.8rem, 1.35rem);
  font-weight: 600;
  line-height: 1.3;
  color: var(--textPrimary);
}

.answer-verbose {
  display: none;
}

body.verbose-details .answer-simple {
  display: none;
}

body.verbose-details .answer-verbose {
  display: block;
}

.answer-label {
  color: var(--textSecondary);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.answer-polarity {
  margin-top: 6px;
  font-size: 1.45rem;
  font-weight: 700;
}

.answer-polarity.yes {
  color: var(--good);
}

.answer-polarity.no {
  color: var(--bad);
}

.answer-text {
  margin-top: 6px;
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.25;
}

.answer-micro {
  margin-top: 8px;
  color: #d6e2ff;
  font-size: 0.95rem;
}

.answer-meta {
  margin-top: 8px;
  color: var(--textSecondary);
  font-size: 0.8rem;
}

.answer-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.64);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.panel-backdrop[hidden] {
  display: none !important;
}

.panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.settings-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: calc(var(--vh, 1vh) * 100);
  width: min(440px, 94vw);
  padding: 16px;
  border-left: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(8, 15, 33, 0.98), rgba(10, 20, 40, 0.97));
  z-index: 51;
  overflow: auto;
  transform: translateX(100%);
  transition: transform 0.28s ease;
  pointer-events: none;
}

.settings-panel.open {
  transform: translateX(0);
  pointer-events: auto;
}

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.settings-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.settings-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--textSecondary);
}

.advanced-settings,
.advanced-settings[hidden] {
  display: none !important;
}

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segment-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 10px;
  font-size: 0.82rem;
  text-align: center;
}

.segment-btn.active {
  color: #08142e;
  border-color: transparent;
  background: linear-gradient(125deg, var(--accentA), var(--accentB));
}

.toggle-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
  margin-top: 8px;
}

.toggle-row strong {
  display: block;
  font-size: 0.92rem;
}

.toggle-row small {
  color: var(--textSecondary);
}

.toggle-row input {
  width: 18px;
  height: 18px;
}

.voice-row {
  display: flex;
  gap: 8px;
}

.persona {
  margin-top: 7px;
  color: var(--textSecondary);
  font-size: 0.82rem;
}

.version {
  color: var(--textSecondary);
  font-size: 0.88rem;
}

.vault {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 18, 0.68);
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 7;
}

.vault[hidden] {
  display: none !important;
}

.vault-card {
  width: min(780px, 95vw);
  max-height: 86vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(11, 21, 43, 0.95), rgba(8, 16, 31, 0.94));
  padding: 16px;
}

.vault-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.vault-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.vault-filters {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.vault-filters input {
  flex: 1 1 220px;
}

.vault-stats {
  margin-top: 8px;
  color: var(--textSecondary);
  font-size: 0.86rem;
}

.vault-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.vault-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
}

.vault-q {
  font-weight: 600;
}

.vault-a {
  margin-top: 4px;
  color: #d8e7ff;
}

.vault-meta {
  margin-top: 6px;
  color: var(--textSecondary);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.vault-details {
  margin-top: 7px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 10px;
  padding: 7px 9px;
  color: var(--textSecondary);
  font-size: 0.8rem;
}

.vault-details[hidden] {
  display: none;
}

.vault-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chaos-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(14, 24, 48, 0.9);
  box-shadow: 0 10px 26px rgba(2, 8, 20, 0.45);
  font-size: 0.88rem;
}

.chaos-toast.show {
  animation: toastFade 1.9s ease forwards;
}

.chaos-toast[hidden] {
  display: none;
}

.sparkle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(133, 222, 255, 0.95) 52%, rgba(255, 255, 255, 0) 76%);
  box-shadow: 0 0 14px rgba(180, 231, 255, 0.9);
  animation: sparklePop 0.8s ease-out forwards;
}

.sparkle.answer-sparkle {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0%, rgba(232, 156, 255, 0.86) 45%, rgba(255, 255, 255, 0) 78%);
  box-shadow: 0 0 14px rgba(214, 132, 255, 0.85);
}

body.whisper .stage {
  box-shadow: 0 16px 42px rgba(2, 5, 15, 0.56), inset 0 0 26px rgba(173, 202, 255, 0.06);
}

body.minimal {
  --line: rgba(255, 255, 255, 0.11);
  --bgNebula1: rgba(124, 153, 255, 0.08);
  --bgNebula2: rgba(164, 111, 255, 0.08);
}

body.minimal .stage {
  padding: 22px;
  box-shadow: 0 18px 46px rgba(2, 5, 15, 0.46), inset 0 0 34px rgba(173, 202, 255, 0.04);
}

body.minimal .orb {
  box-shadow: 0 0 22px rgba(124, 223, 255, 0.24), 0 0 54px rgba(196, 127, 255, 0.17), inset 0 0 24px rgba(255, 255, 255, 0.55);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid rgba(123, 226, 255, 0.85);
  outline-offset: 2px;
}

@keyframes orbFloat {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-7px) scale(1.02);
  }
}

@keyframes titleSweep {
  0% {
    transform: translateX(-48%);
    opacity: 0.08;
  }
  40% {
    opacity: 0.46;
  }
  100% {
    transform: translateX(48%);
    opacity: 0.08;
  }
}

@keyframes titleSparklePop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  26% {
    opacity: 1;
    transform: scale(1.12);
  }
  100% {
    opacity: 0;
    transform: scale(0.2);
  }
}

@keyframes orbSpecSweep {
  0% {
    transform: translateX(-120%) rotate(14deg);
    opacity: 0.35;
  }
  50% {
    transform: translateX(-12%) rotate(14deg);
    opacity: 0.76;
  }
  100% {
    transform: translateX(120%) rotate(14deg);
    opacity: 0.25;
  }
}

@keyframes orbReveal {
  0% {
    transform: scale(1);
    filter: brightness(1);
  }
  48% {
    transform: scale(1.13);
    filter: brightness(1.28);
  }
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
}

@keyframes ritualPulse {
  0%,
  100% {
    transform: scale(1);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.06);
    filter: brightness(1.18);
  }
}

@keyframes flashPop {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes answerHitFlash {
  0% {
    opacity: 0;
  }
  34% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}

@keyframes mistRise {
  0% {
    opacity: 0;
    transform: translateY(16px);
  }
  40% {
    opacity: 0.58;
  }
  100% {
    opacity: 0;
    transform: translateY(-8px);
  }
}

@keyframes cardPull {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes sparklePop {
  0% {
    opacity: 0;
    transform: scale(0.5);
  }
  30% {
    opacity: 1;
    transform: scale(1.15);
  }
  100% {
    opacity: 0;
    transform: scale(0.3);
  }
}

@keyframes hintInOut {
  0% {
    opacity: 0;
    transform: translateY(-6px);
  }
  14% {
    opacity: 1;
    transform: translateY(0);
  }
  86% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@keyframes toastFade {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
  20% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  80% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
}

@keyframes inputShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-3px);
  }
}

@keyframes preRevealShake {
  0% {
    transform: translate3d(0, 0, 0);
  }
  20% {
    transform: translate3d(-3px, 0, 0);
  }
  40% {
    transform: translate3d(3px, 0, 0);
  }
  60% {
    transform: translate3d(-2px, 0, 0);
  }
  80% {
    transform: translate3d(2px, 0, 0);
  }
  100% {
    transform: translate3d(0, 0, 0);
  }
}

@media (max-width: 780px) {
  .settings-panel {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: min(84vh, 640px);
    border-left: none;
    border-top: 1px solid var(--line);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    transform: translateY(102%);
  }

  .settings-panel.open {
    transform: translateY(0);
  }

  .segment {
    grid-template-columns: 1fr;
  }

  .hint {
    right: 14px;
    top: 68px;
  }
}

@media (max-width: 560px) {
  .stage {
    padding: 20px;
    border-radius: 24px;
  }
}

/* v1.2.4 iOS mobile patch */
@media (max-width: 480px) {
  body {
    background:
      radial-gradient(760px 520px at 18% 10%, rgba(88, 112, 210, 0.16), transparent 62%),
      radial-gradient(680px 540px at 84% 12%, rgba(82, 156, 214, 0.12), transparent 66%),
      linear-gradient(165deg, #070c1d, #0d1838 52%, #132654);
  }

  .stage {
    width: 92vw;
    max-width: min(92vw, 520px);
    padding: 18px;
    border-radius: 28px;
    background: rgba(16, 22, 36, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }

  .hero {
    gap: 8px;
  }

  h1 {
    font-size: clamp(1.8rem, 8.3vw, 2.2rem);
  }

  .tagline {
    margin-top: 2px;
    font-size: 0.95rem;
  }

  .orb-shell {
    margin-top: 10px;
  }

  .controls {
    margin-top: 8px;
  }

  .actions {
    margin-top: 10px;
  }

  input,
  textarea,
  select {
    font-size: 16px;
  }

  .oracle-bg-video {
    opacity: 0.62;
    filter: saturate(1.14) contrast(1.12) brightness(0.54);
  }
}

@supports (-webkit-touch-callout: none) {
  .stage::before {
    /* iOS fog clamp: no backdrop blur, darker glass tint */
    background: rgba(7, 11, 20, 0.78);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-color: rgba(255, 255, 255, 0.07);
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  .oracle-bg-video {
    opacity: 0.74;
    filter: saturate(1.06) contrast(1.2) brightness(0.42);
  }

  /* iOS fog clamp: disable milky reveal overlays on main screen */
  #flash,
  #mist {
    display: none !important;
  }
}

@supports (-webkit-touch-callout: none) and (max-width: 600px) {
  /* v1.2.6 mobile Safari anti-fog pass */
  .stage::before {
    background: rgba(7, 11, 20, 0.82);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    box-shadow: 0 18px 56px rgba(0, 0, 0, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }

  .oracle-bg-video {
    opacity: 0.76;
    filter: saturate(1.04) contrast(1.22) brightness(0.38);
  }

  .stage input,
  .stage select,
  .stage textarea,
  .stage .ghost,
  .stage .primary {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .orb::before,
  .title-sweep,
  .answer-card.reveal,
  #flash.active,
  #flash.answer-hit,
  #mist.active,
  .sparkle,
  .title-sparkle,
  .hint.show,
  .chaos-toast.show,
  body.is-revealing .orb,
  .stage.pre-reveal-shake {
    animation: none !important;
  }

  .settings-panel {
    transition: none;
  }
}

/* Galaxy Canvas v1 */
.view[hidden] {
  display: none !important;
}

#oracleView {
  min-height: calc(var(--vh, 1vh) * 100 - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  display: grid;
  align-items: center;
  justify-items: center;
}

.header-icons {
  display: flex;
  gap: 10px;
  align-items: center;
}

.galaxy-view {
  position: fixed;
  inset: 0;
  z-index: 20;
  background:
    radial-gradient(900px 580px at 12% 8%, rgba(100, 134, 255, 0.2), transparent 62%),
    radial-gradient(700px 560px at 86% 16%, rgba(121, 211, 255, 0.15), transparent 65%),
    linear-gradient(160deg, #050814, #09132f 44%, #11224d);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.galaxy-bg-video {
  position: absolute;
  inset: 0;
  z-index: 0;
  --video-visible-opacity: 0.45;
}

.galaxyBgVideo {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  pointer-events: none;
  filter: saturate(110%) contrast(105%);
  --video-visible-opacity: 0.45;
}

.galaxyModeSelect {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(4, 8, 20, 0.58);
}

.galaxy-view.mode-menu .galaxyModeSelect {
  display: flex;
}

.galaxyModeCard {
  width: min(420px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  background: linear-gradient(170deg, rgba(12, 22, 46, 0.92), rgba(10, 17, 34, 0.9));
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.38);
  padding: 20px;
  display: grid;
  gap: 12px;
}

.galaxyModeTitle {
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d7e5ff;
  user-select: none;
}

.debugLevelPanel {
  display: none;
  border: 1px solid rgba(148, 221, 255, 0.28);
  border-radius: 14px;
  background: rgba(10, 20, 42, 0.7);
  padding: 10px;
  gap: 8px;
}

.debugLevelPanel.unlocked {
  display: grid;
}

.debugLevelLabel {
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #b9cdf5;
}

.debugLevelRow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.debugLevelSelect,
.debugLevelBtn {
  min-height: 40px;
  border-radius: 10px;
}

.debugLevelSelect {
  border: 1px solid rgba(183, 212, 255, 0.26);
  background: rgba(255, 255, 255, 0.1);
  color: #edf4ff;
  padding: 0 10px;
}

.debugLevelBtn {
  border: 1px solid rgba(145, 244, 181, 0.4);
  background: rgba(120, 255, 170, 0.16);
  color: #d9ffe8;
  font-weight: 700;
  padding: 0 12px;
}

.modeBtn,
.modeBackBtn {
  min-height: 44px;
  border-radius: 999px;
}

.modeBtn {
  border: 1px solid rgba(168, 236, 255, 0.38);
  background: linear-gradient(125deg, rgba(123, 226, 255, 0.9), rgba(246, 167, 255, 0.88));
  color: #0a1734;
  font-weight: 700;
}

.modeBackBtn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--textPrimary);
}

.galaxy-topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding:
    calc(10px + env(safe-area-inset-top, 0px))
    max(14px, env(safe-area-inset-right, 0px))
    10px
    max(14px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 16, 35, 0.68);
  backdrop-filter: blur(10px);
}

.galaxy-view.mode-menu .galaxy-topbar,
.galaxy-view.mode-menu .galaxy-hint {
  visibility: hidden;
}

.galaxy-view.mode-arcade .galaxy-topbar {
  display: none;
}

.galaxy-title {
  font-size: 0.92rem;
  letter-spacing: 0.04em;
  color: var(--textSecondary);
}

.galaxy-tools {
  display: flex;
  gap: 8px;
}

.galaxy-tools .ghost {
  border-color: rgba(230, 240, 255, 0.26);
  background: rgba(255, 255, 255, 0.08);
  color: #eef6ff;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.08);
}

.galaxy-tools .active {
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0) 42%),
    radial-gradient(circle at 64% 66%, rgba(166, 238, 255, 0.96), rgba(211, 151, 255, 0.58) 58%, rgba(66, 42, 116, 0.94) 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow:
    0 0 24px rgba(124, 223, 255, 0.46),
    0 0 42px rgba(196, 127, 255, 0.24),
    inset 0 0 18px rgba(255, 255, 255, 0.3);
}

.galaxy-tools .active svg {
  fill: #ffffff;
}

#galaxyPlayCanvas {
  position: fixed;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  pointer-events: auto;
}

.debug * {
  outline: 1px solid rgba(255, 0, 0, 0.08);
}

.galaxy-hint {
  position: relative;
  z-index: 2;
  padding:
    10px
    max(14px, env(safe-area-inset-right, 0px))
    calc(10px + env(safe-area-inset-bottom, 0px))
    max(14px, env(safe-area-inset-left, 0px));
  font-size: 0.82rem;
  color: var(--textSecondary);
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 16, 35, 0.56);
}

.galaxy-view.mode-arcade .galaxy-hint {
  display: none;
}

.arcadeHud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: none;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding:
    calc(8px + env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    8px
    max(12px, env(safe-area-inset-left, 0px));
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 14, 30, 0.74);
}

.galaxy-view.mode-arcade .arcadeHud {
  display: flex;
}

.hudBtn,
.arcadeOverlayBtn {
  min-height: 44px;
  border-radius: 999px;
  padding: 10px 14px;
}

.hudBtn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
}

.hudCenter {
  display: grid;
  justify-items: center;
  gap: 2px;
  min-width: 120px;
}

.hudLevel {
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: #b7c9ff;
}

.hudTimer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1rem;
  font-weight: 700;
  color: #dff8ff;
}

.hudTimer.danger {
  color: rgba(255, 103, 103, 0.96);
  text-shadow: 0 0 8px rgba(255, 57, 57, 0.7), 0 0 18px rgba(255, 34, 34, 0.5);
}

.arcadeTimerBackdrop {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 180ms linear;
}

.galaxy-view.mode-arcade .arcadeTimerBackdrop {
  display: flex;
}

.arcadeTimerGhost {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: clamp(3rem, 19vw, 9rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(193, 228, 255, 0.58);
  text-shadow: 0 0 14px rgba(118, 206, 255, 0.2);
  transition: color 160ms linear, text-shadow 160ms linear;
}

.arcadeTimerBackdrop.danger .arcadeTimerGhost {
  color: rgba(255, 88, 88, 0.78);
  text-shadow: 0 0 10px rgba(255, 66, 66, 0.62), 0 0 24px rgba(255, 34, 34, 0.52);
}

.arcadeOverlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  place-items: center;
  text-align: center;
  background: rgba(6, 10, 24, 0.52);
  padding: 22px;
}

.arcadeOverlay.show {
  display: grid;
}

.arcadeOverlayText {
  font-size: clamp(1.6rem, 5.8vw, 2.4rem);
  letter-spacing: 0.1em;
  font-weight: 700;
  color: #9af8c4;
  text-shadow: 0 0 14px rgba(100, 255, 171, 0.45);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 1000ms ease, transform 1000ms ease;
}

.arcadeOverlayText.show {
  opacity: 1;
  transform: translateY(0);
}

.arcadeOverlayText.fadeOut {
  opacity: 0;
  transform: translateY(-4px);
}

.arcadeOverlaySub {
  margin-top: 8px;
  color: #d4e2ff;
}

.arcadeOverlayBtn {
  margin-top: 16px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(165, 238, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .galaxy-topbar {
    backdrop-filter: none;
  }

  .bg-video {
    opacity: 0.28;
  }

  .arcadeOverlayText {
    text-shadow: none;
  }

  .arcadeTimerBackdrop {
    transition: none;
  }

  .arcadeTimerGhost {
    text-shadow: none;
  }
}
