/* CubeQuest — bold, game-like 11+ cube nets lesson */
:root {
  --bg0: #1a1140;
  --bg1: #2a1d63;
  --surface: #ffffff;
  --ink: #1f1840;
  --ink-soft: #6b6391;
  --line: #ece8fb;
  --brand: #7c4dff;
  --brand-d: #5a30d6;
  --gold: #ffc83d;
  --good: #23c16b;
  --bad: #ff5a6a;
  --r-lg: 26px;
  --r-md: 18px;
  --shadow: 0 18px 40px -18px rgba(20, 10, 60, 0.55);
  --font-d: "Fredoka", system-ui, sans-serif;
  --font-b: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-b);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, #3a2680 0%, var(--bg1) 42%, var(--bg0) 100%);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.app {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
  max-width: 1280px; margin: 0 auto; padding: 14px 16px 16px;
  gap: 12px;
}

/* ---------- Top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.cube-glyph {
  width: 38px; height: 38px; border-radius: 11px; position: relative; flex: 0 0 auto;
  background: conic-gradient(from 210deg, #ff5a5f, #ffb400, #23c16b, #2e8fff, #9b5de5, #ff5a5f);
  box-shadow: 0 6px 16px -4px rgba(124, 77, 255, 0.7), inset 0 0 0 3px rgba(255,255,255,.25);
}
.cube-glyph::after { content: ""; position: absolute; inset: 10px; border-radius: 6px; background: rgba(26,17,64,.55); }
.brand-text { line-height: 1; }
.brand-name { font-family: var(--font-d); font-weight: 700; font-size: 22px; letter-spacing: .3px; }
.brand-sub { font-size: 12px; font-weight: 700; color: #c9bdf6; text-transform: uppercase; letter-spacing: 1.4px; }

.hud { display: flex; align-items: center; gap: 16px; }
.progress { display: flex; gap: 7px; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: rgba(255,255,255,.22); transition: .3s; }
.dot.active { background: var(--gold); transform: scale(1.25); box-shadow: 0 0 0 4px rgba(255,200,61,.22); }
.dot.done { background: var(--good); }

.points {
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18); padding: 7px 14px 7px 10px; border-radius: 999px;
  color: #fff; font-family: var(--font-d); font-weight: 600; position: relative;
}
.points svg { width: 22px; height: 22px; filter: drop-shadow(0 2px 3px rgba(0,0,0,.25)); }
.points #points { font-size: 19px; min-width: 22px; text-align: center; }
.points.pop { animation: pop .45s ease; }
@keyframes pop { 0%{transform:scale(1)} 40%{transform:scale(1.18)} 100%{transform:scale(1)} }
.float-pts {
  position: absolute; right: 14px; top: -6px; color: var(--gold); font-family: var(--font-d);
  font-weight: 700; font-size: 18px; pointer-events: none; animation: floatUp 1s ease forwards;
}
@keyframes floatUp { 0%{opacity:0; transform:translateY(6px)} 20%{opacity:1} 100%{opacity:0; transform:translateY(-26px)} }

/* ---------- Stage ---------- */
.stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  border-radius: var(--r-lg); overflow: hidden;
  background:
    radial-gradient(80% 70% at 50% 38%, rgba(124,77,255,.30), rgba(124,77,255,0) 70%),
    linear-gradient(180deg, #221858, #15103c);
  box-shadow: var(--shadow), inset 0 0 0 1px rgba(255,255,255,.06);
}
#canvas { position: absolute; inset: 0; }
#canvas canvas { display: block; }

.ghost-btn {
  position: absolute; top: 14px; left: 14px; z-index: 3;
  width: 46px; height: 46px; border-radius: 14px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(20,12,52,.55); color: #fff; font-size: 22px; cursor: pointer;
  display: grid; place-items: center; backdrop-filter: blur(6px); transition: .15s;
}
.ghost-btn:active { transform: scale(.92); }

.drag-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 3;
  display: flex; align-items: center; gap: 8px; color: #d9cffb; font-weight: 700; font-size: 14px;
  background: rgba(20,12,52,.5); padding: 8px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.14);
  pointer-events: none; transition: opacity .4s; animation: bob 1.8s ease-in-out infinite;
}
.drag-hint.hide { opacity: 0; }
@keyframes bob { 0%,100%{transform:translateX(-50%) translateY(0)} 50%{transform:translateX(-50%) translateY(-4px)} }

#confetti { position: absolute; inset: 0; z-index: 4; pointer-events: none; }

/* ---------- Coach panel ---------- */
.coach {
  flex: 0 0 auto;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px 22px; position: relative;
  display: flex; flex-direction: column; gap: 10px;
}
.coach-top { display: flex; flex-direction: column; align-items: flex-start; gap: 9px; }
.step-label {
  font-family: var(--font-d); font-weight: 600; font-size: 13px; letter-spacing: .6px;
  color: var(--brand); text-transform: uppercase;
  background: #f1ecff; padding: 4px 12px; border-radius: 999px;
}
.headline { font-family: var(--font-d); font-weight: 600; font-size: 26px; margin: 0; color: var(--ink); line-height: 1.1; }
.body { margin: 0; font-size: 17px; line-height: 1.45; color: var(--ink-soft); font-weight: 600; max-width: 70ch; text-wrap: pretty; }
.body b { color: var(--ink); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--ink); }
.swatch { width: 15px; height: 15px; border-radius: 5px; display: inline-block; vertical-align: -2px; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 4px; }

/* chunky pressable buttons */
.btn {
  font-family: var(--font-d); font-weight: 600; font-size: 19px; letter-spacing: .2px;
  border: none; cursor: pointer; border-radius: 16px; padding: 14px 26px; color: #fff;
  background: var(--brand); position: relative; transition: transform .06s, filter .15s;
  box-shadow: 0 6px 0 0 var(--brand-d), 0 14px 22px -10px rgba(90,48,214,.7);
  min-height: 54px; display: inline-flex; align-items: center; gap: 10px;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 0 var(--brand-d), 0 6px 12px -8px rgba(90,48,214,.7); }
.btn.secondary { background: #efeaff; color: var(--brand-d); box-shadow: 0 6px 0 0 #d6caff; }
.btn.secondary:active { box-shadow: 0 1px 0 0 #d6caff; }
.btn.good { background: var(--good); box-shadow: 0 6px 0 0 #149a52, 0 14px 22px -10px rgba(20,154,82,.6); }
.btn.good:active { box-shadow: 0 1px 0 0 #149a52; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn .ico { font-size: 22px; line-height: 0; }

.spacer { flex: 1 1 auto; }
.hint-text { font-size: 14px; color: var(--ink-soft); font-weight: 700; }

/* ---------- Quiz ---------- */
.quiz { display: flex; flex-direction: column; gap: 12px; }
.q-options { display: flex; gap: 12px; flex-wrap: wrap; }
.opt {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: #f7f5ff; border: 2px solid var(--line); border-radius: 16px;
  padding: 12px 18px 12px 12px; font-family: var(--font-d); font-weight: 600; font-size: 18px; color: var(--ink);
  transition: .12s; min-height: 56px;
}
.opt:active { transform: scale(.97); }
.opt .chip { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex: 0 0 auto; box-shadow: inset 0 0 0 3px rgba(255,255,255,.35); }
.opt .chip svg { width: 22px; height: 22px; }
.opt.correct { border-color: var(--good); background: #e7faf0; box-shadow: 0 0 0 4px rgba(35,193,107,.18); }
.opt.wrong { border-color: var(--bad); background: #ffeef0; }
.opt.disabled { pointer-events: none; opacity: .8; }
.feedback { font-family: var(--font-d); font-weight: 600; font-size: 18px; min-height: 24px; }
.feedback.good { color: var(--good); }
.feedback.bad { color: var(--bad); }

/* ---------- Finish card ---------- */
.finish { text-align: center; align-items: center; }
.stars { display: flex; gap: 10px; justify-content: center; margin: 4px 0; }
.stars svg { width: 46px; height: 46px; }
.big-score { font-family: var(--font-d); font-weight: 700; font-size: 40px; color: var(--brand); }

/* ---------- Responsive ---------- */
@media (max-width: 760px), (max-height: 620px) {
  .headline { font-size: 22px; }
  .body { font-size: 15.5px; }
  .btn { font-size: 17px; padding: 12px 20px; }
  .brand-sub { display: none; }
}
@media (max-height: 560px) {
  .coach { padding: 12px 18px; }
  .headline { font-size: 20px; }
}
