:root {
  --bg: #111214;
  --surface: #1a1b1e;
  --surface-2: #24262a;
  --border: #2e3136;
  --text: #ececec;
  --muted: #9a9ea6;
  --accent: #e8d5b5;
  --good: #2f9e6a;
  --bad: #d1495b;
  --golden: #f3c14b;
  --radius: 14px;
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1 { margin: 0 0 12px; font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
h2 { margin: 0 0 8px; font-size: 21px; }
h3 { margin: 20px 0 10px; font-size: 16px; }
.muted { color: var(--muted); }
.error { color: #ff8b8b; margin: 10px 0 0; }
.notice { margin: 16px 0 0; padding: 14px; border-radius: 10px; background: var(--surface-2); }

.page-center { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; width: min(440px, 100%); }
.card-wide { width: min(760px, 100%); }

label { display: block; margin: 20px 0 8px; font-weight: 500; }
input:not([type]), input[type="text"], input[type="password"], textarea {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn { border: 1px solid transparent; border-radius: 10px; padding: 11px 18px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; background: var(--surface-2); color: var(--text); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); color: #1a1a1a; }
.btn-block { width: 100%; margin-top: 16px; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-good { background: var(--good); color: #fff; }
.btn-bad { background: var(--bad); color: #fff; }

.check { display: flex; gap: 10px; align-items: center; margin-top: 20px; cursor: pointer; }
.check input { width: 18px; height: 18px; }
.rules { line-height: 1.55; }
.rules h3 { margin: 22px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent); }
.rules h3:first-child { margin-top: 0; }
.rules ol { margin: 0; padding-left: 28px; }
.rules li { margin: 5px 0; }
.rules-scroll { max-height: 58vh; overflow: auto; padding-right: 8px; margin-top: 12px; }

/* quiz */
#screen-quiz { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.quiz-bar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.progress-text { font-variant-numeric: tabular-nums; min-width: 84px; }
.progress { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
#progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.quiz-main { flex: 1; width: min(1100px, 100%); margin: 0 auto; padding: 20px 20px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }

.stage { position: relative; flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; }
/* the photo's own max-height keeps the buttons below it on screen */
#photo { display: block; max-width: 100%; max-height: max(200px, min(72vh, calc(100dvh - 250px))); object-fit: contain; cursor: zoom-in; transition: opacity .15s; }
#photo.loading { opacity: .2; }
.stage-error { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); margin: 0; background: var(--surface); padding: 8px 14px; border-radius: 8px; }
.photo-meta { font-size: 13px; font-variant-numeric: tabular-nums; }
.answer-buttons { display: flex; justify-content: center; gap: 12px; }
.answer-buttons .btn { min-width: 180px; padding: 15px 26px; font-size: 17px; }
.btn-link { border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; padding: 4px 8px; cursor: pointer; }
.btn-link:hover:not(:disabled) { color: var(--text); }
.btn-link:disabled { opacity: .4; cursor: default; }
@media (max-width: 640px) {
  .quiz-bar { padding: 10px 12px; gap: 10px; }
  .quiz-main { padding: 12px 12px 16px; gap: 10px; }
  .answer-buttons { width: 100%; }
  .answer-buttons .btn { flex: 1; min-width: 0; }
}

/* zoom modal (see js/zoom.js): no window chrome, the photo floats over a light dim */
.zoom { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .6); }
.zoom-window { position: absolute; inset: 0; }
/* the quiz screen would show through the light dim (a second set of buttons, the photo's edge) */
.zoom-open #screen-quiz { visibility: hidden; }
/* padding = room kept free around the fitted photo for the close button and the answer buttons */
.zoom-viewer { position: absolute; inset: 0; padding: 60px 24px 100px; overflow: hidden; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.zoom-viewer.dragging { cursor: grabbing; }
.zoom-viewer img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; -webkit-user-drag: none; pointer-events: none; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.zoom-hint { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); padding: 5px 11px; border-radius: 8px; background: rgba(0, 0, 0, .65); color: #d4d6db; font-size: 13px; white-space: nowrap; pointer-events: none; }
.zoom-viewer.loading-full::after { content: "Загружаю оригинал…"; position: absolute; left: 16px; bottom: 16px; padding: 5px 11px; border-radius: 8px; background: rgba(0, 0, 0, .65); color: #d4d6db; font-size: 13px; pointer-events: none; }
.zoom .zoom-close { position: absolute; z-index: 1; top: 10px; right: 14px; width: 40px; height: 40px; border-radius: 10px; background: rgba(0, 0, 0, .55); color: #ddd; }
.zoom-answer { position: absolute; z-index: 1; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; gap: 12px; }
.zoom-answer .btn { min-width: 160px; box-shadow: 0 6px 20px rgba(0, 0, 0, .45); }
@media (max-width: 640px) {
  .zoom-viewer { padding: 56px 8px 92px; }
  .zoom-hint { display: none; }
  .zoom-answer { left: 12px; right: 12px; transform: none; }
  .zoom-answer .btn { flex: 1; min-width: 0; }
}

/* modal */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, .72); }
.modal-card { position: relative; width: min(760px, 100%); max-height: 90vh; overflow: auto; padding: 28px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-card.wide { width: min(1120px, 100%); }
.modal-close { position: absolute; top: 8px; right: 12px; border: 0; background: none; color: var(--muted); font-size: 30px; line-height: 1; cursor: pointer; }

/* admin */
.admin { max-width: 1280px; margin: 0 auto; padding: 24px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.stat-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat-label { margin-top: 4px; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button { padding: 10px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font: inherit; font-size: 15px; cursor: pointer; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: 0; }
th { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; }
td.empty { padding: 28px; text-align: center; }
.acc { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.acc-bar { width: 80px; height: 6px; overflow: hidden; background: var(--surface-2); border-radius: 3px; }
.acc-bar div { height: 100%; background: var(--accent); }
.flag { color: #f3b04b; font-size: 12px; }
.status { padding: 2px 8px; border-radius: 999px; background: var(--surface-2); font-size: 12px; }
.status-finished { background: rgba(47, 158, 106, .2); color: #7ad6a6; }
.status-in_progress { background: rgba(232, 213, 181, .14); color: var(--accent); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.thumb { display: block; overflow: hidden; color: var(--text); text-decoration: none; background: var(--surface); border: 2px solid var(--border); border-radius: 10px; }
.thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #000; }
.thumb-cap { display: block; padding: 8px 10px; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.thumb-wrong { border-color: var(--bad); }
.thumb { position: relative; }
.thumb-link { display: block; color: inherit; text-decoration: none; }
.thumb-golden { border-color: var(--golden); }
.thumb-golden.thumb-wrong { border-color: var(--bad); box-shadow: 0 0 0 2px var(--golden); }
.golden-text { color: var(--golden); }
.flag-golden { color: var(--golden); }
.golden-btn {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 20px; line-height: 1; cursor: pointer;
}
.golden-btn:hover:not(:disabled) { background: rgba(0, 0, 0, .8); }
.golden-btn[aria-pressed="true"] { color: var(--golden); }
.golden-btn:disabled { opacity: .5; cursor: wait; }
.photos-toolbar { margin-bottom: 12px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { padding: 8px 14px; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.seg button.active { background: var(--surface-2); color: var(--text); }
.label-good { color: #7ad6a6; }
.label-bad { color: #ff8b8b; }
.panel { margin-bottom: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel h2 { margin-bottom: 12px; }
.rules-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
.rules-editor textarea { min-height: 460px; font-family: ui-monospace, Consolas, monospace; font-size: 14px; resize: vertical; }
.rules-editor .rules { max-height: 460px; overflow: auto; padding: 4px 8px; }
@media (max-width: 860px) { .rules-editor { grid-template-columns: 1fr; } }
