/* Where On Earth?: one stylesheet for the game and the notes page.
   Direction: a calm risograph-printed map. Soft pink and blue inks plus a yellow on off-white paper, flat
   tints (no fine dot screens: they shimmer), and only the mystery country printed slightly off-register.
   Chunky rounded type.
   Deliberately unlike Overbooked (black/yellow signage, condensed caps) and The Scoreboard (navy, LED). */
/* Fonts are hosted with the site (SIL Open Font License, see fonts/), so no visitor data goes to a font service. */
@font-face { font-family: "Bagel Fat One"; src: url("../fonts/bagel-fat-one-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Instrument Sans"; src: url("../fonts/instrument-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
:root {
  --paper: #f4f3ef;
  --paper-2: #eae8e1;
  --card: #fcfbf8;
  --ink: #262b4f;          /* text is printed in deep blue, not black */
  --muted: #61658a;
  --line: #d6d6df;
  --blue: #5a72c8;         /* blue ink: globe outline, the pin */
  --sea: #e3ebf5;
  --yellow: #f1dc8e;
  --accent: #e85a83;       /* soft riso pink: the mystery country, main buttons */
  --accent-ink: #262b4f;
  --misprint: #a9b7e8;     /* the off-register plate: a gentle periwinkle */
  --t1: #efe0a6; --t2: #cdd6ef; --t3: #d5e6ca; --t4: #ecd6e0; --t5: #e7e0d1;  /* flat country tints */
  --grain: .035;
  --good: #1a8d55;
  --bad: #cc3a62;
  --s1: #3aa56c; --s2: #e9c03f; --s3: #f08c3c; --s4: #dc4a5e;
  --f-display: "Bagel Fat One", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  --f-body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #17172c; --paper-2: #202039; --card: #1e1e38; --ink: #ecebf7; --muted: #a4a3c2; --line: #33334f;
    --blue: #8193dd; --sea: #1f2a4d; --yellow: #b9a560; --accent: #f27a9c; --accent-ink: #17172c; --misprint: #4d5da0;
    --t1: #514a2e; --t2: #34406d; --t3: #34503f; --t4: #553b4c; --t5: #45403a;
    --grain: .025;
    --good: #45c886; --bad: #ff7a9c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #17172c; --paper-2: #202039; --card: #1e1e38; --ink: #ecebf7; --muted: #a4a3c2; --line: #33334f;
  --blue: #8193dd; --sea: #1f2a4d; --yellow: #b9a560; --accent: #f27a9c; --accent-ink: #17172c; --misprint: #4d5da0;
  --t1: #514a2e; --t2: #34406d; --t3: #34503f; --t4: #553b4c; --t5: #45403a;
  --grain: .025;
  --good: #45c886; --bad: #ff7a9c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--f-body);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 48px;
}
/* paper grain over everything */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 1 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 26px; }
h1, h2, h3 { font-family: var(--f-display); font-weight: 400; line-height: 1; margin: 0; text-wrap: balance; }
h2 { font-size: clamp(30px, 6vw, 40px); }
h3 { font-size: 22px; }
p { margin: 0; }
a { color: inherit; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
b, strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.hint { font-size: 14px; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- masthead ---------- */
.mast { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand svg { width: 54px; height: 54px; flex: none; }
.brand .word { font-family: var(--f-display); line-height: .9; font-size: 26px; display: flex; flex-direction: column; }
.brand .word em { font-style: normal; color: var(--accent); text-shadow: 1.5px 1.5px 0 var(--misprint); font-size: 1.32em; }
.tools { display: flex; gap: 8px; align-items: center; flex: none; }
.icon-btn { width: 40px; height: 40px; padding: 0; border-radius: 50%; border: 2px solid var(--ink); background: var(--card); color: var(--ink); font: 400 20px var(--f-display); cursor: pointer; }
.chip-btn { height: 40px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--ink); background: var(--card); color: var(--ink); font: 700 15px var(--f-body); max-width: 15ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover, .chip-btn:hover { background: var(--yellow); color: #1d2357; } }
.tagline { font-size: 17px; max-width: 46ch; }
.tagline b { background: linear-gradient(transparent 55%, color-mix(in srgb, var(--yellow) 85%, transparent) 55%); }

/* ---------- buttons ---------- */
button { font: 700 16px var(--f-body); border-radius: 999px; border: 2px solid var(--ink); background: var(--card); color: var(--ink); padding: 11px 20px; cursor: pointer; }
button.go { background: var(--accent); color: var(--accent-ink); box-shadow: 2px 2px 0 var(--misprint); }
button.go:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--misprint); }
button.ghost { background: var(--card); }
button.link { background: none; border: 0; padding: 4px 0; color: var(--muted); font-weight: 500; font-size: 14px; text-decoration: underline; border-radius: 0; justify-self: start; }
button.danger { background: var(--bad); border-color: var(--bad); color: #ffffff; }
button:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ---------- game ---------- */
.game { display: grid; gap: 12px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.round { font-family: var(--f-display); font-size: 22px; }
.pips { display: flex; gap: 6px; }
.pip { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: transparent; }
.pip.now { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.pip.s1 { background: var(--s1); } .pip.s2 { background: var(--s2); } .pip.s3 { background: var(--s3); } .pip.s4 { background: var(--s4); }
.pip.miss { background: var(--ink); }
.score { font-size: 15px; }
.score b { font-weight: 700; font-size: 20px; margin-left: 4px; font-variant-numeric: tabular-nums; }

.stage { position: relative; background: var(--paper); border: 2px solid var(--ink); border-radius: 28px; overflow: hidden; aspect-ratio: 1 / 1; max-height: 64vh; width: 100%; max-width: 100%; justify-self: center; }
@media (min-width: 620px) { .stage { aspect-ratio: 4 / 3; } }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sticker { position: absolute; font: 700 13px var(--f-body); letter-spacing: .02em; background: var(--yellow); color: #1d2357; border: 2px solid #1d2357; border-radius: 999px; padding: 3px 10px; }
.stage-tag { top: 12px; left: 12px; transform: rotate(-3deg); }
.dial { position: absolute; top: 10px; right: 10px; width: 66px; height: 66px; }
.dial svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.dial .track { fill: var(--card); stroke: var(--line); stroke-width: 8; }
.dial .arc { fill: none; stroke: var(--accent); stroke-width: 8; stroke-dasharray: 263.9; stroke-dashoffset: 0; }
.dial #dialTicks line { stroke: var(--ink); stroke-width: 3; }
.dial .ring { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.dial span { position: absolute; inset: 0; display: grid; place-items: center; font: 400 24px var(--f-display); font-variant-numeric: tabular-nums; }
.dial.low .arc { stroke: var(--bad); }
.dial.low span { color: var(--bad); }
.reveal-name { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%) rotate(-1.5deg); background: var(--card); border: 2px solid var(--ink); border-radius: 16px; padding: 6px 16px 8px; font: 400 26px var(--f-display); white-space: nowrap; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; box-shadow: 3px 3px 0 var(--misprint); }
.reveal-name small { display: block; font: 600 13px var(--f-body); color: var(--muted); }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; }
.overlay .box { background: var(--card); border: 2px solid var(--ink); border-radius: 22px; padding: 22px 20px; max-width: 400px; display: grid; gap: 12px; justify-items: center; box-shadow: 3px 3px 0 var(--misprint); }
.overlay .kicker { font: 700 13px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.overlay h3 { font-size: 26px; }

.answer { display: grid; gap: 10px; }
.answer-row { display: flex; gap: 8px; align-items: stretch; }
.combo { position: relative; flex: 1; min-width: 0; }
.combo input { width: 100%; height: 100%; font: 500 18px var(--f-body); color: var(--ink); background: var(--card); border: 2px solid var(--ink); border-radius: 999px; padding: 12px 18px; }
.combo input::placeholder { color: var(--muted); }
.combo input:focus { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.list { position: absolute; left: 8px; right: 8px; bottom: calc(100% + 6px); background: var(--card); border: 2px solid var(--ink); border-radius: 16px; margin: 0; padding: 6px; list-style: none; max-height: 260px; overflow: auto; z-index: 5; box-shadow: 0 8px 24px rgba(20, 20, 50, .15); }
.list li { padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.list li[aria-selected="true"] { background: var(--yellow); color: #1d2357; }
.list li .alias { color: var(--muted); font-size: 13px; margin-left: 6px; }
.list li[aria-selected="true"] .alias { color: inherit; opacity: .7; }
.misses { display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px; align-items: center; }
.miss-chip { font-size: 13px; font-weight: 600; border: 2px solid var(--bad); color: var(--bad); border-radius: 999px; padding: 0 10px; text-decoration: line-through; }
.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }
.dym { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 18px; background: var(--card); }
.dym p { flex: 1 1 220px; min-width: 0; }
.dym b { color: var(--accent); }
.dym .hint { display: block; }
.dym.none { box-shadow: none; border-style: dashed; }
.dym button { padding: 7px 14px; font-size: 14px; }
.coach { display: grid; gap: 10px; padding: 14px 16px; border-radius: 18px; background: var(--yellow); color: #1d2357; border: 2px solid #1d2357; }
.coach button { padding: 8px 16px; font-size: 14px; }
.coach button.ghost { background: transparent; color: #1d2357; border-color: #1d2357; }

/* ---------- results ---------- */
.results { display: grid; gap: 22px; }
.results-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.total { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.total b { font: 400 clamp(58px, 15vw, 84px)/1 var(--f-display); font-weight: 400; color: var(--accent); text-shadow: 3px 2px 0 var(--misprint); }
.tag { display: inline-block; font: 700 12px var(--f-body); letter-spacing: .05em; text-transform: uppercase; background: var(--yellow); color: #1d2357; border: 2px solid #1d2357; border-radius: 999px; padding: 2px 10px; transform: rotate(-3deg); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.stats div { display: grid; gap: 0; padding: 10px 12px; background: var(--card); border: 2px solid var(--ink); border-radius: 16px; }
.stats b { font: 400 24px var(--f-display); font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 8px; border-bottom: 2px dotted var(--line); }
th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.you td { background: color-mix(in srgb, var(--accent) 18%, transparent); font-weight: 700; }
.panelled { background: var(--card); border: 2px solid var(--ink); border-radius: 22px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.share { background: var(--paper); border: 2px dashed var(--line); border-radius: 14px; padding: 12px 14px; font-size: 15px; white-space: pre-wrap; user-select: all; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { padding: 5px 12px; font-size: 13px; }
.tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.example-note { font-size: 12px; color: var(--muted); }
.nudge { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border: 2px solid var(--ink); border-radius: 18px; background: var(--yellow); color: #1d2357; }
.nudge p { flex: 1 1 220px; min-width: 0; font-size: 15px; }

/* ---------- how it plays ---------- */
.how { display: grid; gap: 14px; }
.how ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 620px) { .how ol { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.how li { background: var(--card); border: 2px solid var(--ink); border-radius: 18px; padding: 12px; display: grid; gap: 6px; align-content: start; }
.how li canvas { width: 100%; aspect-ratio: 1; border-radius: 12px; background: var(--sea); display: block; }
.how li b { font: 400 18px var(--f-display); }
.how li span { font-size: 13px; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); }

footer.site { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--muted); border-top: 2px dotted var(--line); padding-top: 14px; }

/* ---------- dialogs ---------- */
dialog { border: 2px solid var(--ink); border-radius: 24px; background: var(--card); color: var(--ink); padding: 0; width: min(440px, calc(100% - 32px)); box-shadow: 3px 3px 0 var(--misprint); }
dialog::backdrop { background: rgba(21, 20, 43, .55); }
.dlg { padding: 22px; display: grid; gap: 14px; }
.dlg h3 { font-size: 28px; }
.steps { display: grid; gap: 8px; padding-left: 1.3em; margin: 0; }
.acct-form { display: flex; flex-wrap: wrap; gap: 8px; }
.acct-form input { flex: 1 1 180px; min-width: 0; font: 500 17px var(--f-body); color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: 10px 16px; }
.acct-form input:focus { outline: none; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent); }
.preview-note { font-size: 13px; color: var(--muted); background: var(--paper); border: 2px dashed var(--line); border-radius: 12px; padding: 8px 12px; }
.error { color: var(--bad); font-size: 14px; font-weight: 600; }
.close { justify-self: end; }

/* ---------- notes page ---------- */
.notes { display: grid; gap: 40px; }
.section { display: grid; gap: 14px; }
.section > p { max-width: 66ch; }
.eyebrow { font: 700 13px var(--f-body); letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 14px; }
.panel { background: var(--card); border: 2px solid var(--ink); border-radius: 20px; padding: 16px 18px; display: grid; gap: 8px; align-content: start; min-width: 0; }
.panel p, .panel li { font-size: 15px; }
ul, ol { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; }
.timeline { overflow-x: auto; }
.timeline svg { display: block; min-width: 620px; width: 100%; height: auto; }
.tag.free { background: var(--s1); color: #ffffff; border-color: var(--s1); }
.tag.paid { background: var(--s3); color: #1d2357; border-color: var(--s3); }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; background: var(--c); border: 2px solid var(--ink); }
.notes footer { color: var(--muted); font-size: 13px; }

@media (prefers-reduced-motion: reduce) { .shake { animation: none; } }
