:root {
  --bg: #0b0f1a;
  --bg2: #10192e;
  --ink: #eaf0ff;
  --muted: #7d8bb0;
  --accent: #ffcf5c;
  --accent2: #6ee7ff;
  --card: rgba(20, 28, 48, 0.72);
  --line: rgba(120, 150, 220, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Bricolage Grotesque", sans-serif;
  background:
    radial-gradient(1200px 700px at 70% -10%, #1a2544 0%, transparent 60%),
    radial-gradient(900px 600px at 10% 110%, #17233f 0%, transparent 55%),
    var(--bg);
  color: var(--ink);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app-root {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* animated background orbs */
.bg-orbs { position: absolute; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .35; }
.orb1 { width: 340px; height: 340px; background: #3a5cff; top: -80px; left: -60px; animation: float 14s ease-in-out infinite; }
.orb2 { width: 300px; height: 300px; background: #ffcf5c; bottom: -90px; right: -50px; animation: float 18s ease-in-out infinite reverse; }
.orb3 { width: 260px; height: 260px; background: #6ee7ff; top: 40%; left: 60%; animation: float 22s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px,-40px) scale(1.1); } }

/* header */
.app-header {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; gap: 12px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff, var(--accent) 60%, #c98a17);
  box-shadow: 0 0 16px var(--accent);
  animation: pulseDot 2.4s ease-in-out infinite;
}
@keyframes pulseDot { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.brand h1 { font-size: 20px; font-weight: 800; letter-spacing: -.5px;
  background: linear-gradient(90deg, #fff, var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.header-right { display: flex; align-items: center; gap: 14px; }
.pops { font-size: 13px; color: var(--muted); font-family: "Fira Code", monospace; }
.pops b { color: var(--accent); }

.toggle { display: flex; background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.tg { border: none; background: transparent; color: var(--muted); padding: 6px 16px; border-radius: 999px; font-family: inherit; font-weight: 500; font-size: 13px; cursor: pointer; transition: .2s; }
.tg-on { background: var(--accent); color: #1a1206; font-weight: 800; }
.tg-dis { opacity: .4; cursor: not-allowed; }

/* main */
.app-main { position: relative; z-index: 2; flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; min-height: 0; }

/* clicker */
.clicker-wrap { position: relative; width: 100%; max-width: 520px; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ball-area { position: relative; width: 300px; height: 300px; display: flex; align-items: center; justify-content: center; cursor: pointer; user-select: none; }

.ball {
  width: 170px; height: 170px; border-radius: 50%;
  background:
    radial-gradient(circle at 32% 28%, #9ff6ff 0%, #57c9ff 30%, #3a5cff 70%, #2038b0 100%);
  box-shadow: 0 20px 60px rgba(58,92,255,.5), inset 0 -18px 40px rgba(0,0,20,.4);
  display: flex; align-items: center; justify-content: center;
  position: relative;
  animation: bob 3s ease-in-out infinite;
  transition: transform .16s cubic-bezier(.34,1.56,.64,1);
}
@keyframes bob { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-14px) scale(1.02); } }
.ball-squish { animation: none; transform: scale(.86) translateY(4px); }
.ball-glow { box-shadow: 0 0 90px 20px var(--accent), 0 20px 60px rgba(255,207,92,.6); }
.ball-shine { position: absolute; top: 22px; left: 34px; width: 46px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.55); filter: blur(4px); }
.ball-label { font-family: "Fira Code", monospace; font-weight: 600; font-size: 15px; color: rgba(255,255,255,.85); letter-spacing: 2px; }

.ripple { position: absolute; width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); transform: translate(-50%,-50%); animation: rippleAnim .65s ease-out forwards; pointer-events: none; }
@keyframes rippleAnim { from { width: 12px; height: 12px; opacity: .9; } to { width: 220px; height: 220px; opacity: 0; } }

.particle { position: absolute; width: 9px; height: 9px; border-radius: 50%; transform: translate(-50%,-50%); animation: partAnim .7s ease-out forwards; pointer-events: none; }
@keyframes partAnim { from { transform: translate(-50%,-50%) translate(0,0) scale(1); opacity: 1; } to { transform: translate(-50%,-50%) translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

/* fact card */
.fact-card {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
  width: min(90vw, 440px); padding: 34px 28px 26px; text-align: center;
  background: var(--card); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 24px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5);
  cursor: pointer; z-index: 5;
  animation: cardIn .45s cubic-bezier(.34,1.56,.64,1) forwards, cardOut .5s ease-in 5.5s forwards;
}
@keyframes cardIn { from { opacity: 0; transform: translate(-50%,-42%) scale(.85); } to { opacity: 1; transform: translate(-50%,-50%) scale(1); } }
@keyframes cardOut { to { opacity: 0; transform: translate(-50%,-58%) scale(.95); } }
.count-ring { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; transform: rotate(-90deg); }
.count-ring .ring-bg { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 10; }
.count-ring .ring-fg { fill: none; stroke: var(--accent); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 339.3; stroke-dashoffset: 0; animation: drain 6s linear forwards; }
@keyframes drain { to { stroke-dashoffset: 339.3; } }
.fact-text { font-size: clamp(19px, 4.5vw, 27px); font-weight: 500; line-height: 1.35; letter-spacing: -.3px; }
.fact-hint { margin-top: 16px; font-family: "Fira Code", monospace; font-size: 11px; color: var(--muted); letter-spacing: 1px; }

.empty-hint { position: absolute; bottom: 24%; font-size: 13px; color: var(--muted); font-family: "Fira Code", monospace; }

.sub-line { position: relative; z-index: 2; text-align: center; padding: 0 16px 8px; font-size: 12.5px; color: var(--muted); font-family: "Fira Code", monospace; }

/* generating pill */
.gen-pill { position: fixed; bottom: 62px; left: 50%; transform: translateX(-50%); z-index: 10; display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: rgba(20,28,48,.9); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; color: var(--accent2); font-family: "Fira Code", monospace; animation: cardIn .3s ease; }
.gen-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent2); animation: pulseDot 1s infinite; }

.toast { position: fixed; top: 76px; left: 50%; transform: translateX(-50%); z-index: 20; background: rgba(20,28,48,.95); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; font-size: 13px; }

/* quiz */
.quiz-wrap { width: 100%; max-width: 520px; padding: 8px 20px; z-index: 2; }
.center-col { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; }
.quiz-top { display: flex; justify-content: space-between; font-family: "Fira Code", monospace; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.quiz-progress { height: 6px; background: rgba(255,255,255,.08); border-radius: 999px; overflow: hidden; margin-bottom: 22px; }
.quiz-progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent2), var(--accent)); transition: width .4s ease; }
.quiz-q { font-size: clamp(19px,4.5vw,26px); font-weight: 500; line-height: 1.35; margin-bottom: 22px; animation: cardIn .4s ease; letter-spacing: -.3px; }
.quiz-opts { display: flex; flex-direction: column; gap: 12px; }
.opt-btn { text-align: left; padding: 15px 18px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.04); color: var(--ink); font-family: inherit; font-size: 15px; cursor: pointer; transition: .18s; }
.opt-btn:hover { background: rgba(255,255,255,.09); transform: translateX(3px); }
.opt-correct { background: rgba(56,220,120,.2); border-color: #38dc78; color: #b7ffcf; }
.opt-wrong { background: rgba(255,72,88,.18); border-color: #ff4858; color: #ffc0c6; }
.opt-dim { opacity: .45; }
.opt-shake { animation: shake .45s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px)} 40%{transform:translateX(8px)} 60%{transform:translateX(-5px)} 80%{transform:translateX(5px)} }

.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255,255,255,.12); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.quiz-loading { color: var(--muted); font-family: "Fira Code", monospace; font-size: 14px; }

.result-in { animation: cardIn .5s cubic-bezier(.34,1.56,.64,1); }
.result-score { font-size: 64px; font-weight: 800; background: linear-gradient(90deg,var(--accent2),var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.result-rank { font-size: 26px; font-weight: 800; }
.result-row { margin-top: 10px; }

.primary-btn { padding: 13px 28px; border: none; border-radius: 999px; background: var(--accent); color: #1a1206; font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; transition: .2s; box-shadow: 0 8px 24px rgba(255,207,92,.4); }
.primary-btn:hover { transform: translateY(-2px); }
.ghost-btn { margin-top: 22px; background: transparent; border: 1px solid var(--line); color: var(--muted); padding: 8px 18px; border-radius: 999px; font-family: "Fira Code", monospace; font-size: 12px; cursor: pointer; transition: .2s; }
.ghost-btn:hover { color: var(--ink); }

/* footer */
.app-footer { position: relative; z-index: 3; text-align: center; padding: 10px; }
.app-footer a { color: var(--muted); font-size: 12px; font-family: "Fira Code", monospace; text-decoration: none; opacity: .7; transition: .2s; }
.app-footer a:hover { color: var(--accent); opacity: 1; }

@media (max-width: 480px) {
  .ball-area { width: 240px; height: 240px; }
  .ball { width: 140px; height: 140px; }
  .header-right { gap: 8px; }
  .pops { display: none; }
}