:root {
  --bg: #f4f2fb;
  --ink: #15131f;
  --ink-2: #4b4760;
  --ink-3: #6e6a84;
  --paper: #ffffff;
  --green: #0f5f4a;
  --green-deep: #0a4536;
  --coral: #ff7a6b;
  --butter: #ffd95a;
  --mint: #8ef0c8;
  --lilac: #c9b9ff;
  --hit: #12b886;
  --hit-soft: #d3f9e8;
  --miss: #e03e3e;
  --miss-soft: #ffe3e3;
  --display: 'Bricolage Grotesque', 'Segoe UI', system-ui, sans-serif;
  --sans: 'Inter', system-ui, 'Segoe UI', sans-serif;
  --r: 18px;
  --shadow: 4px 4px 0 var(--ink);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 16px/1.5 var(--sans); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(var(--lilac) 1px, transparent 1.5px);
  background-size: 22px 22px; background-attachment: fixed;
}
main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; outline: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* stickers: the one visual idea, used everywhere */
.sticker { background: var(--paper); border: 2px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); }

/* ---------- header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; max-width: 760px; width: 100%; margin: 0 auto; padding: 14px 16px 6px; }
.brand { display: inline-flex; align-items: baseline; gap: 4px; text-decoration: none; color: var(--ink); font-family: var(--display); }
.brand b { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.brand span { font-weight: 800; font-size: 22px; background: var(--butter); border: 2px solid var(--ink); border-radius: 10px; padding: 0 8px; transform: rotate(-3deg); display: inline-block; }
.streak { font: 800 18px var(--display); background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 3px 12px; box-shadow: 3px 3px 0 var(--ink); }
.streak.bump { animation: bump .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 40% { transform: scale(1.3) rotate(-6deg); } }

/* ---------- home ---------- */
.hero { font: 800 clamp(34px, 8vw, 56px)/1.02 var(--display); letter-spacing: -.035em; margin: 18px 0 10px; }
.hero .hl { background: var(--mint); border: 2px solid var(--ink); border-radius: 14px; padding: 0 10px; display: inline-block; transform: rotate(-1.5deg); box-shadow: 3px 3px 0 var(--ink); }
.sub { color: var(--ink-2); margin: 0 0 22px; font-size: 17px; max-width: 34em; }

.subjects { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.subj {
  position: relative; display: flex; flex-direction: column; gap: 2px; padding: 14px 14px 12px; min-height: 118px;
  text-decoration: none; color: var(--ink); border: 2px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.subj:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--ink); }
.subj:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.subj .emo { font-size: 30px; line-height: 1; margin-bottom: auto; }
.subj b { font: 800 18px/1.1 var(--display); letter-spacing: -.01em; margin-top: 10px; }
.subj small { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.subj[aria-current="true"]::after { content: '✓'; position: absolute; top: 10px; right: 10px; width: 26px; height: 26px; display: grid; place-items: center; background: var(--ink); color: #fff; border-radius: 50%; font-weight: 800; font-size: 14px; }
.subj[aria-current="false"] { opacity: .72; }
.c-chemistry { background: var(--coral); }
.c-biology { background: var(--mint); }
.c-physics { background: var(--butter); }
.c-computer-science { background: var(--lilac); }

.panel { padding: 20px; }
.label { margin: 0 0 8px; font: 700 12px var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding: 2px 2px 6px; margin-left: -2px; scrollbar-width: none; }
.chip { flex: none; border: 2px solid var(--ink); background: var(--paper); border-radius: 999px; padding: 6px 14px; font-weight: 600; font-size: 14px; white-space: nowrap; }
.chip small { color: var(--ink-3); font-weight: 500; margin-left: 4px; }
#counts .chip { min-width: 64px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; }
.chip[aria-pressed="true"] small { color: #c9c6d8; }

.go {
  width: 100%; border: 2px solid var(--ink); border-radius: 16px; background: var(--green); color: #fff; padding: 16px;
  font: 800 22px var(--display); letter-spacing: -.01em; box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease;
}
.go:hover { background: var(--green-deep); }
.go:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.ghost { width: 100%; margin-top: 10px; border: 2px dashed var(--ink); background: var(--butter); border-radius: 14px; padding: 12px; font-weight: 700; }
.settings { margin-top: 16px; font-size: 14px; color: var(--ink-2); }
.settings summary { cursor: pointer; font-weight: 600; }
.settings label { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.settings select { border: 2px solid var(--ink); border-radius: 10px; padding: 4px 8px; background: var(--paper); }
.note { font-size: 14px; color: var(--ink-2); margin: 12px 0 0; }

/* ---------- question ---------- */
.stories { display: flex; gap: 4px; margin: 6px 0 12px; }
.stories i { flex: 1; height: 5px; border-radius: 99px; background: #dcd7ee; }
.stories i.done { background: var(--ink); }
.stories i.now { background: var(--ink); animation: grow .6s ease both; transform-origin: left; }
@keyframes grow { from { transform: scaleX(.15); } }
.qbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.qbar .tag { flex: 1; font-weight: 600; font-size: 14px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round { width: 40px; height: 40px; flex: none; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); font-size: 16px; display: grid; place-items: center; }

.examiner { padding: 22px 22px 20px; position: relative; overflow: hidden; }
.examiner .kicker { margin: 0; font: 700 13px var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.term { margin: 2px 0 0; padding-right: 70px; font: 800 clamp(34px, 9vw, 60px)/1 var(--display); letter-spacing: -.035em; overflow-wrap: anywhere; }
.term-marks { position: absolute; top: 14px; right: 14px; background: var(--butter); border: 2px solid var(--ink); border-radius: 999px; padding: 2px 10px; font: 800 14px var(--display); transform: rotate(4deg); }
.examiner.c-chemistry { background: #ffe9e5; }
.examiner.c-biology { background: #e3fcf2; }
.examiner.c-physics { background: #fff6d6; }
.examiner.c-computer-science { background: #efeaff; }

.points { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.pt { border: 2px dashed #b9b4cc; color: var(--ink-3); background: rgba(255, 255, 255, .7); border-radius: 12px; padding: 6px 12px; font-weight: 700; font-size: 14px; transition: background .2s ease, color .2s ease; }
.pt.hit { border: 2px solid var(--ink); background: var(--hit); color: #fff; box-shadow: 3px 3px 0 var(--ink); animation: pop .45s cubic-bezier(.3, 1.7, .5, 1); }
@keyframes pop { 0% { transform: scale(.6) rotate(-8deg); } 60% { transform: scale(1.12) rotate(3deg); } }

.bubble {
  min-height: 56px; padding: 14px 16px; border: 2px solid var(--ink); border-radius: 20px 20px 20px 6px; background: var(--paper);
  font-size: 18px; line-height: 1.45; box-shadow: 3px 3px 0 var(--ink); margin-bottom: 14px; overflow-wrap: anywhere;
}
.bubble.empty { color: var(--ink-3); font-style: italic; border-style: dashed; box-shadow: none; background: transparent; }
.bubble mark.good { background: var(--hit-soft); color: #0a6b4e; border-radius: 4px; padding: 0 3px; font-weight: 600; }
.bubble mark.bad { background: var(--miss-soft); color: var(--miss); border-radius: 4px; padding: 0 3px; text-decoration: line-through 2px; }

.typed { display: block; width: 100%; min-height: 90px; padding: 14px 16px; border: 2px solid var(--ink); border-radius: 16px; resize: vertical; font-size: 18px; line-height: 1.45; background: var(--paper); margin-bottom: 14px; }
.typed[hidden] { display: none; }

.dock { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.dock .side { border: 2px solid var(--ink); background: var(--paper); border-radius: 999px; padding: 10px 14px; font-weight: 700; font-size: 14px; justify-self: start; }
.dock .side.right { justify-self: end; }
.mic {
  width: 92px; height: 92px; border-radius: 50%; border: 2px solid var(--ink); background: var(--coral); box-shadow: var(--shadow);
  display: grid; place-items: center; position: relative; transition: transform .12s ease;
}
.mic:active { transform: scale(.94); }
.mic svg { width: 34px; height: 34px; }
.mic .wave { display: none; gap: 4px; align-items: center; height: 36px; }
.mic .wave i { width: 5px; height: 10px; border-radius: 3px; background: var(--ink); animation: wave 1s ease-in-out infinite; }
.mic .wave i:nth-child(2) { animation-delay: .15s; }
.mic .wave i:nth-child(3) { animation-delay: .3s; }
.mic .wave i:nth-child(4) { animation-delay: .45s; }
.mic .wave i:nth-child(5) { animation-delay: .6s; }
@keyframes wave { 50% { height: 32px; } }
.mic.on { background: var(--butter); }
.mic.on svg { display: none; }
.mic.on .wave { display: flex; }
.mic.on::before { content: ''; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid var(--ink); animation: ring 1.4s ease-out infinite; }
@keyframes ring { from { transform: scale(.9); opacity: .8; } to { transform: scale(1.35); opacity: 0; } }
.mic.talk .wave i { animation-duration: .45s; }
.mic[disabled] { opacity: .45; box-shadow: none; cursor: default; }
.hint { text-align: center; margin: 10px 0 0; font-size: 14px; font-weight: 600; color: var(--ink-2); min-height: 1.4em; }
.hint.err { color: var(--miss); }
.submit { margin-top: 16px; }

/* ---------- result ---------- */
.result { margin-top: 18px; padding: 20px; animation: rise .35s ease; }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } }
.res-top { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.score {
  flex: none; margin: 0; font: 800 46px/1 var(--display); letter-spacing: -.03em; border: 2px solid var(--ink); border-radius: 20px;
  padding: 10px 14px; transform: rotate(-5deg); box-shadow: var(--shadow); background: var(--paper);
}
.score small { font-size: .55em; color: var(--ink-3); }
.score.full { background: var(--hit); color: #fff; }
.score.full small { color: #dff8ee; }
.score.part { background: var(--butter); }
.score.zero { background: var(--miss-soft); }
.verdict { margin: 0; font: 800 24px/1.15 var(--display); letter-spacing: -.02em; }
.checklist { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; padding: 8px 10px; border-radius: 12px; }
.checklist li.y { background: var(--hit-soft); }
.checklist li.n { background: var(--miss-soft); }
.checklist .ic { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; margin-top: 1px; }
.checklist .y .ic { background: var(--hit); }
.checklist .n .ic { background: var(--miss); }
.checklist em { display: block; font-style: normal; font-size: 13px; color: var(--miss); }
.answer-box { background: #f6f4fd; border-radius: 14px; padding: 12px 14px; margin: 0 0 16px; }
.answer-box b { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 2px; }
.warn { color: var(--miss); font-weight: 600; font-size: 14px; margin: 0 0 12px; }

/* ---------- summary ---------- */
.wrap { padding: 24px 20px; text-align: center; margin-top: 14px; }
.big { font: 800 clamp(70px, 20vw, 120px)/.9 var(--display); letter-spacing: -.05em; margin: 6px 0 4px; }
.big small { font-size: .38em; color: var(--ink-3); letter-spacing: -.02em; }
.grade { display: inline-block; font: 800 20px var(--display); border: 2px solid var(--ink); border-radius: 999px; padding: 4px 14px; transform: rotate(-2deg); margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.stats div { border: 2px solid var(--ink); border-radius: 14px; padding: 8px; background: var(--paper); }
.stats b { display: block; font: 800 24px var(--display); }
.stats span { font-size: 12px; color: var(--ink-3); font-weight: 600; }
.recap { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; }
.recap li { border-top: 2px solid #ebe8f5; }
.recap summary { display: flex; align-items: center; gap: 10px; padding: 10px 2px; cursor: pointer; list-style: none; font-weight: 600; }
.recap summary::-webkit-details-marker { display: none; }
.recap summary span { flex: 1; }
.recap summary b { font: 800 15px var(--display); border-radius: 999px; padding: 2px 10px; }
.recap .full b { background: var(--hit-soft); color: #0a6b4e; }
.recap .short b { background: var(--miss-soft); color: var(--miss); }
.recap details p { margin: 0 2px 12px; font-size: 14px; color: var(--ink-2); }
.btns { display: grid; gap: 10px; }
.btn2 { border: 2px solid var(--ink); background: var(--paper); border-radius: 14px; padding: 12px; font-weight: 700; box-shadow: 3px 3px 0 var(--ink); }

/* ---------- join a class ---------- */
.join { margin-top: 22px; padding: 18px; display: grid; gap: 10px; }
.join .label { margin-bottom: 2px; }
.join-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--ink); text-decoration: none;
  border: 2px solid var(--ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--ink); transition: transform .12s ease, box-shadow .12s ease;
}
.join-link:hover { transform: translate(-2px, -2px); box-shadow: 5px 5px 0 var(--ink); }
.join-link .emo { font-size: 26px; flex: none; }
.join-link > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.join-link b { font: 800 17px/1.2 var(--display); }
.join-link small { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.join-link .arrow { font: 800 20px var(--display); }
.follow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.follow a { font-weight: 700; font-size: 14px; color: var(--ink); text-decoration: none; border: 2px solid var(--ink); border-radius: 999px; padding: 5px 12px; background: var(--paper); }
.follow a::before { content: '📸 '; }
.follow a:hover { background: var(--lilac); }
.credit a { color: inherit; text-decoration: none; }
.credit a:hover { color: var(--ink); text-decoration: underline; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.credit { text-align: center; font-size: 11px; letter-spacing: .14em; color: var(--ink-3); padding: 18px 16px 24px; font-weight: 600; }
.empty { text-align: center; color: var(--ink-3); padding: 40px 0; }

@media (max-width: 640px) {
  .subjects { grid-template-columns: repeat(2, 1fr); }
  .subj { min-height: 104px; }
  .mic { width: 84px; height: 84px; }
  .dock .side { padding: 9px 12px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
