/* StudyRally — arcade cabinet meets school notebook */
:root {
  --ink: #201d3d;
  --ink-2: #343054;
  --paper: #fff9e9;
  --paper-2: #f4ecd6;
  --white: #ffffff;
  --coral: #ff6b57;
  --coral-dark: #db463a;
  --yellow: #ffd34e;
  --yellow-dark: #e2a91b;
  --mint: #59d6a1;
  --mint-dark: #209469;
  --blue: #58a9ff;
  --blue-dark: #2676ca;
  --lavender: #a78bfa;
  --red: #ef476f;
  --muted: #77728d;
  --border: 3px solid var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-lg: 10px 10px 0 var(--ink);
  --radius-sm: 12px;
  --radius: 20px;
  --radius-lg: 30px;
  font-family: "Nunito", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 8% 14%, rgba(255, 211, 78, 0.2) 0 6%, transparent 6.2%),
    radial-gradient(circle at 92% 54%, rgba(89, 214, 161, 0.16) 0 8%, transparent 8.2%),
    var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 3px;
}

.page-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.13;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.3'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  padding: 10px 16px;
  transform: translateY(-160%);
  border: var(--border);
  border-radius: 10px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 82px;
  padding: 12px clamp(18px, 4vw, 64px);
  border-bottom: var(--border);
  background: rgba(255, 249, 233, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  gap: 8px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  transition: transform 180ms ease;
}

.brand:hover .brand-mark {
  transform: rotate(-7deg) translateY(-2px);
}

.brand-mark svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.brand-word {
  font-family: "Bowlby One", sans-serif;
  font-size: clamp(18px, 2vw, 24px);
  letter-spacing: -0.04em;
}

.brand-word span {
  color: var(--coral);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--white);
  box-shadow: 3px 3px 0 rgba(32, 29, 61, 0.14);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
  transition: 160ms ease;
}

.nav-link:hover {
  color: var(--ink);
  background: var(--paper);
}

.nav-link.is-active {
  background: var(--ink);
  color: var(--white);
}

.nav-icon,
.mobile-nav-link > span,
.mobile-create > span {
  display: inline-grid;
  width: 20px;
  height: 20px;
  place-items: center;
}

.nav-icon svg,
.mobile-nav svg,
.icon svg {
  width: 100%;
  height: 100%;
}

.player-status {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 12px;
}

.xp-pill {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 8px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 2px 2px 0 var(--ink);
  font-weight: 900;
}

.xp-pill small {
  font-size: 10px;
  letter-spacing: 0.08em;
}

.xp-spark {
  font-size: 18px;
  animation: twinkle 2.4s ease-in-out infinite;
}

.avatar-button {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
}

.avatar-face {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  font-family: "Bowlby One", sans-serif;
  font-size: 18px;
}

.online-dot {
  position: absolute;
  right: -2px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
}

#main-content {
  min-height: calc(100vh - 82px);
}

.view {
  width: min(1240px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(32px, 5vw, 72px) 0 96px;
  animation: view-in 380ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--coral-dark);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 26px;
  height: 3px;
  border-radius: 99px;
  background: currentColor;
  content: "";
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
.display-type {
  font-family: "Bowlby One", sans-serif;
  font-weight: 400;
  letter-spacing: -0.035em;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  gap: clamp(34px, 6vw, 84px);
  align-items: center;
  min-height: 505px;
}

.hero-copy {
  position: relative;
  z-index: 2;
}

.hero-copy h1 {
  max-width: 760px;
  margin-bottom: 22px;
  font-size: clamp(48px, 7vw, 92px);
  line-height: 0.98;
}

.hero-copy h1 .highlight {
  position: relative;
  display: inline-block;
  color: var(--coral);
}

.hero-copy h1 .highlight::after {
  position: absolute;
  right: 0;
  bottom: -9px;
  width: 95%;
  height: 11px;
  background: url("data:image/svg+xml,%3Csvg width='300' height='12' viewBox='0 0 300 12' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 8C54 1 91 12 149 5c58-7 98 6 149-2' fill='none' stroke='%23ffcf4a' stroke-width='6' stroke-linecap='round'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  content: "";
}

.hero-copy > p:not(.eyebrow) {
  max-width: 600px;
  margin-bottom: 28px;
  color: #5e5872;
  font-size: clamp(17px, 2vw, 21px);
  font-weight: 700;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}

.btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 19px;
  border: var(--border);
  border-radius: 13px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-weight: 1000;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--ink);
}

.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--ink);
}

.btn-primary {
  background: var(--coral);
  color: var(--white);
}

.btn-yellow {
  background: var(--yellow);
}

.btn-mint {
  background: var(--mint);
}

.btn-ink {
  background: var(--ink);
  color: var(--white);
}

.btn-ghost {
  box-shadow: none;
  background: transparent;
}

.btn-small {
  min-height: 38px;
  padding: 8px 12px;
  border-width: 2px;
  border-radius: 10px;
  box-shadow: 2px 2px 0 var(--ink);
  font-size: 13px;
}

.btn-icon {
  width: 20px;
  height: 20px;
}

.hero-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.hero-note span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
  color: var(--ink);
  font-size: 12px;
}

.hero-machine {
  position: relative;
  min-height: 460px;
  perspective: 1000px;
}

.arcade-card {
  position: absolute;
  inset: 25px 22px 20px 10px;
  display: flex;
  flex-direction: column;
  padding: 28px;
  overflow: hidden;
  transform: rotate(2deg);
  border: var(--border);
  border-radius: 36px 36px 24px 24px;
  background: var(--ink);
  box-shadow: 13px 13px 0 var(--coral), 16px 16px 0 var(--ink);
  color: var(--white);
}

.arcade-card::before {
  position: absolute;
  inset: 0;
  opacity: 0.19;
  background-image: radial-gradient(circle, var(--white) 1.5px, transparent 1.5px);
  background-size: 18px 18px;
  content: "";
}

.machine-top {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  z-index: 1;
}

.machine-label {
  padding: 7px 12px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 2px 2px 0 var(--white);
  color: var(--ink);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.machine-dots {
  display: flex;
  gap: 7px;
}

.machine-dots i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 14px 0 0 var(--yellow), 28px 0 0 var(--mint);
}

.mascot-wrap {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  z-index: 1;
}

.mascot-orbit {
  position: absolute;
  width: 270px;
  height: 270px;
  border: 3px dashed rgba(255, 255, 255, 0.26);
  border-radius: 50%;
  animation: orbit 18s linear infinite;
}

.mascot-orbit::before,
.mascot-orbit::after {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  content: "";
}

.mascot-orbit::before {
  top: 18px;
  right: 22px;
  transform: rotate(18deg);
  background: var(--yellow);
}

.mascot-orbit::after {
  bottom: 25px;
  left: 7px;
  transform: rotate(-22deg);
  background: var(--blue);
}

.brain-mascot {
  position: relative;
  width: 182px;
  height: 155px;
  transform: rotate(-4deg);
  border: 4px solid var(--ink);
  border-radius: 47% 53% 45% 49% / 54% 48% 52% 46%;
  background: var(--coral);
  box-shadow: 8px 9px 0 var(--yellow);
  animation: mascot-bob 3.5s ease-in-out infinite;
}

.brain-mascot::before,
.brain-mascot::after {
  position: absolute;
  top: 45px;
  width: 18px;
  height: 27px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
  content: "";
}

.brain-mascot::before {
  left: 48px;
}

.brain-mascot::after {
  right: 48px;
}

.mascot-pupils {
  position: absolute;
  top: 55px;
  left: 58px;
  width: 8px;
  height: 10px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 57px 0 0 var(--ink);
}

.mascot-smile {
  position: absolute;
  bottom: 35px;
  left: 50%;
  width: 48px;
  height: 22px;
  transform: translateX(-50%);
  border-bottom: 4px solid var(--ink);
  border-radius: 0 0 50% 50%;
}

.mascot-bolt {
  position: absolute;
  top: -30px;
  left: 50%;
  width: 42px;
  height: 54px;
  transform: translateX(-50%) rotate(7deg);
  clip-path: polygon(52% 0, 100% 0, 67% 36%, 91% 36%, 23% 100%, 39% 51%, 12% 51%);
  background: var(--yellow);
  filter: drop-shadow(3px 3px 0 var(--ink));
}

.machine-score {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.machine-score > div {
  padding: 12px 14px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.08);
}

.machine-score small {
  display: block;
  margin-bottom: 2px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.machine-score strong {
  font-family: "Bowlby One", sans-serif;
  font-size: 24px;
  font-weight: 400;
}

.sticker {
  position: absolute;
  z-index: 4;
  display: grid;
  place-items: center;
  border: var(--border);
  background: var(--white);
  box-shadow: var(--shadow-sm);
  font-weight: 1000;
}

.sticker-streak {
  top: 0;
  right: -5px;
  width: 96px;
  height: 74px;
  transform: rotate(8deg);
  border-radius: 44% 56% 46% 54%;
  background: var(--yellow);
  font-size: 13px;
  line-height: 1.1;
  text-align: center;
}

.sticker-streak strong {
  display: block;
  font-family: "Bowlby One", sans-serif;
  font-size: 23px;
  font-weight: 400;
}

.sticker-xp {
  bottom: 2px;
  left: -25px;
  padding: 12px 15px;
  transform: rotate(-8deg);
  border-radius: 12px;
  background: var(--mint);
  font-size: 13px;
}

.section-block {
  margin-top: clamp(52px, 8vw, 104px);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.section-head h2 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 44px);
}

.section-head p {
  max-width: 480px;
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 0;
  border: 0;
  border-bottom: 3px solid var(--coral);
  background: transparent;
  color: var(--ink);
  font-weight: 1000;
  cursor: pointer;
}

.set-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.set-card {
  position: relative;
  display: flex;
  min-height: 265px;
  flex-direction: column;
  padding: 20px;
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.set-card:hover {
  transform: translate(-2px, -4px) rotate(-0.3deg);
  box-shadow: 9px 11px 0 var(--ink);
}

.set-card::after {
  position: absolute;
  top: -46px;
  right: -42px;
  width: 130px;
  height: 130px;
  border: 3px solid var(--ink);
  border-radius: 50%;
  background: var(--set-color, var(--yellow));
  content: "";
}

.set-card-top {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.set-icon {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  transform: rotate(-3deg);
  border: var(--border);
  border-radius: 17px;
  background: var(--set-color, var(--yellow));
  box-shadow: var(--shadow-sm);
  font-size: 28px;
}

.card-menu {
  position: relative;
  z-index: 4;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--white);
  font-size: 20px;
  font-weight: 1000;
  cursor: pointer;
}

.set-card h3 {
  margin: 22px 0 7px;
  font-family: "Bowlby One", sans-serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.set-subject {
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.set-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
}

.set-meta {
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mini-progress {
  width: 66px;
  height: 8px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-2);
}

.mini-progress i {
  display: block;
  height: 100%;
  background: var(--set-color, var(--mint));
}

.create-card {
  display: grid;
  min-height: 265px;
  place-items: center;
  padding: 28px;
  border: 3px dashed var(--ink);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
  cursor: pointer;
  transition: 180ms ease;
}

.create-card:hover {
  transform: rotate(1deg);
  background: var(--yellow);
}

.create-card-icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  place-items: center;
  border: var(--border);
  border-radius: 50%;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.create-card-icon svg {
  width: 28px;
}

.create-card strong {
  display: block;
  font-family: "Bowlby One", sans-serif;
  font-size: 20px;
  font-weight: 400;
}

.create-card small {
  color: var(--muted);
  font-weight: 800;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}

.mode-card {
  position: relative;
  min-height: 215px;
  padding: 22px;
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.mode-card:nth-child(1) {
  background: var(--blue);
}

.mode-card:nth-child(2) {
  background: var(--yellow);
}

.mode-card:nth-child(3) {
  background: var(--mint);
}

.mode-number {
  position: absolute;
  right: 12px;
  bottom: -34px;
  opacity: 0.14;
  font-family: "Bowlby One", sans-serif;
  font-size: 130px;
  line-height: 1;
}

.mode-card-icon {
  display: grid;
  width: 48px;
  height: 48px;
  margin-bottom: 25px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 3px 3px 0 var(--ink);
}

.mode-card-icon svg {
  width: 25px;
}

.mode-card h3 {
  position: relative;
  margin-bottom: 6px;
  font-family: "Bowlby One", sans-serif;
  font-size: 24px;
  font-weight: 400;
}

.mode-card p {
  position: relative;
  max-width: 250px;
  margin: 0;
  font-weight: 800;
  line-height: 1.4;
}

.mission-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  margin-top: 72px;
  padding: 18px 22px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--ink);
  box-shadow: 7px 7px 0 var(--yellow);
  color: var(--white);
}

.mission-icon {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border: 2px solid var(--white);
  border-radius: 15px;
  background: var(--coral);
  font-size: 26px;
}

.mission-copy strong {
  display: block;
  margin-bottom: 3px;
  font-size: 17px;
}

.mission-copy span {
  color: rgba(255, 255, 255, 0.66);
  font-size: 13px;
  font-weight: 700;
}

.mission-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 260px;
}

.mission-bar {
  flex: 1;
  height: 13px;
  overflow: hidden;
  border: 2px solid var(--white);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
}

.mission-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--yellow);
}

.mission-progress strong {
  min-width: 42px;
  font-size: 13px;
}

/* Library and shared page headings */
.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.page-heading h1 {
  margin-bottom: 8px;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1;
}

.page-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 520px;
}

.search-box > span {
  position: absolute;
  top: 50%;
  left: 15px;
  width: 21px;
  height: 21px;
  transform: translateY(-50%);
}

.search-box input,
.select-control,
.field input,
.field textarea,
.field select {
  width: 100%;
  border: var(--border);
  border-radius: 13px;
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
}

.search-box input {
  height: 52px;
  padding: 0 18px 0 48px;
  box-shadow: var(--shadow-sm);
}

.select-control {
  width: auto;
  height: 52px;
  padding: 0 40px 0 15px;
  box-shadow: var(--shadow-sm);
}

.empty-state {
  display: grid;
  min-height: 380px;
  place-items: center;
  padding: 40px;
  border: 3px dashed var(--ink);
  border-radius: var(--radius-lg);
  text-align: center;
}

.empty-state-graphic {
  display: grid;
  width: 110px;
  height: 110px;
  margin: 0 auto 20px;
  place-items: center;
  transform: rotate(-5deg);
  border: var(--border);
  border-radius: 35% 65% 42% 58%;
  background: var(--yellow);
  box-shadow: var(--shadow);
  font-size: 48px;
}

.empty-state h2 {
  font-size: 28px;
}

/* Set detail */
.back-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 25px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 1000;
  cursor: pointer;
}

.set-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: end;
  padding: clamp(25px, 5vw, 48px);
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--set-color, var(--yellow));
  box-shadow: var(--shadow-lg);
}

.set-hero::after {
  position: absolute;
  top: -120px;
  right: -60px;
  width: 350px;
  height: 350px;
  border: 4px solid var(--ink);
  border-radius: 50%;
  opacity: 0.16;
  content: "";
}

.set-hero-content {
  position: relative;
  z-index: 2;
}

.set-hero-icon {
  display: grid;
  width: 72px;
  height: 72px;
  margin-bottom: 22px;
  place-items: center;
  transform: rotate(-5deg);
  border: var(--border);
  border-radius: 20px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  font-size: 34px;
}

.set-hero h1 {
  max-width: 750px;
  margin-bottom: 10px;
  font-size: clamp(38px, 6vw, 68px);
  line-height: 1;
}

.set-hero p {
  margin: 0;
  font-weight: 900;
}

.set-hero-actions {
  position: relative;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.mode-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-top: 52px;
}

.play-mode {
  position: relative;
  min-height: 220px;
  padding: 23px;
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  transition: 180ms ease;
}

.play-mode:hover {
  transform: translateY(-5px);
  box-shadow: 7px 11px 0 var(--ink);
}

.play-mode .mode-badge {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 24px;
  place-items: center;
  border: var(--border);
  border-radius: 15px;
  box-shadow: var(--shadow-sm);
}

.play-mode:nth-child(1) .mode-badge {
  background: var(--blue);
}

.play-mode:nth-child(2) .mode-badge {
  background: var(--yellow);
}

.play-mode:nth-child(3) .mode-badge {
  background: var(--mint);
}

.play-mode .mode-badge svg {
  width: 26px;
}

.play-mode h3 {
  margin-bottom: 7px;
  font-family: "Bowlby One", sans-serif;
  font-size: 22px;
  font-weight: 400;
}

.play-mode p {
  margin-bottom: 18px;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.45;
}

.play-mode strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
}

.question-list {
  display: grid;
  gap: 12px;
  margin-top: 50px;
}

.question-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.question-list-head h2 {
  margin: 0;
  font-size: 30px;
}

.question-preview {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 16px 18px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--white);
}

.question-number {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--paper-2);
  font-weight: 1000;
}

.question-preview strong {
  display: block;
  line-height: 1.35;
}

.question-preview small {
  color: var(--mint-dark);
  font-weight: 900;
}

.choice-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

/* Builder */
.builder-view {
  width: min(1040px, calc(100% - 36px));
}

.builder-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.builder-topbar h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 52px);
}

.builder-actions {
  display: flex;
  gap: 10px;
}

.builder-panel {
  margin-bottom: 24px;
  padding: clamp(20px, 4vw, 32px);
  border: var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.builder-meta-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label,
.field > span {
  font-size: 13px;
  font-weight: 1000;
}

.field input,
.field textarea,
.field select {
  min-height: 50px;
  padding: 11px 14px;
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.color-swatch {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 10px;
  background: var(--swatch);
  cursor: pointer;
  transition: 150ms ease;
}

.color-swatch.is-selected {
  transform: translateY(-4px) rotate(-4deg);
  box-shadow: var(--shadow-sm);
}

.builder-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.builder-section-head h2 {
  margin: 0;
  font-size: 26px;
}

.question-editor-list {
  display: grid;
  gap: 18px;
}

.question-editor {
  position: relative;
  padding: 22px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: var(--paper);
}

.question-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.question-editor-head strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

.question-editor-head strong span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--yellow);
}

.remove-question {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 9px;
  background: var(--white);
  cursor: pointer;
}

.answer-editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.answer-field {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 2px solid var(--ink);
  border-radius: 12px;
  background: var(--white);
}

.answer-field input[type="radio"] {
  width: 19px;
  height: 19px;
  accent-color: var(--mint-dark);
}

.answer-field input[type="text"] {
  min-width: 0;
  padding: 4px;
  border: 0;
  outline: 0;
  background: transparent;
  font-weight: 800;
}

.answer-field:has(input[type="radio"]:checked) {
  background: #dff8ed;
  box-shadow: inset 5px 0 0 var(--mint);
}

.answer-hint {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.add-question-wide {
  width: 100%;
  margin-top: 18px;
  border-style: dashed;
  box-shadow: none;
}

/* Game */
.game-shell {
  min-height: calc(100vh - 82px);
  padding: 24px clamp(16px, 4vw, 48px) 54px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--ink);
  background-size: 32px 32px;
  color: var(--white);
}

.is-playing .topbar,
.is-playing .mobile-nav {
  display: none;
}

.is-playing .game-shell {
  min-height: 100vh;
}

.game-topbar {
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 24px;
  width: min(1080px, 100%);
  margin: 0 auto 42px;
}

.quit-game {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.56);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  cursor: pointer;
}

.game-progress-wrap {
  display: flex;
  align-items: center;
  gap: 13px;
}

.game-progress {
  flex: 1;
  height: 14px;
  overflow: hidden;
  border: 2px solid var(--white);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.game-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--yellow);
  transition: width 300ms ease;
}

.game-progress-wrap span {
  min-width: 48px;
  font-size: 13px;
  font-weight: 1000;
}

.game-stats {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-stat {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 7px 11px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 1000;
}

.game-stat.timer.is-low {
  border-color: var(--coral);
  background: rgba(255, 107, 87, 0.18);
  color: #ff9d91;
  animation: pulse 700ms ease-in-out infinite alternate;
}

.question-stage {
  width: min(920px, 100%);
  margin: 0 auto;
}

.question-context {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.question-card-game {
  position: relative;
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: clamp(28px, 6vw, 62px);
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 8px 8px 0 var(--coral);
  color: var(--ink);
  text-align: center;
  animation: question-in 330ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.question-card-game::before {
  position: absolute;
  top: 13px;
  left: 16px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 18px 0 0 var(--yellow), 36px 0 0 var(--mint);
  content: "";
}

.question-card-game h1 {
  margin: 0;
  font-family: "Nunito", sans-serif;
  font-size: clamp(25px, 4.5vw, 43px);
  font-weight: 1000;
  letter-spacing: -0.025em;
  line-height: 1.22;
}

.answer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 24px;
}

.answer-choice {
  position: relative;
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  min-height: 84px;
  gap: 14px;
  padding: 14px 18px;
  border: 3px solid var(--ink);
  border-radius: 17px;
  background: var(--white);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.45);
  color: var(--ink);
  font-weight: 900;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.answer-choice:nth-child(1) .answer-key {
  background: var(--coral);
}

.answer-choice:nth-child(2) .answer-key {
  background: var(--blue);
}

.answer-choice:nth-child(3) .answer-key {
  background: var(--yellow);
}

.answer-choice:nth-child(4) .answer-key {
  background: var(--mint);
}

.answer-choice:hover:not(:disabled) {
  transform: translate(-2px, -3px);
  box-shadow: 8px 9px 0 rgba(0, 0, 0, 0.48);
}

.answer-choice:active:not(:disabled) {
  transform: translate(3px, 3px);
  box-shadow: none;
}

.answer-choice:disabled {
  cursor: default;
}

.answer-choice.is-dimmed {
  opacity: 0.28;
}

.answer-choice.is-correct {
  background: #d8f8e9;
  box-shadow: 5px 5px 0 var(--mint);
}

.answer-choice.is-wrong {
  background: #ffe0dc;
  box-shadow: 5px 5px 0 var(--coral);
}

.answer-key {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 10px;
  font-family: "Bowlby One", sans-serif;
  font-size: 15px;
  font-weight: 400;
}

.game-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  margin-top: 22px;
}

.powerup {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 2px solid rgba(255, 255, 255, 0.48);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.09);
  color: var(--white);
  font-weight: 900;
  cursor: pointer;
}

.powerup:disabled {
  opacity: 0.35;
  cursor: default;
}

.powerup-badge {
  display: grid;
  min-width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 7px;
  background: var(--yellow);
  color: var(--ink);
  font-size: 11px;
}

.feedback-panel {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 17px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
}

.feedback-panel.is-visible {
  display: flex;
  animation: feedback-in 220ms ease both;
}

.feedback-copy strong {
  display: block;
  margin-bottom: 2px;
  font-size: 17px;
}

.feedback-copy span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 700;
}

.feedback-copy.is-correct strong {
  color: #8ff0c6;
}

.feedback-copy.is-wrong strong {
  color: #ff9f94;
}

.next-question {
  min-width: 120px;
  background: var(--yellow);
}

.streak-pop {
  position: fixed;
  top: 120px;
  left: 50%;
  z-index: 80;
  transform: translateX(-50%) rotate(-3deg);
  padding: 10px 16px;
  border: var(--border);
  border-radius: 12px;
  background: var(--yellow);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-family: "Bowlby One", sans-serif;
  animation: pop-float 1100ms ease both;
}

/* Results */
.results-view {
  width: min(980px, calc(100% - 36px));
  margin: 0 auto;
  padding: 54px 0 100px;
}

.results-hero {
  position: relative;
  padding: clamp(32px, 6vw, 65px);
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius-lg);
  background: var(--yellow);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.results-burst {
  display: grid;
  width: 108px;
  height: 108px;
  margin: 0 auto 24px;
  place-items: center;
  transform: rotate(-5deg);
  clip-path: polygon(50% 0%, 61% 16%, 78% 7%, 82% 27%, 100% 29%, 88% 47%, 100% 61%, 80% 68%, 80% 90%, 59% 82%, 48% 100%, 37% 82%, 17% 92%, 17% 70%, 0 62%, 12% 46%, 0 29%, 21% 26%, 23% 6%, 40% 16%);
  background: var(--coral);
  color: var(--white);
  font-size: 43px;
}

.results-hero h1 {
  margin-bottom: 10px;
  font-size: clamp(40px, 7vw, 70px);
  line-height: 1;
}

.results-hero > p {
  margin-bottom: 30px;
  font-size: 18px;
  font-weight: 800;
}

.results-stats {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.result-stat {
  padding: 16px 10px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.result-stat strong {
  display: block;
  font-family: "Bowlby One", sans-serif;
  font-size: 28px;
  font-weight: 400;
}

.result-stat small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 32px;
}

.review-panel {
  margin-top: 48px;
}

.review-panel h2 {
  font-size: 30px;
}

.review-list {
  display: grid;
  gap: 12px;
}

.review-item {
  padding: 17px 19px;
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: var(--white);
}

.review-item > span {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--coral-dark);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.review-item strong {
  display: block;
  margin-bottom: 7px;
}

.review-item p {
  margin: 0;
  color: var(--mint-dark);
  font-size: 14px;
  font-weight: 900;
}

/* Progress dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 30px;
}

.stat-card {
  position: relative;
  min-height: 150px;
  padding: 20px;
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.stat-card:nth-child(1) { background: var(--yellow); }
.stat-card:nth-child(2) { background: var(--mint); }
.stat-card:nth-child(3) { background: var(--blue); }
.stat-card:nth-child(4) { background: var(--coral); color: var(--white); }

.stat-card > span {
  display: block;
  margin-bottom: 18px;
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  font-family: "Bowlby One", sans-serif;
  font-size: clamp(30px, 4vw, 42px);
  font-weight: 400;
  line-height: 1;
}

.stat-card small {
  display: block;
  margin-top: 6px;
  font-weight: 800;
  opacity: 0.7;
}

.progress-layout {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 24px;
}

.progress-panel {
  padding: 25px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.progress-panel h2 {
  margin-bottom: 5px;
  font-size: 26px;
}

.progress-panel > p {
  color: var(--muted);
  font-weight: 700;
}

.mastery-list {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.mastery-row-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 1000;
}

.mastery-bar {
  height: 15px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-2);
}

.mastery-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--bar-color, var(--mint));
}

.activity-list {
  display: grid;
  gap: 12px;
  margin-top: 20px;
}

.activity-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 2px dashed var(--paper-2);
}

.activity-icon {
  display: grid;
  width: 39px;
  height: 39px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: var(--yellow);
}

.activity-copy strong {
  display: block;
  font-size: 13px;
}

.activity-copy small {
  color: var(--muted);
  font-weight: 700;
}

.activity-score {
  font-family: "Bowlby One", sans-serif;
  font-size: 16px;
}

.level-card {
  position: relative;
  margin-top: 24px;
  padding: 24px;
  overflow: hidden;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--ink);
  box-shadow: 7px 7px 0 var(--coral);
  color: var(--white);
}

.level-card::after {
  position: absolute;
  right: -27px;
  bottom: -40px;
  font-family: "Bowlby One", sans-serif;
  font-size: 130px;
  color: rgba(255, 255, 255, 0.06);
  content: attr(data-level);
}

.level-card strong {
  display: block;
  margin-bottom: 5px;
  font-family: "Bowlby One", sans-serif;
  font-size: 25px;
  font-weight: 400;
}

.level-card p {
  color: rgba(255, 255, 255, 0.67);
  font-weight: 700;
}

.level-bar {
  position: relative;
  z-index: 2;
  height: 15px;
  overflow: hidden;
  border: 2px solid var(--white);
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}

.level-bar i {
  display: block;
  height: 100%;
  background: var(--yellow);
}

/* Modals, toasts, menus */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 18, 46, 0.72);
  backdrop-filter: blur(7px);
  animation: fade-in 180ms ease both;
}

.modal {
  width: min(500px, 100%);
  max-height: calc(100vh - 40px);
  padding: 28px;
  overflow-y: auto;
  border: var(--border);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 10px 10px 0 var(--coral);
  animation: modal-in 240ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.modal h2 {
  margin-bottom: 6px;
  font-size: 30px;
}

.modal p {
  color: var(--muted);
  font-weight: 700;
}

.modal-close {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: var(--white);
  cursor: pointer;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.mode-modal-options {
  display: grid;
  gap: 11px;
}

.mode-modal-option {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 13px;
  border: 2px solid var(--ink);
  border-radius: 13px;
  background: var(--white);
  text-align: left;
  cursor: pointer;
  transition: 150ms ease;
}

.mode-modal-option:hover {
  transform: translateX(4px);
  background: var(--yellow);
}

.mode-modal-option .mode-mini-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: var(--blue);
}

.mode-modal-option:nth-child(2) .mode-mini-icon { background: var(--yellow); }
.mode-modal-option:nth-child(3) .mode-mini-icon { background: var(--mint); }

.mode-modal-option strong,
.mode-modal-option small {
  display: block;
}

.mode-modal-option small {
  color: var(--muted);
  font-weight: 700;
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 24px;
  z-index: 400;
  display: grid;
  gap: 10px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 11px;
  max-width: 360px;
  padding: 13px 16px;
  border: var(--border);
  border-radius: 13px;
  background: var(--white);
  box-shadow: var(--shadow);
  font-weight: 900;
  animation: toast-in 250ms ease both;
}

.toast-dot {
  width: 13px;
  height: 13px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--mint);
}

.toast.is-error .toast-dot {
  background: var(--coral);
}

.confetti-root {
  position: fixed;
  inset: 0;
  z-index: 350;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -25px;
  width: 12px;
  height: 19px;
  border: 2px solid var(--ink);
  background: var(--confetti-color);
  animation: confetti-fall var(--fall-duration) cubic-bezier(0.16, 0.7, 0.35, 1) var(--fall-delay) forwards;
}

.context-menu {
  position: fixed;
  z-index: 150;
  display: grid;
  min-width: 160px;
  padding: 6px;
  border: 2px solid var(--ink);
  border-radius: 11px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.context-menu button {
  padding: 9px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.context-menu button:hover {
  background: var(--paper-2);
}

.context-menu button.danger {
  color: var(--coral-dark);
}

.mobile-nav {
  display: none;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes question-in {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes mascot-bob {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50% { transform: rotate(1deg) translateY(-10px); }
}

@keyframes orbit {
  to { transform: rotate(360deg); }
}

@keyframes twinkle {
  0%, 100% { transform: scale(1) rotate(0); }
  50% { transform: scale(1.28) rotate(18deg); }
}

@keyframes pulse {
  to { transform: scale(1.04); }
}

@keyframes feedback-in {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pop-float {
  0% { opacity: 0; transform: translate(-50%, 18px) scale(0.7) rotate(-3deg); }
  25% { opacity: 1; transform: translate(-50%, 0) scale(1.08) rotate(2deg); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -38px) scale(0.95) rotate(-2deg); }
}

@keyframes fade-in { from { opacity: 0; } }

@keyframes modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96) rotate(-1deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes confetti-fall {
  to { transform: translate3d(var(--drift), 110vh, 0) rotate(var(--spin)); }
}

@media (max-width: 1000px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .main-nav {
    display: none;
  }

  .hero-grid {
    grid-template-columns: 1fr 390px;
    gap: 30px;
  }

  .hero-copy h1 {
    font-size: clamp(48px, 7vw, 70px);
  }

  .set-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .progress-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 76px;
  }

  body.is-playing {
    padding-bottom: 0;
  }

  .topbar {
    min-height: 68px;
    padding: 9px 16px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-word {
    font-size: 18px;
  }

  .xp-pill {
    padding: 7px 9px;
  }

  .avatar-button {
    display: none;
  }

  #main-content {
    min-height: calc(100vh - 68px);
  }

  .view {
    width: min(100% - 28px, 620px);
    padding-top: 34px;
    padding-bottom: 50px;
  }

  .hero-grid {
    display: flex;
    min-height: 0;
    flex-direction: column;
  }

  .hero-copy h1 {
    font-size: clamp(45px, 14vw, 68px);
  }

  .hero-copy > p:not(.eyebrow) {
    font-size: 17px;
  }

  .hero-machine {
    width: min(100%, 410px);
    min-height: 410px;
    align-self: center;
  }

  .arcade-card {
    inset: 18px 18px 20px 8px;
  }

  .mascot-orbit {
    width: 220px;
    height: 220px;
  }

  .brain-mascot {
    width: 157px;
    height: 136px;
  }

  .brain-mascot::before { left: 39px; }
  .brain-mascot::after { right: 39px; }
  .mascot-pupils { left: 49px; box-shadow: 51px 0 0 var(--ink); }

  .section-block {
    margin-top: 68px;
  }

  .section-head,
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .set-grid,
  .mode-grid,
  .mode-picker,
  .answer-grid {
    grid-template-columns: 1fr;
  }

  .set-card,
  .create-card {
    min-height: 235px;
  }

  .mission-strip {
    grid-template-columns: auto 1fr;
  }

  .mission-progress {
    grid-column: 1 / -1;
    min-width: 0;
  }

  .page-heading h1 {
    font-size: 45px;
  }

  .page-heading .btn {
    width: 100%;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box,
  .select-control {
    width: 100%;
    max-width: none;
  }

  .set-hero {
    grid-template-columns: 1fr;
  }

  .set-hero-actions {
    justify-content: flex-start;
  }

  .builder-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .builder-actions {
    width: 100%;
  }

  .builder-actions .btn {
    flex: 1;
  }

  .builder-meta-grid,
  .answer-editor-grid {
    grid-template-columns: 1fr;
  }

  .game-shell {
    min-height: calc(100vh - 68px);
    padding: 17px 14px 40px;
  }

  .game-topbar {
    grid-template-columns: auto 1fr;
    gap: 12px;
    margin-bottom: 28px;
  }

  .game-stats {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .question-card-game {
    min-height: 170px;
    padding: 32px 20px;
  }

  .answer-choice {
    min-height: 69px;
  }

  .game-tools {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .powerup {
    align-self: flex-start;
  }

  .feedback-panel.is-visible {
    align-items: stretch;
    flex-direction: column;
  }

  .results-stats {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .question-preview {
    grid-template-columns: 40px 1fr;
  }

  .choice-count {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
    align-items: end;
    height: 72px;
    padding: 8px 12px 7px;
    border-top: var(--border);
    background: rgba(255, 249, 233, 0.96);
    backdrop-filter: blur(12px);
  }

  .mobile-nav-link {
    display: grid;
    justify-items: center;
    gap: 3px;
    padding: 4px;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-weight: 900;
    cursor: pointer;
  }

  .mobile-nav-link.is-active {
    color: var(--ink);
  }

  .mobile-nav-link > span {
    width: 22px;
    height: 22px;
  }

  .mobile-nav-link small {
    font-size: 10px;
  }

  .mobile-create {
    display: grid;
    width: 55px;
    height: 55px;
    justify-self: center;
    place-items: center;
    transform: translateY(-13px) rotate(-3deg);
    border: var(--border);
    border-radius: 17px;
    background: var(--coral);
    box-shadow: var(--shadow-sm);
    color: var(--white);
  }

  .toast-root {
    right: 14px;
    bottom: 90px;
    left: 14px;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 450px) {
  .brand-word {
    font-size: 16px;
  }

  .xp-pill {
    font-size: 13px;
  }

  .xp-spark,
  .xp-pill small {
    display: none;
  }

  .hero-copy h1 {
    font-size: 43px;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .hero-machine {
    min-height: 380px;
  }

  .arcade-card {
    padding: 21px;
  }

  .sticker-streak {
    right: 0;
  }

  .sticker-xp {
    left: -5px;
  }

  .page-heading h1 {
    font-size: 39px;
  }

  .set-card {
    box-shadow: 4px 5px 0 var(--ink);
  }

  .builder-panel,
  .question-editor {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .results-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
