:root {
  --bg0: #0c0a1f;
  --bg1: #16123a;
  --violet: #7c5cff;
  --violet-2: #b98bff;
  --cyan: #5ce0ff;
  --gold: #ffd56b;
  --ink: #ece9ff;
  --muted: #9a93c8;
  --yes: #46d999;
  --no: #ff6b7a;
  --maybe: #ffce5c;
  --dunno: #8b9bd4;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.12);
}

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

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg0);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(120% 90% at 50% -10%, #2a1f5e 0%, var(--bg1) 38%, var(--bg0) 72%),
    radial-gradient(60% 50% at 80% 110%, #221a52 0%, transparent 60%);
  background-attachment: fixed;
}

/* drijvende sterren */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255,255,255,0.7), transparent),
    radial-gradient(1.5px 1.5px at 78% 14%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1px 1px at 35% 64%, rgba(255,255,255,0.5), transparent),
    radial-gradient(1.5px 1.5px at 64% 82%, rgba(200,220,255,0.6), transparent),
    radial-gradient(1px 1px at 88% 56%, rgba(255,255,255,0.4), transparent),
    radial-gradient(1px 1px at 22% 88%, rgba(255,255,255,0.4), transparent);
  pointer-events: none;
  opacity: 0.7;
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.45; } to { opacity: 0.85; } }

#app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  max-width: 560px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.screen { display: none; flex: 1; flex-direction: column; align-items: center; }
.screen.active { display: flex; }

/* ---------- Orb ---------- */
.orb {
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(40% 38% at 38% 32%, rgba(255,255,255,0.85), transparent 60%),
    radial-gradient(120% 120% at 50% 50%, var(--violet-2) 0%, var(--violet) 38%, #3a2a8c 70%, #1c1545 100%);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.18) inset,
    0 0 38px 6px rgba(124, 92, 255, 0.55),
    0 0 90px 18px rgba(124, 92, 255, 0.28);
  animation: breathe 3.6s ease-in-out infinite;
}
.orb::after {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 1px solid rgba(185, 139, 255, 0.25);
  animation: halo 3.6s ease-in-out infinite;
}
.orb-eye {
  font-size: 44px;
  color: #fff;
  text-shadow: 0 0 18px rgba(255,255,255,0.9), 0 0 40px var(--cyan);
  animation: gaze 5s ease-in-out infinite;
}
@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 1px rgba(255,255,255,0.18) inset, 0 0 34px 5px rgba(124,92,255,0.5), 0 0 84px 16px rgba(124,92,255,0.24); }
  50% { transform: scale(1.045); box-shadow: 0 0 0 1px rgba(255,255,255,0.22) inset, 0 0 46px 8px rgba(124,92,255,0.66), 0 0 110px 22px rgba(124,92,255,0.34); }
}
@keyframes halo { 0%,100% { opacity: 0.3; transform: scale(1); } 50% { opacity: 0.6; transform: scale(1.06); } }
@keyframes gaze { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.orb.thinking { animation: think 1.1s ease-in-out infinite; }
.orb.thinking .orb-eye { animation: spin 1.2s linear infinite; }
@keyframes think {
  0%,100% { transform: scale(1.02); box-shadow: 0 0 0 1px rgba(255,255,255,0.3) inset, 0 0 50px 10px rgba(92,224,255,0.6), 0 0 120px 26px rgba(124,92,255,0.45); }
  50% { transform: scale(1.09); box-shadow: 0 0 0 1px rgba(255,255,255,0.4) inset, 0 0 70px 16px rgba(92,224,255,0.8), 0 0 150px 34px rgba(124,92,255,0.55); }
}
@keyframes spin { to { transform: rotate(360deg); } }

.orb.win { animation: breathe 3.6s ease-in-out infinite, glowGold 2s ease-in-out infinite; }
@keyframes glowGold {
  0%,100% { box-shadow: 0 0 40px 8px rgba(255,213,107,0.5), 0 0 100px 22px rgba(255,213,107,0.3); }
  50% { box-shadow: 0 0 64px 14px rgba(255,213,107,0.75), 0 0 140px 32px rgba(255,213,107,0.45); }
}
.orb.lose { filter: saturate(0.6) brightness(0.85); }
.orb.idle { animation-duration: 4.4s; }

/* ---------- Intro ---------- */
.logo {
  margin: 26px 0 6px;
  font-size: clamp(34px, 11vw, 52px);
  letter-spacing: 0.16em;
  font-weight: 800;
  background: linear-gradient(120deg, var(--violet-2), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 40px rgba(124, 92, 255, 0.4);
}
.tagline { margin: 0 0 16px; font-size: 18px; color: var(--ink); text-align: center; }
.tagline b { color: var(--violet-2); }
.hint {
  margin: 0 0 26px;
  max-width: 30em;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}
.hint b { color: var(--ink); font-weight: 600; }
.record { margin-top: 20px; color: var(--muted); font-size: 14px; min-height: 1.2em; }
.record b { color: var(--gold); }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 22px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn.primary {
  background: linear-gradient(120deg, var(--violet), #5b3edb);
  border-color: transparent;
  box-shadow: 0 8px 26px rgba(124, 92, 255, 0.45);
  font-size: 17px;
  padding: 17px 28px;
}
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 12px; border-radius: 12px; font-size: 16px; }

/* ---------- Spel ---------- */
#game { justify-content: flex-start; }
.topbar { width: 100%; display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.counter { font-weight: 800; font-size: 20px; white-space: nowrap; }
.counter .of { color: var(--muted); font-weight: 600; font-size: 14px; margin-left: 3px; }
.progress { flex: 1; height: 7px; border-radius: 99px; background: rgba(255,255,255,0.08); overflow: hidden; }
.progress-fill {
  height: 100%;
  width: 5%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--violet), var(--cyan));
  transition: width 0.4s ease;
}

.orb-wrap { margin: 18px 0 6px; }
#game .orb { width: 124px; height: 124px; }
#game .orb-eye { font-size: 36px; }

.phase { margin: 14px 0 2px; color: var(--cyan); font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; min-height: 1.1em; }
.question {
  margin: 4px 0 22px;
  font-size: clamp(21px, 6vw, 27px);
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  max-width: 18em;
  min-height: 2.4em;
  display: flex;
  align-items: center;
}

.answers { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: auto; }
.btn.ans { padding: 18px; font-size: 18px; border-width: 1.5px; }
.btn.ans.yes { border-color: rgba(70, 217, 153, 0.5); color: var(--yes); }
.btn.ans.no { border-color: rgba(255, 107, 122, 0.5); color: var(--no); }
.btn.ans.maybe { border-color: rgba(255, 206, 92, 0.45); color: var(--maybe); }
.btn.ans.dunno { border-color: rgba(139, 155, 212, 0.45); color: var(--dunno); }
.btn.ans:active { background: rgba(255,255,255,0.1); }

/* guess-modus: twee brede knoppen */
.answers.guess { grid-template-columns: 1fr 1fr; }
.btn.ans.correct { border-color: rgba(70, 217, 153, 0.6); color: var(--yes); background: rgba(70,217,153,0.08); }
.btn.ans.wrong { border-color: rgba(255, 107, 122, 0.6); color: var(--no); }

.log { width: 100%; margin-top: 16px; color: var(--muted); font-size: 14px; }
.log summary { cursor: pointer; padding: 6px 0; color: var(--violet-2); }
.log ol { margin: 4px 0 0; padding-left: 22px; max-height: 30vh; overflow-y: auto; }
.log li { margin-bottom: 6px; line-height: 1.4; }
.log .a { color: var(--ink); font-weight: 600; }

/* ---------- Einde ---------- */
#end { justify-content: center; gap: 6px; }
#end .orb { width: 132px; height: 132px; margin-bottom: 18px; }
.end-title { margin: 6px 0; font-size: clamp(26px, 8vw, 38px); font-weight: 800; text-align: center; }
.end-title.win { color: var(--gold); }
.end-title.lose { color: var(--cyan); }
.end-text { margin: 0 0 8px; text-align: center; font-size: 18px; color: var(--ink); max-width: 22em; line-height: 1.4; }
.end-extra { margin: 8px 0 22px; text-align: center; color: var(--muted); font-size: 15px; min-height: 1.2em; }
.end-extra input {
  font: inherit; margin-top: 8px; width: 100%; max-width: 280px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(255,255,255,0.06); color: var(--ink); text-align: center;
}
.end-extra input::placeholder { color: var(--muted); }

.shake { animation: shake 0.4s ease; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

@media (max-width: 360px) {
  .orb { width: 124px; height: 124px; }
  .btn.ans { padding: 15px; font-size: 16px; }
}
