:root {
  --bg: #16120c; --panel: #211b12; --panel-2: #2b2317; --text: #f3ead8; --muted: #b9a988; --line: #4a3d28;
  --ink: #e9dcc0; --gold: #f2b64a; --gold-ink: #241805; --you: #7fd6c2; --rival: #c98b6b; --bad: #ef7d6a; --good: #9ad77f;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--gold); text-underline-offset: 3px; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Every game: a way back to the others, and who's signed in. */
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line); font-size: 15px;
}
.bar .home { color: var(--muted); text-decoration: none; }
.bar .home:hover { color: var(--text); }
.bar .account { color: var(--muted); text-align: right; }
.bar .account strong { color: var(--text); }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 48px; }
.title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(34px, 8vw, 50px); margin: 4px 0 0; font-weight: 700; letter-spacing: 0.01em; }
h2 { font-size: 15px; margin: 0 0 6px; color: var(--muted); font-weight: 600; }
.tagline { color: var(--muted); margin: 4px 0 14px; }

button {
  font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.primary { background: var(--gold); color: var(--gold-ink); border-color: var(--gold); font-weight: 700; }
button.link { background: none; border: 0; color: var(--gold); text-decoration: underline; padding: 0; }

.words { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.words button { font-family: Georgia, serif; font-style: italic; font-size: 17px; padding: 6px 12px; }
.words button[aria-current="true"] { border-color: var(--gold); color: var(--gold); }
.words .best { font-family: system-ui, sans-serif; font-style: normal; font-size: 12px; color: var(--muted); margin-left: 6px; }

.era {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; align-items: end;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px;
}
.form-wrap { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.year { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 18px; }
.form { font-family: Georgia, serif; font-style: italic; font-size: clamp(28px, 7vw, 40px); color: var(--you); transition: color 0.3s; }
.era-stats { display: flex; gap: 16px; text-align: right; }
.era-stats .label { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.era-stats strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.needed { grid-column: 1 / -1; margin: 4px 0 0; color: var(--muted); }
.needed strong { color: var(--gold); }
.needed em { color: var(--ink); font-family: Georgia, serif; }

.board { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
#map { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; user-select: none; }
#map .sense circle { fill: var(--ink); }
#map .sense text { fill: var(--ink); font-size: 3.8px; font-family: Georgia, serif; }
#map .sense.needed circle { fill: var(--gold); }
#map .sense.needed text { fill: var(--gold); font-weight: 700; }
#map .sense.held text { text-decoration: underline; }
#map .sense .was-wanted { fill: none; stroke: var(--gold); stroke-width: 0.5; stroke-opacity: 0.8; }
#map .sense.unknown circle { fill: var(--muted); opacity: 0.5; }
#map .sense.unknown text { fill: var(--muted); opacity: 0.6; }
#map .rival circle { fill: var(--rival); fill-opacity: 0.14; stroke: var(--rival); stroke-opacity: 0.6; stroke-width: 0.3; }
#map .rival text { fill: var(--rival); font-size: 3.4px; font-style: italic; font-family: Georgia, serif; }
#map .reach { fill: none; stroke: var(--you); stroke-opacity: 0.45; stroke-width: 0.3; stroke-dasharray: 1 1; }
#map .now { fill: none; stroke: var(--you); stroke-opacity: 0.5; stroke-width: 0.3; }
#map .ghost { fill: var(--you); fill-opacity: 0.16; stroke: var(--you); stroke-width: 0.6; }
#map .ghost-word { fill: var(--you); font-size: 4px; font-family: Georgia, serif; font-style: italic; font-weight: 700; }
#map .trail { fill: none; stroke: var(--you); stroke-width: 0.6; stroke-opacity: 0.8; }
#map .history { fill: none; stroke: var(--gold); stroke-width: 0.6; stroke-dasharray: 1.5 1.2; }
#map .target-star { fill: var(--gold); font-size: 4.5px; }
#map .grid { stroke: var(--line); stroke-width: 0.15; }
.steps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 15px; line-height: 1.4; }
.steps li b {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--muted); font-size: 13px;
}
#map .arrow { stroke: var(--you); stroke-width: 0.7; }
#map .arrowhead { fill: var(--you); }
.board .controls { margin: 6px 0 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 4px; padding: 0; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none; }
.key-you { border: 2px solid var(--you); background: rgba(127, 214, 194, 0.16); }
.key-reach { border: 1.5px dashed var(--you); }
.key-wanted { border: 1.5px solid var(--gold); }
.key-unknown { background: var(--muted); opacity: 0.5; width: 6px !important; height: 6px !important; margin: 0 4px; }
.key-rival { background: rgba(201, 139, 107, 0.25); border: 1px solid var(--rival); }
.key-star { color: var(--gold); font-weight: 400; }
.breadth { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 8px 0 4px; }
#breadth-val { min-width: 7em; text-align: center; color: var(--muted); font-size: 14px; }

.preview { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 12px; }
.preview ul { list-style: none; margin: 0; padding: 0; }
.preview li { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.preview li .amt { font-variant-numeric: tabular-nums; font-weight: 700; }
.preview .total { margin: 8px 0 0; text-align: right; }
.pos { color: var(--good); }
.neg { color: var(--bad); }

.controls { display: flex; justify-content: center; margin: 16px 0; }
.controls .primary { font-size: 18px; padding: 12px 24px; width: min(100%, 360px); }

.chronicle summary { cursor: pointer; color: var(--muted); }
.chronicle ol { list-style: none; padding: 0; margin: 8px 0 0; }
.chronicle li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.chronicle li .y { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 8px; }
.chronicle li .f { font-family: Georgia, serif; font-style: italic; color: var(--you); margin-right: 8px; }
.chronicle li .w { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.chronicle li .w strong { color: var(--gold); }
.chronicle li q { color: var(--ink); font-family: Georgia, serif; }
.also { margin-top: 28px; color: var(--muted); font-size: 14px; text-align: center; }

dialog {
  max-width: 560px; width: calc(100% - 32px); background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 14px; padding: 20px;
}
dialog::backdrop { background: rgba(10, 8, 4, 0.75); }
dialog h2 { font-family: Georgia, serif; font-size: 26px; color: var(--text); margin-bottom: 8px; }
dialog .lede { line-height: 1.5; }
dialog ul { padding-left: 18px; line-height: 1.5; }
dialog form { margin-top: 12px; text-align: right; }
.small { color: var(--muted); font-size: 14px; }
.big { font-size: 32px; font-weight: 800; margin: 4px 0 8px; }
.end-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

@media (max-width: 520px) {
  .era { grid-template-columns: 1fr; }
  .era-stats { text-align: left; }
}
