/* Study Quest: pixel UI + readable study cards. */

/* Ark Pixel 10px (SIL OFL): 1 font pixel = 1/10 em, so use multiples of 10px (20, 30, 40) to stay crisp. One weight only: never synthesise bold. */
@font-face { font-family: "Ark Pixel"; src: url(../fonts/ArkPixel10-Regular.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url(../fonts/NotoSans-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Noto Sans"; src: url(../fonts/NotoSans-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Noto Sans Mono"; src: url(../fonts/NotoSansMono-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }

:root {
  /* Sweetie-16 based palette */
  --ink: #1a1c2c; --plum: #5d275d; --red: #b13e53; --orange: #ef7d57; --gold: #ffcd75;
  --lime: #a7f070; --green: #38b764; --teal: #257179; --navy: #29366f; --blue: #3b5dc9;
  --sky: #41a6f6; --cyan: #73eff7; --white: #f4f4f4; --mist: #94b0c2; --slate: #566c86; --dusk: #333c57;

  --bg: var(--ink); --panel: var(--dusk); --panel-hi: var(--slate); --text: var(--white);
  --accent: var(--gold); --accent-ink: var(--ink);
  --card: #f6f1e4; --card-ink: #1f2133; --card-mute: #5b6178; --card-line: #d9d1bd;
  --ok: var(--green); --bad: var(--red);
  --px: 3px; /* one "pixel" of UI chrome */
  --radius: 0;
  --pixel-font: "Ark Pixel", ui-monospace, monospace;
  --read-font: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono-font: "Noto Sans Mono", ui-monospace, Consolas, monospace;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px);
  --tap: 44px;
}

/* region themes */
[data-theme="networks"]           { --accent: #ffcd75; --region-a: #257179; --region-b: #41a6f6; --region-c: #f4e4a1; }
[data-theme="algorithms"]         { --accent: #ef7d57; --region-a: #29366f; --region-b: #5d275d; --region-c: #f1d6a8; }
[data-theme="numerical-analysis"] { --accent: #73eff7; --region-a: #333c57; --region-b: #8a6fd1; --region-c: #e6f7fb; }
[data-theme="signals"]            { --accent: #e06bd0; --region-a: #3a1f5d; --region-b: #38b7a4; --region-c: #f3e1fb; }
[data-theme="digital-circuits"]   { --accent: #a7f070; --region-a: #1f4d3a; --region-b: #c27c3a; --region-c: #e5f6dc; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body {
  min-height: 100vh; min-height: 100dvh;
  font-family: var(--read-font);
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img, canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

#app {
  min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 12px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 12px);
  max-width: 1040px; margin: 0 auto;
  display: flex; flex-direction: column;
}
#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; pointer-events: none; z-index: 50; }

.pixel { font-family: var(--pixel-font); letter-spacing: 0; -webkit-font-smoothing: none; font-smooth: never; }
.boot { margin: auto; font-size: 20px; color: var(--mist); }

/* ---------- pixel frames & buttons ---------- */
.frame {
  background: var(--panel);
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink), 0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink), var(--px) 0 0 0 var(--ink),
    inset 0 var(--px) 0 0 rgba(255,255,255,.12), inset 0 calc(-1 * var(--px)) 0 0 rgba(0,0,0,.25);
  margin: var(--px);
}
.btn {
  font-family: var(--pixel-font); font-size: 20px; line-height: 20px;
  min-height: var(--tap); min-width: var(--tap); padding: 12px 16px;
  border: 0; background: var(--panel-hi); color: var(--white);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink), 0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink), var(--px) 0 0 0 var(--ink),
    inset 0 calc(-1 * var(--px)) 0 0 rgba(0,0,0,.35), inset 0 var(--px) 0 0 rgba(255,255,255,.18);
  margin: var(--px); user-select: none; -webkit-user-select: none; touch-action: manipulation;
  text-align: center;
}
.btn:active:not(:disabled) { transform: translateY(var(--px)); box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--ink), 0 var(--px) 0 0 var(--ink),
    calc(-1 * var(--px)) 0 0 0 var(--ink), var(--px) 0 0 0 var(--ink), inset 0 var(--px) 0 0 rgba(0,0,0,.35); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .chip:focus-visible, .tile:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.good { background: var(--green); color: var(--white); }
.btn.bad { background: var(--red); color: var(--white); }
.btn.ghost { background: transparent; box-shadow: none; color: var(--mist); }
.btn.small { min-height: 36px; padding: 8px 10px; font-size: 20px; line-height: 20px; }
.btn.big { font-size: 30px; line-height: 30px; padding: 16px 24px; }
.btn.block { display: flex; width: calc(100% - 2 * var(--px)); }
.btn .ico { width: 16px; height: 16px; }
.icon-btn { padding: 8px; }
.badge {
  flex: none; white-space: nowrap; display: inline-block;
  font-family: var(--pixel-font); font-size: 20px; line-height: 20px; padding: 3px 6px; min-width: 22px; text-align: center;
  background: var(--red); color: var(--white); box-shadow: 0 0 0 2px var(--ink);
}
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--mist); }
.center { text-align: center; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; font-weight: 400; }
.h-pixel { font-family: var(--pixel-font); font-size: 30px; line-height: 36px; }
.h-pixel.xl { font-size: 40px; line-height: 48px; }
.h-pixel.sm { font-size: 20px; line-height: 24px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.topbar .title { font-family: var(--pixel-font); font-size: 30px; line-height: 36px; flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xpchip { font-family: var(--pixel-font); font-size: 20px; display: inline-flex; gap: 6px; align-items: center; padding: 6px 8px; background: var(--dusk); }
.xpchip.streak { color: var(--orange); gap: 4px; }
@media (max-width: 480px) {
  /* phones: the title gets the whole first row (next to the back button), the chips and buttons go on the second */
  .xpbar { display: none; }
  .topbar { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  .topbar .title { font-size: 30px; line-height: 36px; flex: 1 0 100%; }
  .topbar > .btn:first-child + .title { flex-basis: calc(100% - 52px); }
  .topbar .xpchip { padding: 6px 5px; }
  .topbar .icon-btn { padding: 6px; min-width: 38px; }
}
.xpbar { width: 60px; height: 8px; background: var(--ink); position: relative; }
.xpbar > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--gold); }

/* ---------- world map ---------- */
.map-wrap { position: relative; width: 100%; margin: 0 auto 12px; }
.map-wrap canvas { display: block; margin: 0 auto; touch-action: manipulation; cursor: pointer; }
.region-list { display: grid; grid-template-columns: 1fr; gap: 8px; }
@media (min-width: 640px) { .region-list { grid-template-columns: 1fr 1fr; } }
.region-card { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 12px; width: calc(100% - 2 * var(--px)); justify-content: flex-start; }
.region-card canvas { flex: none; }
.region-card .rc-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.region-card .rc-name { font-size: 20px; line-height: 20px; }
.region-card .rc-sub { font-family: var(--read-font); font-size: 13px; line-height: 1.3; color: var(--mist); }
.region-card.locked { opacity: .6; }
.prog { height: 8px; background: var(--ink); width: 100%; max-width: 160px; position: relative; }
.prog > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); }
.mode-row { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 6px 0 10px; }
@media (min-width: 640px) { .mode-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }

/* ---------- region path ---------- */
.region-head { display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 10px; background: var(--region-a, var(--dusk)); }
.region-head canvas { flex: none; }
.region-head .rh-text { min-width: 0; }
.region-head p { margin: 4px 0 0; font-size: 14px; color: var(--region-c, var(--mist)); }
.path { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 4px 0 12px; }
.node {
  display: flex; align-items: center; gap: 12px; text-align: left; justify-content: flex-start;
  width: calc(100% - 2 * var(--px)); padding: 10px 12px; min-height: 64px;
  background: var(--panel);
}
@media (min-width: 700px) {
  .path { padding-left: 8%; padding-right: 8%; }
  .node:nth-child(4n+2) { margin-left: 8%; } .node:nth-child(4n+3) { margin-left: 14%; } .node:nth-child(4n) { margin-left: 8%; }
  .node { width: 72%; }
}
.node .num { flex: none; width: 40px; height: 40px; display: grid; place-items: center; font-size: 30px; background: var(--region-a, var(--ink)); color: var(--white); box-shadow: 0 0 0 var(--px) var(--ink); }
.node .ntext { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.node .nt { font-family: var(--pixel-font); font-size: 20px; line-height: 22px; overflow-wrap: anywhere; hyphens: auto; }
.node .ns { font-family: var(--read-font); font-size: 13px; line-height: 1.35; color: var(--mist); }
.node .stars { flex: none; font-family: var(--pixel-font); font-size: 20px; color: var(--gold); letter-spacing: 2px; }
.node.locked { opacity: .5; }
.node.cleared .num { background: var(--green); }
.node.warmup .num { background: var(--plum); }
.node.boss { background: var(--plum); min-height: 76px; }
.node.boss .num { background: var(--red); }
.node.exam { background: var(--navy); }

/* ---------- play screen ---------- */
.play { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.hud { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--pixel-font); font-size: 20px; line-height: 20px; }
.hud .hearts { display: flex; gap: 2px; }
.hud .hearts canvas { display: block; }
.hud .combo { color: var(--gold); min-width: 64px; }
.hud .combo.hot { color: var(--orange); }
.hud .timer { color: var(--cyan); }
.hud .timer.low { color: var(--red); }
.progress { height: 10px; background: var(--ink); box-shadow: 0 0 0 2px var(--dusk); position: relative; overflow: hidden; }
.progress > i { position: absolute; inset: 0 auto 0 0; background: var(--accent); transition: width .25s steps(6); }
.progress.boss > i { background: var(--red); }
.stage { position: relative; display: flex; justify-content: center; align-items: flex-end; min-height: 40px; background: var(--region-a, var(--dusk)); overflow: hidden; }
.stage canvas { display: block; }
.bosshp { display: flex; align-items: center; gap: 8px; font-family: var(--pixel-font); font-size: 20px; }
.bosshp .progress { flex: 1; }

/* the study card: readable, calm */
.card {
  background: var(--card); color: var(--card-ink);
  font-family: var(--read-font); font-size: 17px; line-height: 1.55;
  padding: 16px; margin: var(--px);
  box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--ink), 0 var(--px) 0 0 var(--ink), calc(-1 * var(--px)) 0 0 0 var(--ink), var(--px) 0 0 0 var(--ink), inset 0 calc(-1 * var(--px)) 0 0 var(--card-line);
}
@media (min-width: 700px) { .card { font-size: 18px; padding: 20px 24px; } }
.card .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-family: var(--pixel-font); font-size: 20px; line-height: 20px; color: var(--card-mute); }
.card .meta .tag { background: #e8e0cb; padding: 4px 6px; }
.card .meta .tag.review { background: #f9d9a8; color: #7a3d10; }
.card .meta .tag.warn { background: #f7c6c6; color: #7a1d2b; }
.card .meta .tag.exam { background: #d6e4ff; color: #22336e; }
.card .prompt { margin: 0 0 12px; overflow-wrap: anywhere; }
.card .prompt p { margin: 0 0 8px; }
.card .hint { font-size: 14px; color: var(--card-mute); margin: -4px 0 10px; }
.codeblock { font-family: var(--mono-font); font-size: 14px; line-height: 1.45; background: #22253a; color: #e8ecf5; padding: 10px 12px; margin: 0 0 12px; overflow-x: auto; white-space: pre; -webkit-overflow-scrolling: touch; tab-size: 4; }
.codeblock .k { color: #ffcd75; } .codeblock .s { color: #a7f070; } .codeblock .c { color: #94b0c2; font-style: italic; } .codeblock .n { color: #73eff7; } .codeblock .p { color: #ef7d57; }

/* rich text / math */
.rich .katex { font-size: 1.06em; }
.rich .katex-display { margin: .4em 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; -webkit-overflow-scrolling: touch; }
.rich .katex-display > .katex { font-size: 1.12em; }
.rich strong { font-weight: 700; }

/* options (mcq) */
.options { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left;
  min-height: var(--tap); padding: 10px 12px; border: 0; background: #fffdf6; color: var(--card-ink);
  font-family: var(--read-font); font-size: inherit; line-height: 1.45;
  box-shadow: 0 0 0 2px var(--card-line), 0 3px 0 2px var(--card-line);
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.opt .key { flex: none; width: 26px; height: 26px; display: grid; place-items: center; font-family: var(--pixel-font); font-size: 20px; background: #e8e0cb; color: var(--card-mute); }
.opt.multi .key { border-radius: 0; }
.opt .otext { flex: 1; min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.opt[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--blue), 0 3px 0 3px var(--blue); background: #eef3ff; }
.opt[aria-pressed="true"] .key { background: var(--blue); color: var(--white); }
.opt.right { box-shadow: 0 0 0 3px var(--green), 0 3px 0 3px var(--green); background: #e7f7ea; }
.opt.right .key { background: var(--green); color: #fff; }
.opt.wrong { box-shadow: 0 0 0 3px var(--red), 0 3px 0 3px var(--red); background: #fbe9ec; }
.opt.wrong .key { background: var(--red); color: #fff; }
.opt:disabled { cursor: default; }

/* true / false swipe card */
.tf-zone { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 6px 0; }
.tf-card {
  width: 100%; max-width: 520px; min-height: 140px; padding: 18px; background: #fffdf6; color: var(--card-ink);
  box-shadow: 0 0 0 3px var(--card-line), 0 6px 0 3px var(--card-line);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab; position: relative; padding-top: 44px;
  display: flex; align-items: center; justify-content: center; text-align: center; font-size: 1.05em;
}
.tf-card.dragging { cursor: grabbing; transition: none; }
.tf-card .stamp { position: absolute; top: 8px; font-family: var(--pixel-font); font-size: 30px; padding: 4px 8px; opacity: 0; }
.tf-card .stamp.yes { right: 8px; color: var(--green); box-shadow: 0 0 0 3px var(--green); }
.tf-card .stamp.no { left: 8px; color: var(--red); box-shadow: 0 0 0 3px var(--red); }
.tf-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 520px; }
.tf-hint { font-size: 13px; color: var(--card-mute); }

/* chips (fill, diagram labels) */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding: 8px; background: #ece5d2; min-height: 60px; align-content: flex-start; }
.chip {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: var(--tap);
  padding: 8px 12px; border: 0; background: #fffdf6; color: var(--card-ink); font-family: var(--read-font); font-size: 16px; line-height: 1.3;
  box-shadow: 0 0 0 2px #b9ae94, 0 3px 0 2px #b9ae94; touch-action: none; user-select: none; -webkit-user-select: none;
}
.chip.selected { box-shadow: 0 0 0 3px var(--blue), 0 3px 0 3px var(--blue); background: #eef3ff; }
.chip.used { visibility: hidden; }
.chip.ghost { position: fixed; z-index: 60; pointer-events: none; opacity: .92; transform: translate(-50%, -60%) scale(1.05); box-shadow: 0 0 0 3px var(--blue), 0 8px 0 3px rgba(0,0,0,.25); }
.fill-text { line-height: 2.3; }
.blank {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  min-width: 90px; min-height: 38px; padding: 2px 8px; margin: 0 2px; border: 0;
  background: #fffdf6; color: var(--card-ink); box-shadow: inset 0 -3px 0 var(--slate), 0 0 0 2px #cfc5ab; font-size: 16px; line-height: 1.3;
}
.blank.target { box-shadow: inset 0 -3px 0 var(--blue), 0 0 0 3px var(--blue); }
.blank.right { box-shadow: inset 0 -3px 0 var(--green), 0 0 0 3px var(--green); background: #e7f7ea; }
.blank.wrong { box-shadow: inset 0 -3px 0 var(--red), 0 0 0 3px var(--red); background: #fbe9ec; }
input.blank { width: 9em; max-width: 60vw; font-family: var(--read-font); text-align: center; outline: none; border-radius: 0; -webkit-appearance: none; appearance: none; }
input.blank:focus { box-shadow: inset 0 -3px 0 var(--blue), 0 0 0 3px var(--blue); }
.solution { margin-top: 8px; font-size: 15px; color: var(--card-mute); }
.solution b { color: var(--green); }

/* order */
.order-list { display: flex; flex-direction: column; gap: 8px; position: relative; }
.tile {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 10px; background: #fffdf6; color: var(--card-ink);
  box-shadow: 0 0 0 2px var(--card-line), 0 3px 0 2px var(--card-line); touch-action: none; user-select: none; -webkit-user-select: none;
  border: 0; width: 100%; text-align: left; font: inherit; position: relative;
}
.tile .grip { flex: none; width: 18px; align-self: stretch; background:
  radial-gradient(circle, #a69c84 1.5px, transparent 2px) 0 0 / 6px 6px; opacity: .9; }
.tile .ttext { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.tile .pos { flex: none; font-family: var(--pixel-font); font-size: 20px; color: var(--card-mute); width: 20px; text-align: center; }
.tile.dragging { z-index: 5; box-shadow: 0 0 0 3px var(--blue), 0 10px 0 3px rgba(0,0,0,.15); background: #eef3ff; }
.tile.selected { box-shadow: 0 0 0 3px var(--blue), 0 3px 0 3px var(--blue); background: #eef3ff; }
.tile.right { box-shadow: 0 0 0 3px var(--green), 0 3px 0 3px var(--green); background: #e7f7ea; }
.tile.wrong { box-shadow: 0 0 0 3px var(--red), 0 3px 0 3px var(--red); background: #fbe9ec; }
.tile .sol { font-size: 20px; color: var(--green); font-family: var(--pixel-font); }

/* match */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; align-items: start; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-col .tile { min-height: 56px; padding: 8px; font-size: .95em; }
.tile .pairtag { position: absolute; top: -8px; right: -6px; font-family: var(--pixel-font); font-size: 20px; line-height: 20px; padding: 2px 5px; color: var(--white); box-shadow: 0 0 0 2px var(--ink); }
.match-help { font-size: 13px; color: var(--card-mute); margin-bottom: 8px; }

/* numeric */
.numeric { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.num-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.num-input { width: 11em; max-width: 70vw; min-height: 48px; padding: 8px 12px; font-size: 20px; font-family: var(--mono-font); border: 0; border-radius: 0; background: #fffdf6; color: var(--card-ink); box-shadow: inset 0 -3px 0 var(--slate), 0 0 0 2px #cfc5ab; -webkit-appearance: none; appearance: none; }
.num-input:focus { outline: none; box-shadow: inset 0 -3px 0 var(--blue), 0 0 0 3px var(--blue); }
.num-input.right { box-shadow: 0 0 0 3px var(--green); background: #e7f7ea; }
.num-input.wrong { box-shadow: 0 0 0 3px var(--red); background: #fbe9ec; }
.num-unit { font-size: 18px; color: var(--card-mute); }
.num-slider { width: 100%; max-width: 480px; height: 44px; accent-color: var(--blue); touch-action: pan-y; }
.num-help { font-size: 13px; color: var(--card-mute); }

/* diagram */
.diagram { position: relative; width: 100%; margin: 4px auto 0; background: #fffdf6; box-shadow: 0 0 0 2px var(--card-line); }
.diagram svg { display: block; width: 100%; height: auto; shape-rendering: crispEdges; }
.diagram .ov { position: absolute; inset: 0; pointer-events: none; }
.diagram .dtext, .diagram .dslot {
  position: absolute; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: max(10px, calc(13px * var(--ds, 1))); line-height: 1.15; color: var(--card-ink); padding: 1px 2px; overflow: hidden;
}
.diagram .dtext { overflow: visible; }
.diagram .dtext.small { font-size: max(9px, calc(11px * var(--ds, 1))); color: var(--card-mute); white-space: nowrap; }
.diagram .dtext.edge { background: rgba(255, 253, 246, .9); }
.diagram .dtext.head { font-weight: 700; }
.diagram .dtext.term { font-weight: 700; justify-content: flex-start; }
.diagram .dtext.pin { font-size: max(9px, calc(10px * var(--ds, 1))); justify-content: flex-start; }
.diagram .dtext.pin.right { justify-content: flex-end; }
.diagram .dtext.boxtitle { font-weight: 700; font-size: max(9px, calc(11px * var(--ds, 1))); }
.diagram .dtext.title { font-family: var(--pixel-font); font-size: 20px; }
.diagram .dslot {
  pointer-events: auto; border: 0; background: #e9f0ff; box-shadow: inset 0 0 0 2px var(--blue); cursor: pointer;
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(59,93,201,.08) 6px 12px); min-height: 24px;
}
.diagram .dslot.filled { background: #fff6dc; background-image: none; box-shadow: inset 0 0 0 2px #c79a3a; }
.diagram .dslot.target { box-shadow: inset 0 0 0 3px var(--orange); }
.diagram .dslot.right { background: #e7f7ea; box-shadow: inset 0 0 0 3px var(--green); }
.diagram .dslot.wrong { background: #fbe9ec; box-shadow: inset 0 0 0 3px var(--red); }
.diagram .dslot .sl-sol { display: block; font-size: .85em; color: var(--green); }
.diagram .dslot .slot-num { font-family: var(--pixel-font); font-size: 20px; line-height: 20px; color: var(--blue); opacity: .75; }
.diagram-help { font-size: 13px; color: var(--card-mute); margin: 8px 0 0; }

/* feedback */
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.feedback { margin-top: 12px; padding: 12px 14px; font-size: 16px; line-height: 1.5; background: #fff; color: var(--card-ink); box-shadow: 0 0 0 3px var(--card-line); }
.feedback.ok { box-shadow: 0 0 0 3px var(--green); background: #eefaf0; }
.feedback.bad { box-shadow: 0 0 0 3px var(--red); background: #fdf0f2; }
.feedback .fb-title { font-family: var(--pixel-font); font-size: 20px; line-height: 20px; margin-bottom: 6px; }
.feedback.ok .fb-title { color: #1d7a41; } .feedback.bad .fb-title { color: #8d2236; }
.src-link { margin-top: 8px; display: inline-flex; align-items: center; gap: 6px; border: 0; background: #ece5d2; color: var(--card-ink); padding: 8px 10px; min-height: 40px; font-size: 14px; }
.retry-note { font-size: 13px; color: #7a3d10; margin-top: 6px; }

/* results / stats */
.results { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.results .big-stars { font-family: var(--pixel-font); font-size: 40px; line-height: 48px; color: var(--gold); text-align: center; letter-spacing: 8px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-family: var(--pixel-font); font-size: 20px; line-height: 24px; }
.panel { padding: 14px; }
.panel h3 { font-family: var(--pixel-font); font-size: 20px; line-height: 24px; margin-bottom: 10px; color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 8px; }
.miss { background: var(--card); color: var(--card-ink); padding: 10px 12px; font-size: 15px; line-height: 1.5; }
.miss .mq { font-weight: 700; margin-bottom: 4px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) 120px 60px; gap: 8px; align-items: center; font-size: 14px; }
.bar-row .bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .bv { font-family: var(--pixel-font); font-size: 20px; text-align: right; }
.bar { height: 10px; background: var(--ink); position: relative; }
.bar > i { position: absolute; inset: 0 auto 0 0; }
.activity { display: grid; grid-template-columns: repeat(14, 1fr); gap: 3px; align-items: end; }
.act-col { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.act-bar-wrap { position: relative; width: 100%; height: 64px; background: var(--ink); }
.act-bar-wrap > i { position: absolute; left: 0; right: 0; bottom: 0; }
.act-n { font-family: var(--pixel-font); font-size: 20px; line-height: 20px; height: 20px; color: var(--mist); transform: scale(.75); }
.act-d { font-family: var(--pixel-font); font-size: 20px; line-height: 20px; color: var(--mist); }
.act-col.today .act-d { color: var(--gold); }
.mastery-grid { display: flex; flex-wrap: wrap; gap: 3px; }
.mastery-grid button { width: 18px; height: 18px; border: 0; padding: 0; min-width: 0; }
@media (pointer: coarse) { .mastery-grid { gap: 4px; } .mastery-grid button { width: 32px; height: 32px; } } /* finger-sized on phones */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs .btn[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
details.topic { margin: 4px 0; }
details.topic summary { cursor: pointer; padding: 6px 0; list-style: none; }
details.topic summary::-webkit-details-marker { display: none; }

/* settings */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 2px solid var(--ink); font-size: 15px; }
.setting:last-child { border-bottom: 0; }
.toggle { min-width: 84px; }
textarea.json-box { width: 100%; min-height: 160px; font-family: var(--mono-font); font-size: 16px; background: var(--ink); color: var(--white); border: 0; padding: 8px; }

/* modal */
#modal-root:empty { display: none; }
.modal-back { position: fixed; inset: 0; background: rgba(10, 10, 20, .7); z-index: 70; display: flex; align-items: center; justify-content: center; padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px); }
.modal { width: 100%; max-width: 520px; max-height: 100%; overflow: auto; padding: 16px; background: var(--panel); }
.modal h2 { font-family: var(--pixel-font); font-size: 30px; line-height: 36px; margin-bottom: 8px; }
.modal p { line-height: 1.5; }
.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 20px); transform: translateX(-50%); z-index: 80; padding: 10px 14px; font-family: var(--pixel-font); font-size: 20px; background: var(--ink); color: var(--white); box-shadow: 0 0 0 3px var(--gold); max-width: calc(100vw - 32px); text-align: center; }
.banner { padding: 8px 10px; margin-bottom: 8px; font-size: 13px; background: var(--plum); color: var(--white); }

/* sign-in */
.login-hero { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 18px 0 14px; text-align: center; flex-wrap: wrap; }
.login-hero p { margin: 4px 0 0; }
.login { max-width: 460px; width: 100%; margin: 0 auto; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.login-label { display: flex; flex-direction: column; gap: 6px; font-family: var(--pixel-font); font-size: 20px; line-height: 20px; color: var(--mist); }
.field { font-family: var(--read-font); font-size: 16px; min-height: 46px; padding: 10px 12px; border: 0; border-radius: 0; background: var(--ink); color: var(--white);
  box-shadow: inset 0 0 0 2px var(--slate); -webkit-appearance: none; appearance: none; }
.field:focus { outline: none; box-shadow: inset 0 0 0 3px var(--cyan); }
.login-hint { margin: 0; font-size: 13px; color: var(--mist); line-height: 1.5; }
.login-msg { min-height: 20px; font-size: 14px; color: #ff9aa9; }
.login-warn { margin: 14px 0 0; padding: 10px 12px; font-size: 13px; line-height: 1.5; background: rgba(239, 125, 87, .15); box-shadow: inset 0 0 0 2px rgba(239, 125, 87, .5); }
.tabs .btn[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }

/* leaderboard */
.lb { display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 40px 64px 36px 36px; gap: 6px; align-items: center; padding: 8px 6px; background: var(--ink); font-family: var(--pixel-font); font-size: 20px; line-height: 20px; }
.lb-row > span:nth-child(n+3) { text-align: right; display: flex; justify-content: flex-end; align-items: center; }
.lb-head { background: transparent; color: var(--mist); }
.lb-row.me { background: var(--navy); box-shadow: inset 0 0 0 2px var(--gold); }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-rank { text-align: center; }
.sync-dot { width: 10px; height: 10px; display: inline-block; background: var(--slate); box-shadow: 0 0 0 2px var(--ink); }
.sync-dot.synced { background: var(--green); } .sync-dot.syncing { background: var(--gold); } .sync-dot.offline, .sync-dot.error { background: var(--red); }

/* boss entrance + level up */
.boss-intro {
  position: fixed; inset: 0; z-index: 75; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: radial-gradient(circle, rgba(93, 39, 93, .92), rgba(26, 28, 44, .97)); cursor: pointer;
  padding: calc(var(--safe-t) + 16px) 16px calc(var(--safe-b) + 16px);
  animation: bossin .5s steps(5);
}
.boss-intro .bi-warn { font-family: var(--pixel-font); font-size: 30px; line-height: 30px; color: var(--red); animation: blink .6s steps(1) infinite; }
.boss-intro .bi-name { font-family: var(--pixel-font); font-size: 30px; line-height: 36px; color: var(--gold); text-align: center; }
.boss-intro .bi-hint { font-size: 13px; color: var(--mist); }
.boss-intro canvas { filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .4)); }
@keyframes bossin { from { transform: scale(1.4); opacity: 0; } to { transform: none; opacity: 1; } }
.bosshp .bossname { font-size: 20px; color: var(--gold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.levelup {
  position: fixed; left: 50%; top: 28%; transform: translate(-50%, -50%); z-index: 78; pointer-events: none;
  padding: 14px 22px; background: var(--ink); box-shadow: 0 0 0 4px var(--gold), 0 0 0 8px var(--ink);
  text-align: center; animation: lvl 1.8s steps(12) forwards;
}
.levelup .lu-title { font-family: var(--pixel-font); font-size: 40px; line-height: 40px; color: var(--gold); }
.levelup .lu-sub { font-family: var(--pixel-font); font-size: 20px; line-height: 30px; color: var(--white); margin-top: 4px; }
@keyframes lvl { 0% { transform: translate(-50%, -30%) scale(.6); opacity: 0; } 15% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; } 25% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%); } }

/* juice */
@keyframes shake { 0%,100% { transform: translate(0,0); } 20% { transform: translate(-6px, 2px); } 40% { transform: translate(5px,-3px); } 60% { transform: translate(-4px, 1px); } 80% { transform: translate(3px, 0); } }
.shake { animation: shake .32s steps(5) 1; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
.pop { animation: pop .3s steps(4) 1; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.enter { animation: rise .22s steps(4); } /* no fill-mode: content stays visible even if animations are paused */
@keyframes blink { 50% { opacity: .2; } }
.blink { animation: blink 1s steps(1) infinite; }

.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  :root:not(.motion-on) *, :root:not(.motion-on) *::before, :root:not(.motion-on) *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 480px) {
  .codeblock { font-size: 12.5px; line-height: 1.4; tab-size: 2; margin-left: -8px; margin-right: -8px; padding: 8px; }
}
@media (max-width: 380px) {
  .card { padding: 12px; font-size: 16px; }
  .btn { padding: 10px 12px; }
  .h-pixel.xl { font-size: 30px; line-height: 36px; }
}

/* ---------- profile, onboarding, avatar editor ---------- */
.badge.ok { background: var(--green); color: var(--ink); }
.badge.warn { background: var(--orange); color: var(--ink); }
.avatar-cv { image-rendering: pixelated; display: block; }
.pfp-btn { padding: 0; width: var(--tap); height: var(--tap); display: inline-flex; align-items: center; justify-content: center; }
.pfp-btn canvas { width: 30px; height: 30px; }
.verify-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; line-height: 1.5;
  background: rgba(255, 205, 117, .12); box-shadow: inset 0 0 0 2px rgba(255, 205, 117, .55); padding: 10px 12px; margin: 8px 0; }
.verify-banner b { overflow-wrap: anywhere; }
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.profile-pfp { background: var(--ink); padding: 8px; box-shadow: inset 0 0 0 3px var(--navy); }
.profile-meta { flex: 1 1 200px; min-width: 0; }
.profile-meta h2 { margin: 0 0 4px; overflow-wrap: anywhere; }
.profile-meta p { margin: 0 0 10px; }
.sem-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.sem-btn { flex-direction: column; min-height: 56px; gap: 2px; padding: 6px 4px; }
.sem-btn small { font-size: 11px; }
@media (max-width: 360px) { .sem-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; } }
.sem-btn.primary small { color: var(--ink); }
.subj-pick { display: flex; flex-direction: column; gap: 10px; }
.subj-group { border: 0; margin: 0; padding: 10px; background: var(--ink); }
.subj-group legend { float: left; width: 100%; font-family: var(--pixel-font); font-size: 20px; line-height: 24px; padding: 0 0 6px; color: var(--gold); }
.subj-group legend + * { clear: both; }
.subj-group p { font-size: 13px; margin: 4px 0; }
.subj-item { display: flex; align-items: center; gap: 10px; min-height: var(--tap); font-size: 15px; cursor: pointer; }
.subj-item input { width: 22px; height: 22px; accent-color: var(--gold); flex: 0 0 auto; }
.map-foot { text-align: center; font-size: 13px; margin: 10px 0 4px; }
.map-foot a { color: var(--gold); }
.welcome-head { text-align: center; margin: 14px 0 10px; }
.welcome-head p { margin: 4px 0 0; }
.welcome { max-width: 760px; margin: 0 auto; }
.welcome h2 { margin: 10px 0; }
.welcome .row { justify-content: space-between; margin-top: 12px; }
.welcome-steps { display: flex; gap: 6px; flex-wrap: wrap; font-family: var(--pixel-font); font-size: 20px; }
.wstep { padding: 4px 8px; background: var(--ink); color: var(--mist); }
.wstep.on { background: var(--gold); color: var(--ink); }
.wstep.done { color: var(--lime); }
.lb-name { display: flex; align-items: center; gap: 8px; }
.lb-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name canvas { flex: 0 0 auto; }

.av-ed { display: grid; grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); gap: 14px; align-items: start; }
.av-preview { position: sticky; top: calc(8px + var(--safe-t)); display: flex; flex-direction: column; align-items: center; gap: 10px;
  background: radial-gradient(circle at 50% 40%, var(--navy), var(--ink) 75%); padding: 14px 10px; box-shadow: inset 0 0 0 3px var(--ink); }
.av-big { min-height: 192px; display: flex; align-items: flex-end; justify-content: center; }
.av-side { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.av-status { min-height: 18px; font-size: 13px; margin: 0; text-align: center; }
.av-tabs { position: sticky; top: calc(4px + var(--safe-t)); z-index: 2; background: var(--panel); padding: 4px 0; }
.av-sec h4 { margin: 12px 0 6px; font-family: var(--pixel-font); font-size: 20px; font-weight: normal; }
.av-sec h4 small { font-family: var(--read-font); font-size: 12px; }
.av-grid { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.av-grid.color { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
.av-opt { position: relative; min-height: var(--tap); min-width: var(--tap); padding: 4px; border: 0; background: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: inset 0 0 0 2px var(--dusk); }
.av-opt:hover { box-shadow: inset 0 0 0 2px var(--slate); }
.av-opt:focus-visible { outline: 3px solid var(--cyan); outline-offset: 1px; }
.av-opt.on { box-shadow: inset 0 0 0 3px var(--gold); background: var(--navy); }
.av-opt.locked canvas, .av-opt.locked .sw { opacity: .3; filter: grayscale(.8); }
.av-opt .lock { position: absolute; right: 2px; bottom: 1px; font-size: 13px; }
.av-opt .sw { display: block; width: 30px; height: 30px; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .35); }
.avatar-screen { max-width: 980px; margin: 0 auto; }
.avatar-actions { max-width: 980px; margin: 10px auto 0; gap: 8px; align-items: center; position: sticky; bottom: 0; z-index: 3; background: var(--bg); padding: 10px 0 calc(10px + var(--safe-b)); }
@media (max-width: 640px) {
  .av-ed { grid-template-columns: 1fr; }
  .av-preview { position: static; flex-direction: row; justify-content: center; gap: 14px; }
  .av-big { min-height: 0; }
  .sem-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
}
@media (max-width: 480px) {
  .lb-row { grid-template-columns: 26px minmax(0, 1fr) 56px 30px 30px; gap: 4px; padding: 8px 4px; font-size: 20px; }
  .lb-row > span:nth-child(3) { display: none; }
  .lb-name { gap: 5px; }
}

/* ---------------------------------------------------------------- coins, battles, loot */
.coinchip { border: 0; color: var(--gold); cursor: pointer; gap: 4px; }
.coinchip canvas, .coinlabel canvas { display: block; }
.coinlabel { display: inline-flex; align-items: center; gap: 4px; font-family: var(--pixel-font); color: var(--gold); }
.btn .coinlabel { color: inherit; }
.bosshp .hp-n { flex: none; font-size: 20px; color: var(--mist); min-width: 44px; text-align: right; }
.bosshp.minion .bossname { color: var(--white); }
.progress.boss { height: 12px; }
.progress.boss > i { box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .25); }
.hud .combo.warm { color: var(--gold); }
.hud .combo.hot { color: var(--orange); }
.hud .combo.blaze { color: var(--red); animation: blink .5s steps(1) infinite; }
.heart-break { animation: heartbreak .5s steps(4); }
@keyframes heartbreak { 0% { transform: scale(1.4); filter: brightness(2); } 50% { transform: scale(.8) rotate(-10deg); } 100% { transform: none; } }
.stage .shout { position: absolute; left: 50%; top: 10%; transform: translateX(-50%); font-family: var(--pixel-font); font-size: 30px; line-height: 30px; color: var(--gold); text-shadow: 3px 3px 0 var(--ink); white-space: nowrap; animation: shout 1.1s steps(8) forwards; pointer-events: none; }
.stage .shout.hot { color: var(--orange); }
@keyframes shout { 0% { transform: translateX(-50%) scale(.5); opacity: 0; } 20% { transform: translateX(-50%) scale(1.15); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateX(-50%) translateY(-12px); opacity: 0; } }
.coin-float { position: absolute; z-index: 70; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; font-family: var(--pixel-font); font-size: 20px; color: var(--gold); text-shadow: 2px 2px 0 var(--ink); pointer-events: none; animation: coinfloat 1s steps(10) forwards; }
@keyframes coinfloat { from { opacity: 1; margin-top: 0; } to { opacity: 0; margin-top: -48px; } }
.chest-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 12px 0; }
.chest { border: 0; background: none; padding: 8px; cursor: pointer; animation: chestidle 1.2s steps(2) infinite; }
.chest canvas { display: block; }
.chest.wobble { animation: wobble .65s steps(6); }
.chest-label { font-family: var(--pixel-font); font-size: 20px; line-height: 24px; color: var(--gold); text-align: center; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; }
@keyframes chestidle { 50% { transform: translateY(-3px); } }
@keyframes wobble { 0%, 100% { transform: none; } 20% { transform: rotate(-8deg); } 40% { transform: rotate(8deg); } 60% { transform: rotate(-6deg) scale(1.05); } 80% { transform: rotate(6deg) scale(1.1); } }

/* reward pop-ups (quests, badges) */
.reward-pop { position: fixed; z-index: 90; left: 50%; top: calc(var(--safe-t) + 12px); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--ink); box-shadow: 0 0 0 3px var(--gold), 0 6px 0 3px rgba(0, 0, 0, .35); width: max-content; max-width: calc(100vw - 32px); animation: rpin .3s steps(4); }
.reward-pop.out { animation: rpout .4s steps(4) forwards; }
.reward-pop canvas { flex: none; display: block; }
.rp-title { font-family: var(--pixel-font); font-size: 20px; line-height: 24px; color: var(--gold); }
.rp-sub { font-size: 14px; color: var(--mist); }
@keyframes rpin { from { transform: translate(-50%, -120%); } to { transform: translate(-50%, 0); } }
@keyframes rpout { to { transform: translate(-50%, -140%); opacity: 0; } }

/* daily quests */
.quests h3 { margin-bottom: 8px; }
.quest { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 2px solid var(--ink); }
.quests h3 + .quest { border-top: 0; }
.quest > canvas { flex: none; }
.quest .q-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.quest .q-text { font-size: 15px; }
.quest .q-bar { position: relative; height: 18px; background: var(--ink); }
.quest .q-bar > i { position: absolute; inset: 0 auto 0 0; background: var(--green); transition: width .3s steps(6); }
.quest .q-bar > span { position: absolute; right: 4px; top: -1px; font-family: var(--pixel-font); font-size: 20px; line-height: 20px; color: var(--white); text-shadow: 1px 1px 0 var(--ink); }
.quest.done .q-bar > i { background: var(--gold); }
.quest.claimed { opacity: .55; }
.quest .q-ok { font-family: var(--pixel-font); font-size: 20px; color: var(--green); }
.quest .q-claim { animation: blink 1s steps(1) infinite; }
.q-foot { font-size: 13px; margin: 6px 0 0; }

/* badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 8px; }
@media (max-width: 360px) { .badge-grid { grid-template-columns: 1fr 1fr; } }
.badge-cell { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px; background: var(--ink); text-align: center; min-width: 0; }
.badge-cell canvas { display: block; }
.badge-cell .b-title { font-family: var(--pixel-font); font-size: 20px; line-height: 22px; max-width: 100%; overflow-wrap: anywhere; hyphens: auto; }
.badge-cell .b-desc { font-size: 12px; line-height: 1.3; color: var(--mist); }
.badge-cell .b-reward { font-family: var(--pixel-font); font-size: 20px; color: var(--green); }
.badge-cell:not(.got) { opacity: .7; }
.badge-cell:not(.got) .b-title { color: var(--mist); }

/* shop */
.shop-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.shop-preview { display: flex; align-items: flex-end; gap: 12px; padding: 8px; background: var(--ink); }
.shop-preview canvas { display: block; }
.shop-wallet { display: flex; align-items: center; gap: 8px; font-family: var(--pixel-font); font-size: 30px; line-height: 36px; color: var(--gold); }
.shop-head p { font-size: 14px; margin: 6px 0 0; }
.shop-head > div:last-child { flex: 1 1 200px; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.shop-item { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px; background: var(--ink); text-align: center; }
.shop-item.owned { box-shadow: inset 0 0 0 2px var(--green); }
.shop-item.poor .shop-thumb { opacity: .6; }
.shop-thumb { border: 0; background: var(--navy); padding: 4px; min-width: 72px; min-height: 72px; display: grid; place-items: center; cursor: pointer; }
.shop-thumb canvas { display: block; }
.shop-thumb .sw.big { display: block; width: 44px; height: 44px; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .35); }
.si-name { font-size: 13px; line-height: 1.25; min-height: 2.5em; }
.shop-item .btn { width: 100%; justify-content: center; }
.av-opt .price { position: absolute; left: 2px; right: 2px; bottom: 1px; display: flex; align-items: center; justify-content: center; gap: 2px; font-family: var(--pixel-font); font-size: 20px; line-height: 20px; color: var(--gold); text-shadow: 1px 1px 0 var(--ink); }

/* theory */
.node-row { display: flex; gap: 6px; align-items: stretch; }
.node-row .node { flex: 1; min-width: 0; }
.theory-btn { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 76px; padding: 6px 4px; background: var(--navy); }
.theory-btn canvas { display: block; }
.theory-btn .tb-l { font-size: 20px; line-height: 20px; }
.theory-btn.read { background: var(--teal); }
.theory { display: flex; flex-direction: column; gap: 12px; }
.th-head { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--region-a, var(--dusk)); }
.th-head canvas { flex: none; }
.th-head h1 { margin: 0; }
.th-head p { margin: 4px 0 0; }
.th-class { font-family: var(--pixel-font); font-size: 20px; }
.th-time { margin: 0; font-size: 13px; }
.th-intro { font-size: 17px; line-height: 1.6; margin: 0; }
.th-lesson { display: flex; flex-direction: column; gap: 12px; }
.th-card { background: var(--card); color: var(--card-ink); padding: 14px 16px; box-shadow: 0 0 0 var(--px) var(--ink); overflow-wrap: anywhere; }
.th-card h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-family: var(--pixel-font); font-size: 20px; line-height: 24px; font-weight: normal; color: var(--card-ink); }
.th-n { flex: none; width: 30px; height: 30px; display: grid; place-items: center; background: var(--region-a, var(--navy)); color: var(--white); }
.th-body p { margin: 0 0 10px; font-size: 16px; line-height: 1.65; }
.th-body ul, .th-key ul { margin: 0 0 10px; padding-left: 22px; font-size: 16px; line-height: 1.6; }
.th-body li, .th-key li { margin-bottom: 4px; }
.th-note { margin: 0 0 10px; padding: 8px 12px; background: #fdf0c9; border-left: 4px solid var(--orange); font-size: 15px; line-height: 1.55; }
.th-key { background: #e9f5e0; }
.th-card .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.th-actions { justify-content: center; flex-wrap: wrap; }
.th-loading { padding: 24px; text-align: center; }
.rich code.icode { font-family: var(--mono-font); font-size: .92em; padding: 1px 4px; background: rgba(26, 28, 44, .08); box-shadow: inset 0 0 0 1px rgba(26, 28, 44, .12); overflow-wrap: anywhere; }

/* login: password show/hide, email tips */
.pw-wrap { position: relative; display: flex; align-items: stretch; }
.pw-wrap .field { flex: 1; min-width: 0; padding-right: 74px; }
.pw-wrap .pw-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); margin: 0; min-height: 36px; padding: 6px 8px; color: var(--mist); }
.pw-wrap .pw-eye:active:not(:disabled) { transform: translateY(-50%); }
.mail-sent { padding: 10px 12px; background: rgba(56, 183, 100, .12); box-shadow: inset 0 0 0 2px rgba(56, 183, 100, .5); font-size: 14px; line-height: 1.5; }
.mail-sent p { margin: 0 0 6px; }
.mail-tips { margin: 6px 0 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--mist); }
.mail-tips li { margin-bottom: 2px; }
.theory-link { margin-left: 6px; background: #e3ecff; }
.theory-modal .th-card { box-shadow: 0 0 0 2px var(--ink); }
.modal:has(.theory-modal) { max-width: 680px; }

/* avatar editor: ready-made characters */
.av-presets-h { margin: 0 0 6px; font-family: var(--pixel-font); font-size: 20px; font-weight: normal; }
.av-presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; margin-bottom: 10px; }
.av-preset { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 0; background: var(--ink); color: var(--white); cursor: pointer; font-size: 13px; }
.av-preset:hover { box-shadow: inset 0 0 0 2px var(--slate); }
.av-preset:focus-visible { outline: 3px solid var(--cyan); outline-offset: 1px; }
.av-preset canvas { display: block; }
.results .center > .row { justify-content: center; } /* stars under the victory heading */
@media (max-width: 480px) {
  /* question labels (topic, difficulty, review/exam tags): compact text instead of the wide pixel font */
  .card .meta { font-family: var(--read-font); font-size: 13px; line-height: 1.2; gap: 6px; }
  .card .meta .tag { padding: 3px 6px; }
}

/* ---------- legal pages (privacy / terms / cookies) + footer links */
.legal-links { text-align: center; font-family: var(--read-font); font-size: 13px; line-height: 1.8; margin: 16px 0 20px; color: var(--mist); }
.legal-links a { color: var(--mist); text-decoration: underline; text-underline-offset: 3px; padding: 4px 2px; }
.legal-links a:hover, .legal-links a:focus-visible { color: var(--gold); }
.legal-note a, .legal a { color: var(--gold); }
.legal-tabs { justify-content: center; max-width: 760px; margin: 0 auto 8px; }
.legal-tabs .btn { text-decoration: none; }
.legal-tabs .btn[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.legal { max-width: 760px; margin: 0 auto; font-family: var(--read-font); }
.legal p, .legal li { font-size: 15px; line-height: 1.65; margin: 0 0 10px; }
.legal ul { margin: 0 0 10px; padding-left: 22px; }
.legal li { margin-bottom: 6px; }
.legal h3 { margin-top: 22px; }
.legal .legal-date { font-size: 13px; margin-bottom: 14px; }
.legal a { overflow-wrap: anywhere; }
.legal-table-wrap { overflow-x: auto; margin: 0 0 10px; }
.legal-table { border-collapse: collapse; width: 100%; font-size: 14px; line-height: 1.5; }
.legal-table th, .legal-table td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 2px solid rgba(255, 255, 255, .12); }
.legal-table th { color: var(--mist); font-weight: 600; white-space: nowrap; }
.legal-table code { white-space: nowrap; }
@media (max-width: 560px) { /* stack the cookies table into cards on phones */
  .legal-table thead { display: none; }
  .legal-table tr { display: block; padding: 8px 0; border-bottom: 2px solid rgba(255, 255, 255, .12); }
  .legal-table td { display: block; border: 0; padding: 2px 0; }
  .legal-table td:nth-child(2), .legal-table td:nth-child(4) { color: var(--mist); font-size: 13px; }
}
