/* accessiSim. One stylesheet, one centered column.
   Every color that carries text clears 7:1 on --bg and --bg-soft.
   Control edges clear 3:1. Ratios are beside each token. */

:root {
  --fg: #000;           /* 21:1 on --bg, 18.1:1 on --bg-soft */
  --bg: #fff;
  --bg-soft: #f1f1f1;
  --muted: #3d3d3d;     /* 10.9:1 on --bg, 9.6:1 on --bg-soft */
  --link: #0040c0;      /* 8.4:1 on --bg, 7.5:1 on --bg-soft */
  --border: #595959;    /* 7.0:1 on --bg, 6.2:1 on --bg-soft */
  --focus: #ffbf47;
  --focus-halo: #000;
  --page-width: 44rem;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fg: #fff;         /* 21:1 on --bg, 17.1:1 on --bg-soft */
    --bg: #000;
    --bg-soft: #1c1c1c;
    --muted: #d0d0d0;   /* 13.4:1 on --bg, 10.9:1 on --bg-soft */
    --link: #9cc3ff;    /* 11.7:1 on --bg, 9.5:1 on --bg-soft */
    --border: #a8a8a8;  /* 8.6:1 on --bg, 7.0:1 on --bg-soft */
    --focus-halo: #fff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --fg: #fff;
  --bg: #000;
  --bg-soft: #1c1c1c;
  --muted: #d0d0d0;
  --link: #9cc3ff;
  --border: #a8a8a8;
  --focus-halo: #fff;
  color-scheme: dark;
}

:root { font-size: 112.5%; }
:root[data-size="large"] { font-size: 137.5%; }
:root[data-size="larger"] { font-size: 162.5%; }
:root[data-font="system"] { --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  line-height: 1.6;
}

main {
  max-width: var(--page-width);
  margin: 0 auto;
  padding: 1rem 1rem 4rem;
}

h1, h2, h3 { line-height: 1.25; margin: 1.6em 0 0.5em; }
h1 { font-size: 2rem; margin-top: 0.5em; }
h2 { font-size: 1.5rem; border-top: 2px solid var(--border); padding-top: 0.8em; }
h3 { font-size: 1.2rem; }
p, li { max-width: 70ch; }

:where(a, a:visited) { color: var(--link); text-decoration: underline; }

:focus { outline: none; }
:focus-visible,
[tabindex="-1"]:focus {
  outline: 4px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 8px var(--focus-halo);
}

button {
  font: inherit;
  color: var(--fg);
  background: var(--bg-soft);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 1.1rem;
  min-height: 48px;
  cursor: pointer;
}
button:hover { border-color: var(--fg); text-decoration: underline; }
button[aria-disabled="true"] { border-style: dashed; color: var(--muted); }

.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1rem 0; padding: 0; list-style: none; }

/* A recovery code, big and spaced so each character stands apart. */
.code {
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  padding: 0.6rem 1rem;
}

input[type="password"] {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  min-height: 48px;
  width: 100%;
  max-width: 24rem;
}

/* The game menu. Items look like buttons and take focus one at a time. */
.menu-title { font-weight: 700; margin: 0.5rem 0; }
.game-menu [role="menu"] { list-style: none; margin: 0 0 0.5rem; padding: 0; }
.game-menu [role="menuitem"] {
  display: block;
  margin: 0 0 0.5rem;
  padding: 0.6rem 1.1rem;
  min-height: 48px;
  border: 2px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  cursor: pointer;
  max-width: none;
}
.game-menu [role="menuitem"][aria-haspopup]::after { content: " ›" / ""; }
.game-menu [role="menuitem"][aria-disabled="true"] { border-style: dashed; color: var(--muted); }
.game-menu [role="menuitem"]:hover { border-color: var(--fg); }

/* A heading that opens and closes the section under it. */
.fold {
  display: block;
  width: 100%;
  text-align: left;
  font-size: inherit;
  font-weight: 700;
  background: var(--bg);
  border-color: var(--border);
}
.fold::before { content: "+ " / ""; }
.fold[aria-expanded="true"]::before { content: "- " / ""; }
h2 .fold { padding: 0.6rem 0.8rem; }

.actions { list-style: none; margin: 0.25rem 0 1rem; padding: 0; }
.actions li { margin: 0 0 0.5rem; max-width: none; }
.actions button { display: block; width: 100%; text-align: left; }

textarea {
  display: block;
  width: 100%;
  font: inherit;
  line-height: 1.5;
  color: var(--fg);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}

.lines { list-style: none; padding: 0; }
.lines > li { border-left: 4px solid var(--border); padding-left: 0.75rem; margin: 0.75rem 0; }
.line-talk { padding-left: 1rem; border-left: 4px solid var(--border); }

input[type="text"], select {
  font: inherit;
  color: var(--fg);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  min-height: 48px;
  max-width: 100%;
}
input[type="text"] { width: 100%; max-width: 24rem; }
input[type="radio"], input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
  margin: 0.2rem 0.6rem 0 0;
  flex: none;
  accent-color: var(--link);
}

fieldset {
  border: 2px solid var(--border);
  border-radius: 8px;
  margin: 1.25rem 0;
  padding: 0.75rem 1rem 1rem;
}
legend { font-weight: 700; font-size: 1.1rem; padding: 0 0.4rem; }

.field { margin: 1.25rem 0; }
.field > label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.choice { display: flex; align-items: flex-start; margin: 0.6rem 0; }
.choice label { font-weight: 700; }
.choice .desc { display: block; font-weight: 400; color: var(--muted); }
.hint { color: var(--muted); }
.error { font-weight: 700; border-left: 6px solid var(--fg); padding-left: 0.75rem; }

.status-time, .status-where { font-weight: 700; margin: 0.25rem 0; }
.needs { list-style: none; padding: 0; margin: 0.75rem 0; }
.needs li { padding: 0.15rem 0; }
.warning { font-weight: 700; border-left: 6px solid var(--fg); padding-left: 0.75rem; }

.result { background: var(--bg-soft); border: 2px solid var(--border); border-radius: 8px; padding: 0.25rem 1rem; }
.line { margin: 0.75rem 0; }
.line-changes { color: var(--muted); }

.log ol { padding-left: 1.5rem; }
.log li { margin: 0.5rem 0; }
summary { cursor: pointer; font-weight: 700; min-height: 48px; padding: 0.6rem 0; }

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

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
