:root {
  --bg: #f6f2e9;
  --surface: #fffdf8;
  --ink: #1f2a33;
  --muted: #6b7780;
  --line: #e2dccd;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #d9efeb;
  --good: #17805a;
  --good-soft: #dcf3e8;
  --bad: #c2453a;
  --bad-soft: #fbe3df;
  --warn: #a96a12;
  --ocean: #d7e7ee;
  --land: #f5efe0;
  --land-stroke: #a59d8a;
  --found: #2a9d8f;
  --missed: #e58a6f;
  --endpoint: #e9a23b;
  --route: #8f7ad6;
  --shadow: 0 1px 2px rgba(31, 42, 51, 0.06), 0 8px 24px rgba(31, 42, 51, 0.06);
  --radius: 14px;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10171c;
    --surface: #18222a;
    --ink: #e8edf0;
    --muted: #94a2ac;
    --line: #2a3842;
    --accent: #4fd1c5;
    --accent-ink: #06211f;
    --accent-soft: #173b3a;
    --good: #5bd6a2;
    --good-soft: #143629;
    --bad: #f08a7d;
    --bad-soft: #40201c;
    --warn: #e2b05e;
    --ocean: #0d202b;
    --land: #2a3944;
    --land-stroke: #5a6b77;
    --found: #3fbfae;
    --missed: #d9735a;
    --endpoint: #f0b24a;
    --route: #a594e8;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  }
}

* { box-sizing: border-box; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; }
img { display: block; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }

/* ---------- header ---------- */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px;
}
.brand {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark { color: var(--accent); }
.site-header nav { display: flex; gap: 4px; flex-wrap: wrap; }
.site-header nav a {
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}
.site-header nav a:hover { color: var(--ink); }
.site-header nav a.active { background: var(--accent-soft); color: var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 8px 20px 64px; }

/* ---------- buttons & controls ---------- */

.btn {
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input[type='text'], input[type='search'] {
  font: inherit;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.seg button:hover:not(:disabled) { border-color: var(--muted); }
.seg button.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.seg button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- home ---------- */

.hero { padding: 48px 0 32px; max-width: 720px; }
.hero h1 { font-size: clamp(36px, 6vw, 60px); letter-spacing: -0.02em; }
.hero p { font-size: 19px; color: var(--muted); margin: 16px 0 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.game-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.game-card h2 { font-size: 24px; }
.game-card p { margin: 0; color: var(--muted); flex: 1; }
.tag {
  align-self: flex-start;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 999px;
}
.go { font-weight: 700; color: var(--accent); margin-top: 8px; }

/* ---------- map game ---------- */

.map-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 0;
  background: var(--bg);
}
.map-bar input { flex: 1 1 220px; font-size: 18px; }
.stat {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.stat b { font-size: 18px; color: var(--accent); }
.stat span { color: var(--muted); margin-left: 4px; }

.hint { min-height: 24px; font-size: 14px; font-weight: 600; color: var(--muted); }
.hint.good { color: var(--good); }
.hint.bad { color: var(--bad); }
.hint.warn { color: var(--warn); }

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  padding: 14px 18px;
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--bad-soft);
}
.summary.win { background: var(--good-soft); }
.summary strong { font-family: var(--display); font-size: 22px; }

.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 10px; }
.chip {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 12px 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 13px;
}
.chip b { font-variant-numeric: tabular-nums; }
.chip i { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--found); transition: width 0.3s ease; }
.chip.done { border-color: var(--found); }

.map-wrap {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--ocean);
  border: 1px solid var(--line);
}
#map { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; cursor: grab; touch-action: none; }
#map:active { cursor: grabbing; }
.map-status { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); }

.land {
  fill: var(--land);
  stroke: var(--land-stroke);
  stroke-width: 0.5px;
  vector-effect: non-scaling-stroke;
  transition: fill 0.25s ease;
}
.land.found { fill: var(--found); }
.land.missed { fill: var(--missed); }
.land.endpoint { fill: var(--endpoint); }
.land.route { fill: var(--route); }
.land.dot { stroke-width: 0.8px; }
.land.pulse { animation: pulse 0.9s ease-out; }
@keyframes pulse {
  0% { fill: #ffd166; }
  100% { fill: var(--found); }
}

.tooltip {
  position: absolute;
  transform: translate(-50%, calc(-100% - 12px));
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  white-space: nowrap;
  pointer-events: none;
}
.tooltip img { height: 12px; border-radius: 2px; }

.zoom-controls { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.zoom-controls button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.map-note { margin: 8px 0 20px; font-size: 13px; color: var(--muted); }

.lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; }
.lists h3 { font-size: 16px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.lists ul, .missed { list-style: none; margin: 8px 0 0; padding: 0; }
.lists li { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 14px; }
.lists li img { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); }
.lists li.miss { color: var(--bad); }

/* ---------- quiz ---------- */

.panel {
  max-width: 720px;
  margin: 24px auto 0;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.panel h1 { font-size: 40px; }
.lede { color: var(--muted); margin: 8px 0 0; font-size: 17px; }
.setup label {
  display: block;
  margin: 24px 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.setup-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 16px; margin-top: 28px; }

.quiz-top { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.quit { color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap; }
.quit:hover { color: var(--ink); }
.progress { flex: 1; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width 0.3s ease; }
.counter { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.streak { color: var(--warn); font-weight: 700; white-space: nowrap; }
.streak:empty { display: none; }

.prompt { text-align: center; padding: 36px 0 28px; min-height: 190px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.q-label { margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.prompt h2 { font-size: clamp(30px, 6vw, 46px); letter-spacing: -0.01em; }
.q-flag { height: 170px; max-width: 100%; margin-top: 8px; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.25)); }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  text-align: left;
  color: var(--ink);
  background: var(--bg);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option kbd {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  font: 600 12px/1 inherit;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.option.right { background: var(--good-soft); border-color: var(--good); }
.option.wrong { background: var(--bad-soft); border-color: var(--bad); }
.options.pictures .option { justify-content: center; position: relative; padding: 18px; }
.options.pictures kbd { position: absolute; top: 8px; left: 8px; }
.options.pictures img { height: 90px; max-width: 100%; filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.25)); }

.type-form { display: flex; gap: 10px; flex-wrap: wrap; }
.type-form input { flex: 1 1 220px; font-size: 18px; }

.feedback { min-height: 64px; margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; font-weight: 600; }
.feedback.good { color: var(--good); justify-content: center; }
.feedback.bad { color: var(--bad); padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--bad-soft); }
.feedback.bad b { color: var(--ink); }

.results { text-align: center; }
.results h1 { font-size: 64px; }
.results .setup-foot { justify-content: center; }
.results h3 { margin-top: 32px; text-align: left; font-size: 18px; }
.missed li { display: grid; grid-template-columns: 36px 1fr 1fr; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); text-align: left; }
.missed img { width: 36px; height: 24px; object-fit: contain; }
.missed span { color: var(--muted); }
.perfect { margin-top: 28px; color: var(--good); font-weight: 700; }

/* ---------- outlines ---------- */

.q-shape { width: min(100%, 420px); height: auto; margin-top: 4px; }
.q-shape path { fill: var(--accent); stroke: var(--ink); stroke-width: 1px; stroke-linejoin: round; fill-opacity: 0.85; }
.loading { text-align: center; color: var(--muted); padding: 64px 0; }

/* ---------- connect ---------- */

.connect-head { padding: 20px 0 14px; max-width: 760px; }
.connect-head h1 { font-size: clamp(28px, 5vw, 44px); }
.connect-head .end { color: var(--endpoint); }
.arrow { color: var(--muted); }
.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.chain .arrow { font-size: 14px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 14px;
}
.pill img { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; }
.pill.end { border-color: var(--endpoint); }
.pill.step { border-color: var(--found); }
.pill.route { border-color: var(--route); }
.pill.gap { border-style: dashed; color: var(--muted); padding-inline: 16px; }
.summary span { flex-basis: 100%; }

/* ---------- atlas ---------- */

.atlas-head { display: grid; gap: 14px; padding: 24px 0 20px; }
.atlas-head h1 { font-size: 40px; }
.atlas-head input { max-width: 420px; }
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.atlas-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.atlas-card img { width: 60px; height: 40px; object-fit: contain; flex: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2)); }
.atlas-card div { display: grid; min-width: 0; }
.atlas-card span { color: var(--muted); font-size: 14px; }
.atlas-card small { color: var(--muted); font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase; opacity: 0.8; }

@media (max-width: 560px) {
  .panel { padding: 20px; border-radius: 16px; }
  .options { grid-template-columns: 1fr; }
  .options.pictures { grid-template-columns: 1fr 1fr; }
  .q-flag { height: 130px; }
  .missed li { grid-template-columns: 36px 1fr; }
  .missed span { grid-column: 2; }
}

/* ---------- ranked ---------- */

.hero-ranked { font-size: 16px !important; }
.hero-ranked a { color: var(--accent); font-weight: 600; }

.site-header nav a.account-link { border: 1px solid var(--line); }
.site-header nav a.account-link.signed-in { color: var(--accent); border-color: var(--accent); }

.seg a {
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}
.seg a:hover { border-color: var(--muted); }
.seg a.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
a.btn { display: inline-block; text-decoration: none; }

.badge {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--endpoint);
  color: #2b1d05;
  white-space: nowrap;
}
.clock { font-weight: 700; font-variant-numeric: tabular-nums; }
.ranked-strip { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; font-weight: 600; }

.panel-wide { max-width: 720px; margin: 16px auto 0; }
#ranked-slot:not(:empty) { margin-top: 24px; }
.ranked-card {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
  padding: 24px;
  border-radius: 20px;
  border: 1.5px solid var(--endpoint);
  background: var(--surface);
}
.ranked-card .tag { background: var(--endpoint); color: #2b1d05; }
.ranked-card h3 { font-size: 24px; margin-top: 8px; }
.ranked-card p { color: var(--muted); margin: 8px 0 0; }
.ranked-card .setup-foot { margin-top: 18px; }

.board { list-style: none; margin: 0; padding: 0; }
.board li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto auto;
  align-items: baseline;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.board li.me { background: var(--accent-soft); border-radius: 8px; }
.board .rk { color: var(--muted); font-weight: 700; }
.board .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board small { color: var(--muted); }
.board .tm { font-weight: 700; }
.board li:nth-child(1) .rk { color: #d4a017; }
.board-empty { margin: 8px 0; }
.board-panel { max-width: 720px; }
.board-panel h2 { font-size: 28px; }
.board-panel h2 .muted { font-family: inherit; font-size: 15px; font-weight: 500; }
.board-panel #board { margin-top: 18px; }

.ranked-result { text-align: center; width: 100%; }
.ranked-result h2 { font-size: 48px; margin: 4px 0; }
.ranked-result .board { text-align: left; margin-top: 16px; }
.ranked-result .setup-foot { justify-content: center; }
.summary #ranked-result, .summary .ranked-result { flex-basis: 100%; }

.auth { max-width: 460px; }
.auth h1 { margin-top: 20px; font-size: 34px; }
.auth-form { display: grid; gap: 14px; margin-top: 22px; }
.auth-form label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); }
.auth-form input {
  font: inherit;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--ink);
}
.auth-form .hint:empty { display: none; }

@media (max-width: 700px) {
  .ranked-card { grid-template-columns: 1fr; }
}

.clock.low { color: var(--bad); }
.btn.small { padding: 5px 10px; font-size: 13px; }
