/* Same palette as the other tools; the accent follows the belt being tested. */
:root {
  --bg: #0e1013;
  --panel: #171a20;
  --panel-2: #1f232b;
  --line: #2b313b;
  --text: #f3f5f8;
  --muted: #9aa4b2;
  --pass: #5fd08a;
  --work: #ffb454;
  --belt: #f4c430; /* set from the chosen belt */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
body { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
body[data-view="test"] { height: 100vh; height: 100dvh; overflow: hidden; } /* the test screen never scrolls */

/* ---------- header ---------- */
.top {
  flex: none; position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 0.6rem;
  padding: max(0.5rem, env(safe-area-inset-top)) 1rem 0.5rem;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.app { flex: 1 1 auto; margin: 0; font-size: 1.15rem; font-weight: 700; }
.link {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-width: 2.75rem; min-height: 2.75rem; padding: 0 0.8rem;
  color: var(--text); text-decoration: none; font-size: 0.9rem; font-weight: 600;
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.6rem;
}
.link svg { width: 1.1rem; height: 1.1rem; fill: currentColor; }
@media (max-width: 559px) {
  .link { padding: 0; }
  .link span { display: none; }
}
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--belt); outline-offset: 2px; }

main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 38rem; margin: 0 auto; padding: 1rem 1rem calc(1.5rem + env(safe-area-inset-bottom)); }
body[data-view="setup"] #test, body[data-view="setup"] #results,
body[data-view="test"] #setup, body[data-view="test"] #results,
body[data-view="results"] #setup, body[data-view="results"] #test { display: none; }

h1 { margin: 0 0 0.3rem; font-size: clamp(1.6rem, 6vw, 2.1rem); line-height: 1.15; }
.lead { margin: 0 0 1.2rem; color: var(--muted); line-height: 1.45; }

button { font: inherit; cursor: pointer; }
.primary, .secondary {
  min-height: 3.25rem; padding: 0 1.2rem; border-radius: 0.8rem; font-weight: 700; font-size: 1.05rem;
}
.primary { background: var(--belt); color: #101216; border: 1px solid var(--belt); }
.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.primary:disabled { opacity: 0.4; cursor: default; }

/* ---------- setup ---------- */
.setup { display: flex; flex-direction: column; gap: 0.8rem; }
.label { margin: 0.2rem 0 -0.3rem; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.belts { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.belt {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 2.75rem; padding: 0 0.85rem;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; font-weight: 600;
}
.belt .swatch { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--c); }
.belt[aria-pressed="true"] { color: var(--text); background: var(--panel-2); border-color: var(--c); }

.setting, .toggle {
  display: flex; align-items: center; gap: 0.7rem;
  min-height: 3.75rem; padding: 0.5rem 0.9rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 0.9rem;
}
.setting .name { flex: 1 1 auto; }
.name { display: block; font-size: 1.05rem; font-weight: 600; }
.hint { display: block; margin-top: 0.15rem; color: var(--muted); font-size: 0.85rem; line-height: 1.35; }
/* The count can be typed as well as stepped; it still reads as a big number between − and +. */
.value {
  width: 4.4rem; height: 2.9rem; padding: 0;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 0.7rem;
  font: inherit; font-size: 1.6rem; font-weight: 800; text-align: center; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield; appearance: textfield;
}
.value::-webkit-outer-spin-button, .value::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.value:disabled { opacity: 1; background: transparent; border-color: transparent; }
.step {
  width: 2.9rem; height: 2.9rem; padding: 0;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 0.7rem; font-size: 1.5rem; font-weight: 700; line-height: 1;
}
.step:disabled { opacity: 0.35; cursor: default; }
.toggle { justify-content: space-between; cursor: pointer; }
.toggle input { flex: none; width: 1.45rem; height: 1.45rem; margin: 0; accent-color: var(--belt); cursor: pointer; }
#start { margin-top: 0.4rem; }
/* "All techniques" makes the count and favour settings irrelevant. */
.setup.all .random-only { opacity: 0.4; }
.setup.all .toggle.random-only { cursor: default; }
/* Yellow has no previous rank to include. */
.toggle.unavailable { opacity: 0.4; cursor: default; }

/* ---------- one technique at a time ---------- */
.test { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.9rem; }
.progress { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.bar { flex: 1 1 auto; height: 0.5rem; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
#fill { display: block; height: 100%; width: 0; background: var(--belt); }
.card {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; justify-content: center;
  padding: 1.2rem; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--belt); border-radius: 1rem;
}
.where { margin: 0 0 0.5rem; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.groups { margin: 0 0 0.4rem; color: var(--muted); font-size: clamp(1.05rem, 4.5vw, 1.35rem); font-weight: 600; }
.groups:empty { display: none; }
.technique { margin: 0; font-size: clamp(1.7rem, 8vw, 2.8rem); font-weight: 800; line-height: 1.15; overflow-wrap: break-word; }
.technique .num { color: var(--muted); font-weight: 700; margin-right: 0.35em; }

.marks { flex: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; }
.mark {
  min-height: 4rem; border-radius: 0.9rem; font-size: 1.15rem; font-weight: 800;
  background: var(--panel); color: var(--text); border: 2px solid var(--line);
}
.mark.pass { border-color: color-mix(in srgb, var(--pass) 60%, transparent); }
.mark.work { border-color: color-mix(in srgb, var(--work) 60%, transparent); }
.mark.pass[aria-pressed="true"] { background: var(--pass); color: #101216; }
.mark.work[aria-pressed="true"] { background: var(--work); color: #101216; }
.nav { flex: none; display: flex; justify-content: space-between; }
.plain { min-height: 2.75rem; padding: 0 0.6rem; background: none; border: 0; color: var(--muted); font-weight: 600; }
.plain:disabled { opacity: 0.35; cursor: default; }

/* ---------- results ---------- */
.result-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.4rem; }
.result-actions .primary[hidden] { display: none; }
.results h2 {
  display: flex; justify-content: space-between; margin: 1.2rem 0 0.4rem; padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--line); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
}
.results ul { list-style: none; margin: 0; padding: 0; }
.results li { display: flex; gap: 0.7rem; padding: 0.6rem 0.2rem; line-height: 1.35; border-bottom: 1px solid color-mix(in srgb, var(--line) 50%, transparent); }
.results .sign { flex: none; width: 1.3rem; font-weight: 800; }
.results .work-sign { color: var(--work); }
.results .pass-sign { color: var(--pass); }
.results .ctx { display: block; color: var(--muted); font-size: 0.85rem; }

/* Landscape phones: the card and buttons side by side keep the test on one screen. */
@media (max-height: 520px) and (orientation: landscape) {
  main { max-width: none; padding-top: 0.5rem; padding-bottom: 0.5rem; }
  .test { display: grid; grid-template-columns: minmax(0, 1fr) 15rem; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0.5rem 1rem; }
  .progress { grid-column: 1 / -1; }
  .card { grid-column: 1; grid-row: 2 / 4; }
  .marks { grid-column: 2; grid-row: 2; grid-template-columns: 1fr; align-content: center; }
  .nav { grid-column: 2; grid-row: 3; }
  .mark { min-height: 3.2rem; }
}
