:root {
  --ink: #111111;
  --paper: #ffffff;
  --soft: #eef2f8;
  --line: #111111;
  --brand: #0a3a8f;       /* 10.9:1 against white */
  --brand-ink: #ffffff;
  --good: #0b5d1e;        /* 7.4:1 against white */
  --warn: #8a1c00;        /* 8.6:1 against white */
  --focus: #ffbf00;
  --radius: 16px;
  --tap: 72px;
  font-size: clamp(20px, 2.2vw + 8px, 26px);
}

* { box-sizing: border-box; }

html, body { margin: 0; background: var(--paper); color: var(--ink); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  min-height: 100vh;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.screen { max-width: 1100px; margin: 0 auto; padding: 16px 24px 48px; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  justify-content: space-between; padding-bottom: 12px;
  border-bottom: 3px solid var(--line); margin-bottom: 24px;
}
.brand { font-weight: 800; font-size: 1.4rem; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.chip {
  border: 3px solid var(--line); border-radius: 999px; padding: 6px 18px;
  font-weight: 700; background: var(--soft);
}

h1 { font-size: 2rem; line-height: 1.2; margin: 0 0 12px; }
h1:focus { outline: none; }
h2 { font-size: 1.3rem; margin: 0 0 10px; }
p { margin: 0 0 16px; max-width: 46em; }
.lead { font-size: 1.1rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  min-height: var(--tap); min-width: 180px; padding: 12px 28px;
  font: inherit; font-size: 1.2rem; font-weight: 700;
  border: 4px solid var(--brand); border-radius: var(--radius);
  background: var(--brand); color: var(--brand-ink); cursor: pointer;
  touch-action: manipulation;
}
.btn.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn[disabled] { background: #d7dbe2; border-color: #5a5f69; color: #2d3138; cursor: not-allowed; }
.btn[aria-disabled="true"] { background: #d7dbe2; border-color: #5a5f69; color: #2d3138; cursor: not-allowed; }
.btn.small { min-width: 0; min-height: 56px; padding: 8px 18px; font-size: 1rem; }
.btn:active:not([disabled]):not([aria-disabled="true"]) { transform: translateY(2px); }

:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 3px;
  box-shadow: 0 0 0 8px var(--focus);
}

.icon { display: inline-flex; width: 1.4em; height: 1.4em; flex: none; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.actions { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 24px; }

/* Language choice */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 24px; }
.lang-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  min-height: 140px; padding: 20px 24px; text-align: left;
  font: inherit; color: var(--ink); background: var(--paper);
  border: 4px solid var(--line); border-radius: var(--radius); cursor: pointer;
  touch-action: manipulation;
}
.lang-btn .name { font-size: 2rem; font-weight: 800; }
.lang-btn .meta { font-size: 1.05rem; }
.lang-btn.current { background: var(--soft); border-color: var(--brand); }
.heading-sub { display: block; font-size: 1.05rem; font-weight: 600; margin-top: 6px; }

/* Shopping list */
.list-card {
  list-style: none; margin: 16px 0; padding: 20px 24px;
  border: 4px solid var(--line); border-radius: var(--radius); background: var(--soft);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 12px 24px;
}
.list-card li { font-size: 1.8rem; font-weight: 700; display: flex; align-items: center; gap: 14px; }
.list-card li::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--brand); flex: none;
}
.notice {
  border-left: 8px solid var(--brand); background: var(--soft);
  padding: 12px 18px; border-radius: 8px; font-weight: 600;
}

/* Difficulty */
.difficulty { margin: 24px 0 0; padding: 16px 20px; border: 3px solid var(--line); border-radius: var(--radius); }
.difficulty h2 { margin-bottom: 12px; }
.difficulty .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.difficulty .btn { min-width: 0; }
.level-readout { flex: 1 1 12em; font-size: 1.15rem; font-weight: 700; text-align: center; }

/* Recall tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 16px; margin: 16px 0; }
.tile {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  min-height: 96px; padding: 12px 18px;
  font: inherit; font-size: 1.5rem; font-weight: 700; text-align: left; overflow-wrap: anywhere;
  color: var(--ink); background: var(--paper); border: 4px solid var(--line); border-radius: var(--radius);
  cursor: pointer; touch-action: manipulation;
}
.tile .mark {
  flex: none; width: 36px; height: 36px; border: 3px solid currentColor; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tile .mark .icon { width: 26px; height: 26px; visibility: hidden; }
.tile[aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.tile[aria-pressed="true"] .mark { background: #fff; color: var(--brand); border-color: #fff; }
.tile[aria-pressed="true"] .mark .icon { visibility: visible; }

.counter { font-weight: 700; font-size: 1.15rem; }
.hint { font-size: .95rem; margin-top: 8px; }

/* Feedback */
.verdict { display: flex; align-items: center; gap: 14px; }
.verdict .icon { width: 2.2rem; height: 2.2rem; }
.review { list-style: none; margin: 12px 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 10px 20px; }
.review li { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 1.3rem; font-weight: 700; padding: 10px 14px; border: 3px solid var(--line); border-radius: 12px; }
.review .state { margin-left: auto; white-space: nowrap; font-size: 1rem; font-weight: 700; }
.review li.found { border-color: var(--good); }
.review li.found .icon, .review li.found .state { color: var(--good); }
.review li.missed { border-style: dashed; border-color: var(--warn); }
.review li.missed .icon, .review li.missed .state { color: var(--warn); }
.summary { font-size: 1.4rem; font-weight: 800; }

dialog {
  border: 5px solid var(--line); border-radius: var(--radius); padding: 24px 28px;
  max-width: min(92vw, 640px); color: var(--ink); background: var(--paper);
}
dialog::backdrop { background: rgba(0, 0, 0, .75); }

@media (max-width: 640px) {
  .screen { padding: 12px 16px 40px; }
  h1 { font-size: 1.6rem; }
  .list-card li { font-size: 1.5rem; }
  .btn { width: 100%; }
  .difficulty .btn { width: auto; flex: 1 1 140px; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.site-footer { max-width: 1100px; margin: 0 auto; padding: 0 24px 32px; font-size: .9rem; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 1.05rem; }
ul.plain li { padding: 8px 0; border-top: 2px solid var(--soft); }
ul.plain li:first-child { border-top: 0; }
.difficulty + .difficulty { margin-top: 16px; }

.devbanner {
  flex: 1 0 100%; margin: 0 0 4px; padding: 6px 12px; text-align: center;
  background: #b45309; color: #fff; font-weight: 800; font-size: .9rem; border-radius: 8px;
}
