:root {
  color-scheme: light dark;
  --bg: #efece6;
  --panel: #ffffff;
  --ink: #1f1d1a;
  --muted: #6d6860;
  --line: #d9d4ca;
  --accent: #b5562c;
  --accent-ink: #fff;
  --shadow: 0 6px 24px rgb(0 0 0 / .12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --panel: #1f2025;
    --ink: #ecebe8;
    --muted: #9c9a94;
    --line: #2f3036;
    --accent: #f0915e;
    --accent-ink: #141414;
    --shadow: 0 6px 24px rgb(0 0 0 / .5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.4 var(--font);
  overflow: hidden;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

.bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  z-index: 2;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand strong { font-size: 16px; letter-spacing: -.01em; }
.theme { color: var(--muted); font-size: 13px; }
.trail { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; }
.trail button {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
}
.trail button[aria-current="page"] { color: var(--ink); font-weight: 600; cursor: default; }
.trail .sep { color: var(--muted); }
.tools { display: flex; gap: 8px; align-items: center; }
input, button { font: inherit; color: inherit; }
input {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 9px;
}
button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
input:focus-visible, button:focus-visible, canvas:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.goto { display: flex; gap: 4px; }
.goto[hidden] { display: none; }

.stage { position: relative; flex: 1; min-height: 0; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
canvas.dragging { cursor: grabbing; }

.hint-box {
  position: absolute;
  left: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 12px;
  color: var(--muted);
  width: min(280px, calc(100% - 24px));
}

.legend {
  position: absolute;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  font-size: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
}
@media (max-width: 640px) { .legend { display: none; } }

.panel {
  position: absolute;
  top: 12px;
  right: 12px;
  width: min(320px, calc(100% - 24px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
}
@media (max-width: 640px) {
  /* At the top on phones: the hint box is at the bottom, and a cell the
     finger just tapped is usually lower on the screen. */
  .panel { top: 8px; right: 8px; left: 8px; width: auto; }
}
.panel .close { position: absolute; top: 6px; right: 6px; border: 0; font-size: 20px; line-height: 1; padding: 4px 8px; }
.panel-head { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; padding-right: 24px; }
.panel-head .big { font-size: 38px; line-height: 1; }
.panel-head h2 { margin: 0; font-size: 18px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0 0 12px; }
.kv dt { color: var(--muted); font-size: 12.5px; padding-top: 1px; }
.kv dd { margin: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; font-size: 12.5px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; border: 1px solid rgb(0 0 0 / .15); }
.panel .primary { width: 100%; padding: 9px; }
.panel .primary[hidden] { display: none; }

.chooser { z-index: 1; }
/* Next to its cell (app.js anchorPopups sets left and top). */
.panel.anchored { right: auto; width: min(300px, calc(100% - 16px)); }
@media (max-width: 640px) { .panel.anchored { width: calc(100% - 16px); } }
.options { display: grid; gap: 6px; margin-bottom: 8px; }
.options button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 600;
}
.options button:hover, .options button:focus-visible { border-color: var(--accent); }
.options .em { font-size: 24px; line-height: 1; }
.options .swatch { margin: 0 0 0 auto; width: 14px; height: 14px; }
.small { font-size: 12.5px; margin: 0; }
.hint-box[hidden], .nick[hidden] { display: none; }

/* One line under the map: the AI notice and the privacy page (task 134). */
.foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 14px;
  padding: 5px 12px;
  padding-bottom: max(5px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 12px;
  text-align: center;
}
.foot a { color: var(--accent); }

/* privacy.html: a plain readable page. */
body.doc { display: block; overflow: auto; height: auto; }
.doc main { max-width: 44rem; margin: 0 auto; padding: 24px 18px 48px; }
.doc h1 { font-size: 24px; margin: 0 0 4px; }
.doc h2 { font-size: 17px; margin: 26px 0 6px; }
.doc p, .doc li { line-height: 1.55; }
.doc a { color: var(--accent); }

.theme-ask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgb(0 0 0 / .25);
  padding: 16px;
}
.theme-ask[hidden] { display: none; }
.theme-ask form {
  width: min(380px, 100%);
  background: var(--panel);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.theme-ask p { margin: 0 0 8px; }
.theme-ask input { width: 100%; margin: 6px 0 12px; }
.theme-ask .row { display: flex; justify-content: flex-end; gap: 8px; }

.resting {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 8px 14px;
  text-align: center;
  max-width: calc(100% - 24px);
}
.resting[hidden] { display: none; }
.toast {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: calc(100% - 24px);
}
