/* Light only (operator, design rev 5). Every pair is WCAG AA; see design §2.5. */
:root {
  color-scheme: light;
  --bg: #FFFFFF;
  --fg: #1F2328;
  --box-bg: #FFFFFF;
  --box-border: #6E7781;
  --error: #B42318;
  --accent: #F95816;
  --on-accent: #FFFFFF;
  --focus: #1F2328;
}

*, *::before, *::after { box-sizing: border-box; }

html { background: var(--bg); color: var(--fg); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

main {
  width: 100%;
  max-width: 26rem;
  padding-inline: .25rem;
  text-align: center;
}

main > svg { display: block; height: 2.5rem; width: auto; margin: 0 auto 2.5rem; }

form, .done { display: flex; flex-direction: column; align-items: center; gap: 1.25rem; }

label, legend { display: block; padding: 0; }

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-inline-size: 0;
}

fieldset > legend { width: 100%; margin-bottom: 1.25rem; }

/* One row that never wraps (design §2.2): the boxes shrink with the viewport instead.
   Widest: 8 x 2.5rem + 8 gaps x .5rem + the 1rem dash = 25rem, inside main's 26rem.
   At 320 CSS px: 8 x 1.75rem + 8 x .25rem + 1rem = 17rem (272px), inside 312px. */
.row {
  --gap: clamp(.25rem, 1.2vw, .5rem);
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: var(--gap);
}

.half { display: flex; flex-wrap: nowrap; gap: var(--gap); }

.dash { flex: 0 0 1rem; width: 1rem; text-align: center; }

input {
  font: 1.375rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--fg);
  background: var(--box-bg);
  border: 1.5px solid var(--box-border);
  border-radius: 6px;
  text-align: center;
  height: 3.25rem;
}

#code { width: 12ch; letter-spacing: .1em; }

.half input { flex: 0 0 auto; width: clamp(1.75rem, 8vw, 2.5rem); padding: 0; text-transform: uppercase; }

input[aria-invalid="true"] { border-color: var(--error); }

#go {
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  min-height: 2.75rem;
  padding: .5rem 1.5rem;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  animation: appear 120ms ease-out;
}

/* A display rule on #go would otherwise override the hidden attribute. */
#go[hidden] { display: none; }

#status { margin: 0; min-height: 1.5rem; color: var(--error); }

#status:empty { min-height: 0; }

a { color: var(--fg); text-decoration: underline; }

code { font: .875rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; word-break: break-all; display: block; max-width: 32ch; }

.done p { margin: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@keyframes appear { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  #go { animation: none; }
}
