/* frappe — FR.game (js/game/meta.js): header chip, trainer card, predicted scores, history charts,
   game settings, daily quests + bonus chest, achievements gallery, cosmetics shop, and the
   purchasable colour themes. Classes are prefixed mt-. Built on game-base.css (.g-*) and the theme
   tokens; fixed hex values only appear in item art (coins, chest, balls, frames) and chart series.
   Text colours: --text for values, --g-gloss for every label, gloss and secondary text that carries meaning,
   --g-coin-ink / --g-ok-ink (and the rarity inks of the shop) for coloured text. --sub only for decoration
   (bars, grid lines, outlines): it is about 2:1, unreadable as text. */

/* ================================================================ native widgets follow the theme
   Date pickers, select popups, scrollbars and autofill use the theme's lightness: every theme is dark except
   the light ones listed here (legacy themes of style.css + the light shop themes below). meta.js owns the theme
   catalog, so a new light theme must be added to this list. */
:root {
  color-scheme: dark;
}
:root[data-theme="baguette"],
:root[data-theme="craie"],
:root[data-theme="macaron"],
:root[data-theme="camembert"],
:root[data-theme="riviera"] {
  color-scheme: light;
}

/* ================================================================ shop colour themes
   Registered in window.frappe.themes by meta.js once owned; all 8 tokens per theme. */
[data-theme="camembert"] {
  --bg: #f7f1e1;
  --main: #8f5212;
  --caret: #c9821e;
  --sub: #8f8268;
  --sub-alt: #ebe2c9;
  --text: #3a3020;
  --error: #b3261e;
  --error-extra: #e2938a;
}
[data-theme="riviera"] {
  --bg: #eef6f8;
  --main: #0a6782;
  --caret: #e8912a;
  --sub: #6f8d97;
  --sub-alt: #d9eaef;
  --text: #12313b;
  --error: #c0392b;
  --error-extra: #eba091;
}
[data-theme="foret"] {
  --bg: #1b2a22;
  --main: #8fd694;
  --caret: #e9c46a;
  --sub: #5f7a68;
  --sub-alt: #15211a;
  --text: #dfeadf;
  --error: #ff7b6b;
  --error-extra: #8a3a31;
}
[data-theme="montmartre"] {
  --bg: #221c2c;
  --main: #f4d58d;
  --caret: #e8566b;
  --sub: #776c8c;
  --sub-alt: #1a1522;
  --text: #ece5f3;
  --error: #ff6b81;
  --error-extra: #8c3343;
}
[data-theme="bretagne"] {
  --bg: #16212c;
  --main: #ffd23f;
  --caret: #f4f1e8;
  --sub: #617487;
  --sub-alt: #101922;
  --text: #e6edf3;
  --error: #ff6b6b;
  --error-extra: #8f3434;
}
[data-theme="versailles"] {
  --bg: #152039;
  --main: #e6c27a;
  --caret: #f6a33b;
  --sub: #5d6f95;
  --sub-alt: #0f1830;
  --text: #f1ece2;
  --error: #ff7a7a;
  --error-extra: #8f3434;
}

/* ================================================================ shared bits */
.mt-coin {
  display: inline-block;
  flex: none;
  width: 0.9em;
  height: 0.9em;
  margin-right: 0.25em;
  border-radius: 50%;
  vertical-align: -0.12em;
  background: var(--g-coin);
  background: radial-gradient(circle at 35% 32%, #fff4b8 0 14%, var(--g-coin) 42%, #b8860b 100%);
  box-shadow: inset 0 0 0 0.09em rgba(120, 80, 0, 0.45);
}
.mt-page {
  padding-top: 0.5rem;
}
.mt-page .g-btn:focus-visible,
.mt-page .g-tab:focus-visible,
.mt-opt:focus-visible,
.mt-av-btn:focus-visible,
.mt-modal .g-btn:focus-visible,
.mt-table summary:focus-visible {
  outline: 2px solid var(--main);
  outline-offset: 2px;
}
.mt-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.mt-en {
  display: block;
  font-size: 0.75rem;
  margin-top: 0.1rem;
}
.mt-h3 {
  margin: 0 0 0.7rem;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 400;
}
.mt-panel {
  min-width: 0;
}
.mt-two {
  display: grid;
  gap: var(--g-gap);
  grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
}
.mt-lvrow {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.4rem;
}
.mt-lvrow .g-bar {
  flex: 1;
  min-width: 4rem;
}
.mt-lvrow .g-sub {
  white-space: nowrap;
}
/* secondary buttons sitting on a --sub-alt card get the --bg surface so they read as buttons */
.mt-item .g-btn:not(.primary):not(.ghost),
.mt-quest > .g-btn,
.mt-chest-act .g-btn:not(.primary),
.mt-loot .g-btn:not(.primary),
.mt-links .g-btn,
.mt-settings .g-btn:not(.ghost),
.mt-data .g-btn:not(.mt-danger),
.mt-preview-bar .g-btn {
  background: var(--bg);
}
.mt-item .g-btn:not(.primary):not(.ghost):hover,
.mt-quest > .g-btn:hover,
.mt-chest-act .g-btn:not(.primary):hover,
.mt-loot .g-btn:not(.primary):hover,
.mt-links .g-btn:hover,
.mt-settings .g-btn:not(.ghost):hover,
.mt-data .g-btn:not(.mt-danger):hover,
.mt-preview-bar .g-btn:hover {
  background: var(--text);
  color: var(--bg);
}
.g-btn.mt-danger {
  background: var(--error);
  color: var(--bg);
}
.g-btn.mt-danger:hover {
  filter: brightness(1.1);
}

/* ================================================================ header chip (FR.game.chipHtml) */
.mt-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--g-gloss);
  font-size: 0.85rem;
  white-space: nowrap;
}
.mt-chip-lv {
  color: var(--text);
}
.mt-chip-coins {
  display: inline-flex;
  align-items: center;
  color: var(--text);
}
.mt-chip-flame {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
}
.mt-chip-flame > span {
  filter: grayscale(1);
  opacity: 0.55;
}
.mt-chip-flame.lit {
  color: var(--text);
}
.mt-chip-flame.lit > span {
  filter: none;
  opacity: 1;
}
.mt-chip-ring {
  width: 1.1rem;
  height: 1.1rem;
  transform: rotate(-90deg);
  fill: none;
}
.mt-chip-ring circle {
  fill: none;
  stroke-width: 5;
}
.mt-chip-ring .bg {
  stroke: var(--bg);
}
.mt-chip-ring .fg {
  stroke: var(--main);
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s;
}
.mt-chip.met .mt-chip-ring .fg {
  stroke: var(--g-ok);
}
/* learn.css hides "#xp-chip span:last-child" on phones (legacy chip); keep ours visible */
#xp-chip span.mt-chip,
#xp-chip .mt-chip span {
  display: inline-flex;
}

/* ================================================================ avatars & frames */
.mt-av {
  --av: var(--main);
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 3.2rem;
  height: 3.2rem;
  padding: 0.22rem;
  box-sizing: border-box;
  border-radius: 50%;
  background: var(--mt-frame, transparent);
}
.mt-av-in {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--sub-alt);
  background: color-mix(in srgb, var(--av) 28%, var(--sub-alt));
  box-shadow: inset 0 0 0 0.2rem var(--av);
  font-size: 1.6rem;
  line-height: 1;
}
.mt-av-sm {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0.16rem;
}
.mt-av-sm .mt-av-in {
  font-size: 1.15rem;
  box-shadow: inset 0 0 0 0.14rem var(--av);
}
.mt-av-lg {
  width: 6rem;
  height: 6rem;
  padding: 0.34rem;
}
.mt-av-lg .mt-av-in {
  font-size: 3rem;
  box-shadow: inset 0 0 0 0.3rem var(--av);
}
.mt-frame-bronze {
  --mt-frame: linear-gradient(135deg, #7a4a22, #e0a46a 45%, #8c5a2b);
}
.mt-frame-argent {
  --mt-frame: linear-gradient(135deg, #7f8b97, #f1f4f7 45%, #8e9aa6);
}
.mt-frame-or {
  --mt-frame: linear-gradient(135deg, #a87600, #ffe27a 45%, #b8860b);
  box-shadow: 0 0 0.6rem rgba(242, 194, 48, 0.45);
}
.mt-frame-tricolore {
  --mt-frame: conic-gradient(#0055a4 0 33.3%, #f5f5f5 0 66.6%, #ef4135 0);
}
.mt-frame-laurier {
  --mt-frame: repeating-conic-gradient(#3f8f3a 0 9deg, #8fd17a 9deg 18deg);
}
.mt-frame-arc-en-ciel {
  --mt-frame: conic-gradient(#e53935, #fb8c00, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935);
}
.mt-frame-diamant {
  --mt-frame: conic-gradient(#b9f2ff, #ffffff, #7fd8ff, #e0f7ff, #a7c7ff, #ffffff, #b9f2ff);
  box-shadow: 0 0 0.8rem rgba(127, 216, 255, 0.6);
}

/* ================================================================ trainer card */
.mt-tcard {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem 1.25rem;
}
.mt-av-btn {
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.12s;
}
.mt-av-btn:hover {
  transform: scale(1.04);
}
.mt-tinfo {
  min-width: 0;
}
.mt-name-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.mt-name {
  color: var(--text);
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}
.mt-name-input {
  max-width: 16rem;
  padding: 0.35rem 0.6rem;
  font-size: 1.2rem;
}
.mt-rank {
  color: var(--g-gloss);
  font-size: 0.9rem;
  margin-top: 0.15rem;
}
.mt-rank b {
  color: var(--main);
  font-weight: 400;
}
.mt-epithet {
  color: var(--text);
  font-family: "Lexend Deca", sans-serif;
}
.mt-lvbadge {
  padding: 0.1rem 0.5rem;
  border-radius: 0.4rem;
  background: var(--main);
  color: var(--bg);
  font-size: 0.8rem;
  white-space: nowrap;
}
.mt-tinfo .mt-lvrow {
  flex-wrap: wrap;
  row-gap: 0.3rem;
}
.mt-xpbar {
  flex: 1 1 6rem;
  height: 0.6rem;
}
.mt-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}
.mt-facts .g-pill {
  background: var(--bg);
  white-space: normal;
}
.mt-goal {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.mt-ring {
  position: relative;
  display: inline-block;
  width: 6.4rem;
  height: 6.4rem;
}
.mt-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  fill: none;
}
.mt-ring circle {
  fill: none;
  stroke-width: 10;
}
.mt-ring .bg {
  stroke: var(--bg);
}
.mt-ring .fg {
  stroke: var(--main);
  stroke-linecap: round;
  transition: stroke-dasharray 0.5s;
}
.mt-ring-txt {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}
.mt-ring-txt b {
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 400;
}
.mt-ring-txt small {
  color: var(--g-gloss);
  font-size: 0.7rem;
}

/* ================================================================ predicted TCF scores */
.mt-overall {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 1.1rem;
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0.9rem;
}
.mt-overall b {
  color: var(--main);
  font-weight: 400;
}
.mt-ov-bar {
  flex-basis: 100%;
}
.mt-stats {
  display: grid;
  gap: 0.9rem 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.mt-stat-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
}
.mt-stat-name {
  color: var(--text);
}
.mt-stat-val {
  color: var(--text);
  white-space: nowrap;
}
.mt-stat-bar {
  position: relative;
  height: 0.7rem;
  margin: 1rem 0 0.75rem;
  border-radius: 1rem;
  background: var(--bg);
}
.mt-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 1rem;
  background: var(--main);
  transition: width 0.4s ease;
}
.mt-range {
  position: absolute;
  bottom: -0.45rem;
  height: 0.2rem;
  border-radius: 0.2rem;
  background: var(--sub);
}
.mt-b2 {
  position: absolute;
  top: -0.25rem;
  bottom: -0.25rem;
  width: 2px;
  margin-left: -1px;
  background: var(--text);
  opacity: 0.8;
}
.mt-b2 span {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  color: var(--g-gloss);
  font-size: 0.7rem;
  font-weight: 400;
  line-height: 1.3;
}
.mt-stat.unsure .mt-fill {
  background: var(--sub);
  background: color-mix(in srgb, var(--main) 40%, var(--bg));
}
.mt-stat-foot {
  font-size: 0.75rem;
}
.mt-note {
  margin: 0.9rem 0 0;
  font-size: 0.75rem;
}

/* ================================================================ Vocadex counts, badges, weak spots, counters */
.mt-nums {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(4.3rem, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.mt-num {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.45rem 0.2rem;
  border-radius: 0.6rem;
  background: var(--bg);
  font-size: 0.72rem;
  color: var(--g-gloss);
}
.mt-num b {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 400;
}
.mt-links {
  margin-top: 0.9rem;
}
.mt-brow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.45rem 0;
  border-top: 1px solid rgba(127, 127, 127, 0.18);
}
.mt-brow:first-of-type {
  border-top: 0;
}
.mt-breg {
  color: var(--text);
  font-size: 0.88rem;
}
.mt-badges {
  display: flex;
  gap: 0.3rem;
  align-items: center;
}
.mt-badge,
.mt-champ {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg);
  font-size: 1rem;
}
.mt-badge {
  filter: grayscale(1);
  opacity: 0.4;
}
.mt-badge.on {
  filter: none;
  opacity: 1;
  box-shadow: 0 0 0 2px var(--g-coin);
}
.mt-brow.champ .mt-breg {
  color: var(--main);
}
.mt-weak {
  list-style: none;
  margin: 0 0 0.9rem;
  padding: 0;
  display: grid;
  gap: 0.55rem;
}
.mt-wk {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  background: var(--bg);
}
.mt-wk-ic {
  font-size: 1.3rem;
}
.mt-wk-body {
  min-width: 0;
}
.mt-wk-body b {
  color: var(--text);
  font-weight: 400;
}
.mt-wk-bar {
  margin-top: 0.35rem;
  height: 0.3rem;
  background: var(--sub-alt);
}
.mt-wk-bar > i {
  background: var(--error);
}
.mt-counters {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.2rem, 1fr));
  gap: 0.5rem;
}
.mt-ctr {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.6rem 0.75rem;
  border-radius: 0.6rem;
  background: var(--bg);
}
.mt-ctr b {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 400;
}

/* ================================================================ history charts (inline SVG) */
.mt-chart {
  /* categorical series, dark surfaces (validated: CVD ΔE ≥ 9, contrast ≥ 3:1) */
  --mt-co: #3987e5;
  --mt-ce: #d95926;
  --mt-st: #199e70;
  --mt-ee: #9085e9;
  --mt-eo: #d55181;
  margin: 0;
  min-width: 0;
}
[data-theme="baguette"] .mt-chart,
[data-theme="craie"] .mt-chart,
[data-theme="macaron"] .mt-chart,
[data-theme="camembert"] .mt-chart,
[data-theme="riviera"] .mt-chart {
  /* light surfaces: same hues, light steps (relief: direct labels + table view) */
  --mt-co: #2a78d6;
  --mt-ce: #eb6834;
  --mt-st: #1baf7a;
  --mt-ee: #4a3aa7;
  --mt-eo: #e87ba4;
}
.mt-charts {
  display: grid;
  gap: 1rem 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}
.mt-chart figcaption {
  display: block;
  margin-bottom: 0.3rem;
}
.mt-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.9rem;
  color: var(--text);
  font-size: 0.78rem;
  margin-bottom: 0.3rem;
}
.mt-key {
  display: inline-block;
  width: 0.9rem;
  height: 0.22rem;
  margin-right: 0.35rem;
  border-radius: 0.2rem;
  vertical-align: middle;
}
.mt-key.mt-s-co {
  background: var(--mt-co);
}
.mt-key.mt-s-ce {
  background: var(--mt-ce);
}
.mt-key.mt-s-st {
  background: var(--mt-st);
}
.mt-key.mt-s-ee {
  background: var(--mt-ee);
}
.mt-key.mt-s-eo {
  background: var(--mt-eo);
}
.mt-chart-svg {
  display: block;
  width: 100%;
  max-width: 24rem;
  height: auto;
  overflow: visible;
  fill: none;
  stroke: none;
}
.mt-grid {
  stroke: var(--sub);
  stroke-width: 1;
  opacity: 0.35;
}
.mt-grid.ref {
  stroke: var(--text);
  stroke-dasharray: 4 3;
  opacity: 0.6;
}
.mt-axis,
.mt-lab {
  font-family: "Roboto Mono", monospace;
  stroke: none;
}
.mt-axis {
  fill: var(--g-gloss);
  font-size: 11px;
}
.mt-axis.ref {
  fill: var(--text);
}
.mt-lab {
  fill: var(--text);
  font-size: 11.5px;
}
.mt-col rect {
  fill: transparent;
  pointer-events: all;
}
.mt-col line {
  stroke: var(--sub);
  stroke-width: 1;
  opacity: 0;
}
.mt-col:hover line {
  opacity: 0.9;
}
.mt-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  pointer-events: none;
}
.mt-dot {
  stroke: var(--sub-alt);
  stroke-width: 2;
  pointer-events: none;
}
.mt-tick {
  stroke-width: 3;
  stroke-linecap: round;
}
.mt-line.mt-s-co,
.mt-tick.mt-s-co {
  stroke: var(--mt-co);
}
.mt-line.mt-s-ce,
.mt-tick.mt-s-ce {
  stroke: var(--mt-ce);
}
.mt-line.mt-s-st,
.mt-tick.mt-s-st {
  stroke: var(--mt-st);
}
.mt-line.mt-s-ee,
.mt-tick.mt-s-ee {
  stroke: var(--mt-ee);
}
.mt-line.mt-s-eo,
.mt-tick.mt-s-eo {
  stroke: var(--mt-eo);
}
.mt-dot.mt-s-co {
  fill: var(--mt-co);
}
.mt-dot.mt-s-ce {
  fill: var(--mt-ce);
}
.mt-dot.mt-s-st {
  fill: var(--mt-st);
}
.mt-dot.mt-s-ee {
  fill: var(--mt-ee);
}
.mt-dot.mt-s-eo {
  fill: var(--mt-eo);
}
.mt-table {
  margin-top: 0.9rem;
  font-size: 0.8rem;
}
.mt-table summary {
  cursor: pointer;
  color: var(--g-gloss);
}
.mt-table summary:hover {
  color: var(--text);
}
.mt-table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}
.mt-table table {
  border-collapse: collapse;
  min-width: 100%;
}
.mt-table th,
.mt-table td {
  padding: 0.3rem 0.5rem;
  text-align: right;
  white-space: nowrap;
}
.mt-table th {
  color: var(--g-gloss);
  font-weight: 400;
}
.mt-table td {
  color: var(--text);
}
.mt-table th:first-child,
.mt-table td:first-child {
  text-align: left;
}
.mt-table tbody tr:nth-child(odd) td {
  background: var(--bg);
}

/* ================================================================ settings & data */
.mt-set {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 1fr;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.6rem 0;
  border-top: 1px solid rgba(127, 127, 127, 0.18);
}
.mt-set-l {
  color: var(--text);
  font-size: 0.9rem;
}
.mt-set-c {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}
/* option chips: readable when unselected too (the beginner has to read every choice), with a visible edge
   because --bg on the --sub-alt card is too close to show where the button is */
.mt-opt {
  padding: 0.35rem 0.7rem;
  border-radius: 0.5rem;
  background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--g-edge);
  color: var(--g-gloss);
  font-size: 0.85rem;
  transition: color 0.12s, background 0.12s, box-shadow 0.12s;
}
.mt-opt:hover {
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--text);
}
.mt-opt.on {
  background: var(--main);
  box-shadow: inset 0 0 0 1px var(--main);
  color: var(--bg);
}
.mt-opt-min {
  font-size: 0.85em;
}
.mt-range-in {
  width: min(14rem, 100%);
  accent-color: var(--main);
}
.mt-date {
  width: auto;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
}
.mt-data .g-row {
  margin-top: 0.6rem;
}

/* ================================================================ dialogs */
.mt-ask .g-h {
  margin-bottom: 0.6rem;
}
.mt-ask-body {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.55;
}
.mt-ask-body p {
  margin: 0.3rem 0;
}
.mt-ask-btns {
  justify-content: flex-end;
  margin-top: 1.1rem;
}
.mt-ask-prev {
  display: flex;
  justify-content: center;
  margin: 0.4rem 0 0.6rem;
}

/* ================================================================ daily quests */
.mt-quests {
  display: grid;
  gap: 0.75rem;
}
.mt-quest {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem 1rem;
}
.mt-quest.done {
  box-shadow: inset 0 0 0 2px var(--g-ok);
}
.mt-q-ic {
  width: 2.7rem;
  height: 2.7rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg);
  font-size: 1.5rem;
}
.mt-q-body {
  min-width: 0;
}
.mt-q-title {
  color: var(--text);
  font-family: "Lexend Deca", sans-serif;
  font-size: 0.98rem;
}
.mt-q-rew {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.mt-q-rew .g-pill {
  background: var(--bg);
}
.mt-weak-tag {
  color: var(--error) !important;
}
.mt-q-check {
  width: 2.2rem;
  height: 2.2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--g-ok);
  color: #fff;
  font-size: 1.1rem;
}

/* ---- bonus chest */
.mt-chest-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}
.mt-chest-card.ready {
  box-shadow: inset 0 0 0 2px var(--g-coin);
}
.mt-chest {
  --mt-wood: #8b4513;
  --mt-wood-hi: #b5653a;
  --mt-wood-dk: #4a2511;
  position: relative;
  flex: none;
  width: 4.4rem;
  height: 3.9rem;
}
.mt-chest-box {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 58%;
  box-sizing: border-box;
  border: 3px solid var(--mt-wood-dk);
  border-radius: 0 0 0.5rem 0.5rem;
  background: linear-gradient(180deg, var(--mt-wood-hi), var(--mt-wood));
  z-index: 1;
}
.mt-chest-box::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -0.35rem;
  width: 0.75rem;
  height: 0.95rem;
  transform: translateX(-50%);
  border-radius: 0.2rem;
  background: var(--g-coin);
  box-shadow: inset 0 0 0 2px var(--mt-wood-dk);
}
.mt-chest-lid {
  position: absolute;
  left: 0;
  right: 0;
  top: 6%;
  height: 40%;
  box-sizing: border-box;
  border: 3px solid var(--mt-wood-dk);
  border-radius: 1.2rem 1.2rem 0.25rem 0.25rem;
  background: linear-gradient(180deg, var(--mt-wood-hi), var(--mt-wood));
  transform-origin: 8% 100%;
  transition: transform 0.45s cubic-bezier(0.3, 1.6, 0.5, 1);
  z-index: 2;
}
.mt-chest-glow {
  position: absolute;
  inset: -35%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 194, 48, 0.75), rgba(242, 194, 48, 0) 65%);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.5s, transform 0.5s;
}
.mt-chest-card.ready .mt-chest {
  animation: mt-bob 1.8s ease-in-out infinite;
}
.mt-chest-card.shaking .mt-chest {
  animation: mt-wobble 0.25s ease-in-out 3;
}
.mt-chest-card.open .mt-chest {
  animation: none;
}
.mt-chest-card.open .mt-chest-lid {
  transform: translateY(-0.3rem) rotate(-32deg);
}
.mt-chest-card.open .mt-chest-glow {
  opacity: 1;
  transform: scale(1);
}
.mt-chest-txt {
  min-width: 0;
  color: var(--text);
}
.mt-chest-txt > b {
  font-weight: 400;
}
.mt-loot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.6rem;
  animation: mt-pop 0.4s ease-out;
}
.mt-loot .g-pill {
  font-size: 1rem;
  background: var(--bg);
}
.mt-loot-item {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.88rem;
}
.mt-loot-item b {
  font-weight: 400;
  color: var(--main);
}
@keyframes mt-bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-0.2rem);
  }
}
@keyframes mt-wobble {
  0%,
  100% {
    transform: rotate(0);
  }
  25% {
    transform: rotate(-9deg);
  }
  75% {
    transform: rotate(9deg);
  }
}
@keyframes mt-pop {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  70% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* ---- achievements gallery */
.mt-achs {
  margin-top: 0.5rem;
}
.mt-cat {
  margin: 1.2rem 0 0.55rem;
  color: var(--text);
  font-size: 1rem;
  font-weight: 400;
}
.mt-ach-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}
.mt-ach {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--g-radius);
  background: var(--sub-alt);
}
.mt-ach-ic {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--bg);
  font-size: 1.35rem;
  filter: grayscale(1);
  opacity: 0.45;
}
.mt-ach-body {
  min-width: 0;
  flex: 1;
}
/* locked titles stay readable (they say what to do); the unlocked ones step up to --text, the coin edge and the
   coloured icon */
.mt-ach-body b {
  display: block;
  color: var(--g-gloss);
  font-weight: 400;
  line-height: 1.3;
  hyphens: auto;
  text-wrap: balance;
}
/* the English gloss of the title gets its own line instead of breaking the French title mid-pair */
.mt-ach-body b + .g-en {
  display: block;
  margin-top: 0.1rem;
  line-height: 1.3;
}
.mt-ach-body .g-sub {
  font-size: 0.78rem;
}
.mt-ach.on {
  box-shadow: inset 0 0 0 1px var(--g-coin);
}
.mt-ach.on .mt-ach-ic {
  filter: none;
  opacity: 1;
  box-shadow: 0 0 0 2px var(--g-coin);
}
.mt-ach.on .mt-ach-body b {
  color: var(--text);
}
.mt-ach.secret {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--sub);
}
/* (0,2,0) beats the .g-sub colour of game-base.css without !important */
.mt-ach-body .mt-ach-at {
  margin-top: 0.25rem;
  color: var(--g-ok-ink);
}

/* ================================================================ shop */
.mt-purse {
  font-size: 1rem;
}
.mt-preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  box-shadow: inset 0 0 0 2px var(--main);
}
.mt-shop-head {
  color: var(--text);
  font-size: 1rem;
}
.mt-shop-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
}
.mt-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.9rem 0.7rem;
  text-align: center;
}
.mt-item.eq {
  box-shadow: inset 0 0 0 2px var(--main);
}
.mt-item-name {
  color: var(--text);
  font-size: 0.92rem;
}
.mt-item .mt-en {
  margin-top: -0.2rem;
}
.mt-prev {
  width: 100%;
  height: 4.4rem;
  display: grid;
  place-items: center;
}
.mt-item.mt-locked .mt-prev {
  filter: grayscale(0.8);
  opacity: 0.5;
}
/* rarity chips: the rare / epic / legendary inks keep the hue and chroma of --g-a2 / --g-b2 / --g-coin and take
   their lightness from --text (same recipe as --g-coin-ink in game-base.css), so they read on light themes too
   (≥ 5:1 on all 16 themes). Without relative colours they fall back to the inherited text colour. */
.mt-rar {
  padding: 0.05rem 0.5rem;
  border-radius: 1rem;
  background: var(--bg);
  color: var(--g-gloss);
  font-size: 0.7rem;
}
.mt-rar-rare {
  color: oklch(from color-mix(in oklab, var(--g-a2) 25%, var(--text)) l 0.119 244);
}
.mt-rar-epic {
  color: oklch(from color-mix(in oklab, var(--g-b2) 25%, var(--text)) l 0.193 309);
}
.mt-rar-legend {
  color: var(--g-coin-ink);
}
.mt-item-act {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  margin-top: auto;
  padding-top: 0.3rem;
}
.mt-item-act .g-sub {
  flex-basis: 100%;
  font-size: 0.72rem;
}
.mt-eq {
  color: var(--main);
  background: var(--bg);
}
.mt-lock {
  color: var(--g-gloss);
  font-size: 0.75rem;
  line-height: 1.35;
}
.mt-prev-ball {
  display: grid;
  place-items: center;
}
.mt-ball,
.mt-ball-svg {
  display: block;
  width: 3rem;
  height: 3rem;
}
.mt-ball-svg svg {
  width: 100%;
  height: 100%;
}
.mt-ball {
  --b1: #e0525e;
  --b2: #f5f5f5;
  position: relative;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--b1) 0 46%, #222 46% 54%, var(--b2) 54% 100%);
  box-shadow: inset -0.25rem -0.3rem 0 rgba(0, 0, 0, 0.18), 0 0.15rem 0.4rem rgba(0, 0, 0, 0.25);
}
.mt-ball::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.95rem;
  height: 0.95rem;
  box-sizing: border-box;
  transform: translate(-50%, -50%);
  border: 0.2rem solid #222;
  border-radius: 50%;
  background: #f5f5f5;
}
.mt-prev-bg {
  display: block;
  width: 100%;
  height: 4.2rem;
  border-radius: 0.55rem;
  background-size: cover;
  background-position: center;
}
.mt-prev-theme {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  width: 5.6rem;
  height: 3.8rem;
  padding: 0.45rem;
  box-sizing: border-box;
  border-radius: 0.55rem;
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, 0.4);
}
.mt-prev-theme b {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
}
.mt-prev-theme span {
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  font-family: "Lexend Deca", sans-serif;
  font-size: 1.15rem;
}
.mt-prev-sfx {
  font-size: 2.3rem;
}
.mt-prev-title {
  padding: 0.3rem 0.7rem;
  border-radius: 2rem;
  background: var(--bg);
  color: var(--text);
  font-family: "Lexend Deca", sans-serif;
  font-size: 0.85rem;
}

/* ================================================================ responsive & motion */
@media (max-width: 640px) {
  .mt-tcard {
    grid-template-columns: auto 1fr;
  }
  .mt-goal {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
  }
  .mt-ring {
    width: 5rem;
    height: 5rem;
  }
  .mt-av-lg {
    width: 4.6rem;
    height: 4.6rem;
    padding: 0.26rem;
  }
  .mt-av-lg .mt-av-in {
    font-size: 2.3rem;
  }
  .mt-set {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 480px) {
  .mt-quest,
  .mt-wk {
    grid-template-columns: auto 1fr;
  }
  .mt-quest > .g-btn,
  .mt-quest > .mt-q-check,
  .mt-wk > .g-btn {
    grid-column: 2;
    justify-self: start;
  }
  .mt-chest-card {
    grid-template-columns: auto 1fr;
  }
  .mt-chest-act {
    grid-column: 2;
  }
  .mt-shop-grid {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 400px) {
  .mt-chip .mt-chip-lv,
  #xp-chip .mt-chip span.mt-chip-lv {
    display: none;
  }
}
.mt-still *,
.mt-still *::before,
.mt-still *::after {
  animation: none !important;
  transition: none !important;
}
