:root {
  --bg: #0b0f14;
  --panel: #131a22;
  --panel-2: #18212b;
  --line: #24303d;
  --text: #e8eef5;
  --muted: #8d9bab;
  --accent: #22c55e;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* Class rules such as .modal set display, which would otherwise beat the
   user-agent rule for [hidden] and leave invisible overlays swallowing clicks. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(11, 15, 20, 0.92);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 9px; color: var(--accent); }
.logo { width: 24px; height: 24px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); }

.icon-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted); }

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 22px 16px 40px;
}

.hero { text-align: center; margin-bottom: 20px; }
.puzzle-no {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.hero h1 { margin: 0 0 8px; font-size: 25px; line-height: 1.2; letter-spacing: -0.02em; }
.sub { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.5; }

.board { margin-bottom: 18px; }
.guesses { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name arrow" "meta meta" "bar bar";
  gap: 6px 10px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.row.correct { border-color: var(--accent); background: rgba(34, 197, 94, 0.08); }
.row-name { grid-area: name; font-weight: 600; font-size: 16px; }
.row-arrow {
  grid-area: arrow;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  align-self: center;
  min-width: 58px;
}
.row-arrow-glyph {
  font-size: 30px;
  line-height: 1;
  color: var(--text);
}
.row-arrow.correct .row-arrow-glyph { color: var(--accent); }
.row-compass {
  font-size: 10.5px;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

.row-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.badge {
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.02em;
}
.badge.ok { color: var(--accent); border-color: rgba(34, 197, 94, 0.45); }

.bar {
  grid-area: bar;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.bar > i { display: block; height: 100%; border-radius: 999px; }

.entry { display: flex; gap: 8px; }
.combo { position: relative; flex: 1; }

#guessInput {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}
#guessInput:focus { border-color: var(--accent); }
#guessInput:disabled { opacity: 0.5; }

button.primary {
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 600;
  color: #04140a;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  cursor: pointer;
}
button.primary:disabled { opacity: 0.45; cursor: default; }

button:focus-visible {
  outline: 2px solid rgba(232, 238, 245, 0.75);
  outline-offset: 2px;
}

button:not(.primary):not(.icon-btn) {
  padding: 13px 18px;
  font-size: 15px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 5px;
  list-style: none;
  max-height: 232px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  z-index: 30;
}
.suggestions li {
  padding: 10px 11px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}
.suggestions li.active, .suggestions li:hover { background: var(--panel); }

.hint { min-height: 20px; margin: 10px 2px 0; font-size: 13px; color: var(--muted); }
.hint.error { color: #f87171; }

.next-line {
  margin: 16px 0 0;
  padding: 11px 14px;
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.next-line.ready { color: var(--accent); cursor: pointer; border-color: rgba(34, 197, 94, 0.45); }

.next-note {
  margin: -6px 0 16px !important;
  font-size: 13px !important;
  text-align: center;
}

.ad-slot {
  margin-top: 28px;
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: #465464;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 7, 10, 0.72);
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 400px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.modal-card h2 { margin: 0 0 8px; font-size: 20px; }
.modal-card p { margin: 0 0 14px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.subhead {
  margin: 18px 0 8px !important;
  font-size: 12px !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rules { margin: 0; padding-left: 18px; color: var(--muted); font-size: 14px; line-height: 1.65; }

.share-grid {
  margin: 0 0 16px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-actions { display: flex; gap: 8px; }
.modal-actions button { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div {
  padding: 10px 6px;
  text-align: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.stats b { display: block; font-size: 19px; }
.stats span { font-size: 11px; color: var(--muted); }

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

/*--------------------------------------------------------------------------
  Onboarding
--------------------------------------------------------------------------*/

.ob-card { position: relative; padding-top: 24px; }

.link-btn {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 6px 8px;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.link-btn:hover { color: var(--text); }

.ob-kicker {
  margin: 0 0 6px !important;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.ob-card h2 {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.ob-copy { margin: 0 0 18px !important; }

.ob-art {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.ob-art .row { animation: none; }

.ob-art--map { align-items: center; padding: 4px 0 10px; }

.globe {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: var(--accent);
  border: 3px solid rgba(34, 197, 94, 0.55);
  background: radial-gradient(circle at 32% 28%, rgba(34, 197, 94, 0.2), transparent 62%);
}

.ob-art .row-arrow-glyph { font-size: 26px; }

.ob-caption {
  margin: 2px 0 0 !important;
  font-size: 12.5px;
  text-align: center;
}

.ob-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin: 0 0 14px;
}
.ob-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
}
.ob-dots span.on { background: var(--accent); }
