/* Wordnest – per-screen styles (start, settings, Find me, Match me, wrap-up). */

/* ---------- Shared pieces ---------- */
.i { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn.block { width: 100%; }
.btn.big { min-height: 56px; font-size: var(--fs-lg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.icon-btn:focus-visible, .btn:focus-visible { outline: var(--focus-ring) solid var(--c-focus); outline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--c-text-muted); }
.card { padding: var(--space-2); border-radius: var(--radius); background: var(--c-surface); box-shadow: var(--shadow); }
.bar { display: flex; height: 8px; overflow: hidden; border-radius: var(--radius-pill); background: var(--c-border); }
.bar > span { display: block; height: 100%; background: var(--c-found); }

/* ---------- Start ---------- */
.brand { display: flex; flex: 1; align-items: center; gap: var(--space-1); }
.brand img { width: 40px; height: 40px; }
.wordmark { font-size: 1.75rem; font-weight: var(--fw-black); line-height: 1; }
.wordmark b { color: var(--c-accent); font-weight: inherit; }

.levels { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 4px; border-radius: var(--radius);
  background: var(--c-surface); box-shadow: inset 0 0 0 2px var(--c-text-muted); }
.level { display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 4px; min-width: 0; min-height: 52px; padding: 4px 6px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--c-text); font-weight: var(--fw-heavy); }
.level .bar { height: 4px; }
.level[aria-checked="true"] { background: var(--c-selected); color: var(--c-on-selected); }
.level[aria-checked="true"] .bar { background: color-mix(in srgb, var(--c-on-selected) 35%, transparent); }
.level[aria-checked="true"] .bar > span { background: var(--c-on-selected); }
.level:disabled { color: var(--c-text-muted); opacity: 0.55; cursor: not-allowed; }
.level:disabled .bar { visibility: hidden; }

.toggle-row { display: flex; align-items: center; gap: var(--space-2); min-height: var(--tap); }
.toggle-row > span { flex: 1; }
.switch { position: relative; flex: none; width: 48px; height: 28px; padding: 0; border: 2px solid var(--c-text-muted); border-radius: var(--radius-pill); background: var(--c-surface); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--c-text-muted);
  transition: transform var(--dur-fast) var(--ease); }
.switch[aria-checked="true"] { border-color: var(--c-selected); background: var(--c-selected); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: var(--c-on-selected); }
/* 44px touch target around the 28px switch */
.switch::before { content: ""; position: absolute; inset: -9px -4px; }

.modes { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); }
.mode { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 80px; padding: var(--space-1) var(--space-2);
  border: 2px solid var(--c-text-muted); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text); text-align: left; }
.mode strong { font-size: var(--fs-md); font-weight: var(--fw-heavy); }
.mode small { font-size: var(--fs-xs); color: var(--c-text-muted); line-height: 1.3; }
.mode[aria-checked="true"] { border-color: var(--c-selected); background: color-mix(in srgb, var(--c-selected) 12%, var(--c-surface)); }
.mode .tick { position: absolute; top: 8px; right: 8px; display: none; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-selected); color: var(--c-on-selected); }
.mode .tick .i { width: 14px; height: 14px; stroke-width: 3; }
.mode[aria-checked="true"] .tick { display: grid; }

.level:focus-visible, .mode:focus-visible, .switch:focus-visible, .picker-btn:focus-visible { outline: var(--focus-ring) solid var(--c-focus); outline-offset: 2px; }

.progress-card { display: flex; flex-direction: column; gap: var(--space-1); }
.progress-card[hidden] { display: none; }
.progress-card .head { display: flex; align-items: center; gap: var(--space-1); font-weight: var(--fw-heavy); }
.progress-card .head .count { margin-left: auto; font-size: var(--fs-sm); }
.progress-card .bar { height: 10px; }
.progress-card .split { display: flex; gap: var(--space-2); min-height: 1.45em; font-size: var(--fs-sm); color: var(--c-text-muted); }
.last { font-size: var(--fs-sm); color: var(--c-text-muted); text-align: center; }
.about h2 { margin-bottom: 4px; font-size: var(--fs-md); }
.about p, .about li { font-size: var(--fs-sm); }
.about ul { margin: 4px 0 0; padding-left: 20px; }
.version-footer { color: var(--c-text-muted); font-size: var(--fs-xs); text-align: center; }

/* ---------- Settings ---------- */
fieldset.field { min-width: 0; margin: 0; padding: 0; border: 0; }
.section-title { padding: 0; font-size: var(--fs-md); font-weight: var(--fw-heavy); }
.hint { font-size: var(--fs-xs); color: var(--c-text-muted); }
.hint.warn { color: var(--c-error); font-weight: var(--fw-bold); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-1); margin: var(--space-1) 0; }
.check-item { position: relative; display: flex; align-items: center; gap: var(--space-1); min-height: var(--tap); padding: 0 var(--space-1);
  border-radius: var(--radius-sm); background: var(--c-surface); font-weight: var(--fw-semibold); cursor: pointer; }
.check-input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.box-check { display: grid; place-items: center; flex: none; width: 22px; height: 22px; border: 2px solid var(--c-text-muted); border-radius: 6px; }
.box-check .i { width: 16px; height: 16px; stroke-width: 3; visibility: hidden; }
.check-item.on .box-check { border-color: var(--c-selected); background: var(--c-selected); color: var(--c-on-selected); }
.check-item.on .box-check .i { visibility: visible; }
.check-item:has(.check-input:focus-visible) { outline: var(--focus-ring) solid var(--c-focus); outline-offset: 2px; }

.stats-card { padding: var(--space-1) 12px; }
.stats-card[hidden] { display: none; }
.stats { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: 6px 4px; text-align: right; }
.stats th:first-child, .stats td:first-child { text-align: left; }
.stats thead th { border-bottom: 1px solid var(--c-border); color: var(--c-text-muted); font-weight: var(--fw-bold); }
.stats tbody th { font-weight: var(--fw-heavy); }
.stats .lang td { padding-top: var(--space-1); font-weight: var(--fw-heavy); }
.stats .lang .flag { display: inline-block; margin-right: 6px; vertical-align: -4px; }
.stats .zero { color: var(--c-text-muted); }

/* ---------- Find me ---------- */
.done-pill { cursor: pointer; min-height: 44px; white-space: nowrap; font-weight: var(--fw-heavy); }
.done-pill .i { width: 18px; height: 18px; color: var(--c-found); stroke-width: 3; }
.done-pill:focus-visible { outline: var(--focus-ring) solid var(--c-focus); outline-offset: 2px; }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.statusbar .meta .flag { width: 18px; height: 12px; }
.statusbar .meta .flag[hidden] { display: none; }

/* Square cells: min(playWidth / C, playHeight / R) via container units on the play area. */
.play[data-screen="find"] { container-type: size; }
.board { --rows: 8; --cols: 8; --board-w: min(100cqw, 100cqh * var(--cols) / var(--rows));
  position: relative; width: var(--board-w); aspect-ratio: var(--cols) / var(--rows); }
.grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr);
  width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  border-radius: var(--radius-sm); cursor: pointer; }
.grid:focus { outline: none; }
.grid:focus-visible { outline: var(--focus-ring) solid var(--c-focus); outline-offset: 3px; }
.grow { display: contents; }
/* The wrapper is the hit area (no gaps between cells); the tile inside draws the 4px gap. */
.cell { display: grid; min-width: 0; min-height: 0; padding: 2px; }
.tile { display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--c-surface); box-shadow: var(--shadow);
  font-size: clamp(14px, calc(var(--board-w) / var(--cols) * 0.5), 30px); font-weight: var(--fw-heavy); line-height: 1;
  text-underline-offset: 3px; transition: background-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease); }
.cell.ok .tile { background: var(--c-found); color: var(--c-on-found); text-decoration: underline; text-decoration-thickness: 2px; }
.cell.ok2 .tile { background: var(--c-found-strong); color: var(--c-on-found); text-decoration: underline double; }
.cell.ok-shared .tile { background: color-mix(in srgb, var(--c-found) 35%, var(--c-surface)); color: var(--c-text);
  text-decoration: underline; text-decoration-style: dotted; }
.cell.sel .tile { background: var(--c-selected); color: var(--c-on-selected); outline: 2px solid var(--c-text); outline-offset: -2px; }
.cell.partial .tile { background: var(--c-accent); color: var(--c-on-accent); outline: 2px solid var(--c-text); outline-offset: -2px; }
/* Selected over a found cell: blue with a green inner ring, so both states stay visible. */
.cell.sel.ok .tile, .cell.sel.ok2 .tile { box-shadow: inset 0 0 0 4px var(--c-found); }
.cell.err .tile { background: var(--c-error); color: var(--c-on-error); outline: 0; box-shadow: none; }
.grid:focus-visible .cell.cursor .tile { outline: var(--focus-ring) solid var(--c-focus); outline-offset: 1px; }

/* Path line: short connectors between consecutive cells (never through the letters). */
.paths { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.paths line { fill: none; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.paths .sel { stroke: var(--c-text); stroke-width: 4px; }
.paths .ok { stroke: var(--c-found-strong); stroke-width: 3px; }

.find-info .row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px var(--space-1); min-width: 0; }
.find-info .word { font-size: var(--fs-xl); font-weight: var(--fw-heavy); line-height: 1.15; overflow-wrap: anywhere; }
.find-info .last-found-word { color: var(--c-found); }
.find-info .art { font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--c-text-muted); }
.find-info .found { margin-left: auto; font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--c-text-muted); white-space: nowrap; }
.find-info .found.lead { margin-left: 0; }
.find-info .trans { font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.25; overflow-wrap: anywhere; }
.find-info .note { font-size: var(--fs-sm); color: var(--c-text-muted); }
.find-info .actions { display: flex; justify-content: flex-end; margin-top: auto; }
.hint-track { display: flex; flex: 1; min-height: 0; overflow-x: auto; scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain; scrollbar-width: thin; }
.hint-track:focus-visible { outline: var(--focus-ring) solid var(--c-focus); outline-offset: -2px; }
.hint-page { flex: 0 0 100%; min-width: 0; padding: 2px; overflow-y: auto; scroll-snap-align: start; }
.hint-nav { display: flex; flex: none; align-items: center; gap: 4px; }
.hint-nav .icon-btn { font-size: var(--fs-xl); }
.hint-nav .icon-btn[aria-disabled="true"] { opacity: 0.4; cursor: default; }
.hint-nav .hint-dots { flex-wrap: wrap; margin-left: 0; }
.chip { display: inline-block; padding: 0 8px; border: 1px solid var(--c-text-muted); border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--c-text-muted); }
.dots { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.dots i { width: 8px; height: 8px; border: 2px solid var(--c-text-muted); border-radius: 50%; }
.dots i.on { border-color: var(--c-found); background: var(--c-found); }

/* ---------- Match me ---------- */
/* Two columns of equal rows fill play + info height; boxes min 56px, 18px text, 12px gap, text wraps. */
.match .note { grid-column: 1 / -1; align-self: center; color: var(--c-text-muted); text-align: center; }
.mcol { display: flex; flex-direction: column; gap: var(--gap-box); min-width: 0; min-height: 0; }
.mbox { display: flex; flex: 1 1 0; align-items: center; justify-content: center; gap: 6px; min-width: 0; min-height: var(--box-min-h);
  padding: var(--space-1); border: 2px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text);
  font-size: var(--fs-lg); font-weight: var(--fw-bold); line-height: 1.2; text-align: center; overflow-wrap: anywhere; hyphens: auto;
  box-shadow: var(--shadow); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    opacity var(--dur) var(--ease), scale var(--dur) var(--ease); }
.mbox .art { font-weight: var(--fw-regular); color: var(--c-text-muted); }
.mbox:focus-visible { outline: var(--focus-ring) solid var(--c-focus); outline-offset: 2px; }
@media (hover: hover) { .mbox:not(.sel, .ok, .err, .empty):hover { border-color: var(--c-text-muted); } }
.mbox.sel { border-color: var(--c-text); background: var(--c-selected); color: var(--c-on-selected); }
.mbox.ok { border-color: var(--c-found); background: var(--c-found); color: var(--c-on-found); cursor: default; }
.mbox.err { border-color: var(--c-error); background: var(--c-error); color: var(--c-on-error); }
.mbox.sel .art, .mbox.ok .art, .mbox.err .art { color: inherit; }
.mbox.ok::before { content: "\2713"; font-weight: var(--fw-black); }
/* Matched pair leaving: fade + collapse (scale, so the row keeps its slot for the new word). */
.mbox.out { opacity: 0; scale: 0.85; }
.mbox.empty { visibility: hidden; }

