:root {
  --bg: #061447;
  --bg-2: #0a1f6b;
  --panel: #0e2a8a;
  --panel-2: #12339e;
  --line: rgba(255, 255, 255, .14);
  --text: #eef2ff;
  --muted: #a9b6e8;
  --gold: #ffc934;
  --gold-2: #ffdf7a;
  --ok: #3ddc84;
  --bad: #ff5d6c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #1640c4 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(6, 20, 71, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top__inner {
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo__mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; flex: none; text-decoration: none;
  background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: var(--bg); font-weight: 900;
}
.topic { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); }
.topic button { background: none; border: 0; padding: 6px 10px; border-radius: 8px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.topic button:hover { color: var(--text); }
.topic button.is-active { background: var(--gold); color: var(--bg); }
.tabs { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.tab {
  background: none; border: 0; padding: 8px 12px; border-radius: 10px; color: var(--muted); white-space: nowrap;
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, .06); }
.tab.is-active { color: var(--bg); background: var(--gold); font-weight: 700; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }
.h1 { margin: 6px 0 18px; font-size: 28px; }
.hint { color: var(--muted); margin: 8px 0 0; font-size: 14px; }

.block {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px;
}
.block__title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-2); margin-bottom: 10px; font-weight: 700; }

.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.mode {
  display: flex; flex-direction: column; gap: 4px; align-items: flex-start; text-align: left;
  padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: rgba(255, 255, 255, .03);
}
.mode small { color: var(--muted); }
.mode__ico { font-size: 20px; color: var(--gold); line-height: 1; }
.mode:hover { border-color: rgba(255, 201, 52, .5); }
.mode.is-active { border-color: var(--gold); background: rgba(255, 201, 52, .1); }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
}
.seg button.is-active { background: var(--gold); color: var(--bg); border-color: var(--gold); font-weight: 700; }
.seg button:disabled { opacity: .35; cursor: not-allowed; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips--extra { margin-top: 12px; flex-direction: column; gap: 8px; }
.chip {
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04);
}
.chip.is-active { background: rgba(255, 201, 52, .16); border-color: var(--gold); color: var(--gold-2); }
.chip small { color: var(--muted); margin-left: 4px; }
.check { display: inline-flex; gap: 8px; align-items: center; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }

.start { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.pool { color: var(--muted); }

.btn {
  padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); font-weight: 600;
}
.btn:hover { filter: brightness(1.15); }
label.btn { display: inline-block; cursor: pointer; }

.sync { margin-top: 18px; }
.sync__form, .sync__on { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sync__form .search { flex: 1 1 200px; min-width: 0; }
code { font: 13px ui-monospace, Consolas, monospace; background: rgba(255, 255, 255, .08); padding: 1px 5px; border-radius: 5px; }
.is-error { color: var(--bad); }
.btn--big {
  padding: 14px 26px; font-size: 18px; border: 0; color: var(--bg); font-weight: 800;
  background: linear-gradient(180deg, var(--gold-2), var(--gold)); box-shadow: var(--shadow);
}
.btn--ghost { background: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px; font: 12px/1.4 ui-monospace, Consolas, monospace;
  background: rgba(0, 0, 0, .18); border: 1px solid rgba(0, 0, 0, .2); vertical-align: middle;
}

/* Вопрос */
.qbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.qbar__progress { flex: 1; height: 8px; background: rgba(255, 255, 255, .1); border-radius: 99px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--gold); transition: width .25s; }
.qbar__score { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
  min-height: 220px; padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center;
}
.card__label { color: var(--gold-2); font-size: 13px; text-transform: uppercase; letter-spacing: .1em; }
.card__big { font-size: clamp(28px, 6vw, 46px); font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.card__sub { color: var(--muted); }
.qflag {
  max-width: min(100%, 420px); max-height: 260px; width: auto; height: auto;
  border-radius: 6px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25), 0 8px 24px rgba(0, 0, 0, .4);
  background: #fff; cursor: zoom-in;
}
.qshot {
  width: min(100%, 640px); max-height: min(48vh, 420px); object-fit: contain; border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .25), 0 8px 24px rgba(0, 0, 0, .4); background: #000; cursor: zoom-in;
}

#answers { margin-top: 16px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  position: relative; padding: 16px 16px 16px 44px; min-height: 64px; text-align: left; font-size: 18px; font-weight: 600;
  border-radius: 12px; border: 2px solid var(--line); background: var(--bg-2);
}
.opt kbd { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); background: rgba(255, 255, 255, .06); border-color: var(--line); }
.opt:hover:not(:disabled) { border-color: var(--gold); }
.opt:disabled { cursor: default; }
.opt.is-right { border-color: var(--ok); background: rgba(61, 220, 132, .16); }
.opt.is-wrong { border-color: var(--bad); background: rgba(255, 93, 108, .16); }
.opt.is-dim { opacity: .5; }
.opts--flags .opt { padding: 12px 12px 26px 44px; display: flex; align-items: center; justify-content: center; min-height: 150px; }
.opts--flags .opt img { max-width: 100%; max-height: 130px; border-radius: 4px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); background: #fff; }
.opts--pic .opt { min-height: 190px; }
.opts--pic .opt img { width: 100%; height: 170px; max-height: none; object-fit: contain; background: none; box-shadow: none; }
.dunno-row { display: flex; justify-content: center; margin-top: 10px; }
.opt__cap { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-top: 6px; }
.opts--flags .opt__cap { position: absolute; bottom: 6px; left: 0; right: 0; text-align: center; }

.inp-row { display: flex; gap: 10px; }
.inp {
  flex: 1; min-width: 0; padding: 14px 16px; font-size: 20px; border-radius: 12px;
  border: 2px solid var(--line); background: var(--bg-2); outline: none;
}
.inp:focus { border-color: var(--gold); }
.inp-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.inp-wrap .inp { width: 100%; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--gold); border-radius: 12px; box-shadow: var(--shadow);
}
.suggest button {
  display: block; width: 100%; padding: 10px 16px; text-align: left; font-size: 18px;
  background: none; border: 0; border-bottom: 1px solid var(--line);
}
.suggest button:last-child { border-bottom: 0; }
.suggest button.is-active, .suggest button:hover { background: rgba(255, 201, 52, .16); }
.suggest small { color: var(--muted); margin-left: 8px; font-size: 14px; }
.cards-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn--ok { background: rgba(61, 220, 132, .2); border-color: var(--ok); }
.btn--bad { background: rgba(255, 93, 108, .2); border-color: var(--bad); }

.feedback {
  margin-top: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .18);
}
.feedback.is-ok { border-color: var(--ok); }
.feedback.is-bad { border-color: var(--bad); }
.feedback__title { font-weight: 800; font-size: 18px; margin-bottom: 4px; }
.feedback__row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.feedback__row img { height: 44px; border-radius: 3px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); background: #fff; }
.feedback__row img.fb-shot { height: 72px; background: #000; cursor: zoom-in; }
.note { color: var(--gold-2); font-size: 14px; margin-top: 6px; }
.note::before { content: "ⓘ "; }
.more { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; flex-wrap: wrap; column-gap: 14px; row-gap: 2px; }
.more a { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 2px; }
.more a:hover { color: var(--gold-2); }
.next-row { margin-top: 16px; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Итог */
.result {
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.result__big { font-size: 56px; font-weight: 900; color: var(--gold); line-height: 1; }
.result__txt { color: var(--muted); }

.list-title { margin: 24px 0 10px; font-size: 18px; }

/* Справочник */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search, .toolbar select {
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2);
}
.search { flex: 1; min-width: 200px; }
.toolbar select option { background: var(--bg-2); }
.ref { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 12px;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line);
}
.item img { width: 72px; height: 48px; object-fit: contain; flex: none; cursor: zoom-in; }
.item__name { font-weight: 700; }
.item__cap { color: var(--gold-2); }
.item__meta { color: var(--muted); font-size: 12px; }
.item .note { font-size: 12px; margin-top: 4px; }
.ref.hide-caps .hideable { filter: blur(6px); cursor: pointer; }
.ref.hide-caps .hideable.is-shown { filter: none; }
.item--pic { flex-direction: column; }
.item--pic img { width: 100%; height: auto; aspect-ratio: 4 / 3; border-radius: 6px; background: #000; }
.tag { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, .1); color: var(--muted); margin-left: 4px; vertical-align: 1px; }
.empty { color: var(--muted); padding: 20px 0; }

/* Похожие флаги */
.sim { margin-bottom: 14px; }
.sim__row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.sim__f { width: 150px; text-align: center; font-size: 14px; }
.sim__f img { width: 150px; height: 100px; object-fit: contain; cursor: zoom-in; }
.sim__f span { display: block; margin-top: 4px; }

/* Статистика */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { padding: 14px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.stat b { display: block; font-size: 26px; color: var(--gold); }
.stat small { color: var(--muted); }
.bar { height: 6px; background: rgba(255, 255, 255, .1); border-radius: 9px; overflow: hidden; margin-top: 8px; }
.bar i { display: block; height: 100%; background: var(--ok); }

.zoom {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .85);
  display: grid; place-items: center; padding: 16px; cursor: zoom-out;
}
.zoom img { max-width: 100%; max-height: 90vh; background: #fff; box-shadow: var(--shadow); }

@media (max-width: 640px) {
  .h1 { font-size: 22px; }
  .tabs { margin-left: 0; width: 100%; }
  .logo { min-width: 0; max-width: 100%; }
  .topic { min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .topic button { padding: 6px 8px; font-size: 14px; }
  .opts { grid-template-columns: 1fr; }
  .opts--flags { grid-template-columns: 1fr 1fr; }
  .opts--flags .opt { min-height: 110px; padding: 8px 8px 22px; }
  .opts--flags .opt kbd { display: none; }
  .opts--flags .opt img { max-height: 80px; }
  .opts--pic .opt { min-height: 120px; }
  .opts--pic .opt img { height: 100px; }
  .opt { font-size: 16px; min-height: 54px; }
  .card { min-height: 180px; padding: 18px; }
  .qflag { max-height: 200px; }
  .inp-row { flex-direction: column; }
  .sim__f, .sim__f img { width: 120px; }
  .sim__f img { height: 80px; }
  .result__big { font-size: 44px; }
}
