/* ---------- themes ---------- */
:root,
[data-theme="classique"] {
  --bg: #323437;
  --main: #e2b714;
  --caret: #e2b714;
  --sub: #646669;
  --sub-alt: #2c2e31;
  --text: #d1d0c5;
  --error: #ca4754;
  --error-extra: #7e2a33;
}
[data-theme="tricolore"] {
  --bg: #0f1b3d;
  --main: #ffffff;
  --caret: #ef4135;
  --sub: #5b6b94;
  --sub-alt: #0a1430;
  --text: #dfe4f2;
  --error: #ef4135;
  --error-extra: #8f2620;
}
/* light themes: --main is also the text colour of primary buttons (on --bg) and of active tabs and links, so it
   stays ≥ 4.5:1 against --bg */
[data-theme="baguette"] {
  --bg: #f3e7d3;
  --main: #96501a;
  --caret: #b5651d;
  --sub: #b39c7d;
  --sub-alt: #e9d9bf;
  --text: #4a3520;
  --error: #c0392b;
  --error-extra: #e08b80;
}
[data-theme="lavande"] {
  --bg: #2a2438;
  --main: #b8a1e3;
  --caret: #e7c6ff;
  --sub: #6c618a;
  --sub-alt: #221d2e;
  --text: #e8e2f5;
  --error: #ff6b8b;
  --error-extra: #9c3c52;
}
[data-theme="craie"] {
  --bg: #eeeeee;
  --main: #2b2b2b;
  --caret: #2b7de9;
  --sub: #a3a3a3;
  --sub-alt: #e2e2e2;
  --text: #2b2b2b;
  --error: #da3333;
  --error-extra: #e88a8a;
}
[data-theme="nuit"] {
  --bg: #111111;
  --main: #eeeeee;
  --caret: #eeeeee;
  --sub: #444444;
  --sub-alt: #1a1a1a;
  --text: #cccccc;
  --error: #da3333;
  --error-extra: #791717;
}
[data-theme="provence"] {
  --bg: #2f3b2f;
  --main: #c9b6e4;
  --caret: #f4d35e;
  --sub: #6b7d63;
  --sub-alt: #263026;
  --text: #e6ead9;
  --error: #e76f51;
  --error-extra: #8f3f2c;
}
[data-theme="macaron"] {
  --bg: #fdf0f3;
  --main: #b83d65;
  --caret: #6cc3b5;
  --sub: #d8aab7;
  --sub-alt: #f8e1e7;
  --text: #5b3a47;
  --error: #c3303a;
  --error-extra: #e7949a;
}
[data-theme="ardoise"] {
  --bg: #1e2733;
  --main: #4fc3f7;
  --caret: #4fc3f7;
  --sub: #4b5a6b;
  --sub-alt: #19212b;
  --text: #cfd8e3;
  --error: #f0616d;
  --error-extra: #8c3640;
}
[data-theme="bordeaux"] {
  --bg: #2b1519;
  --main: #e0b25d;
  --caret: #e0b25d;
  --sub: #7a4f55;
  --sub-alt: #231114;
  --text: #f0dfd8;
  --error: #ff5c5c;
  --error-extra: #9a3636;
}

/* ---------- base ---------- */
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  min-height: 100%;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Roboto Mono", ui-monospace, monospace;
  transition: background 0.25s, color 0.25s;
  overflow-x: hidden;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
a {
  color: inherit;
  text-decoration: none;
}
kbd {
  background: var(--sub);
  color: var(--bg);
  padding: 0.1em 0.35em;
  border-radius: 0.25em;
  font-family: inherit;
  font-size: 0.75em;
}
code {
  color: var(--main);
}
svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  /* minmax(0, …): a wide child (footer links, a long word) must not stretch the whole column past the screen */
  grid-template-columns: minmax(0, 1fr);
  gap: 2rem;
  padding: 2rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* ---------- header ---------- */
#header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: opacity 0.15s;
}
#logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  margin-right: 0.5rem;
}
.logo-icon {
  width: 2.5rem;
  height: 1.8rem;
  color: var(--main);
  stroke-width: 2.5;
}
.logo-text {
  font-family: "Lexend Deca", sans-serif;
  line-height: 1;
  position: relative;
}
.logo-top {
  font-size: 0.65rem;
  color: var(--sub);
  position: absolute;
  top: -0.6rem;
  left: 0.1rem;
  transition: color 0.15s;
}
.logo-name {
  font-size: 2rem;
  color: var(--text);
}
body.typing .logo-top,
body.typing .logo-name {
  color: var(--sub);
}
#nav {
  display: flex;
  gap: 0.25rem;
}
/* --g-gloss (css/game-base.css): the readable secondary text colour; the labels are what a beginner reads */
.nav-btn {
  color: var(--g-gloss, var(--sub));
  padding: 0.5rem;
  font-size: 1.25rem;
  line-height: 0;
  border-radius: 0.5rem;
  transition: color 0.15s;
}
.nav-btn:hover,
.nav-btn:focus-visible {
  color: var(--text);
  outline: none;
}
.nav-btn:focus-visible,
#logo:focus-visible,
#xp-chip:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--main);
}
#logo {
  border-radius: 0.5rem;
}
/* main menu: icon over a short French label (labels collapse on small screens) */
#nav {
  gap: 0.1rem;
  flex-wrap: nowrap;
  min-width: 0;
}
.nav-btn.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  line-height: 1;
  padding: 0.4rem 0.45rem 0.35rem;
  min-width: 2.4rem;
}
.nav-lbl {
  font-size: 0.65rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.nav-btn.nav-item.active {
  color: var(--main);
  /* the inactive items are a readable grey now: a bar under the current one keeps it obvious on every theme */
  box-shadow: inset 0 -2px 0 var(--main);
}
.nav-btn.nav-item.active:focus-visible {
  box-shadow: 0 0 0 2px var(--main), inset 0 -2px 0 var(--main);
}
.nav-btn.nav-item.active .nav-lbl {
  color: var(--text);
}
.nav-btn.nav-text {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  line-height: 1;
}
.nav-btn.nav-text span {
  font-size: 0.75rem;
}
.listen-btn {
  color: var(--main);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.1rem;
  padding: 0.4rem 0.9rem;
  border-radius: 0.5rem;
  background: var(--sub-alt);
}
.listen-btn:hover {
  color: var(--bg);
  background: var(--main);
}
.listen-tip {
  font-size: 0.75rem;
  color: var(--sub);
  margin-top: 0.4rem;
}
@media (max-width: 700px) {
  .nav-btn.nav-text span {
    display: none;
  }
}
#header-right {
  margin-left: auto;
  min-width: 0;
}
/* medium screens: the menu gets its own row under the logo and the chip */
@media (max-width: 1020px) {
  #header {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }
  #nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }
}
/* phones: icons only, except the current screen which keeps its label (a touch screen has no title tooltip, so
   the name of each icon shows up once it is tapped); smaller logo */
@media (max-width: 560px) {
  .nav-lbl {
    display: none;
  }
  .nav-btn.nav-item.active .nav-lbl {
    display: block;
    font-size: 0.6rem;
  }
  .nav-btn.nav-item {
    padding: 0.45rem 0.3rem;
    min-width: 0;
  }
  .logo-icon {
    width: 2rem;
  }
  .logo-name {
    font-size: 1.6rem;
  }
  .logo-top {
    display: none;
  }
}

/* ---------- views ---------- */
#main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.view {
  display: none;
}
.view.active {
  display: block;
  animation: fade 0.15s ease-out;
}
@keyframes fade {
  from {
    opacity: 0;
  }
}

/* ---------- config bar ---------- */
#config-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  margin: 0 auto 2rem;
  background: var(--sub-alt);
  border-radius: 0.5rem;
  padding: 0 0.5rem;
  font-size: 0.75rem;
  flex-wrap: wrap;
  transition: opacity 0.15s;
}
.cfg-group {
  display: flex;
}
.cfg-btn {
  color: var(--sub);
  padding: 0.55rem 0.55rem;
  transition: color 0.15s;
  white-space: nowrap;
}
.cfg-btn:hover {
  color: var(--text);
}
.cfg-btn.active {
  color: var(--main);
}
.cfg-icon {
  margin-right: 0.35rem;
  display: inline-block;
  min-width: 0.6em;
  text-align: center;
}
.cfg-spacer {
  width: 0.25rem;
  height: 1.2rem;
  background: var(--bg);
  border-radius: 1rem;
  margin: 0 0.5rem;
}
.cfg-spacer.hide {
  display: none;
}
.cfg-gear svg {
  vertical-align: -0.15em;
}

/* ---------- test ---------- */
#test-area {
  --font-size: 1.5rem;
  position: relative;
}
#list-row {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
  transition: opacity 0.15s;
}
#list-btn {
  color: var(--sub);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.5rem;
  transition: color 0.15s;
}
#list-btn:hover {
  color: var(--text);
}
#live-row {
  font-size: calc(var(--font-size) * 1.05);
  color: var(--main);
  height: calc(var(--font-size) * 1.6);
  display: flex;
  gap: 1.5rem;
  opacity: 0;
  transition: opacity 0.15s;
}
body.running #live-row {
  opacity: 1;
}

#words-wrapper {
  position: relative;
  font-size: var(--font-size);
  height: calc(3 * (1.5em + 0.5rem + 2px));
  overflow: hidden;
  cursor: default;
  user-select: none;
}
#words {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  transition: filter 0.2s;
}
#words.blurred {
  filter: blur(4px);
  opacity: 0.6;
}
.word {
  margin: 0.25rem 0.6em 0.25rem 0;
  line-height: 1.5;
  color: var(--sub);
  border-bottom: 2px solid transparent;
  display: flex;
}
.word.gone {
  display: none;
}
.letter {
  position: relative;
}
.letter.correct {
  color: var(--text);
}
.letter.incorrect {
  color: var(--error);
}
.letter.extra {
  color: var(--error-extra);
}
.word.error {
  border-bottom-color: var(--error);
}
body.blind .letter.incorrect {
  color: var(--text);
}
body.blind .letter.extra {
  display: none;
}
body.blind .word.error {
  border-bottom-color: transparent;
}
.zen-placeholder {
  color: var(--sub);
}

#caret {
  position: absolute;
  width: 0.1em;
  height: 1.2em;
  background: var(--caret);
  border-radius: 1px;
  z-index: 2;
  top: 0;
  left: 0;
  animation: blink 1s infinite;
}
#caret.smooth {
  transition: left 0.1s linear, top 0.1s ease-out;
}
#caret.no-blink {
  animation: none;
}
#caret.style-block {
  width: 0.6em;
  opacity: 0.5;
  border-radius: 2px;
}
#caret.style-underline {
  width: 0.6em;
  height: 0.12em;
}
#caret.style-off {
  display: none;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
#caret.style-block {
  animation-name: blink-half;
}
@keyframes blink-half {
  0%,
  100% {
    opacity: 0.5;
  }
  50% {
    opacity: 0;
  }
}

#words-input {
  position: absolute;
  opacity: 0;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
  font-size: 16px;
}

#focus-warning {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 1rem;
  color: var(--text);
  z-index: 3;
  cursor: pointer;
  text-align: center;
}
#focus-warning svg {
  width: 1.1em;
  height: 1.1em;
}
#caps-warning {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--main);
  color: var(--bg);
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-size: 1rem;
  z-index: 4;
  display: none;
  pointer-events: none;
}
#caps-warning.show {
  display: block;
}

#hint {
  min-height: 1.6rem;
  margin-top: 1rem;
  text-align: center;
  color: var(--sub);
  font-size: 0.95rem;
}
#hint.prompt {
  font-size: 1.6rem;
  margin-top: 1.25rem;
}
#hint .hint-fr {
  color: var(--text);
}
#hint .hint-en {
  color: var(--main);
}
#hint .speak {
  color: var(--sub);
  margin-left: 0.5rem;
  vertical-align: -0.1em;
}
#hint .speak:hover {
  color: var(--text);
}

#accent-bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
  transition: opacity 0.15s;
}
#accent-bar button {
  color: var(--sub);
  background: var(--sub-alt);
  border-radius: 0.35rem;
  min-width: 2rem;
  padding: 0.3rem 0.45rem;
  font-size: 0.95rem;
  transition: color 0.1s, background 0.1s;
}
#accent-bar button:hover {
  color: var(--bg);
  background: var(--text);
}

#restart-btn {
  display: block;
  margin: 1.5rem auto 0;
  color: var(--sub);
  font-size: 1.15rem;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  line-height: 0;
  transition: color 0.15s, background 0.15s;
}
#restart-btn:hover,
#restart-btn:focus-visible {
  color: var(--text);
  outline: none;
}
#restart-btn:focus-visible {
  background: var(--text);
  color: var(--bg);
}

/* focus mode: hide chrome while typing */
body.typing #header,
body.typing #config-bar,
body.typing #list-row,
body.typing #footer,
body.typing #restart-btn,
body.typing #accent-bar {
  opacity: 0;
}
body.typing #header .logo-name {
  opacity: 1;
}

/* ---------- results ---------- */
#result {
  animation: fade 0.2s ease-out;
}
#result-top {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
}
/* labels and empty states carry meaning: the readable secondary colour, not the decorative --sub */
.stat .label {
  color: var(--g-gloss, var(--sub));
  font-size: 1rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.stat .value {
  color: var(--main);
  font-size: 2rem;
  line-height: 1;
}
.stat .value.small {
  font-size: 1rem;
  line-height: 1.3;
}
.stat.big .label {
  font-size: 2rem;
}
.stat.big .value {
  font-size: 4rem;
}
#result-big {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#chart-wrap {
  position: relative;
  height: 200px;
}
#chart {
  width: 100%;
  height: 100%;
}
#chart .grid {
  stroke: var(--sub-alt);
  stroke-width: 1;
}
#chart .axis-label {
  fill: var(--sub);
  stroke: none;
  font-size: 11px;
  font-family: "Roboto Mono", monospace;
}
#chart .wpm-line {
  stroke: var(--main);
  stroke-width: 3;
}
#chart .wpm-area {
  fill: var(--main);
  stroke: none;
  opacity: 0.08;
}
#chart .raw-line {
  stroke: var(--sub);
  stroke-width: 2;
}
#chart .err {
  stroke: var(--error);
  stroke-width: 2;
}
#chart .hover-line {
  stroke: var(--sub);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
#chart-tip {
  position: absolute;
  background: var(--sub-alt);
  color: var(--text);
  font-size: 0.75rem;
  padding: 0.5rem 0.65rem;
  border-radius: 0.4rem;
  pointer-events: none;
  white-space: nowrap;
  z-index: 3;
  line-height: 1.5;
}
#chart-tip .k {
  color: var(--sub);
}
#result-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2.5rem;
  margin-top: 1.5rem;
}
#result-bottom .value {
  font-size: 1.75rem;
}
#pb-badge {
  margin-top: 1rem;
  color: var(--main);
}
#review {
  margin-top: 1.5rem;
}
#review .label {
  color: var(--sub);
  margin-bottom: 0.5rem;
}
#review-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.review-item {
  background: var(--sub-alt);
  border-radius: 0.4rem;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  cursor: pointer;
  transition: background 0.1s;
}
.review-item:hover {
  background: var(--sub);
}
.review-item .fr {
  color: var(--text);
}
.review-item .typed {
  color: var(--error);
  text-decoration: line-through;
}
.review-item .en {
  color: var(--sub);
}
.review-item:hover .en {
  color: var(--bg);
}
.review-empty {
  color: var(--g-gloss, var(--sub));
  font-size: 0.85rem;
}
#result-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}
.icon-btn {
  color: var(--sub);
  font-size: 1.15rem;
  padding: 1rem 2rem;
  border-radius: 0.5rem;
  line-height: 0;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover {
  color: var(--text);
}
.icon-btn:focus-visible {
  background: var(--text);
  color: var(--bg);
  outline: none;
}

/* ---------- footer ---------- */
#footer {
  color: var(--sub);
  font-size: 0.75rem;
  transition: opacity 0.15s;
}
#footer-keys {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1.5rem;
}
/* the typing test shortcuts only make sense in the dojo (in the game, Esc closes a dialog or leaves a battle);
   body[data-screen] is set by showView (js/app.js) */
body:not([data-screen="test"]):not([data-screen="course"]):not([data-screen="settings"]):not([data-screen="profile"]) #footer-keys {
  display: none;
}
#footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
}
.footer-links a:hover,
.text-btn:hover {
  color: var(--text);
}
.footer-right {
  display: flex;
  gap: 1.25rem;
  align-items: center;
}
.text-btn {
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ---------- command line ---------- */
#modal,
#custom-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 12vh;
  z-index: 50;
  animation: fade 0.1s;
}
#custom-modal {
  align-items: center;
  padding: 1rem;
}
#cmd {
  width: min(700px, calc(100vw - 2rem));
  background: var(--bg);
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--sub-alt), 0 10px 40px rgba(0, 0, 0, 0.35);
}
#cmd-input {
  width: 100%;
  background: none;
  border: 0;
  outline: none;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 2px solid var(--sub-alt);
}
#cmd-input::placeholder {
  color: var(--sub);
}
#cmd-list {
  max-height: 55vh;
  overflow-y: auto;
  padding: 0.25rem 0;
}
.cmd-item {
  padding: 0.55rem 1.25rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.cmd-item .check {
  width: 1rem;
  color: var(--main);
}
.cmd-item .swatch {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
  padding: 3px;
  border-radius: 1rem;
}
.cmd-item .swatch span {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
}
.cmd-item.selected {
  background: var(--text);
  color: var(--bg);
}
.cmd-item.selected .check {
  color: var(--bg);
}
.cmd-empty {
  padding: 1rem 1.25rem;
  color: var(--sub);
  font-size: 0.85rem;
}

.dialog {
  width: min(700px, 100%);
  background: var(--bg);
  border-radius: 0.5rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 0 0 1px var(--sub-alt), 0 10px 40px rgba(0, 0, 0, 0.35);
}
.dialog-title {
  color: var(--sub);
  font-size: 1.25rem;
}
#custom-text {
  min-height: 200px;
  background: var(--sub-alt);
  color: var(--text);
  border: 0;
  border-radius: 0.5rem;
  padding: 1rem;
  font: inherit;
  resize: vertical;
  outline: none;
}
.check {
  color: var(--sub);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}
.wide-btn {
  background: var(--sub-alt);
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  transition: background 0.1s, color 0.1s;
}
.wide-btn:hover,
.wide-btn:focus-visible {
  background: var(--text);
  color: var(--bg);
  outline: none;
}

/* ---------- notifications ---------- */
#notifications {
  position: fixed;
  top: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 60;
}
.notif {
  background: var(--sub-alt);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.8rem;
  max-width: 320px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  border-left: 3px solid var(--main);
  animation: fade 0.15s;
}

/* ---------- settings / profile / about ---------- */
.page,
#settings,
#profile {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}
.page h2,
#settings h2,
#profile h2 {
  color: var(--text);
  font-weight: 400;
  font-size: 1.5rem;
  margin: 0 0 1.5rem;
}
/* the about page is English prose: the game typeface reads better than the typing monospace */
.page.about {
  font-family: "Lexend Deca", sans-serif;
}
.page h3 {
  color: var(--g-gloss, var(--sub));
  font-weight: 400;
  margin: 2rem 0 0.5rem;
}
.page p {
  line-height: 1.7;
  color: var(--text);
  font-size: 0.9rem;
}
.page ul {
  margin: 0.25rem 0 0.75rem;
  padding-left: 1.25rem;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.7;
}
.page li {
  margin-bottom: 0.4rem;
}
.page li::marker {
  color: var(--main);
}
/* links from the dojo pages (settings, records) to the game screens */
.game-settings-link {
  display: flex;
  align-items: center;
  gap: 1rem 2rem;
  flex-wrap: wrap;
  justify-content: space-between;
  background: var(--sub-alt);
  border-radius: 0.6rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
.game-settings-link > div {
  flex: 1 1 18rem;
  min-width: 0;
}
.game-settings-link .wide-btn {
  width: auto;
  flex: 0 1 auto;
  max-width: 100%;
  background: var(--bg);
}
.game-settings-link .wide-btn:hover,
.game-settings-link .wide-btn:focus-visible {
  background: var(--text);
}
.theme-shop-note a {
  color: var(--main);
}
.theme-shop-note a:hover {
  text-decoration: underline;
}
.dojo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin-top: 0.6rem;
}
.dojo-links .text-btn {
  font-size: 0.85rem;
  color: var(--g-gloss, var(--sub));
}
.dojo-links .text-btn:hover,
.dojo-links .text-btn:focus-visible {
  color: var(--main);
}
.setting {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 2rem;
  align-items: center;
  padding: 1rem 0;
}
.setting-title {
  color: var(--text);
  font-size: 1rem;
}
.setting-desc {
  color: var(--g-gloss, var(--text));
  font-size: 0.8rem;
  grid-column: 1;
}
.setting-options {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.opt {
  background: var(--sub-alt);
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  min-width: 5rem;
  transition: background 0.1s, color 0.1s;
}
.opt:hover {
  background: var(--sub);
}
.opt.active {
  background: var(--main);
  color: var(--bg);
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.theme-tile {
  border-radius: 0.5rem;
  padding: 0.65rem 0.8rem;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  outline: 2px solid transparent;
  outline-offset: 2px;
}
.theme-tile.active {
  outline-color: var(--main);
}
.theme-tile .dots {
  display: flex;
  gap: 3px;
}
.theme-tile .dots span {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
}
.danger {
  background: var(--error) !important;
  color: var(--bg) !important;
}

.pb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.pb-card {
  background: var(--sub-alt);
  border-radius: 0.5rem;
  padding: 1rem;
  text-align: center;
}
.pb-card .t {
  color: var(--g-gloss, var(--sub));
  font-size: 0.8rem;
}
.pb-card .w {
  color: var(--text);
  font-size: 2rem;
  margin: 0.25rem 0;
}
.pb-card .a {
  color: var(--g-gloss, var(--sub));
  font-size: 0.8rem;
}
.summary {
  display: flex;
  gap: 3rem;
  flex-wrap: wrap;
  margin-bottom: 2rem;
}
.history {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.history th {
  color: var(--g-gloss, var(--sub));
  font-weight: 400;
  text-align: left;
  padding: 0.5rem;
}
.history td {
  padding: 0.6rem 0.5rem;
  color: var(--text);
}
.history tr:nth-child(even) td {
  background: var(--sub-alt);
}
.history td:first-child {
  border-radius: 0.4rem 0 0 0.4rem;
}
.history td:last-child {
  border-radius: 0 0.4rem 0.4rem 0;
}
.section-label {
  color: var(--g-gloss, var(--sub));
  margin: 1.5rem 0 0.75rem;
}

/* ---------- English help in the dojo (gloss() in js/app.js; the .g-en look comes from css/game-base.css) ---------- */
body.en-off .dj-en {
  display: none !important;
}
div.dj-en {
  margin-top: 0.15rem;
}
.stat .label div.dj-en {
  line-height: 1.2;
}
div.dj-en + .history {
  margin-top: 0.5rem;
}
/* inside a button the gloss follows the button colour (hover, primary); text buttons are already a secondary colour */
.text-btn .dj-en,
.wide-btn .dj-en,
.continue-btn .dj-en {
  color: inherit;
}
.wide-btn:not(.primary) .dj-en {
  opacity: 0.8;
}

/* ---------- small screens ---------- */
@media (max-width: 700px) {
  #app {
    padding: 1rem;
    gap: 1.25rem;
  }
  .cfg-btn {
    padding: 0.5rem 0.4rem;
  }
  .cfg-icon {
    display: none;
  }
  /* 360 px phones: the seven test modes wrap instead of running off the screen */
  .cfg-group {
    flex-wrap: wrap;
    justify-content: center;
  }
  /* the dojo's course header (css/course.css): stats and the continue button wrap too */
  #course .course-stats {
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
  }
  #result-top {
    grid-template-columns: 1fr;
  }
  #result-big {
    flex-direction: row;
    gap: 2rem;
  }
  .stat.big .value {
    font-size: 3rem;
  }
  .setting {
    grid-template-columns: 1fr;
  }
  .setting-options {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
  }
  #footer-keys {
    display: none;
  }
}
