/* Layout: one column, phone first. The play view stacks the two photos so both fit one screen. */
:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --fg: #23201c;
  --muted: #6f675d;
  --accent: #d9480f;
  --accent-fg: #ffffff;
  --hit: #2b8a3e;
  --miss: #e03131;
  --done: #d3f0d9;
  --line: #e2dcd2;
  --shade: rgba(20, 16, 12, .5);
  --font: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1916; --surface: #26231f; --fg: #eee8df; --muted: #a59c90; --accent: #f76707;
    --accent-fg: #1b1916; --hit: #51cf66; --miss: #ff6b6b; --done: #24442c; --line: #3a352f;
    --shade: rgba(0, 0, 0, .6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1916; --surface: #26231f; --fg: #eee8df; --muted: #a59c90; --accent: #f76707;
  --accent-fg: #1b1916; --hit: #51cf66; --miss: #ff6b6b; --done: #24442c; --line: #3a352f;
  --shade: rgba(0, 0, 0, .6); color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* views and panels toggle with el.hidden */
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button {
  font: inherit; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  background: var(--accent); color: var(--accent-fg);
}
button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.error { color: var(--miss); }

/* menu */
.menu { max-width: 480px; margin: 0 auto; padding-block: 12px 24px; display: flex; flex-direction: column; gap: 14px; }
.menu h1 { font-size: 22px; margin: 4px 0 0; text-wrap: balance; }
.menu h1 small { display: block; font-size: 13px; color: var(--muted); font-weight: normal; margin-top: 4px; }
.toggle { display: flex; gap: 8px; align-items: center; }
.stages { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stages button {
  width: 100%; padding: 14px 0; background: var(--surface); color: var(--fg);
  border: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.stages button.done { background: var(--done); }
.logbox { display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.logrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sync { color: var(--muted); font-size: 13px; }
#logpanel { display: flex; flex-direction: column; gap: 8px; }
#logtext { width: 100%; font: 12px/1.4 ui-monospace, Consolas, monospace; background: var(--surface); color: var(--fg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }

/* play */
.play { touch-action: manipulation; -webkit-user-select: none; user-select: none; overscroll-behavior: none; }
.hud { display: flex; align-items: center; gap: 12px; height: 44px; max-width: 480px; margin: 0 auto; font-variant-numeric: tabular-nums; }
.hud .back { font-size: 20px; padding: 4px 10px; background: transparent; color: var(--fg); }
.hud #found { margin-left: auto; font-weight: 600; }
.boards { display: flex; flex-direction: column; align-items: center; gap: 6px; }
/* two squares fit between the header (44px) and the footer (~64px) */
.wrap {
  position: relative; aspect-ratio: 1; max-width: 100%; touch-action: manipulation;
  width: min(100%, 480px, calc((100vh - 120px) / 2));
  width: min(100%, 480px, calc((100dvh - 120px) / 2));
}
.wrap canvas { width: 100%; height: 100%; display: block; }
.wrap.mirrored { transform: scaleX(-1); }
.marks { position: absolute; inset: 0; pointer-events: none; }
.hit { position: absolute; aspect-ratio: 1; min-width: 28px; transform: translate(-50%, -50%); border: 3px solid var(--hit); border-radius: 50%; box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.miss { position: absolute; width: 28px; height: 28px; transform: translate(-50%, -50%); }
.miss::before, .miss::after { content: ""; position: absolute; left: 50%; top: 0; width: 4px; height: 100%; margin-left: -2px; background: var(--miss); border-radius: 2px; }
.miss::before { transform: rotate(45deg); }
.miss::after { transform: rotate(-45deg); }
.bottom { display: flex; justify-content: center; padding-block: 10px; }
.report { background: var(--muted); color: var(--bg); }
.report.on { background: var(--miss); color: #fff; }
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 8px;
}
.overlay { position: fixed; inset: 0; background: var(--shade); display: flex; align-items: center; justify-content: center; padding: 16px; }
.card { background: var(--surface); border-radius: 16px; padding: 24px; width: min(320px, 100%); display: flex; flex-direction: column; gap: 10px; text-align: center; }
.card h2 { margin: 0; }
.card p { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
