/* ============================================================
   Charlotte · Verb Quest — Conjugation Game
   A clean, flat-with-purpose game UI. Minimal gradients,
   strong hierarchy, tactile interactions, theme-aware.
   Namespace: .cq-*
   ============================================================ */

.cq-root {
  --w: #7c8cff;
  --w-soft: color-mix(in srgb, var(--w) 16%, transparent);
  --w-line: color-mix(in srgb, var(--w) 42%, var(--line));
  --cq-good: var(--brand, #55e69c);
  --cq-bad: var(--danger, #ff6f7d);
  --cq-gold: #ffcf5a;
  --cq-card: color-mix(in srgb, var(--surface-2) 92%, var(--text) 2%);
  --cq-ink: var(--text);
  color: var(--cq-ink);
  display: block;
}

.cq-app {
  display: grid;
  gap: 16px;
  margin-top: 6px;
}

.cq-app * { box-sizing: border-box; }

/* subtle keyframes ------------------------------------------------ */
@keyframes cq-fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cq-pop { 0% { transform: scale(.9); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
@keyframes cq-shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
@keyframes cq-node-pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--w) 45%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
@keyframes cq-ring-fill { from { stroke-dashoffset: var(--dash-full); } to { stroke-dashoffset: var(--dash-target); } }
@keyframes cq-confetti-fall { 0% { transform: translateY(-12%) rotate(0); opacity: 0; } 12% { opacity: 1; } 100% { transform: translateY(560%) rotate(540deg); opacity: 0; } }
@keyframes cq-flame { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* ==========================================================
   TOP BAR (hub)
   ========================================================== */
.cq-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.cq-brand { display: flex; align-items: center; gap: 12px; }

.cq-brand-badge {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-3));
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line));
  color: var(--accent);
  font-size: 1.1rem;
}

.cq-brand h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.01em; }
.cq-brand p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }

/* segmented mode switch */
.cq-modes {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.cq-mode {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: .85rem;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: color .15s ease, background .15s ease;
}
.cq-mode i { font-size: .82em; }
.cq-mode:hover { color: var(--text); }
.cq-mode.active {
  color: var(--text);
  background: var(--surface-3);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--text) 6%, transparent) inset;
}
.cq-mode-dropdown { display: none; }

@media (min-width: 761px) {
  .cq-modes {
    gap: 6px;
    padding: 6px;
    border-radius: 18px;
  }
  .cq-mode {
    min-height: 46px;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: .94rem;
  }
  .cq-mode i { font-size: .9em; }
}

@media (max-width: 760px) {
  .cq-modes { display: none; }
  .cq-app:not([data-view="adventure"]) .cq-stat-streak,
  .cq-app:not([data-view="adventure"]) .cq-stat-roadmap {
    display: none;
  }
  .cq-mode-dropdown {
    position: relative;
    min-width: 0;
    display: block;
    flex: 1 1 250px;
  }
  .cq-mode-dropdown.open { z-index: 210; }
  .cq-mode-dropdown-trigger {
    width: 100%;
    min-height: 56px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 11px;
    padding: 7px 11px;
    border: 1px solid color-mix(in srgb, var(--accent) 52%, var(--line));
    border-radius: 15px;
    color: var(--text);
    background:
      linear-gradient(135deg, color-mix(in srgb, var(--accent) 15%, transparent), transparent 64%),
      var(--cq-card, var(--surface-2));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .07);
    cursor: pointer;
    font: inherit;
    text-align: start;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
  }
  .cq-mode-dropdown-trigger:hover,
  .cq-mode-dropdown-trigger:focus-visible,
  .cq-mode-dropdown.open .cq-mode-dropdown-trigger {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
    outline: none;
  }
  .cq-mode-dropdown-trigger:active { transform: translateY(1px); }
  .cq-mode-dropdown-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--line));
    border-radius: 11px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, var(--surface-3));
  }
  .cq-mode-dropdown-copy {
    min-width: 0;
    display: grid;
    gap: 1px;
  }
  .cq-mode-dropdown-copy small {
    color: var(--muted);
    font-size: .64rem;
    font-weight: 800;
    letter-spacing: .09em;
    text-transform: uppercase;
  }
  .cq-mode-dropdown-copy b {
    overflow: hidden;
    color: var(--text);
    font-size: .96rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cq-mode-dropdown-chevron {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--muted);
    background: color-mix(in srgb, var(--text) 5%, transparent);
    font-size: .72rem;
    transition: transform .18s ease, color .18s ease, background .18s ease;
  }
  .cq-mode-dropdown.open .cq-mode-dropdown-chevron {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    transform: rotate(180deg);
  }
  .cq-mode-dropdown-menu {
    position: fixed;
    z-index: 220;
    inset-block-start: var(--cq-mode-menu-top, 120px);
    right: auto;
    left: var(--cq-mode-menu-left, 16px);
    width: var(--cq-mode-menu-width, calc(100vw - 32px));
    max-width: none;
    margin: 0;
    overflow: hidden;
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
    border-radius: 18px;
    color: var(--text);
    background: color-mix(in srgb, var(--cq-card, var(--surface)) 96%, transparent);
    box-shadow:
      0 24px 60px rgba(0, 0, 0, .38),
      0 0 0 1px color-mix(in srgb, var(--accent) 9%, transparent);
    backdrop-filter: blur(20px) saturate(145%);
    -webkit-backdrop-filter: blur(20px) saturate(145%);
    animation: cq-mode-menu-in .16s ease both;
  }
  .cq-mode-dropdown-menu[hidden] { display: none !important; }
  .cq-mode-dropdown-head {
    padding: 4px 5px 10px;
    border-bottom: 1px solid var(--line);
  }
  .cq-mode-dropdown-head > span {
    display: grid;
    gap: 2px;
  }
  .cq-mode-dropdown-head b { font-size: .9rem; }
  .cq-mode-dropdown-head small {
    color: var(--muted);
    font-size: .7rem;
  }
  .cq-mode-dropdown-options {
    display: grid;
    gap: 6px;
    padding-top: 8px;
  }
  .cq-mode-dropdown-option {
    min-width: 0;
    min-height: 58px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 8px 9px;
    border: 1px solid transparent;
    border-radius: 13px;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: start;
    transition: border-color .13s ease, background .13s ease, transform .13s ease;
  }
  .cq-mode-dropdown-option:hover,
  .cq-mode-dropdown-option:focus-visible {
    border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
    background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
    outline: none;
  }
  .cq-mode-dropdown-option:active { transform: scale(.99); }
  .cq-mode-dropdown-option.is-selected {
    border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  }
  .cq-mode-dropdown-option-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: var(--muted);
    background: var(--surface-2);
  }
  .cq-mode-dropdown-option.is-selected .cq-mode-dropdown-option-icon {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
    background: color-mix(in srgb, var(--accent) 13%, var(--surface-2));
  }
  .cq-mode-dropdown-option > span:nth-child(2) {
    min-width: 0;
    display: grid;
    gap: 2px;
  }
  .cq-mode-dropdown-option b { font-size: .88rem; }
  .cq-mode-dropdown-option small {
    overflow: hidden;
    color: var(--muted);
    font-size: .68rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cq-mode-dropdown-check {
    color: transparent;
    font-size: .72rem;
  }
  .cq-mode-dropdown-option.is-selected .cq-mode-dropdown-check { color: var(--accent); }
  @keyframes cq-mode-menu-in {
    from { opacity: 0; transform: translateY(-5px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}

:root[data-theme="light"] .cq-mode-dropdown-menu {
  background: color-mix(in srgb, #ffffff 96%, transparent);
}

/* stat rail ------------------------------------------------ */
.cq-statrail {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 12px;
}

.cq-stat {
  background: var(--cq-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  display: grid;
  gap: 4px;
  align-content: center;
}

.cq-stat-top { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .74rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.cq-stat-top i { color: var(--accent); }
.cq-stat b { font-size: 1.5rem; line-height: 1; letter-spacing: -.02em; }
.cq-stat small { color: var(--muted); font-size: .76rem; }

.cq-level-bar {
  height: 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
  margin-top: 6px;
}
.cq-level-bar > span {
  display: block; height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}

.cq-stat .cq-flame { color: var(--warn); }
.cq-stat.is-streak b { color: var(--warn); }

/* ==========================================================
   WORLD SELECT
   ========================================================== */
.cq-section-label {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted);
  font-size: .74rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  margin: 4px 2px 0;
}

/* ---- tense selector (Adventure) -------------------------------------- */
.cq-tenses {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 2px 0 2px;
}
.cq-tense {
  appearance: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(140,150,190,.28));
  background: var(--cq-card, var(--surface-2));
  color: var(--text, inherit);
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.cq-tense b { font-size: .9rem; font-weight: 800; line-height: 1.1; }
.cq-tense span { font-size: .66rem; color: var(--muted); text-transform: capitalize; }
.cq-tense:hover { transform: translateY(-1px); border-color: var(--accent); }
.cq-tense.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--cq-card, var(--surface-2)));
  box-shadow: 0 0 0 1px var(--accent) inset;
}

/* tense badge shown on each play prompt */
.cq-prompt-tense {
  display: inline-block; margin-left: 6px;
  padding: 1px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent);
  font-size: .72rem; font-weight: 800; letter-spacing: 0; text-transform: none;
}

.cq-worlds {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.cq-world {
  --w: #7c8cff;
  appearance: none;
  text-align: left;
  cursor: pointer;
  position: relative;
  background: var(--cq-card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  padding-left: 18px;
  display: grid;
  gap: 10px;
  color: var(--text);
  overflow: hidden;
  transition: transform .16s ease, border-color .16s ease, background .16s ease;
}
.cq-world::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--w);
  opacity: .8;
}
.cq-world:hover { transform: translateY(-3px); border-color: var(--w-line); }
.cq-world.active {
  border-color: var(--w-line);
  background: color-mix(in srgb, var(--w) 8%, var(--cq-card));
  box-shadow: 0 10px 30px -14px color-mix(in srgb, var(--w) 60%, transparent);
}
.cq-world.locked { opacity: .55; }
.cq-world.locked:hover { transform: none; }

.cq-world-top { display: flex; align-items: center; justify-content: space-between; }
.cq-world-icon {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--w-soft);
  border: 1px solid var(--w-line);
  color: var(--w);
  font-size: 1rem;
}
.cq-world-lock { color: var(--muted); font-size: .95rem; }

.cq-world-kicker { color: var(--w); font-size: .66rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.cq-world h3 { margin: 0; font-size: 1.02rem; }
.cq-world small { color: var(--muted); font-size: .8rem; line-height: 1.35; display: block; }

.cq-world-foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.cq-world-progress {
  flex: 1;
  height: 6px; border-radius: 999px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
}
.cq-world-progress > span { display: block; height: 100%; background: var(--w); border-radius: inherit; transition: width .5s ease; }
.cq-world-count { font-size: .74rem; font-weight: 800; color: var(--muted); white-space: nowrap; }
.cq-world.active .cq-world-count { color: var(--w); }

/* ==========================================================
   STAGE + SKILL PATH
   ========================================================== */
.cq-stage {
  --w: #7c8cff;
  background: var(--cq-card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  display: grid;
  gap: 18px;
  position: relative;
  overflow: hidden;
  animation: cq-fade-up .3s ease both;
}
.cq-stage::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--w); opacity: .7;
}

.cq-stage-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.cq-stage-head .cq-world-kicker { color: var(--w); }
.cq-stage-head h3 { margin: 4px 0 4px; font-size: 1.5rem; letter-spacing: -.01em; }
.cq-stage-head p { margin: 0; color: var(--muted); font-size: .88rem; max-width: 46ch; }

.cq-stage-reward {
  text-align: right;
  border: 1px solid var(--w-line);
  background: var(--w-soft);
  border-radius: 14px;
  padding: 10px 14px;
}
.cq-stage-reward span { display: block; color: var(--muted); font-size: .72rem; font-weight: 700; }
.cq-stage-reward b { font-size: 1.15rem; color: var(--w); }

/* the path */
.cq-path { display: grid; gap: 0; }

.cq-level {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.cq-level-spine {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 92px;
}
.cq-connector {
  position: absolute;
  left: 50%; transform: translateX(-50%);
  width: 4px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
  border-radius: 999px;
}
.cq-connector.top { top: 0; height: 50%; }
.cq-connector.bottom { bottom: 0; height: 50%; }
.cq-connector.done { background: var(--w); }

.cq-node {
  appearance: none;
  position: relative;
  z-index: 2;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  font-weight: 800;
  font-size: 1rem;
  border: 2px solid transparent;
  background: var(--surface-3);
  color: var(--muted);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}
.cq-node:hover:not(.locked) { transform: scale(1.08); }
.cq-node.locked { cursor: not-allowed; color: color-mix(in srgb, var(--muted) 70%, transparent); }

.cq-node.unlocked {
  background: color-mix(in srgb, var(--w) 14%, var(--surface-3));
  border-color: var(--w-line);
  color: var(--w);
}
.cq-node.current {
  background: var(--w);
  color: #0b0d12;
  border-color: color-mix(in srgb, var(--w) 60%, #fff);
  animation: cq-node-pulse 2s ease-in-out infinite;
}
.cq-node.completed {
  background: var(--w);
  color: #0b0d12;
  border-color: color-mix(in srgb, var(--w) 55%, #fff);
}
.cq-node.boss {
  width: 60px; height: 60px;
  border-radius: 16px;
  font-size: 1.2rem;
}
.cq-node.boss.locked { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.cq-node.boss.unlocked, .cq-node.boss.current, .cq-node.boss.completed { color: var(--cq-gold); }
.cq-node.boss.current, .cq-node.boss.completed { background: color-mix(in srgb, var(--cq-gold) 20%, var(--surface-3)); border-color: color-mix(in srgb, var(--cq-gold) 55%, transparent); }

.cq-level-card {
  align-self: center;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px 16px;
  display: grid;
  gap: 3px;
  transition: border-color .15s ease, transform .15s ease;
  margin: 8px 0;
}
.cq-level.is-open .cq-level-card { border-color: var(--w-line); cursor: pointer; }
.cq-level.is-open .cq-level-card:hover { transform: translateX(3px); }
.cq-level.is-locked .cq-level-card { opacity: .6; }

.cq-level-type { font-size: .66rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.cq-level.is-open .cq-level-type { color: var(--w); }
.cq-level-card b { font-size: 1.02rem; }
.cq-level-status { color: var(--muted); font-size: .8rem; display: flex; align-items: center; gap: 8px; }

.cq-stars { display: inline-flex; gap: 3px; }
.cq-stars i { color: color-mix(in srgb, var(--muted) 55%, transparent); font-size: .78rem; }
.cq-stars i.on { color: var(--cq-gold); }

/* ==========================================================
   BADGES STRIP
   ========================================================== */
.cq-badges {
  background: var(--cq-card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px 18px;
}
.cq-badges h4 { margin: 0 0 12px; font-size: .95rem; }
.cq-badge-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cq-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: .82rem; font-weight: 600;
  color: var(--muted);
}
.cq-badge.unlocked {
  color: var(--text);
  border-color: color-mix(in srgb, var(--cq-gold) 40%, var(--line));
  background: color-mix(in srgb, var(--cq-gold) 10%, var(--surface-2));
}
.cq-badge.unlocked i { color: var(--cq-gold); }

/* ==========================================================
   CUSTOM PRACTICE
   ========================================================== */
.cq-panel {
  background: var(--cq-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 22px;
  animation: cq-fade-up .3s ease both;
}
.cq-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cq-panel-head h3 { margin: 0 0 4px; font-size: 1.3rem; }
.cq-panel-head p { margin: 0; color: var(--muted); font-size: .88rem; }

.cq-config { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; margin-top: 20px; }
.cq-field > label {
  display: block; color: var(--muted);
  font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  margin-bottom: 9px;
}
.cq-options { display: flex; flex-wrap: wrap; gap: 8px; }
.cq-opt { position: relative; cursor: pointer; }
.cq-opt input { position: absolute; opacity: 0; pointer-events: none; }
.cq-opt span {
  display: inline-flex; align-items: center;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: .86rem; font-weight: 600;
  transition: border-color .14s ease, background .14s ease, color .14s ease;
}
.cq-opt:hover span { border-color: var(--line-strong); }
.cq-opt input:checked + span {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  color: var(--text);
}
.cq-tense-picker { min-width: 0; }
.cq-tense-dropdown { display: none; }

@media (max-width: 760px) {
  .cq-tenses,
  .cq-field-tense .cq-options {
    display: none;
  }
  .cq-tense-dropdown {
    position: relative;
    width: 100%;
    min-width: 0;
    display: block;
  }
  .cq-tense-dropdown.open { z-index: 190; }
  .cq-tense-dropdown-trigger {
    width: 100%;
    min-height: 62px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 8px 13px;
    border: 1px solid color-mix(in srgb, var(--accent) 58%, var(--line));
    border-radius: 16px;
    color: var(--text);
    background:
      linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), transparent 62%),
      var(--cq-card, var(--surface-2));
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, .07),
      0 10px 26px color-mix(in srgb, var(--accent) 12%, transparent);
    cursor: pointer;
    font: inherit;
    text-align: start;
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
  }
  .cq-tense-dropdown-trigger:hover,
  .cq-tense-dropdown-trigger:focus-visible,
  .cq-tense-dropdown.open .cq-tense-dropdown-trigger {
    border-color: var(--accent);
    box-shadow:
      0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent),
      0 12px 28px color-mix(in srgb, var(--accent) 15%, transparent);
    outline: none;
  }
  .cq-tense-dropdown-trigger:active { transform: translateY(1px); }
  .cq-tense-dropdown-icon {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--line));
    border-radius: 12px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 15%, var(--surface-3));
  }
  .cq-tense-dropdown-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
  }
  .cq-tense-dropdown-copy small {
    color: var(--muted);
    font-size: .67rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
  }
  .cq-tense-dropdown-copy b {
    overflow: hidden;
    color: var(--text);
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cq-tense-dropdown-chevron {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    color: var(--muted);
    border-radius: 9px;
    background: color-mix(in srgb, var(--text) 5%, transparent);
    transition: transform .18s ease, color .18s ease, background .18s ease;
  }
  .cq-tense-dropdown.open .cq-tense-dropdown-chevron {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 13%, transparent);
    transform: rotate(180deg);
  }
  .cq-tense-dropdown-menu {
    position: absolute;
    z-index: 180;
    inset-block-start: calc(100% + 8px);
    inset-inline: 0;
    overflow: hidden;
    padding: 10px;
    border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
    border-radius: 18px;
    color: var(--text);
    background: color-mix(in srgb, var(--cq-card, var(--surface)) 96%, transparent);
    box-shadow:
      0 24px 60px rgba(0, 0, 0, .38),
      0 0 0 1px color-mix(in srgb, var(--accent) 9%, transparent);
    backdrop-filter: blur(20px) saturate(145%);
    -webkit-backdrop-filter: blur(20px) saturate(145%);
    animation: cq-tense-menu-in .16s ease both;
  }
  .cq-tense-dropdown-menu[hidden] { display: none !important; }
  .cq-tense-dropdown-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 5px 10px;
    border-bottom: 1px solid var(--line);
  }
  .cq-tense-dropdown-head > span {
    min-width: 0;
    display: grid;
    gap: 2px;
  }
  .cq-tense-dropdown-head b { font-size: .9rem; }
  .cq-tense-dropdown-head small {
    color: var(--muted);
    font-size: .7rem;
  }
  .cq-tense-dropdown-head em {
    min-width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    font-size: .72rem;
    font-style: normal;
    font-weight: 850;
  }
  .cq-tense-dropdown-options {
    max-height: min(350px, 48vh);
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 8px 2px 2px;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--accent) 45%, transparent) transparent;
  }
  .cq-tense-dropdown-option {
    min-width: 0;
    min-height: 52px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 9px;
    padding: 8px 9px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--text-soft);
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: start;
    transition: border-color .13s ease, background .13s ease, transform .13s ease;
  }
  .cq-tense-dropdown-option:hover,
  .cq-tense-dropdown-option:focus-visible {
    border-color: color-mix(in srgb, var(--accent) 32%, var(--line));
    background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
    outline: none;
  }
  .cq-tense-dropdown-option:active { transform: scale(.985); }
  .cq-tense-dropdown-option.is-selected {
    border-color: color-mix(in srgb, var(--accent) 56%, var(--line));
    color: var(--text);
    background: color-mix(in srgb, var(--accent) 15%, var(--surface-2));
  }
  .cq-tense-dropdown-option > span:last-child {
    min-width: 0;
    display: grid;
    gap: 1px;
  }
  .cq-tense-dropdown-option b {
    overflow: hidden;
    font-size: .82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cq-tense-dropdown-option small {
    overflow: hidden;
    color: var(--muted);
    font-size: .66rem;
    text-overflow: ellipsis;
    text-transform: capitalize;
    white-space: nowrap;
  }
  .cq-tense-dropdown-check {
    width: 23px;
    height: 23px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: transparent;
    background: var(--surface-2);
    font-size: .65rem;
  }
  .cq-tense-dropdown-option.is-selected .cq-tense-dropdown-check {
    color: #0b0d12;
    border-color: var(--accent);
    background: var(--accent);
  }
  @keyframes cq-tense-menu-in {
    from { opacity: 0; transform: translateY(-5px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}

@media (max-width: 480px) {
  .cq-tense-dropdown-options {
    grid-template-columns: 1fr;
  }
  .cq-tense-dropdown-menu {
    padding: 9px;
  }
}

:root[data-theme="light"] .cq-tense-dropdown-menu {
  background: color-mix(in srgb, #ffffff 96%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .cq-tense-dropdown-menu,
  .cq-tense-dropdown-chevron,
  .cq-tense-dropdown-trigger,
  .cq-tense-dropdown-option {
    animation: none !important;
    transition: none !important;
  }
}

.cq-btn {
  appearance: none; cursor: pointer;
  font: inherit; font-weight: 700;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform .12s ease, filter .14s ease, background .14s ease, border-color .14s ease;
}
.cq-btn:active { transform: translateY(1px); }
.cq-btn.primary { background: var(--accent); color: #0b0d12; }
.cq-btn.primary:hover { filter: brightness(1.06); }
.cq-btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.cq-btn.ghost:hover { border-color: var(--line-strong); background: color-mix(in srgb, var(--text) 5%, transparent); }
.cq-btn.subtle { background: var(--surface-3); color: var(--text); }
.cq-btn.subtle:hover { filter: brightness(1.08); }
.cq-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; filter: none; }

/* ==========================================================
   MISTAKES
   ========================================================== */
.cq-mistakes { display: grid; gap: 10px; margin-top: 18px; }
.cq-mistake {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--cq-bad);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 13px 16px;
}
.cq-mistake b { font-size: .96rem; }
.cq-mistake p { margin: 3px 0 0; color: var(--muted); font-size: .8rem; }
.cq-mistake .cq-mistake-fix { color: var(--cq-good); }
.cq-empty { color: var(--muted); font-size: .9rem; padding: 8px 2px; }

/* ==========================================================
   PLAY SCREEN
   ========================================================== */
.cq-play {
  --w: #7c8cff;
  background: var(--cq-card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 0;
  overflow: hidden;
  animation: cq-fade-up .25s ease both;
}

.cq-playbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.cq-quit {
  appearance: none; cursor: pointer;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--line);
  color: var(--muted); font-size: .95rem;
  transition: color .14s ease, background .14s ease;
}
.cq-quit:hover { color: var(--text); background: color-mix(in srgb, var(--cq-bad) 16%, var(--surface-3)); }

.cq-dots { display: flex; gap: 6px; align-items: center; }
.cq-dot { flex: 1; height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); transition: background .3s ease; max-width: 46px; }
.cq-dot.done { background: var(--cq-good); }
.cq-dot.wrong { background: var(--cq-bad); }
.cq-dot.current { background: var(--w); }

.cq-play-meta { display: flex; align-items: center; gap: 14px; }
.cq-combo { display: inline-flex; align-items: center; gap: 7px; font-weight: 800; color: var(--warn); }
.cq-combo i { animation: cq-flame 1.1s ease-in-out infinite; }
.cq-combo.hide { visibility: hidden; }
.cq-play-xp { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; color: var(--accent); }

.cq-play-body { padding: 26px 24px 28px; display: grid; gap: 20px; }

.cq-kicker { display: flex; align-items: center; gap: 8px; color: var(--w); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

.cq-prompt {
  text-align: center;
  padding: 24px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--w) 6%, var(--surface));
}
.cq-prompt .cq-prompt-type { color: var(--muted); font-size: .78rem; font-weight: 700; margin-bottom: 12px; }
.cq-prompt h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.01em; line-height: 1.25; }
.cq-prompt .cq-pron { display: inline-block; color: var(--w); font-weight: 800; }
.cq-prompt .cq-verb { color: var(--text); }
.cq-prompt-hint { margin: 12px 0 0; color: var(--muted); font-size: .84rem; }
.cq-blank { display: inline-block; min-width: 90px; border-bottom: 2px dashed var(--w-line); }

/* choices */
.cq-choices { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.cq-choice {
  appearance: none; cursor: pointer;
  font: inherit; font-size: 1.05rem; font-weight: 600;
  text-align: left;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  transition: transform .12s ease, border-color .14s ease, background .14s ease;
}
.cq-choice:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--w-line); }
.cq-choice:disabled { cursor: default; }
.cq-key {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: .78rem; font-weight: 800; color: var(--muted);
}
.cq-choice.correct { border-color: var(--cq-good); background: color-mix(in srgb, var(--cq-good) 14%, var(--surface-2)); animation: cq-pop .3s ease; }
.cq-choice.correct .cq-key { background: var(--cq-good); color: #06231a; border-color: transparent; }
.cq-choice.wrong { border-color: var(--cq-bad); background: color-mix(in srgb, var(--cq-bad) 12%, var(--surface-2)); animation: cq-shake .4s ease; }
.cq-choice.wrong .cq-key { background: var(--cq-bad); color: #2a0a0e; border-color: transparent; }
.cq-choice.dim { opacity: .5; }

/* typing */
.cq-typing { display: grid; gap: 14px; }
.cq-input {
  width: 100%;
  font: inherit; font-size: 1.3rem; font-weight: 600;
  text-align: center;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.cq-input::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); font-weight: 500; }
.cq-input:focus { outline: none; border-color: var(--w-line); box-shadow: 0 0 0 4px var(--w-soft); }
.cq-input.correct { border-color: var(--cq-good); box-shadow: 0 0 0 4px color-mix(in srgb, var(--cq-good) 18%, transparent); }
.cq-input.wrong { border-color: var(--cq-bad); animation: cq-shake .4s ease; }

.cq-accents { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.cq-accent {
  appearance: none; cursor: pointer;
  min-width: 38px; padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-soft);
  font: inherit; font-size: .95rem;
  transition: border-color .12s ease, background .12s ease;
}
.cq-accent:hover { border-color: var(--w-line); background: color-mix(in srgb, var(--w) 10%, var(--surface-2)); }

.cq-submit-row { display: flex; justify-content: center; }
.cq-submit-row .cq-btn { min-width: 180px; justify-content: center; }

/* feedback banner */
.cq-feedback {
  border-radius: 16px;
  padding: 16px 18px;
  display: grid;
  gap: 6px;
  animation: cq-fade-up .22s ease both;
  border: 1px solid var(--line);
}
.cq-feedback.correct { border-color: color-mix(in srgb, var(--cq-good) 45%, transparent); background: color-mix(in srgb, var(--cq-good) 10%, var(--surface)); }
.cq-feedback.wrong { border-color: color-mix(in srgb, var(--cq-bad) 45%, transparent); background: color-mix(in srgb, var(--cq-bad) 8%, var(--surface)); }
.cq-fb-head { display: flex; align-items: center; gap: 10px; }
.cq-fb-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  font-size: .85rem;
}
.cq-feedback.correct .cq-fb-icon { background: var(--cq-good); color: #06231a; }
.cq-feedback.wrong .cq-fb-icon { background: var(--cq-bad); color: #2a0a0e; }
.cq-fb-title { font-weight: 800; font-size: 1rem; }
.cq-feedback.correct .cq-fb-title { color: var(--cq-good); }
.cq-feedback.wrong .cq-fb-title { color: var(--cq-bad); }
.cq-fb-body { color: var(--text-soft); font-size: .88rem; }
.cq-fb-body .cq-sol { color: var(--text); font-weight: 700; }
.cq-fb-explain { color: var(--muted); font-size: .82rem; }
.cq-feedback .cq-btn { justify-self: end; margin-top: 6px; }

/* ==========================================================
   RESULT
   ========================================================== */
.cq-result {
  position: relative;
  overflow: hidden;
  background: var(--cq-card);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 26px;
  text-align: center;
  animation: cq-fade-up .3s ease both;
}
.cq-result-kicker { color: var(--muted); font-size: .74rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.cq-ring-wrap { position: relative; width: 168px; height: 168px; margin: 18px auto 4px; }
.cq-ring { transform: rotate(-90deg); }
.cq-ring-track { fill: none; stroke: color-mix(in srgb, var(--text) 10%, transparent); stroke-width: 12; }
.cq-ring-val { fill: none; stroke: var(--cq-good); stroke-width: 12; stroke-linecap: round; animation: cq-ring-fill 1s cubic-bezier(.2,.8,.2,1) both; }
.cq-ring-center { position: absolute; inset: 0; display: grid; place-content: center; gap: 2px; }
.cq-ring-center b { font-size: 2.3rem; letter-spacing: -.02em; line-height: 1; }
.cq-ring-center span { color: var(--muted); font-size: .78rem; }

.cq-result-stars { display: inline-flex; gap: 8px; margin: 8px 0 4px; }
.cq-result-stars i { font-size: 1.6rem; color: color-mix(in srgb, var(--muted) 45%, transparent); transition: transform .3s ease, color .3s ease; }
.cq-result-stars i.on { color: var(--cq-gold); animation: cq-pop .4s ease both; }
.cq-result-stars i.on:nth-child(2) { animation-delay: .1s; }
.cq-result-stars i.on:nth-child(3) { animation-delay: .2s; }

.cq-result h2 { margin: 10px 0 2px; font-size: 1.5rem; }
.cq-result-sub { color: var(--muted); font-size: .9rem; margin: 0 0 18px; }

.cq-result-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; max-width: 460px; margin: 0 auto 18px; }
.cq-result-tile { border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); padding: 14px; }
.cq-result-tile b { display: block; font-size: 1.4rem; letter-spacing: -.02em; }
.cq-result-tile.xp b { color: var(--accent); }
.cq-result-tile span { color: var(--muted); font-size: .76rem; }

.cq-result-note { color: var(--muted); font-size: .84rem; max-width: 52ch; margin: 0 auto 18px; }
.cq-result-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 18px; }
.cq-result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* confetti */
.cq-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cq-confetti i {
  position: absolute; top: -6%;
  width: 8px; height: 14px; border-radius: 2px;
  animation: cq-confetti-fall linear infinite;
}

/* ==========================================================
   NEXT-LEVEL ADDITIONS
   ========================================================== */

/* top bar right cluster + sound toggle */
.cq-topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cq-sound {
  appearance: none; cursor: pointer; flex: none;
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
  transition: color .14s ease, background .14s ease;
}
.cq-sound:hover { color: var(--text); background: color-mix(in srgb, var(--accent) 14%, var(--surface-3)); }
.cq-sound.off { color: var(--muted-2); }

@media (min-width: 761px) {
  .cq-sound {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    font-size: 1rem;
  }
}

/* (resume banner styles live in the TOP REGION REFRESH section) */

/* practice presets */
.cq-presets { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.cq-preset {
  appearance: none; cursor: pointer; font: inherit; font-weight: 700; font-size: .85rem;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  transition: border-color .14s ease, background .14s ease, transform .12s ease;
}
.cq-preset:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: color-mix(in srgb, var(--accent) 10%, var(--surface-2)); transform: translateY(-2px); }
.cq-preset i { color: var(--accent); }

/* play HUD — multiplier + speed bar + hint */
.cq-mult {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 800; font-size: .84rem;
  padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
}
.cq-mult.hide { display: none; }
.cq-combo.fire { text-shadow: 0 0 14px color-mix(in srgb, var(--warn) 65%, transparent); }

.cq-speedbar {
  height: 4px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  overflow: hidden;
}
.cq-speedbar > span {
  display: block; height: 100%; width: 100%;
  transform-origin: left center;
  background: linear-gradient(90deg, var(--w), var(--warn));
  animation: cq-speed linear forwards;
}
@keyframes cq-speed { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.cq-hint { text-align: center; color: var(--muted-2); font-size: .76rem; }
.cq-hint kbd {
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 6px; font-size: .72rem; font-family: inherit;
}

/* question entrance transition */
.cq-play-body .cq-prompt { animation: cq-slide-in .3s cubic-bezier(.2,.8,.2,1) both; }
.cq-play-body #cq-answer-area { animation: cq-slide-in .3s cubic-bezier(.2,.8,.2,1) .06s both; }
@keyframes cq-slide-in { from { opacity: 0; transform: translateX(26px); } to { opacity: 1; transform: none; } }

/* feedback chips */
.cq-fb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cq-chip { font-size: .74rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.cq-chip.mult { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.cq-chip.speed { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.cq-chip.streak { background: color-mix(in srgb, var(--cq-good) 16%, transparent); color: var(--cq-good); }

/* result: level-up, bonus, answer review */
.cq-levelup {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 0 auto 16px; padding: 9px 16px; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line));
  color: var(--accent); font-weight: 800;
  animation: cq-pop .5s ease both;
}
.cq-result-tile .cq-bonus { display: block; font-size: .68rem; color: var(--warn); font-weight: 800; margin-top: 3px; }

.cq-review {
  max-width: 520px; margin: 0 auto 20px; text-align: left;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-2); overflow: hidden;
}
.cq-review summary {
  cursor: pointer; padding: 12px 16px; font-weight: 700; font-size: .88rem;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
}
.cq-review summary::-webkit-details-marker { display: none; }
.cq-review summary::after { content: "\203A"; font-size: 1.1rem; color: var(--muted); transform: rotate(90deg); transition: transform .18s ease; }
.cq-review[open] summary::after { transform: rotate(-90deg); }
.cq-review-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  padding: 10px 16px; border-top: 1px solid var(--line); font-size: .85rem;
}
.cq-review-row i { font-size: .8rem; }
.cq-review-row.ok i { color: var(--cq-good); }
.cq-review-row.no i { color: var(--cq-bad); }
.cq-review-q { color: var(--muted); }
.cq-review-a { text-align: right; font-weight: 600; word-break: break-word; }
.cq-review-a s { color: var(--muted); font-weight: 400; margin-right: 5px; }

/* ==========================================================
   TOP REGION REFRESH — stat cards + resume banner
   ========================================================== */
.cq-statrail { grid-template-columns: 1.5fr repeat(3, minmax(0, 1fr)); }

.cq-stat {
  --sc: var(--accent);
  display: block;
  position: relative;
  overflow: hidden;
}
.cq-stat-row { display: flex; align-items: center; gap: 12px; }
.cq-stat-icon {
  flex: none;
  display: grid; place-items: center;
  color: var(--sc); font-size: 1.35rem;
}
.cq-stat-value { font-size: 1.55rem; line-height: 1; letter-spacing: -.02em; }
.cq-stat-label { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; margin-top: 8px; }
.cq-stat-chip {
  margin-left: auto;
  font-size: .7rem; font-weight: 800; padding: 3px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--sc) 16%, transparent);
  color: var(--sc);
  border: 1px solid color-mix(in srgb, var(--sc) 34%, var(--line));
}
.cq-stat-bar { height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; margin-top: 14px; }
.cq-stat-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--sc); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.cq-stat > small { display: block; margin-top: 8px; color: var(--muted); font-size: .74rem; }

/* resume banner */
.cq-resume {
  --w: var(--accent);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  background: color-mix(in srgb, var(--w) 5%, var(--cq-card));
  border: 1px solid var(--line);
  border-left: 3px solid var(--w);
  border-radius: 18px;
  padding: 16px 18px;
  animation: cq-fade-up .3s ease both;
}
.cq-resume-icon {
  width: 52px; height: 52px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  background: color-mix(in srgb, var(--w) 16%, var(--surface-3));
  border: 1px solid color-mix(in srgb, var(--w) 32%, var(--line));
  color: var(--w); font-size: 1.35rem;
}
.cq-resume-info { display: grid; gap: 3px; min-width: 0; }
.cq-resume-kicker { display: inline-flex; align-items: center; gap: 7px; color: var(--w); font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.cq-resume-info b { font-size: 1.2rem; letter-spacing: -.01em; }
.cq-resume-meta { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: .82rem; }
.cq-resume-meta .dot { width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.cq-resume-boss { color: var(--cq-gold); font-weight: 800; }
.cq-resume-progress { display: grid; gap: 6px; min-width: 150px; }
.cq-resume-bar { height: 7px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; }
.cq-resume-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--w); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.cq-resume-progress small { color: var(--muted); font-size: .72rem; white-space: nowrap; }
.cq-resume-go { font-size: .95rem; padding: 12px 22px; }

@media (max-width: 760px) {
  .cq-resume { grid-template-columns: auto minmax(0, 1fr); }
  .cq-resume-progress { grid-column: 1 / -1; min-width: 0; }
  .cq-resume-go { grid-column: 1 / -1; justify-content: center; }
}

/* ==========================================================
   JUICE — motion & tactile feedback (premium game-feel)
   ========================================================== */

/* answer-feedback particle FX layer */
.cq-play { position: relative; }
.cq-fx { position: absolute; inset: 0; overflow: visible; pointer-events: none; z-index: 6; }
.cq-particle {
  position: absolute; width: 8px; height: 8px; border-radius: 2px;
  transform: translate(-50%, -50%);
  animation: cq-particle .72s cubic-bezier(.2,.7,.3,1) forwards;
}
@keyframes cq-particle {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.4) rotate(160deg); }
}
.cq-float-xp {
  position: absolute; transform: translate(-50%, -50%);
  font-weight: 900; font-size: 1.15rem; color: var(--w);
  text-shadow: 0 2px 10px color-mix(in srgb, var(--w) 45%, transparent);
  animation: cq-float-xp .9s cubic-bezier(.2,.8,.2,1) forwards;
}
@keyframes cq-float-xp {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.8); }
  25% { opacity: 1; transform: translate(-50%, -70%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1); }
}

/* screen-edge feedback flashes on the play card */
.cq-play.cq-hit-combo { animation: cq-edge-combo .6s ease; }
.cq-play.cq-hit-wrong { animation: cq-edge-wrong .42s ease; }
@keyframes cq-edge-combo {
  0%, 100% { box-shadow: 0 0 0 0 transparent inset; }
  45% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--w) 60%, transparent), inset 0 0 44px color-mix(in srgb, var(--w) 26%, transparent); }
}
@keyframes cq-edge-wrong {
  0%, 100% { box-shadow: 0 0 0 0 transparent inset; }
  45% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--cq-bad) 60%, transparent), inset 0 0 40px color-mix(in srgb, var(--cq-bad) 22%, transparent); }
}

/* staggered hub entrance — only when .cq-animate-in is present */
.cq-animate-in .cq-stat,
.cq-animate-in .cq-world,
.cq-animate-in .cq-level {
  animation: cq-fade-up .5s cubic-bezier(.2,.8,.2,1) both;
}
.cq-animate-in .cq-stat:nth-child(1) { animation-delay: .04s; }
.cq-animate-in .cq-stat:nth-child(2) { animation-delay: .09s; }
.cq-animate-in .cq-stat:nth-child(3) { animation-delay: .14s; }
.cq-animate-in .cq-stat:nth-child(4) { animation-delay: .19s; }
.cq-animate-in .cq-world:nth-child(1) { animation-delay: .16s; }
.cq-animate-in .cq-world:nth-child(2) { animation-delay: .22s; }
.cq-animate-in .cq-world:nth-child(3) { animation-delay: .28s; }
.cq-animate-in .cq-world:nth-child(4) { animation-delay: .34s; }
.cq-animate-in .cq-level:nth-child(1) { animation-delay: .30s; }
.cq-animate-in .cq-level:nth-child(2) { animation-delay: .37s; }
.cq-animate-in .cq-level:nth-child(3) { animation-delay: .44s; }
.cq-animate-in .cq-level:nth-child(4) { animation-delay: .51s; }
.cq-animate-in .cq-level:nth-child(5) { animation-delay: .58s; }
.cq-animate-in .cq-level:nth-child(6) { animation-delay: .65s; }

/* "you are here" bobbing marker on the current node */
.cq-node.current::after {
  content: "";
  position: absolute; top: -13px; left: 50%;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--w);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--w) 28%, transparent), 0 2px 6px rgba(0,0,0,.35);
  transform: translateX(-50%);
  animation: cq-bob 1.5s ease-in-out infinite;
}
@keyframes cq-bob { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -5px); } }

/* springier presses + node hover */
.cq-btn:active { transform: translateY(1px) scale(.98); }
.cq-choice:active:not(:disabled) { transform: translateY(0) scale(.99); }
.cq-node:hover:not(.locked) { transform: scale(1.1); box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--w) 60%, transparent); }
.cq-resume-go { animation: cq-cta-pulse 2.6s ease-in-out infinite; }
@keyframes cq-cta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 30%, transparent); }
  50% { box-shadow: 0 0 0 6px transparent; }
}

@media (prefers-reduced-motion: reduce) {
  .cq-particle, .cq-float-xp, .cq-node.current::after, .cq-resume-go { animation: none !important; }
}

/* ==========================================================
   WORLD THEMING — a distinct mood per realm (subtle, asset-free)
   ========================================================== */
.cq-stage-motif {
  position: absolute; inset: 0; z-index: 0; pointer-events: none;
  -webkit-mask-image: linear-gradient(180deg, #000 0%, transparent 84%);
  mask-image: linear-gradient(180deg, #000 0%, transparent 84%);
}
.cq-stage > .cq-stage-head,
.cq-stage > .cq-path { position: relative; z-index: 1; }

/* Academy — scholarly graph paper */
.cq-stage[data-world="er-academy"] .cq-stage-motif {
  background-image:
    linear-gradient(color-mix(in srgb, var(--w) 45%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--w) 45%, transparent) 1px, transparent 1px);
  background-size: 30px 30px;
  opacity: .07;
}
/* Forest — soft organic canopy glows */
.cq-stage[data-world="ir-forest"] .cq-stage-motif {
  background-image:
    radial-gradient(circle at 12% 18%, color-mix(in srgb, var(--w) 34%, transparent), transparent 12%),
    radial-gradient(circle at 82% 12%, color-mix(in srgb, var(--w) 26%, transparent), transparent 10%),
    radial-gradient(circle at 68% 62%, color-mix(in srgb, var(--w) 22%, transparent), transparent 13%),
    radial-gradient(circle at 32% 78%, color-mix(in srgb, var(--w) 20%, transparent), transparent 11%);
  opacity: .5;
}
/* Mountain — diagonal elevation contours */
.cq-stage[data-world="re-mountain"] .cq-stage-motif {
  background-image: repeating-linear-gradient(135deg, color-mix(in srgb, var(--w) 24%, transparent) 0 2px, transparent 2px 24px);
  opacity: .4;
}
/* Castle — stone masonry, higher contrast */
.cq-stage[data-world="irregular-castle"] .cq-stage-motif {
  background-image:
    linear-gradient(color-mix(in srgb, var(--w) 30%, transparent) 2px, transparent 2px),
    linear-gradient(90deg, color-mix(in srgb, var(--w) 20%, transparent) 2px, transparent 2px);
  background-size: 48px 32px;
  opacity: .5;
}

/* ==========================================================
   BOSS ARENA
   ========================================================== */
.cq-play.is-boss { border-color: color-mix(in srgb, var(--cq-bad) 26%, var(--line)); }
.cq-play.is-boss .cq-playbar { border-bottom-color: color-mix(in srgb, var(--cq-bad) 20%, var(--line)); }
.cq-boss {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  background: color-mix(in srgb, var(--cq-bad) 8%, var(--surface));
  border-bottom: 1px solid var(--line);
  animation: cq-fade-up .3s ease both;
}
.cq-boss-avatar {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--cq-bad) 18%, var(--surface-3));
  border: 1px solid color-mix(in srgb, var(--cq-bad) 40%, var(--line));
  color: var(--cq-bad); font-size: 1.25rem;
}
.cq-boss-info { flex: 1; min-width: 0; display: grid; gap: 7px; }
.cq-boss-name { font-weight: 800; font-size: .95rem; letter-spacing: .01em; }
.cq-boss-hpbar { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; }
.cq-boss-hpbar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cq-bad), #ff9a6b); transition: width .5s cubic-bezier(.2,.8,.2,1); }
.cq-hearts { display: flex; gap: 6px; flex: none; }
.cq-hearts i { color: var(--cq-bad); font-size: 1.05rem; transition: transform .3s ease, color .3s ease, opacity .3s ease; }
.cq-hearts i.lost { color: color-mix(in srgb, var(--muted) 55%, transparent); opacity: .5; transform: scale(.82); }

/* boss result ribbon */
.cq-boss-ribbon {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 8px auto 2px; padding: 8px 16px; border-radius: 999px; font-weight: 800;
  animation: cq-pop .5s ease both;
}
.cq-boss-ribbon.win { background: color-mix(in srgb, var(--cq-gold) 16%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--cq-gold) 45%, var(--line)); color: var(--cq-gold); }
.cq-boss-ribbon.lose { background: color-mix(in srgb, var(--cq-bad) 12%, var(--surface-2)); border: 1px solid color-mix(in srgb, var(--cq-bad) 40%, var(--line)); color: var(--cq-bad); }

/* ==========================================================
   MASTERY VIEW
   ========================================================== */
.cq-mastery { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 18px; }
.cq-mastery-col { display: grid; gap: 14px; align-content: start; }
.cq-sub { margin: 0; font-size: .72rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 800; }

.cq-fam-list { display: grid; gap: 14px; }
.cq-fam { --w: var(--accent); }
.cq-fam-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.cq-fam-head b { font-size: .95rem; }
.cq-fam-head span { font-weight: 800; color: var(--w); }
.cq-fam-bar { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 8%, transparent); overflow: hidden; }
.cq-fam-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--w); transition: width .6s cubic-bezier(.2,.8,.2,1); }
.cq-fam small { display: block; margin-top: 6px; color: var(--muted); font-size: .76rem; }

.cq-mastery-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 4px; }
.cq-mini-tile { border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); padding: 12px 14px; }
.cq-mini-tile b { display: block; font-size: 1.3rem; letter-spacing: -.02em; }
.cq-mini-tile span { color: var(--muted); font-size: .74rem; }

.cq-heat { display: grid; grid-template-columns: 46px repeat(4, 1fr); gap: 6px; align-items: center; }
.cq-heat-col { text-align: center; font-size: .74rem; font-weight: 800; color: var(--muted); }
.cq-heat-row-label { font-size: .8rem; color: var(--muted); font-weight: 700; }
.cq-heat-cell {
  min-height: 40px;
  display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 800; font-size: .85rem; color: var(--text);
}
.cq-heat-cell.hot { border-color: color-mix(in srgb, var(--cq-bad) 35%, var(--line)); }
.cq-heat-legend { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .76rem; }
.cq-heat-ramp { flex: 1; height: 8px; border-radius: 999px; background: linear-gradient(90deg, var(--surface-2), var(--cq-bad)); border: 1px solid var(--line); }

/* ==========================================================
   LIGHT-THEME PASS
   ========================================================== */
:root[data-theme="light"] .cq-root { --cq-card: #ffffff; }
:root[data-theme="light"] .cq-btn.primary { color: #ffffff; }
:root[data-theme="light"] .cq-brand-badge,
:root[data-theme="light"] .cq-world-icon { box-shadow: none; }
:root[data-theme="light"] .cq-level-card { background: var(--surface); }
:root[data-theme="light"] .cq-prompt { background: color-mix(in srgb, var(--w) 5%, var(--surface)); }
:root[data-theme="light"] .cq-choice,
:root[data-theme="light"] .cq-mini-tile,
:root[data-theme="light"] .cq-heat-cell,
:root[data-theme="light"] .cq-opt span,
:root[data-theme="light"] .cq-preset,
:root[data-theme="light"] .cq-badge { background: #ffffff; }
:root[data-theme="light"] .cq-node { background: var(--surface-3); }
:root[data-theme="light"] .cq-boss { background: color-mix(in srgb, var(--cq-bad) 6%, var(--surface)); }
/* keep dark ink on saturated fills legible in light mode too (world accents are fixed hues) */
:root[data-theme="light"] .cq-node.current,
:root[data-theme="light"] .cq-node.completed { color: #0b0d12; }

/* ==========================================================
   Challenges page CTA (preserved from old markup)
   ========================================================== */
.challenge-conj-panel { margin-top: 10px; }
.challenge-conj-cta {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  text-align: left;
  width: 100%;
}
.challenge-conj-cta img { height: 50px; width: 50px; object-fit: contain; }
.challenge-conj-progress { display: grid; gap: 8px; margin-top: 12px; }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 860px) {
  .cq-statrail { grid-template-columns: 1fr 1fr; }
  .cq-worlds { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .cq-config { grid-template-columns: 1fr; }
  .cq-choices { grid-template-columns: 1fr; }
  .cq-mastery { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cq-topbar { flex-direction: column; align-items: stretch; }
  .cq-topbar-right { justify-content: space-between; }
  .cq-modes { flex-wrap: wrap; justify-content: center; }
  .cq-statrail { grid-template-columns: 1fr; }
  .cq-worlds { grid-template-columns: 1fr; }
  .cq-stage-head { flex-direction: column; align-items: flex-start; }
  .cq-level { grid-template-columns: 48px minmax(0,1fr); gap: 12px; }
  .cq-prompt h2 { font-size: 1.4rem; }
  .cq-result-grid { grid-template-columns: 1fr; }
  .cq-boss { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .cq-app *, .cq-app *::before, .cq-app *::after { animation: none !important; }
}
