:root {
  --ink: #1e293b;
  --muted: #64748b;
  --paper: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --indigo: #4f46e5;
  --violet: #7c3aed;
  --rose: #e11d48;
  --amber: #d97706;
  --teal: #0d9488;
  --sky: #0284c7;
  --shadow: 0 18px 50px rgba(15, 23, 42, .12);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body.studio {
  font-family: "Nunito", "Noto Sans SC", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, #c7d2fe 0%, transparent 55%),
    radial-gradient(900px 420px at 110% 0%, #fbcfe8 0%, transparent 50%),
    var(--paper);
  min-height: 100dvh;
}
a { color: inherit; }
.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.back {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line);
  text-decoration: none; font-weight: 800; color: var(--muted); font-size: .9rem;
}
.hero {
  display: grid; grid-template-columns: 1.15fr .85fr; gap: 22px;
  background: #0f172a; color: #fff; border-radius: 28px; overflow: hidden;
  box-shadow: var(--shadow); margin-bottom: 22px; min-height: 280px;
}
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 280px; }
.hero-copy { padding: 28px 28px 24px; }
.hero-copy .kicker { letter-spacing: .16em; text-transform: uppercase; font-size: .72rem; color: #a5b4fc; font-weight: 800; }
.hero-copy h1 { margin: 8px 0 10px; font-size: clamp(1.7rem, 3vw, 2.4rem); line-height: 1.15; }
.hero-copy p { margin: 0; color: #cbd5e1; line-height: 1.65; }
.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 14px; margin-bottom: 20px; box-shadow: 0 8px 24px rgba(15,23,42,.04);
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 160px; }
.field.wide { min-width: min(100%, 420px); }
.level-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.level-pick {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 12px;
  font-weight: 800; background: #fff; cursor: pointer; user-select: none;
}
.level-pick input { margin: 0; }
.level-pick.on { border-color: #4f46e5; background: #eef2ff; color: #312e81; }
.field label { font-size: .75rem; font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.field select, .field input {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font: inherit; font-weight: 700; background: #fff;
}
.btn {
  border: 0; border-radius: 14px; padding: 11px 16px; font: inherit; font-weight: 900;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
}
.btn-indigo { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; }
.btn-rose { background: linear-gradient(135deg, #e11d48, #f97316); color: #fff; }
.btn-teal { background: linear-gradient(135deg, #0d9488, #0284c7); color: #fff; }
.btn-amber { background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; }
.btn-ghost { background: #f1f5f9; color: #334155; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border-radius: 22px; overflow: hidden; border: 1px solid var(--line);
  box-shadow: var(--shadow); text-decoration: none; display: flex; flex-direction: column;
  transition: transform .15s ease;
}
.card:hover { transform: translateY(-3px); }
.card img { width: 100%; height: 150px; object-fit: cover; background: #e2e8f0; }
.card .body { padding: 14px 16px 16px; }
.tag { font-size: .7rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.tag.easy { color: #059669; }
.tag.standard { color: #d97706; }
.tag.challenge { color: #e11d48; }
.card h3 { margin: 4px 0 6px; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.unit-chip {
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px;
  text-decoration: none; display: block;
}
.unit-chip strong { display: block; }
.unit-chip span { color: var(--muted); font-size: .8rem; }
.unit-chip.active, .unit-chip:hover { border-color: #818cf8; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.play-shell { background: #fff; border-radius: 24px; border: 1px solid var(--line); padding: 20px; box-shadow: var(--shadow); }
.play-shell.spell-play { text-align: center; }
.play-shell.spell-play .q-box,
.play-shell.spell-play .note { text-align: center; margin-left: auto; margin-right: auto; }
.hud { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 16px; font-weight: 800; color: var(--muted); }
.timer { color: #e11d48; font-variant-numeric: tabular-nums; }
.q-box { font-size: 1.35rem; font-weight: 900; margin: 8px 0 18px; line-height: 1.45; }
.spell-input {
  display: block; width: min(460px, 92%); margin: 14px auto 10px;
  text-align: center; font-size: 1.8rem; font-weight: 900; letter-spacing: .18em;
  padding: 14px 16px; border: 2.5px solid #818cf8; border-radius: 16px;
  background: #eef2ff; color: #312e81; outline: none; text-transform: uppercase;
}
.spell-input:focus { box-shadow: 0 0 0 4px rgba(79,70,229,.2); }
.opts { display: grid; gap: 10px; }
.opt {
  text-align: left; border: 2px solid var(--line); background: #fff; border-radius: 14px;
  padding: 12px 14px; font: inherit; font-weight: 800; cursor: pointer;
}
.opt.ok { border-color: #22c55e; background: #f0fdf4; color: #166534; }
.opt.bad { border-color: #ef4444; background: #fef2f2; color: #991b1b; }
.pic-wrap { text-align: center; margin-bottom: 14px; }
.pic-wrap img { max-width: 100%; max-height: 280px; border-radius: 18px; object-fit: contain; background: #0f172a; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.memory-board { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.flip {
  min-height: 228px; border-radius: 16px; border: 0; background: linear-gradient(135deg,#4f46e5,#7c3aed);
  color: #fff; font-weight: 900; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 8px; font-size: 1rem; line-height: 1.3;
  appearance: none; -webkit-appearance: none; overflow: hidden;
}
.flip .qmark { font-size: 2.4rem; font-weight: 900; line-height: 1; margin: auto; }
.flip small { display: block; font-size: .62rem; letter-spacing: .08em; color: #6366f1; font-weight: 800; line-height: 1.2; margin: 6px 0 2px; }
.flip span { display: block; text-align: center; max-width: 100%; word-break: break-word; line-height: 1.35; }
.flip img {
  width: 100%; height: 168px; object-fit: cover; object-position: center;
  border-radius: 12px; margin: 0; background: #eef2ff; flex: 0 0 auto;
}
.flip.open, .flip.done { background: #fff; color: var(--ink); border: 2px solid #c7d2fe; }
.flip.zh.open, .flip.zh.done { border-color: #99f6e4; }
.flip.preview { cursor: default; pointer-events: none; }
.flip.zh { justify-content: center; }
.flip.done { opacity: .75; }
.mem-actions { margin-top: 14px; }
.spell-row { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 16px 0; }
.slot {
  width: 36px; height: 44px; border-bottom: 3px solid #4f46e5; display: flex; align-items: center;
  justify-content: center; font-size: 1.3rem; font-weight: 900;
}
.slot.ok { color: #166534; border-bottom-color: #22c55e; }
.slot.bad { color: #991b1b; border-bottom-color: #ef4444; }
#spellResult { margin-top: 12px; }
#spellNextBtn { margin-top: 4px; }
.explain.spell-wrong, .spell-wrong { background: #fef2f2; color: #991b1b; }
.miss-box {
  margin: 16px 0 8px; padding: 14px 16px; border-radius: 16px; text-align: left;
  background: #fef2f2; border: 1px solid #fecaca;
  max-height: min(42vh, 360px); overflow: auto;
}
.miss-h { font-weight: 900; color: #991b1b; margin-bottom: 8px; }
.miss-list { margin: 0; padding-left: 1.2em; }
.miss-list li { margin: 6px 0; font-weight: 700; line-height: 1.45; }
.miss-you { color: #9f1239; font-weight: 800; }
.spell-all-ok {
  margin: 16px 0 8px; padding: 12px 14px; border-radius: 12px;
  background: #f0fdf4; color: #166534; font-weight: 800;
}
.spell-sizes { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.spell-sizes .kind-btn { min-width: 52px; font-size: 1.05rem; }
#spellSetup h2, #spellGroupDone .q-box { margin-top: 0; }
.keys { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.key {
  min-width: 40px; height: 44px; border-radius: 10px; border: 0; background: #1e293b; color: #fff;
  font-weight: 900; cursor: pointer;
}
.key:disabled { opacity: .4; cursor: not-allowed; }
.key-del { min-width: 64px; background: #9f1239; }
.wheel {
  width: min(280px, 70vw); height: min(280px, 70vw); border-radius: 50%;
  margin: 10px auto 16px; border: 10px solid #0f172a;
  background: conic-gradient(#4f46e5 0 40deg, #e11d48 40deg 80deg, #d97706 80deg 120deg, #0d9488 120deg 160deg, #0284c7 160deg 200deg, #7c3aed 200deg 240deg, #059669 240deg 280deg, #f43f5e 280deg 320deg, #4f46e5 320deg 360deg);
  transition: transform 1.6s cubic-bezier(.2,.8,.2,1);
}
.note { color: var(--muted); font-size: .88rem; }
.toast { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: #eef2ff; font-weight: 700; }
.gap-setup h2 { margin: 0 0 8px; }
.source-picks { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 20px; }
.source-picks.compact { margin: 0 0 12px; }
.src-btn {
  border: 2px solid var(--line); background: #fff; border-radius: 14px;
  padding: 12px 16px; font: inherit; font-weight: 900; cursor: pointer;
}
.src-btn.on { border-color: #4f46e5; background: #eef2ff; color: #312e81; }
.meaning-card {
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; margin: 8px 0 14px;
}
.prompt-line { margin: 10px 0 0; font-weight: 800; color: #4338ca; }
.exam-ref {
  margin-top: 16px; padding: 12px 14px; border-radius: 16px;
  background: #f8fafc; border: 1px dashed #cbd5e1;
}
.exam-sent { margin: 6px 0 4px; font-weight: 800; line-height: 1.5; }
.gap-sent {
  margin: 6px 0 18px; font-size: 1.32rem; font-weight: 800; line-height: 1.65;
}
.gap-sent.filled { color: var(--ink); }
.gap-sent mark.gap-fill {
  background: #dbeafe; color: #1e3a8a; padding: 0 .18em; border-radius: 6px;
}
.gap-follow { margin: 14px 0 4px; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.gap-zh {
  width: 100%; padding: 12px 14px; border-radius: 14px;
  background: #fff7ed; color: #9a3412; font-weight: 700; line-height: 1.65;
}
.opt:disabled { cursor: default; opacity: 1; }
.clinic-lobby { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.clinic-station {
  text-align: left; border: 1.5px solid var(--line); background: #fff; border-radius: 18px;
  padding: 14px 14px 12px; font: inherit; cursor: pointer;
}
.clinic-station h3 { margin: 4px 0 6px; font-size: 1.05rem; line-height: 1.35; }
.clinic-station span { font-size: .8rem; font-weight: 800; color: #7c3aed; }
.clinic-chip.qtype { background: #ecfdf5; color: #047857; }
.clinic-ex { margin: 0; padding-left: 1.15em; color: var(--ink); line-height: 1.7; }
.clinic-ex li { margin: 0 0 8px; }
.clinic-ex li:last-child { margin: 0; }
.clinic-kicker {
  font-size: .72rem; font-weight: 900; letter-spacing: .12em;
  text-transform: uppercase; color: #6366f1; margin-bottom: 6px;
}
.clinic-block { margin: 0 0 16px; }
.clinic-block h3 {
  margin: 0 0 8px; font-size: .78rem; font-weight: 900;
  letter-spacing: .08em; color: #6366f1;
}
.clinic-quote {
  margin: 0; padding: 12px 14px; border-left: 4px solid #818cf8;
  background: #eef2ff; border-radius: 0 12px 12px 0;
  font-weight: 700; line-height: 1.65;
}
.clinic-ask { margin: 10px 0 8px; font-weight: 800; color: #4338ca; }
.q-box.clinic-stem { font-size: 1.15rem; font-weight: 800; }
.exam-line { margin-bottom: 8px; }
.exam-tag {
  display: inline-block; background: #ecfdf5; color: #047857;
  font-size: .75rem; font-weight: 900; letter-spacing: .06em;
  padding: 4px 10px; border-radius: 999px;
}
.clinic-card {
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  padding: 18px 18px 16px; box-shadow: 0 8px 24px rgba(15,23,42,.05);
}
.clinic-card h2 { margin: 0 0 16px; font-size: 1.25rem; line-height: 1.4; }
.clinic-exp { line-height: 1.75; color: var(--ink); }
.clinic-exp p { margin: 0 0 10px; }
.clinic-exp p:last-child { margin: 0; }
.clinic-exp ul, .clinic-exp ol { margin: 0 0 10px; padding-left: 1.2em; }
.clinic-exp li { margin: 0 0 6px; }
.clinic-exp li:last-child { margin: 0; }
.clinic-tips-block .clinic-tips {
  margin: 0; padding: 12px 14px; border-radius: 14px;
  background: #fff7ed; color: #9a3412; line-height: 1.75; font-size: .95rem;
}
.clinic-tips p { margin: 0 0 8px; }
.clinic-tips p:last-child { margin: 0; }
.clinic-chip {
  display: inline-block; background: #ede9fe; color: #5b21b6;
  font-size: .78rem; font-weight: 800; padding: 5px 10px; border-radius: 999px;
  margin-bottom: 8px;
}
.clinic-src { color: var(--muted); font-size: .9rem; line-height: 1.5; margin: 0 0 10px; }
.explain {
  margin-top: 12px; padding: 12px 14px; border-radius: 12px;
  background: #f0fdf4; color: #166534; font-weight: 700; line-height: 1.55;
}
.explain.spell-wrong { background: #fef2f2; color: #991b1b; }
.mix-bar { align-items: center; }
.mix-bar .hint { margin-left: auto; color: var(--muted); font-weight: 800; font-size: .88rem; }
.mix-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin: 0 0 14px;
}
.mix-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 999px;
  background: #fff; font-weight: 800; font-size: .82rem; cursor: pointer;
  user-select: none;
}
.mix-chip input { margin: 0; }
.mix-chip.on { border-color: #4f46e5; background: #eef2ff; color: #312e81; }
.mix-chip.loading { opacity: .6; }
.mix-filter {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 12px;
}
.mix-filter input[type=search] {
  flex: 1; min-width: 180px;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px;
  font: inherit; font-weight: 700;
}
.kind-btn {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 8px 12px; font: inherit; font-weight: 800; cursor: pointer;
}
.kind-btn.on { border-color: #0d9488; background: #ccfbf1; color: #115e59; }
.mix-list {
  background: #fff; border: 1px solid var(--line); border-radius: 20px;
  padding: 8px; max-height: 520px; overflow: auto;
  box-shadow: 0 8px 24px rgba(15,23,42,.04);
}
.mix-unit-h {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px 6px; font-weight: 900; color: #4f46e5; font-size: .82rem;
}
.mix-word {
  display: grid; grid-template-columns: auto minmax(0, 1.1fr) minmax(0, 1.4fr) auto;
  gap: 8px; align-items: center;
  padding: 8px 10px; border-radius: 12px; cursor: pointer;
}
.mix-word:hover { background: #f8fafc; }
.mix-word.on { background: #eef2ff; }
.mix-word .w { font-weight: 900; }
.mix-word .m { color: var(--muted); font-size: .88rem; font-weight: 700; }
.mix-word .k {
  font-size: .72rem; font-weight: 800; color: #7c3aed;
  background: #f5f3ff; padding: 3px 8px; border-radius: 999px;
}
.linkish {
  border: 0; background: none; color: #4f46e5; font: inherit; font-weight: 800;
  cursor: pointer; font-size: .78rem;
}
body.mix.mix-playing .resume-bar,
body.mix.mix-playing .hero,
.hero[hidden],
.resume-bar[hidden],
.pack-bar[hidden],
.pack-words[hidden],
#pickerPanel[hidden],
#playPanel[hidden] {
  display: none !important;
}
.resume-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin: 0 0 18px; padding: 14px 16px;
  background: #ecfeff; border: 1.5px solid #67e8f9; border-radius: 20px;
}
.resume-copy { min-width: min(100%, 240px); }
.resume-copy strong { display: block; font-size: 1.02rem; color: #155e75; }
.resume-copy p { margin: 4px 0 0; color: #0e7490; font-size: .88rem; font-weight: 700; line-height: 1.45; }
.resume-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pack-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px; margin: 0 0 12px; padding: 10px 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  font-weight: 800; color: #334155; font-size: .88rem;
}
.pack-words {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: -4px 0 12px; padding: 0 2px 4px;
}
.pack-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: #eef2ff; color: #312e81; font-size: .78rem; font-weight: 800;
}
.pack-chip small { color: #6366f1; font-size: .68rem; }
.game-switch {
  display: flex; flex-wrap: wrap; gap: 8px;
  position: sticky; top: 8px; z-index: 30;
  margin: 0 0 16px; padding: 10px 12px;
  background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: 0 10px 28px rgba(15,23,42,.08); backdrop-filter: blur(8px);
}
.game-tab {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 12px; font: inherit; font-weight: 800; cursor: pointer;
  font-size: .82rem; color: #334155;
}
.game-tab .n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.25rem; height: 1.25rem; border-radius: 999px;
  background: #e2e8f0; color: #475569; font-size: .68rem;
}
.game-tab.on {
  border-color: #4f46e5; background: #eef2ff; color: #312e81;
}
.game-tab.on .n { background: #4f46e5; color: #fff; }
.game-tab:hover { border-color: #818cf8; }
.game-switch-label {
  align-self: center; font-size: .72rem; font-weight: 900; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); padding: 0 4px 0 2px;
}
@media (max-width: 800px) {
  .mix-word { grid-template-columns: auto 1fr auto; }
  .mix-word .m { grid-column: 2 / span 1; }
  .game-switch { flex-wrap: nowrap; overflow-x: auto; top: 4px; }
  .game-tab { flex: 0 0 auto; }
  .hero { grid-template-columns: 1fr; }
  .hero img { min-height: 180px; max-height: 200px; }
  .board { grid-template-columns: repeat(3, 1fr); }
  .memory-board { grid-template-columns: repeat(2, 1fr); }
  .flip { min-height: 200px; font-size: .9rem; }
  .flip img { height: 132px; }
}
