:root {
  --bg: #05060a;
  --ink: #f4f5f7;
  --ink-dim: rgba(244, 245, 247, 0.55);
  --glass: rgba(16, 18, 26, 0.55);
  --stroke: rgba(255, 255, 255, 0.09);
  --accent1: #7c5cff;
  --accent2: #00e0ff;
  --radius: 18px;
  --font: "Sora", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  overscroll-behavior: none;
}

#bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.blob {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}
.b1 {
  background: radial-gradient(circle at 30% 30%, rgba(124, 92, 255, 0.55), transparent 65%);
  top: -18vmax; left: -14vmax;
  animation: drift1 26s ease-in-out infinite alternate;
}
.b2 {
  background: radial-gradient(circle at 70% 70%, rgba(0, 224, 255, 0.38), transparent 65%);
  bottom: -22vmax; right: -16vmax;
  animation: drift2 32s ease-in-out infinite alternate;
}
@keyframes drift1 { to { transform: translate(9vmax, 7vmax) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-8vmax, -6vmax) scale(1.08); } }
.grain {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

#scene {
  position: fixed; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  touch-action: none;
  cursor: grab;
}
#scene:active { cursor: grabbing; }
#confetti { position: fixed; inset: 0; z-index: 5; pointer-events: none; }

#brand {
  position: fixed; z-index: 10;
  top: max(18px, env(safe-area-inset-top)); left: 22px;
  pointer-events: none;
  animation: rise 0.9s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
#brand h1 {
  font-size: clamp(26px, 4.5vw, 38px);
  font-weight: 800;
  letter-spacing: 0.32em;
  background: linear-gradient(100deg, #fff 20%, var(--accent2) 60%, var(--accent1) 90%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
#brand p { margin-top: 6px; font-size: 12.5px; color: var(--ink-dim); letter-spacing: 0.04em; }

#stats {
  position: fixed; z-index: 10;
  top: max(18px, env(safe-area-inset-top)); right: 22px;
  display: flex; gap: 10px;
  animation: rise 0.9s 0.1s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
.chip {
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 9px 16px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  display: flex; align-items: baseline; gap: 8px;
  min-width: 96px; justify-content: center;
}
.chip .label { font-size: 10px; letter-spacing: 0.22em; color: var(--ink-dim); }
.chip .value { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

#dock {
  position: fixed; z-index: 10;
  left: 50%; transform: translateX(-50%);
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  animation: rise 0.9s 0.2s cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
.buttons {
  display: flex; gap: 10px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 8px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.btn {
  font-family: var(--font);
  font-size: 14px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform 0.16s cubic-bezier(0.3, 1.4, 0.5, 1), background 0.2s, box-shadow 0.2s, opacity 0.2s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: scale(0.93); }
.btn.primary {
  background: linear-gradient(120deg, var(--accent1), var(--accent2));
  box-shadow: 0 6px 24px rgba(124, 92, 255, 0.4);
}
.btn.primary:hover { box-shadow: 0 6px 30px rgba(0, 224, 255, 0.45); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.thinking { pointer-events: none; opacity: 0.7; }

#hint {
  font-size: 11.5px; color: var(--ink-dim); letter-spacing: 0.05em;
  text-align: center; padding: 0 16px;
  transition: opacity 0.8s;
}
#hint.faded { opacity: 0; }

#toast {
  position: fixed; z-index: 20;
  left: 50%; bottom: 118px;
  transform: translate(-50%, 16px);
  background: rgba(12, 14, 20, 0.82);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 13px 22px;
  font-size: 14px; font-weight: 600; letter-spacing: 0.03em;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  white-space: nowrap;
  max-width: 92vw;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#loader {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; flex-direction: column; gap: 18px;
  align-items: center; justify-content: center;
  transition: opacity 0.5s ease;
}
#loader.hide { opacity: 0; pointer-events: none; }
#loader p { font-size: 12px; letter-spacing: 0.3em; color: var(--ink-dim); text-transform: uppercase; }
.spin {
  width: 46px; height: 46px; border-radius: 12px;
  background: conic-gradient(from 0deg, var(--accent1), var(--accent2), var(--accent1));
  animation: cubeflip 1.1s cubic-bezier(0.6, 0.1, 0.3, 0.9) infinite;
}
@keyframes cubeflip {
  0% { transform: perspective(200px) rotateX(0) rotateY(0); border-radius: 12px; }
  50% { transform: perspective(200px) rotateX(-180deg) rotateY(0); border-radius: 50%; }
  100% { transform: perspective(200px) rotateX(-180deg) rotateY(-180deg); border-radius: 12px; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
#dock { animation-name: riseDock; }
@keyframes riseDock { from { opacity: 0; transform: translate(-50%, 14px); } }

@media (max-width: 560px) {
  #brand p { display: none; }
  .btn { padding: 11px 18px; font-size: 13px; }
  #toast { bottom: 132px; font-size: 13px; }
  .chip { min-width: 0; padding: 8px 13px; }
}
