:root {
  --bg: #0e1016;
  --bg-elev: #171a23;
  --bg-elev2: #1e2230;
  --line: #2a2f3d;
  --text: #e8eaf0;
  --muted: #9aa1b2;
  --male: #5aa9e6;
  --female: #f08fb0;
  --accent: #ffd166;
  --good: #2ecc71;
  --mid: #f4b860;
  --bad: #e05a5a;
  --radius: 12px;
  --maxw: 560px;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.topbar {
  width: 100%;
  max-width: var(--maxw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 6px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand h1 {
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  margin: 0;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--male), var(--female));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-mark { color: var(--accent); font-size: 1.1rem; }
.top-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  min-width: 36px;
  height: 36px;
  padding: 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.icon-btn:hover { background: var(--bg-elev2); }

main {
  width: 100%;
  max-width: var(--maxw);
  padding: 0 16px 24px;
  flex: 1;
}

.tagline { text-align: center; color: var(--muted); margin: 2px 0 14px; font-size: 0.92rem; }
.tagline strong { color: var(--text); }

.stats {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  text-align: center;
}
.stat-label { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat.total .stat-value { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-split { display: flex; justify-content: center; gap: 28px; margin-top: 8px; }
.stat-split .stat { display: flex; flex-direction: column; align-items: center; }
.stat-split .stat-value { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.male-dot { background: var(--male); }
.female-dot { background: var(--female); }

.chart-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 8px 6px;
  margin-bottom: 14px;
  height: 420px;
  position: relative;
}
#pyramidChart { width: 100% !important; height: 100% !important; }

.guess-area { margin-bottom: 8px; }
.guess-input { display: flex; gap: 8px; position: relative; }
#guessInput {
  flex: 1;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
}
#guessInput:focus { border-color: var(--male); }
.guess-btn {
  background: linear-gradient(90deg, var(--male), var(--female));
  color: #0b0d12;
  border: none;
  border-radius: 10px;
  padding: 0 20px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}
.guess-btn:disabled { opacity: 0.4; cursor: default; }

.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--bg-elev2);
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 12px 30px rgba(0,0,0,0.5);
}
.suggestions li {
  padding: 9px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.95rem;
}
.suggestions li.active, .suggestions li:hover { background: var(--male); color: #0b0d12; }

.guess-list { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.guess-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  animation: pop 0.18s ease;
}
@keyframes pop { from { transform: scale(0.98); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.guess-row.correct { border-color: var(--good); background: rgba(46,204,113,0.12); }
.guess-row .g-name { font-weight: 700; }
.guess-row .g-dist { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.guess-row .g-arrow { font-size: 1.15rem; }
.guess-row .g-prox {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: right;
}

.end-panel {
  margin-top: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}
.end-msg { font-size: 1.05rem; font-weight: 700; margin: 0 0 12px; }
.end-msg .ans { color: var(--accent); }
.end-stats { display: flex; justify-content: center; gap: 26px; margin-bottom: 14px; }
.end-stats .big { display: block; font-size: 1.5rem; font-weight: 800; }
.end-stats .small { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.share-btn {
  background: var(--good);
  color: #06210f;
  border: none;
  border-radius: 10px;
  padding: 12px 26px;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
}
.countdown { color: var(--muted); font-size: 0.85rem; margin: 12px 0 0; font-variant-numeric: tabular-nums; }

.bonus-panel {
  margin-top: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.bonus-panel h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
.bonus-score {
  background: var(--accent);
  color: #0b0d12;
  border-radius: 999px;
  padding: 1px 10px;
  font-size: 0.85rem;
  font-weight: 800;
}
.bonus-sub { color: var(--muted); font-size: 0.85rem; margin: 0 0 14px; }
.bq { margin-bottom: 16px; }
.bq:last-child { margin-bottom: 0; }
.bq-prompt { font-weight: 600; margin: 0 0 8px; font-size: 0.96rem; }
.bq-choices { display: flex; flex-direction: column; gap: 7px; }
.bq-choice {
  text-align: left;
  background: var(--bg-elev2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.bq-choice:not([disabled]):hover { border-color: var(--male); background: #232838; }
.bq-choice[disabled] { cursor: default; }
.bq-choice.correct { background: rgba(46,204,113,0.18); border-color: var(--good); color: #d7f7e4; }
.bq-choice.wrong { background: rgba(224,90,90,0.16); border-color: var(--bad); color: #f7d7d7; }
.bq-choice.dim { opacity: 0.5; }
.bq-factoid {
  margin: 8px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.45;
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

.site-footer {
  width: 100%;
  max-width: var(--maxw);
  padding: 14px 16px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.72rem;
}
.site-footer a { color: var(--muted); }

.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  max-width: 440px;
  padding: 22px;
  position: relative;
}
.modal-card h2 { margin: 0 0 12px; font-size: 1.2rem; }
.modal-card p { line-height: 1.5; margin: 0 0 12px; font-size: 0.95rem; }
.modal-close {
  position: absolute; top: 10px; right: 12px;
  background: none; border: none; color: var(--muted);
  font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.legend { list-style: none; padding: 0; margin: 0 0 12px; }
.legend li { margin-bottom: 8px; font-size: 0.92rem; }
.sq { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
.sq.g100 { background: var(--good); }
.muted { color: var(--muted); font-size: 0.85rem; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px;
  font-weight: 700; font-size: 0.9rem;
  z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

@media (max-width: 420px) {
  .stat.total .stat-value { font-size: 1.6rem; }
  .stat-split { gap: 18px; }
  .guess-row { padding: 10px 11px; gap: 7px; }
}
