/* Grimoire — quiz Magic */

@font-face { font-family: 'Alegreya'; src: url('/fonts/alegreya-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url('/fonts/alegreya-latin-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Alegreya'; src: url('/fonts/alegreya-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url('/fonts/alegreya-sans-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url('/fonts/alegreya-sans-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url('/fonts/alegreya-sans-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Alegreya Sans'; src: url('/fonts/alegreya-sans-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  /* Playmat night blue, brass accents, mana colours as meaning */
  --bg: #1f2540;
  --bg-2: #282f50;
  --bg-3: #333c66;
  --line: #424c7c;
  --text: #f3efe4;
  --muted: #b0b5d2;
  --brass: #dcb75e;
  --brass-hi: #ecca78;
  --brass-ink: #2a2110;
  --ok: #4fb67f;
  --ok-bg: rgba(79, 182, 127, 0.16);
  --ko: #ec6a4f;
  --ko-bg: rgba(236, 106, 79, 0.16);

  --frame-W: #e8dfbd;
  --frame-U: #3d7cc0;
  --frame-B: #4d4553;
  --frame-R: #c64a32;
  --frame-G: #3a8c5c;
  --frame-M: #cfa548;
  --frame-C: #a7a297;
  --frame-L: #8d6e4c;

  --lvl-learning: #3e8f6a;
  --lvl-known: #5fb98a;
  --lvl-mastered: #a6e3c2;
  --lvl-new: #3a4268;

  --serif: 'Alegreya', 'Iowan Old Style', Georgia, serif;
  --sans: 'Alegreya Sans', 'Segoe UI', system-ui, sans-serif;

  --r-s: 8px;
  --r-m: 12px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 80% at 50% -10%, #2b3359 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.with-nav { padding-bottom: calc(var(--nav-h) + var(--safe-b)); }
body.with-nav.in-game { padding-bottom: 0; }
main { outline: none; }
img { max-width: 100%; display: block; }
a { color: var(--brass-hi); }
a:hover { color: #fff3d0; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.15; margin: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.35rem); letter-spacing: -0.01em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
code { font-size: 0.92em; background: var(--bg-3); padding: 0.05em 0.35em; border-radius: 4px; }
kbd { font-family: var(--sans); }
:focus-visible { outline: 3px solid var(--brass-hi); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ chrome */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 10px clamp(14px, 3vw, 28px);
  padding-top: max(10px, env(safe-area-inset-top));
  background: #1f2540;
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--serif); font-weight: 700; font-size: 1.45rem; color: var(--brass); text-decoration: none; letter-spacing: 0.01em; }
.brand:hover { color: var(--brass-hi); }
.mainnav { display: flex; gap: 4px; margin-left: auto; }
.mainnav a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 500;
}
.mainnav a:hover { color: var(--text); background: var(--bg-2); }
.mainnav a[aria-current='page'] { color: var(--brass-ink); background: var(--brass); }
.mainnav .ms { font-size: 1.05em; }

.profile-menu { position: relative; }
.profile-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px 4px 4px; font: inherit; font-weight: 500; cursor: pointer;
}
.profile-pill:hover { border-color: var(--muted); }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-m);
  padding: 6px; display: grid; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.6);
}
.menu a, .menu button {
  display: block; text-align: left; padding: 10px 12px; border-radius: var(--r-s);
  color: var(--text); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
}
.menu a:hover, .menu button:hover { background: var(--bg-3); }

.avatar {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-family: var(--serif); font-weight: 700; font-size: 1rem; color: #1b1b1b;
}
.avatar-l { width: 56px; height: 56px; font-size: 1.6rem; }
.tone-w { background: var(--frame-W); }
.tone-u { background: #8db8e6; }
.tone-b { background: #b9a9c2; }
.tone-r { background: #f0a083; }
.tone-g { background: #93cfa5; }

@media (max-width: 899px) {
  .mainnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; margin: 0;
    height: calc(var(--nav-h) + var(--safe-b)); padding: 6px 6px var(--safe-b);
    background: rgba(31, 37, 64, 0.97); border-top: 1px solid var(--line);
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
  }
  .mainnav a { flex-direction: column; gap: 2px; justify-content: center; border-radius: var(--r-s); font-size: 0.8rem; padding: 4px; }
  .mainnav a[aria-current='page'] { background: transparent; color: var(--brass); }
  .mainnav .ms { font-size: 1.35rem; }
  .in-game .mainnav { display: none; }
  .pill-name { display: none; }
  .profile-pill { padding: 3px; margin-left: auto; }
}

/* ------------------------------------------------------------------ layout */
.page { max-width: 1040px; margin: 0 auto; padding: clamp(20px, 4vw, 40px) clamp(14px, 3vw, 28px) 48px; display: grid; gap: 24px; align-content: start; }
.page.narrow { max-width: 680px; }
.page-wide { max-width: 1240px; }
.page-head { display: grid; gap: 8px; }
.lead { color: var(--muted); font-size: 1.08rem; max-width: 62ch; }
.hint { color: var(--muted); font-size: 0.9rem; }
.center { display: flex; justify-content: center; }
.stack { display: grid; gap: 16px; }
.back-link { color: var(--muted); text-decoration: none; font-size: 0.95rem; justify-self: start; }
.back-link::before { content: '‹ '; }
.back-link:hover { color: var(--text); }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-m); padding: clamp(16px, 2.5vw, 24px); display: grid; gap: 16px; }
.panel-highlight { border-color: rgba(220, 183, 94, 0.55); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.notice { border: 1px dashed var(--brass); border-radius: var(--r-m); padding: 18px; display: grid; gap: 12px; justify-items: start; }
.error-box, .ok-box { padding: 12px 16px; border-radius: var(--r-s); }
.error-box { background: var(--ko-bg); border: 1px solid var(--ko); }
.ok-box { background: var(--ok-bg); border: 1px solid var(--ok); }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }

/* ------------------------------------------------------------------ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border-radius: 10px;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; transition: background-color 0.15s, border-color 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--brass); color: var(--brass-ink); }
.btn-primary:hover:not(:disabled) { background: var(--brass-hi); color: var(--brass-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--muted); color: var(--text); }
.btn-danger { background: transparent; color: #ffb4a3; border-color: rgba(236, 106, 79, 0.55); }
.btn-danger:hover:not(:disabled) { background: var(--ko-bg); color: #ffd3c8; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 0.9rem; font-weight: 500; }
.btn-block { width: 100%; }
.btn-large { min-height: 52px; font-size: 1.08rem; }
.link-btn { background: none; border: 0; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; padding: 6px; }
.link-btn:hover { color: var(--text); }
.chip { background: var(--bg-3); color: var(--text); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 0.92rem; cursor: pointer; }
.chip:hover { border-color: var(--brass); }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }

input:not([type='checkbox']):not([type='radio']), select {
  width: 100%; min-height: 46px; padding: 0 14px;
  background: #1a2038; color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 1rem;
}
select { padding-right: 34px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus { border-color: var(--brass); outline: none; box-shadow: 0 0 0 3px rgba(220, 183, 94, 0.25); }
input::placeholder { color: #7d84a8; }
label, .field-label { font-weight: 500; }
.field { display: grid; gap: 6px; }
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-weight: 400; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--brass); flex: none; }

.segmented { display: flex; flex-wrap: wrap; gap: 4px; background: #1a2038; border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.seg { flex: 1 1 auto; position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: block; text-align: center; padding: 8px 12px; border-radius: 9px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.seg input:checked + span { background: var(--bg-3); color: var(--text); box-shadow: inset 0 0 0 1px var(--brass); }
.seg input:focus-visible + span { outline: 3px solid var(--brass-hi); outline-offset: 1px; }

.toggle { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-m); font-weight: 400; }
.toggle input { position: absolute; opacity: 0; }
.toggle-ui { flex: none; width: 46px; height: 28px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line); position: relative; transition: background-color 0.15s; margin-top: 2px; }
.toggle-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--muted); transition: transform 0.15s, background-color 0.15s; }
.toggle input:checked + .toggle-ui { background: var(--brass); border-color: var(--brass); }
.toggle input:checked + .toggle-ui::after { transform: translateX(18px); background: var(--brass-ink); }
.toggle input:focus-visible + .toggle-ui { outline: 3px solid var(--brass-hi); outline-offset: 2px; }

.badge { display: inline-block; font-size: 0.8rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--brass); color: var(--brass-hi); }
.delta { font-weight: 700; white-space: nowrap; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--ko); }
.delta.flat { color: var(--muted); font-weight: 500; }

/* ------------------------------------------------------------------ gate (login, profiles) */
.gate { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.gate-inner { width: min(100%, 380px); display: grid; gap: 20px; text-align: center; }
.gate-wide { width: min(100%, 560px); }
.gate-title { font-size: clamp(2.6rem, 9vw, 3.6rem); color: var(--brass); }
.gate-sub { color: var(--muted); font-size: 1.1rem; }
.gate-form { display: grid; gap: 10px; text-align: left; margin-top: 8px; }
.form-error { color: #ffb4a3; }
.profile-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; text-align: left; }
.profile-choice {
  width: 100%; display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center;
  padding: 12px 16px; background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-m);
  font: inherit; cursor: pointer; text-align: left;
}
.profile-choice .avatar { grid-row: span 3; }
.profile-choice:hover { border-color: var(--brass); }
.profile-name { font-family: var(--serif); font-weight: 700; font-size: 1.35rem; }
.profile-meta { color: var(--muted); font-size: 0.9rem; }
.profile-tools { display: flex; gap: 8px; justify-content: flex-end; padding: 8px 4px 0; }
.is-editing .profile-choice { pointer-events: none; opacity: 0.8; }
.new-profile { display: grid; gap: 8px; text-align: left; }

/* ------------------------------------------------------------------ home: modes */
.mode-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 900px) { .mode-list { grid-template-columns: 1fr 1fr; } }
.mode-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center;
  padding: 16px; min-height: 92px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-m);
  color: var(--text); text-decoration: none;
}
.mode-row:hover { border-color: var(--brass); color: var(--text); }
.mode-row:hover .mode-icon { background: var(--brass); color: var(--brass-ink); }
.mode-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--bg-3); color: var(--brass-hi); font-size: 1.45rem; transition: background-color 0.15s, color 0.15s; }
.mode-icon-l { width: 64px; height: 64px; font-size: 2rem; flex: none; }
.mode-text { display: grid; gap: 2px; }
.mode-title { font-family: var(--serif); font-weight: 700; font-size: 1.3rem; line-height: 1.2; }
.mode-desc { color: var(--muted); font-size: 0.95rem; line-height: 1.35; }
.mode-score { display: grid; justify-items: end; text-align: right; }
.mode-rate { font-weight: 800; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.mode-count { color: var(--muted); font-size: 0.82rem; max-width: 7.5em; }
.mode-tag { font-size: 0.82rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
@media (max-width: 420px) {
  .mode-row { grid-template-columns: auto 1fr; }
  .mode-score { grid-column: 2; justify-items: start; text-align: left; display: flex; gap: 8px; align-items: baseline; }
  .mode-rate { font-size: 1.05rem; }
}

/* ------------------------------------------------------------------ setup */
.setup-head { display: flex; gap: 18px; align-items: center; }
.setup-form { display: grid; gap: 20px; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px; margin: 0; display: grid; gap: 16px; min-width: 0; }
legend { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; padding: 0 8px; }

/* ------------------------------------------------------------------ game */
.game { max-width: 1120px; margin: 0 auto; padding: 12px clamp(12px, 3vw, 28px) 40px; display: grid; gap: 14px; }
.game-bar { display: flex; align-items: center; gap: 12px; }
.game-progress { flex: 1; display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.game-score { display: flex; gap: 6px; font-weight: 800; font-variant-numeric: tabular-nums; }
.game-score span { min-width: 2.4em; text-align: center; padding: 2px 8px; border-radius: 999px; }
.game-score .ok { background: var(--ok-bg); color: #9fe2bd; }
.game-score .ok::before { content: '✓ '; }
.game-score .ko { background: var(--ko-bg); color: #ffb4a3; }
.game-score .ko::before { content: '✗ '; }
.timer { height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.timer-fill { height: 100%; background: var(--brass); transform-origin: left center; }

.game-body { display: grid; gap: 18px; align-items: start; }
@media (min-width: 900px) {
  .game-body { grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 32px; }
  .game-intrus .game-body, .game-truefalse .game-body { grid-template-columns: 1fr; max-width: 860px; margin: 0 auto; width: 100%; }
  .game-fiche .game-body { grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); }
  .game-fiche .stage, .game-translate .stage { position: sticky; top: 90px; }
}
.stage { display: grid; justify-items: center; gap: 14px; }
.side, .answers { display: grid; gap: 14px; align-content: start; min-width: 0; }
@media (max-width: 479px) { .q-word { display: none; } }
.question { font-family: var(--serif); font-size: 1.3rem; font-weight: 700; }
.question-l { font-size: clamp(1.3rem, 3vw, 1.7rem); text-align: center; max-width: 40ch; justify-self: center; }

/* The card frame — the one loud element */
.mtg { --frame: var(--frame-C); width: min(100%, 380px); background: #0e0e10; border-radius: 18px; padding: 10px; box-shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.85); position: relative; }
.frame-W { --frame: var(--frame-W); }
.frame-U { --frame: var(--frame-U); }
.frame-B { --frame: var(--frame-B); }
.frame-R { --frame: var(--frame-R); }
.frame-G { --frame: var(--frame-G); }
.frame-M { --frame: var(--frame-M); }
.frame-C { --frame: var(--frame-C); }
.frame-L { --frame: var(--frame-L); }
.mtg-inner {
  position: relative; display: grid; gap: 7px; padding: 8px 8px 14px; border-radius: 10px;
  background:
    linear-gradient(155deg, color-mix(in srgb, var(--frame) 70%, white) 0%, var(--frame) 45%, color-mix(in srgb, var(--frame) 65%, black) 100%);
}
.mtg-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 5px 10px; min-height: 36px; border-radius: 8px / 16px;
  background: linear-gradient(180deg, #faf6ec, #e3dccb);
  color: #1b1a17; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.3);
}
.mtg-name { font-family: var(--serif); font-weight: 700; font-size: 1.12rem; }
.mtg-title { line-height: 1.15; }
.hidden-name { letter-spacing: 0.3em; color: #6b665b; font-size: 1.3rem; }
.mtg-type { font-family: var(--serif); font-weight: 700; font-size: 0.98rem; min-height: 32px; }
.mtg-cost { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; }
.mtg-art { border: 2px solid rgba(0, 0, 0, 0.7); border-radius: 3px; overflow: hidden; background: #1a1a1a; aspect-ratio: 1.37; }
.mtg-art img { width: 100%; height: 100%; object-fit: cover; }
.mtg-text {
  background: color-mix(in srgb, var(--frame) 12%, #f6f1e4);
  color: #1b1a17; font-family: var(--serif); font-size: 1.02rem; line-height: 1.36;
  padding: 12px 14px 18px; border-radius: 3px; min-height: 96px; display: grid; gap: 8px; align-content: start;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);
}
.mtg-pt {
  position: absolute; right: 14px; bottom: -6px;
  min-width: 64px; text-align: center; padding: 3px 10px; border-radius: 8px / 14px;
  background: linear-gradient(180deg, #faf6ec, #e3dccb); color: #1b1a17;
  font-family: var(--serif); font-weight: 700; font-size: 1.15rem;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 0 3px var(--frame), 0 0 0 4px rgba(0, 0, 0, 0.6);
}
.mtg-loyalty { border-radius: 50% 50% 40% 40%; min-width: 48px; }
.mtg-text .ms-cost { font-size: 0.82em; margin: 0 1px; }
.reminder { color: #4a463e; }
.self-name { display: inline-block; padding: 0 0.4em; border-radius: 4px; background: rgba(0, 0, 0, 0.12); font-weight: 700; }
.empty-text { color: #6b665b; font-style: italic; }
.face-split { border: 0; border-top: 1px solid rgba(0, 0, 0, 0.3); margin: 2px 0; width: 100%; }

/* mana symbols */
.ms-cost { margin: 0 1px; box-shadow: -0.06em 0.07em 0 rgba(0, 0, 0, 0.75); }
.cost { display: inline-flex; flex-wrap: wrap; gap: 1px; align-items: center; }
.cost-split { margin: 0 6px; opacity: 0.6; }
.sym { display: inline-grid; place-items: center; min-width: 1.3em; height: 1.3em; padding: 0 0.2em; border-radius: 1em; background: #beb9b2; color: #111; font-size: 0.8em; font-weight: 700; }

.art-frame { margin: 0; width: min(100%, 560px); background: #0e0e10; padding: 10px; border-radius: 16px; box-shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.85); }
.art-frame img { width: 100%; border-radius: 6px; aspect-ratio: 1.37; object-fit: cover; background: #1a1a1a; }

.nameplate {
  width: min(100%, 520px); padding: 22px 20px; border-radius: 16px; text-align: center; position: relative;
  background: linear-gradient(180deg, #faf6ec, #e6dfcd); color: #1b1a17;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3), 0 0 0 6px #0e0e10, 0 24px 50px -24px rgba(0, 0, 0, 0.85);
  display: grid; gap: 6px;
}
.nameplate h2 { font-size: clamp(1.5rem, 4.5vw, 2.1rem); }
.nameplate-sub { color: #59544a; font-family: var(--serif); }
.lang-tag { position: absolute; top: 8px; left: 10px; font-size: 0.72rem; font-weight: 800; color: #59544a; border: 1px solid #a49d8c; border-radius: 4px; padding: 0 5px; }
.statement { font-family: var(--serif); font-size: clamp(1.3rem, 3.6vw, 1.7rem); text-align: center; max-width: 28ch; line-height: 1.3; }
.statement .ms-cost { font-size: 0.85em; }

/* answer buttons */
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 10px 16px;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-m);
  font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer; transition: border-color 0.12s, background-color 0.12s;
}
.choices-serif .choice { font-family: var(--serif); font-size: 1.15rem; font-weight: 700; }
.choice kbd { flex: none; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--bg-3); color: var(--muted); font-size: 0.85rem; font-weight: 700; }
.choice:hover:not(:disabled) { border-color: var(--brass); }
.choice:disabled { cursor: default; }
.is-picked { border-color: var(--muted); }
.is-correct { border-color: var(--ok) !important; background: var(--ok-bg) !important; }
.is-wrong { border-color: var(--ko) !important; background: var(--ko-bg) !important; }
.choice.is-correct kbd { background: var(--ok); color: #0d2417; }
.choice.is-wrong kbd { background: var(--ko); color: #2a0c05; }
.choice:disabled:not(.is-correct):not(.is-wrong) { opacity: 0.55; }
@media (pointer: coarse) { .choice kbd, .tile kbd { display: none; } }

.free-answer { display: grid; gap: 10px; }
.free-answer input { min-height: 54px; font-size: 1.15rem; font-family: var(--serif); }
.free-answer input.is-correct { border-color: var(--ok); }
.free-answer input.is-wrong { border-color: var(--ko); }
.free-actions { display: flex; gap: 10px; }
.free-actions .btn-primary { flex: 1; }

.tf { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tf-btn { justify-content: center; min-height: 72px; font-size: 1.25rem; font-weight: 800; }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tiles .tile:last-child:nth-child(odd) { grid-column: span 2; justify-self: center; width: calc(50% - 5px); }
@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(6, 1fr); }
  .tiles .tile { grid-column: span 2; }
  .tiles .tile:nth-child(4) { grid-column: 2 / span 2; }
  .tiles .tile:last-child:nth-child(odd) { grid-column: 4 / span 2; width: auto; }
}
.tile { position: relative; padding: 5px; background: #0e0e10; border: 2px solid var(--line); border-radius: var(--r-m); cursor: pointer; }
.tile img { width: 100%; aspect-ratio: 1.37; object-fit: cover; border-radius: 6px; background: #1a1a1a; }
.tile kbd { position: absolute; left: 10px; top: 10px; background: rgba(14, 14, 16, 0.8); color: var(--text); border-radius: 6px; padding: 0 7px; font-weight: 700; }
.tile:hover:not(:disabled) { border-color: var(--brass); }
.tile:disabled { cursor: default; }
.tile.is-correct { border-width: 3px; }

/* fiche */
.fiche { display: grid; gap: 16px; }
.fiche-part { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-m); background: rgba(40, 47, 80, 0.6); }
.fiche-part.part-ok { border-color: var(--ok); }
.fiche-part.part-ko { border-color: var(--ko); }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  min-height: 46px; min-width: 64px; padding: 6px 14px; border-radius: 10px; cursor: pointer;
  background: var(--bg-3); color: var(--text); border: 1px solid var(--line); font: inherit; font-weight: 700; font-size: 1.05rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.opt:hover:not(:disabled) { border-color: var(--brass); }
.opt[aria-pressed='true'] { border-color: var(--brass); box-shadow: inset 0 0 0 2px var(--brass); background: #3d4675; }
.opt:disabled { cursor: default; }
.color-opt { min-width: 52px; font-size: 1.5rem; padding: 6px 10px; }
.color-opt[aria-pressed='false'] .ms { opacity: 0.45; filter: grayscale(0.6); }
.opts-text { display: grid; }
.opt-text {
  display: grid; gap: 6px; justify-content: stretch; text-align: left; font-family: var(--serif); font-weight: 400; font-size: 0.98rem; line-height: 1.35;
  background: #efe9db; color: #1b1a17; border-color: #cfc6b0; padding: 10px 14px;
}
.opt-text[aria-pressed='true'] { background: #fff7df; box-shadow: inset 0 0 0 3px var(--brass); }
.opt-text.is-correct { background: #e1f3e8 !important; box-shadow: inset 0 0 0 3px var(--ok); }
.opt-text.is-wrong { background: #f8e0d9 !important; box-shadow: inset 0 0 0 3px var(--ko); }
.opt-text .ms-cost { font-size: 0.82em; }

/* flashcards */
.flash { display: grid; justify-items: center; gap: 14px; width: 100%; }
.flash-front { display: grid; justify-items: center; gap: 14px; width: 100%; }
.flash-actions { display: grid; gap: 12px; }
.flash-actions .tf-btn { font-size: 1.05rem; min-height: 60px; }

/* feedback */
.feedback { display: grid; gap: 14px; padding: 18px; border-radius: var(--r-m); background: var(--bg-2); border: 1px solid var(--line); border-left-width: 6px; scroll-margin-top: 80px; }
.feedback.is-ok { border-left-color: var(--ok); }
.feedback.is-ko { border-left-color: var(--ko); }
.feedback-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 6px 16px; }
.verdict { font-family: var(--serif); font-weight: 700; font-size: 1.45rem; }
.is-ok .verdict { color: #9fe2bd; }
.is-ko .verdict { color: #ffb4a3; }
.mastery-note { color: var(--muted); font-size: 0.92rem; }
.expected { font-size: 1.05rem; }
.expected strong { font-family: var(--serif); font-size: 1.15rem; }
.expected .ms-cost { font-size: 0.85em; }
.reveal { display: flex; flex-wrap: wrap; gap: 14px; }
.reveal-card { margin: 0; display: grid; gap: 6px; width: min(240px, 100%); }
.reveal-many .reveal-card { width: calc((100% - 4 * 14px) / 5); min-width: 120px; }
@media (max-width: 699px) { .reveal-many .reveal-card { width: calc((100% - 14px) / 2); min-width: 0; } }
.reveal-card figcaption { display: grid; font-size: 0.95rem; line-height: 1.25; }
.reveal-card strong, .missed-card strong { font-family: var(--serif); }
.reveal-card.is-intrus .card-img { box-shadow: 0 0 0 3px var(--brass); }
.prop-tag { color: var(--brass-hi); font-weight: 700; font-size: 0.85rem; }
.name-en { color: var(--muted); font-size: 0.9em; }
.card-img { width: 100%; aspect-ratio: 488 / 680; object-fit: cover; border-radius: 4.75% / 3.5%; background: #14182b; }
.card-zoom { padding: 0; border: 0; background: none; cursor: zoom-in; width: 100%; border-radius: 4.75% / 3.5%; }
.next-bar { position: sticky; bottom: 0; padding: 10px 0 calc(4px + var(--safe-b)); background: linear-gradient(180deg, rgba(40, 47, 80, 0), var(--bg-2) 30%); }
@media (min-width: 900px) { .next-bar { position: static; background: none; padding: 0; max-width: 360px; } }

.reveal-big { display: grid; justify-items: center; gap: 10px; }
.reveal-big .card-img { width: min(100%, 340px); }
.reveal-names { display: grid; text-align: center; font-size: 1.1rem; }

/* summary */
.summary { text-align: left; }
.big-score { display: flex; align-items: baseline; gap: 12px; font-family: var(--serif); font-weight: 700; font-size: clamp(3rem, 12vw, 4.5rem); line-height: 1; color: var(--brass); font-variant-numeric: tabular-nums; }
.big-score-sep { font-size: 0.4em; color: var(--muted); font-weight: 400; }
.missed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.missed-card { margin: 0; display: grid; gap: 6px; }
.missed-card figcaption { display: grid; font-size: 0.92rem; line-height: 1.25; }

/* zoom overlay & modals */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 22, 0.78); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.modal { position: relative; width: min(100%, 440px); background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-m); padding: 24px; display: grid; gap: 16px; }
.modal-wide { width: min(100%, 760px); }
.modal-title { padding-right: 32px; }
.modal-close { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 1.6rem; cursor: pointer; }
.modal-close:hover { background: var(--bg-3); color: var(--text); }
.confirm-text { font-size: 1.05rem; padding-right: 24px; }
.zoom { cursor: zoom-out; }
.zoom-cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.zoom-cards img { width: min(88vw, 420px); border-radius: 4.75% / 3.5%; }

.card-detail { display: grid; gap: 20px; }
@media (min-width: 700px) { .card-detail { grid-template-columns: minmax(0, 1.1fr) 1fr; } }
.card-detail-imgs { display: grid; gap: 10px; }
.card-detail-info { display: grid; gap: 10px; align-content: start; }
.detail-cost { font-size: 1.2rem; }

/* toasts */
.toast-zone { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 16px + var(--safe-b)); z-index: 60; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { padding: 12px 16px; border-radius: var(--r-s); background: #11162a; border: 1px solid var(--line); box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.7); transition: opacity 0.4s; }
.toast-error { border-color: var(--ko); }
.toast.leaving { opacity: 0; }

/* ------------------------------------------------------------------ stats */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-m); padding: 14px 16px; display: grid; gap: 2px; }
.kpi-value { font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-value .delta { font-size: inherit; }
.kpi-label { color: var(--muted); font-size: 0.88rem; line-height: 1.3; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters select { width: auto; min-width: 180px; min-height: 40px; }
.filters-bar { align-items: center; }
.filters-bar input[type='search'] { flex: 1 1 220px; width: auto; }
.filters-bar .segmented { flex: none; }

.mastery { display: grid; gap: 12px; }
.mastery-headline strong { font-size: 1.5rem; }
.mastery-bar { display: flex; gap: 2px; height: 22px; border-radius: 6px; overflow: hidden; background: var(--lvl-new); }
.mastery-bar span { display: block; height: 100%; }
.seg-mastered { background: var(--lvl-mastered); }
.seg-known { background: var(--lvl-known); }
.seg-learning { background: var(--lvl-learning); }
.seg-new { background: var(--lvl-new); box-shadow: inset 0 0 0 1px var(--line); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 0.92rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.chart { position: relative; display: grid; gap: 4px; }
.chart-title { color: var(--muted); font-size: 0.9rem; font-weight: 500; }
.chart-svg { width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.chart-svg .grid { stroke: #39426d; stroke-width: 1; }
.chart-svg .baseline { stroke: #4b5585; stroke-width: 1; }
.chart-svg .axis { fill: #9aa0c2; font-size: 11px; font-family: var(--sans); }
.chart-svg .line { fill: none; stroke: var(--brass); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { fill: var(--brass); stroke: var(--bg-2); stroke-width: 2; }
.chart-svg .bar { fill: #8b93b8; }
.chart-svg .crosshair { stroke: #c9cde3; stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; top: 24px; transform: translateX(-50%); pointer-events: none; background: #11162a; border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 10px; font-size: 0.88rem; line-height: 1.35; white-space: nowrap; box-shadow: 0 10px 24px -10px rgba(0, 0, 0, 0.7); }
.chart-tip strong { text-transform: none; }

.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.table thead th { color: var(--muted); font-weight: 500; font-size: 0.88rem; }
.table tbody th { font-weight: 500; }
.table .num { text-align: right; }
.row-icon { color: var(--brass-hi); margin-right: 10px; width: 1.2em; text-align: center; }
@media (max-width: 600px) { .hide-s { display: none; } .table th, .table td { padding: 9px 4px; } }

.color-stats { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.color-stats li { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.color-name { display: flex; align-items: center; gap: 10px; }
.color-name .ms { font-size: 1.2rem; }
.color-rate { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ scoreboard */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 40px auto 1fr auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: var(--r-s); }
.rank-row.is-me { background: rgba(220, 183, 94, 0.1); box-shadow: inset 0 0 0 1px rgba(220, 183, 94, 0.4); }
.rank-place { font-family: var(--serif); font-weight: 700; font-size: 1.15rem; color: var(--muted); }
.place-1 { color: var(--brass); font-size: 1.35rem; }
.rank-name { font-family: var(--serif); font-weight: 700; font-size: 1.12rem; }
.rank-score { display: grid; justify-items: end; text-align: right; font-size: 0.92rem; }
.rank-score b { font-size: 1.2rem; font-variant-numeric: tabular-nums; margin-right: 2px; }
.rank-score .hint { font-size: 0.82rem; }
.rank-grid { display: grid; gap: 16px; }
@media (min-width: 820px) { .rank-grid { grid-template-columns: 1fr 1fr; } }
.empty-rank { padding: 4px 0; }

/* ------------------------------------------------------------------ cards browser */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
@media (max-width: 480px) { .card-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } }
.card-tile { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 4.75% / 3.5%; }
.card-tile:hover .card-img { box-shadow: 0 0 0 3px var(--brass); }
.card-ph { display: grid; place-items: center; aspect-ratio: 488 / 680; background: var(--bg-3); border-radius: 10px; padding: 10px; font-family: var(--serif); }
.level-chip { display: inline-block; font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--lvl-new); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.card-tile .level-chip { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); white-space: nowrap; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); }
.level-learning { background: var(--lvl-learning); color: #fff; box-shadow: none; }
.level-known { background: var(--lvl-known); color: #0f2a1c; box-shadow: none; }
.level-mastered { background: var(--lvl-mastered); color: #0f2a1c; box-shadow: none; }

/* ------------------------------------------------------------------ library */
.collection-list { list-style: none; margin: 0; padding: 0; display: grid; }
.collection-list li { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.collection-name { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
@media (max-width: 520px) { .collection-list li { grid-template-columns: auto auto 1fr; } .collection-list .collection-name { grid-column: 1 / span 2; } .collection-list .hint { grid-column: 3; justify-self: end; } }
.import-status { display: grid; gap: 10px; padding: 14px 16px; border-radius: var(--r-s); border: 1px solid var(--brass); }
.progress { height: 8px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brass); transition: width 0.4s; }

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