:root {
  --bg: #f6f1e7;
  --surface: #fffaf2;
  --ink: #1f1a14;
  --muted: #6e655a;
  --line: #e3d9c8;
  --accent: #b4501e;
  --accent-ink: #fff6ec;
  --cell: #efe6d6;
  --wall: #4a3f35;
  --beam: #ff3d1a;
  --target: #c9bba5;
  --lit: #ffb020;
  --ok: #2f7d4f;
  --bad: #b3261e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f; --surface: #211b16; --ink: #f3eadf; --muted: #a99c8c; --line: #3a3129;
    --accent: #e0793f; --accent-ink: #1b120b; --cell: #2b241d; --wall: #0d0a08;
    --beam: #ff5a36; --target: #5b5045; --lit: #ffc04d; --ok: #6cc28f; --bad: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17130f; --surface: #211b16; --ink: #f3eadf; --muted: #a99c8c; --line: #3a3129;
  --accent: #e0793f; --accent-ink: #1b120b; --cell: #2b241d; --wall: #0d0a08;
  --beam: #ff5a36; --target: #5b5045; --lit: #ffc04d; --ok: #6cc28f; --bad: #ff8a80;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }

.bar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; max-width: 560px; width: 100%; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 62%, 0 100%); }
.lang { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; font-size: 14px; font-weight: 600; min-height: 36px; }

.steps { list-style: none; display: flex; gap: 6px; padding: 0 16px; margin: 0 auto 4px; max-width: 560px; width: 100%; }
.steps li { flex: 1; height: 4px; border-radius: 2px; background: var(--line); transition: background .3s; }
.steps li.on { background: var(--accent); }

main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 8px 16px 24px; }
.screen { animation: in .35s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .screen { animation: none; } }

.kicker { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; margin: 12px 0 4px; }
h1 { font-size: clamp(28px, 8vw, 36px); line-height: 1.12; margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 24px; line-height: 1.2; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.lead { font-size: 18px; }
.small, small { color: var(--muted); font-size: 14px; }
.facts { padding: 0; list-style: none; margin: 16px 0 24px; display: grid; gap: 8px; }
.facts li { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }

.primary { width: 100%; min-height: 52px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 17px; }
.primary:disabled { opacity: .55; }
.ghost { min-height: 44px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.row { display: flex; gap: 8px; margin: 8px 0 16px; }

/* laser board */
.board-wrap { margin: 12px -4px 8px; }
#board { width: 100%; height: auto; display: block; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#board .cell { fill: var(--cell); cursor: pointer; }
#board .cell:active { fill: var(--line); }
#board .wall { fill: var(--wall); }
#board .target { fill: none; stroke: var(--target); stroke-width: 3; }
#board .target.on { fill: var(--lit); stroke: var(--lit); filter: drop-shadow(0 0 5px var(--lit)); }
#board .mirror { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; pointer-events: none; }
#board .beam { fill: none; stroke: var(--beam); stroke-width: 3; stroke-linejoin: round; stroke-linecap: round; pointer-events: none; filter: drop-shadow(0 0 3px var(--beam)); }
#board .emitter { fill: var(--wall); }
#board .emitter-eye { fill: var(--beam); }
.status { display: flex; justify-content: space-between; font-size: 15px; color: var(--muted); }
.status b { color: var(--ink); font-size: 18px; }
.legend { font-size: 14px; color: var(--muted); margin-top: 8px; }
.win { background: var(--surface); border: 1px solid var(--ok); border-radius: 14px; padding: 14px; margin-top: 8px; }
.win p { color: var(--ok); font-weight: 600; }

/* detectors */
.det-list { display: grid; gap: 10px; margin: 16px 0; }
.det { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; text-align: left;
  width: 100%; padding: 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); min-height: 64px; }
.det .id { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 20px; background: var(--cell); }
.det .say { font-size: 16px; }
.det .tag { display: block; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ok); margin-bottom: 2px; }
.det[aria-pressed="true"] { border-color: var(--bad); }
.det[aria-pressed="true"] .id { background: var(--bad); color: var(--surface); }
.det[aria-pressed="true"] .tag { color: var(--bad); }
.feedback { min-height: 1.5em; font-weight: 600; }
.feedback.bad { color: var(--bad); }
.feedback.ok { color: var(--ok); }

/* form */
form { display: grid; gap: 14px; margin-top: 12px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 15px; }
input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; min-height: 48px; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 400; font-size: 16px; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
.file input { font-size: 15px; font-weight: 400; }
.check { grid-template-columns: 24px 1fr; align-items: start; font-weight: 400; font-size: 14px; color: var(--muted); }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }

.done-mark { width: 72px; height: 72px; border-radius: 50%; background: var(--ok); margin: 32px 0 16px;
  position: relative; }
.done-mark::after { content: ""; position: absolute; left: 22px; top: 14px; width: 18px; height: 34px; border: solid var(--surface); border-width: 0 6px 6px 0; transform: rotate(45deg); }

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 16px; }
[hidden] { display: none !important; }
