:root {
  --bg: #0a0a0f;
  --bg-elev: #11121a;
  --bg-elev-2: #1a1c26;
  --border: #23263a;
  --text: #d5d9e5;
  --text-dim: #6f7592;
  --accent: #00ff88;
  --accent-dim: #00ff8855;
  --danger: #ff3860;
  --warn: #ffb454;
  --radius: 5px;
  --font: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(circle at 20% 10%, #0e1a14 0%, transparent 40%),
    radial-gradient(circle at 80% 90%, #0e0e1a 0%, transparent 40%);
}

.hidden { display: none !important; }

/* ─── Капча ─────────────────────────────────────── */
.captcha {
  position: fixed; inset: 0;
  background: rgba(5, 6, 10, 0.95);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.captcha-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  box-shadow: 0 0 24px var(--accent-dim);
  border-radius: var(--radius);
  padding: 32px;
  min-width: 480px;
  text-align: center;
}
.captcha-card h1 {
  margin: 0 0 8px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
  text-transform: uppercase;
}
.captcha-hint { color: var(--text-dim); margin: 0 0 24px; }
.captcha-cats {
  display: flex; gap: 16px; justify-content: center; margin-bottom: 20px;
  min-height: 280px;
}
.captcha-cat {
  display: flex; flex-direction: column; gap: 10px;
  width: 220px;
}
.captcha-photo {
  width: 220px; height: 220px;
  background-size: cover; background-position: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 0 12px rgba(0,0,0,.5);
}
.captcha-cat input { width: 100%; text-align: center; }
.captcha-cat.wrong input {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(255, 56, 96, 0.3);
}
.captcha-cat.wrong .captcha-photo {
  box-shadow: 0 0 12px rgba(255, 56, 96, 0.4);
  border-color: var(--danger);
}
.captcha-error { color: var(--danger); padding: 16px; }
#captcha-submit { min-width: 160px; }

/* ─── Шапка ─────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 14px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.logo {
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-shadow: 0 0 6px var(--accent-dim);
}
.tabs { display: flex; gap: 4px; }
.tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(0, 255, 136, 0.06);
  box-shadow: 0 0 8px var(--accent-dim);
}

/* ─── Основная зона ─────────────────────────────── */
main { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header h2 {
  margin: 0;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--text);
}

.placeholder {
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  padding: 32px;
}

/* ─── Формы ─────────────────────────────────────── */
.row { display: flex; gap: 8px; margin-bottom: 16px; }

input[type=text], input[type=search], input[type=number], textarea, select {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  flex: 1;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-dim);
}
input:disabled, button:disabled { opacity: 0.5; cursor: not-allowed; }

button {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  cursor: pointer;
  transition: background .15s, box-shadow .15s;
}
button:hover:not(:disabled) {
  background: rgba(0, 255, 136, 0.1);
  box-shadow: 0 0 8px var(--accent-dim);
}

/* ─── Таблицы ───────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
}
.data-table tr:last-child td { border-bottom: none; }

/* ─── Стена обложек ─────────────────────────────── */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.games-grid .placeholder { grid-column: 1 / -1; }

/* ─── Граф предложки ────────────────────────────── */
.proposals-graph {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: 440px;
  overflow: hidden;
  background-image: radial-gradient(circle, #1b1e2b 1px, transparent 1px);
  background-size: 22px 22px;
}

/* ─── Игроки ────────────────────────────────────── */
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tbody tr:hover { background: rgba(0, 255, 136, 0.03); }
.avatar-cell { width: 52px; }
.avatar {
  width: 36px; height: 36px; display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.player-name { color: var(--text); text-decoration: none; font-weight: 500; }
.player-name:hover { color: var(--accent); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.actions { text-align: right; white-space: nowrap; }
.icon-btn {
  border: none; padding: 2px 6px; margin-left: 6px;
  color: var(--text-dim); font-size: 12px;
  opacity: 0; transition: opacity .15s, color .15s;
}
tr:hover .icon-btn, .icon-btn:focus-visible { opacity: 1; }
.icon-btn.danger:hover:not(:disabled) { color: var(--danger); background: rgba(255, 56, 96, 0.1); box-shadow: none; }
.small-btn { padding: 4px 10px; font-size: 12px; }
.form-msg { margin: -8px 0 16px; font-size: 13px; }
.form-msg.error { color: var(--danger); }
.form-msg.info { color: var(--text-dim); }
.scan-note { color: var(--warn); font-size: 12px; margin-top: 10px; }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
  .tabs { overflow-x: auto; max-width: 100%; }
  main { padding: 16px; }
  .players-table { display: block; overflow-x: auto; }
  .captcha-card { min-width: 0; width: calc(100% - 32px); padding: 20px; }
  .captcha-cats { flex-direction: column; align-items: center; }
  .icon-btn { opacity: 1; }
}

/* ─── Шапка: «кто ты» и выход ───────────────────── */
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.me-chip {
  display: flex; align-items: center; gap: 8px;
  border-color: var(--border); color: var(--text);
  padding: 4px 10px 4px 4px;
}
.me-chip img { width: 24px; height: 24px; border-radius: 3px; }
.me-chip.unknown { border-color: var(--warn); color: var(--warn); padding-left: 10px; }
.icon-btn.always { opacity: 1; font-size: 15px; }

.dialog {
  background: var(--bg-elev); color: var(--text);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius);
  box-shadow: 0 0 24px var(--accent-dim);
  padding: 24px; min-width: min(360px, calc(100vw - 32px));
}
.dialog::backdrop { background: rgba(5, 6, 10, 0.8); }
.dialog h3 { margin: 0 0 4px; color: var(--accent); letter-spacing: 1px; }
.me-list { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; }
.me-option {
  display: flex; align-items: center; gap: 10px; text-align: left;
  border-color: var(--border); color: var(--text);
}
.me-option img { width: 28px; height: 28px; border-radius: 3px; }
.me-option.active { border-color: var(--accent); color: var(--accent); }

tr.is-me td { background: rgba(0, 255, 136, 0.04); }
.me-tag {
  font-size: 10px; text-transform: uppercase; letter-spacing: 1px;
  color: var(--accent); border: 1px solid var(--accent-dim);
  border-radius: 3px; padding: 1px 5px; margin-left: 6px;
  white-space: nowrap;
}
.player-name a, .form-msg a, td a { color: var(--accent); }

/* ─── Игры: фильтры ─────────────────────────────── */
.player-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.player-chip {
  display: flex; align-items: center; gap: 6px;
  border-color: var(--border); color: var(--text-dim);
  padding: 3px 10px 3px 3px; font-size: 13px;
}
.player-chip img { width: 22px; height: 22px; border-radius: 3px; filter: grayscale(1); opacity: .6; }
.player-chip.on { border-color: var(--accent); color: var(--text); background: rgba(0, 255, 136, 0.06); }
.player-chip.on img { filter: none; opacity: 1; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters select { flex: 0 0 auto; cursor: pointer; }
.filters input[type=search] { min-width: 160px; }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--accent); }
.panel-header { gap: 16px; flex-wrap: wrap; }

/* ─── Игры: стена обложек ───────────────────────── */
.game-card {
  display: flex; flex-direction: column;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .15s, box-shadow .15s, opacity .3s, transform .3s;
}
.game-card:hover, .game-card:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-dim);
}
.game-card.leaving { opacity: 0; transform: scale(.96); }
.game-cover {
  position: relative; display: block;
  aspect-ratio: 2 / 3;
  color: var(--text); text-decoration: none;
  outline: none;
}
.game-cover > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.game-card img.wide { object-position: center; }
.game-fallback-title {
  display: none; position: absolute; inset: 0;
  padding: 12px; align-items: center; justify-content: center; text-align: center;
  color: var(--text-dim); font-size: 13px;
}
.game-card.no-cover .game-cover > img { display: none; }
.game-card.no-cover .game-fallback-title { display: flex; }

.game-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(10,10,15,.94) 0%, rgba(10,10,15,.78) 45%, rgba(10,10,15,.96) 100%);
  opacity: 0; transition: opacity .15s;
}
.game-cover:hover .game-overlay, .game-cover:focus-visible .game-overlay { opacity: 1; }

/* ─── Игры: голоса НЕ/МБ/ДА ─────────────────────── */
.vote-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 5px; border-top: 1px solid var(--border);
}
.vote-btns { display: flex; gap: 3px; }
.vote-btn {
  padding: 3px 6px; font-size: 11px; font-weight: 700;
  border-color: var(--border); color: var(--text-dim);
}
.vote-btn.no:hover:not(:disabled), .vote-btn.no.on { color: var(--danger); border-color: var(--danger); background: rgba(255, 56, 96, 0.14); box-shadow: none; }
.vote-btn.maybe:hover:not(:disabled), .vote-btn.maybe.on { color: var(--warn); border-color: var(--warn); background: rgba(255, 180, 84, 0.14); box-shadow: none; }
.vote-btn.yes:hover:not(:disabled), .vote-btn.yes.on { color: var(--accent); border-color: var(--accent); background: rgba(0, 255, 136, 0.14); box-shadow: none; }
.vote-btn.on { box-shadow: 0 0 6px currentColor !important; }
.vote-others { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.vote-mark {
  width: 18px; height: 18px; border-radius: 3px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; color: var(--text);
  box-shadow: 0 0 0 2px var(--text-dim);
}
.vote-mark img { width: 100%; height: 100%; }
.vote-mark.yes { box-shadow: 0 0 0 2px var(--accent); }
.vote-mark.maybe { box-shadow: 0 0 0 2px var(--warn); }
.vote-mark.no { box-shadow: 0 0 0 2px var(--danger); }
.vote-mark.no img { filter: grayscale(1); }
.game-title { font-size: 12px; font-weight: 700; line-height: 1.3; }
.coop-badge {
  align-self: flex-start;
  font-size: 10px; letter-spacing: .5px; text-transform: uppercase;
  color: var(--accent); border: 1px solid var(--accent-dim); border-radius: 3px; padding: 1px 5px;
}
.game-owners { margin-top: auto; display: flex; flex-wrap: wrap; gap: 4px; }
.owner { display: flex; align-items: center; gap: 3px; font-size: 10px; border-radius: 3px; padding: 1px 4px 1px 1px; }
.owner img { width: 18px; height: 18px; border-radius: 2px; }
.owner.has { background: rgba(0, 255, 136, 0.12); color: var(--accent); }
.owner.no img { filter: grayscale(1); opacity: .35; }
.owner.no { box-shadow: inset 0 0 0 1px rgba(255, 56, 96, 0.5); }
.owner.unknown img { filter: grayscale(1); opacity: .5; }
.owner b { font-weight: 500; }
.game-score {
  align-self: flex-end; text-align: right;
  font-size: 12px; font-weight: 700;
  border-radius: 3px; padding: 3px 6px;
  display: flex; flex-direction: column;
}
.game-score small { font-size: 10px; font-weight: 400; opacity: .85; }
.score-good { background: rgba(0, 255, 136, 0.18); color: var(--accent); }
.score-mid { background: rgba(255, 180, 84, 0.18); color: var(--warn); }
.score-bad { background: rgba(255, 56, 96, 0.18); color: var(--danger); }

@media (hover: none) {
  /* на телефоне ховера нет — инфо всегда видна снизу */
  .game-overlay { opacity: 1; background: linear-gradient(180deg, transparent 35%, rgba(10,10,15,.95) 100%); }
  .game-overlay .game-title { margin-top: auto; }
  .game-owners { margin-top: 0; }
}
@media (max-width: 720px) {
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
  .topbar-right { margin-left: 0; }
  .filters select { flex: 1 1 40%; min-width: 0; }
  .filters input[type=search] { flex: 1 1 100%; }
}

/* ─── Оценки ────────────────────────────────────── */
#ratings-search { width: 100%; margin-bottom: 14px; }
.ratings-list { display: flex; flex-direction: column; gap: 6px; }
.list-sep { margin: 14px 0 2px; }
.rating-row { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); }
.rating-row.open { border-color: var(--accent-dim); }
.rating-line { display: flex; align-items: center; gap: 10px; padding: 8px 10px; cursor: pointer; flex-wrap: wrap; }
.rating-line:hover { background: rgba(0, 255, 136, 0.03); }
.caret { width: 12px; color: var(--text-dim); font-size: 10px; }
.thumb { width: 64px; height: 30px; object-fit: cover; border-radius: 3px; border: 1px solid var(--border); flex: none; }
.rating-name { font-weight: 500; flex: 1 1 160px; }
.chips { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.raters { display: flex; gap: 2px; }
.raters img { width: 20px; height: 20px; border-radius: 3px; }
.rating-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 8px; padding: 0 10px 10px 32px; }
.rating-card { background: var(--bg-elev-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.rating-card.mine { border-color: var(--accent-dim); }
.rating-head { display: flex; align-items: center; gap: 8px; }
.rating-head img { width: 24px; height: 24px; border-radius: 3px; }
.rating-head .small-btn { margin-left: auto; }
.rating-scale, .rating-toggles { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.rating-scale b { color: var(--accent); }
.rating-scale small { color: var(--text-dim); }
.rating-toggles .yes { color: var(--accent); }
.rating-toggles .no { color: var(--text-dim); }
.rating-comment { color: var(--text); font-style: italic; }

.rating-dialog { width: min(520px, calc(100vw - 32px)); }
.rating-dialog h3 { margin-bottom: 16px; }
.rating-sliders { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.slider { display: grid; grid-template-columns: 150px 1fr 56px; align-items: center; gap: 10px; }
.slider input[type=range] { accent-color: var(--accent); width: 100%; }
.slider output { text-align: right; color: var(--accent); font-variant-numeric: tabular-nums; }
.rating-switches { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-ui { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; flex: none; }
.switch-ui b { padding: 3px 8px; font-size: 11px; color: var(--text-dim); font-weight: 700; }
.switch input:not(:checked) + .switch-ui b:first-child { background: rgba(255, 56, 96, 0.15); color: var(--danger); }
.switch input:checked + .switch-ui b:last-child { background: rgba(0, 255, 136, 0.15); color: var(--accent); }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 2px var(--accent-dim); }
.comment-label { display: flex; flex-direction: column; gap: 6px; }
.comment-label textarea { resize: vertical; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.dialog-actions .spacer { flex: 1; }
.danger-btn { border-color: var(--danger); color: var(--danger); }
.vote-btn.rate:hover, .vote-btn.rate:focus-visible { color: var(--accent); border-color: var(--accent); }

/* ─── Предложка ─────────────────────────────────── */
.proposal-add { position: relative; flex: 0 1 340px; }
.proposal-add input { width: 100%; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--bg-elev); border: 1px solid var(--accent-dim); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.6); padding: 4px; display: flex; flex-direction: column; gap: 2px;
}
.search-results[hidden] { display: none; }
.search-results p { padding: 8px; margin: 0; }
.search-item { display: flex; align-items: center; gap: 8px; text-align: left; border: none; color: var(--text); padding: 6px; }
.search-item img { width: 72px; height: 27px; object-fit: cover; border-radius: 2px; }
.graph-svg { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.graph-link { stroke-width: 2.5; opacity: .85; transition: opacity .15s; }
.graph-link.derived { stroke-dasharray: 4 5; stroke-width: 1.5; opacity: .5; }
.graph-link-emoji { font-size: 14px; cursor: default; transition: opacity .15s; }
.graph-node { cursor: grab; transition: opacity .15s; outline: none; }
.graph-node:active { cursor: grabbing; }
.graph-node .ring { fill: var(--bg-elev-2); stroke: var(--accent); stroke-width: 2; }
.graph-node .frame { fill: var(--bg-elev-2); stroke: var(--border); stroke-width: 1.5; }
.graph-node:hover .frame, .graph-node:focus-visible .frame { stroke: var(--accent); }
.graph-node:focus-visible .ring { stroke-width: 4; }
.graph-name { fill: var(--text); font-family: var(--font); font-size: 11px; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.graph-svg.has-focus .graph-link, .graph-svg.has-focus .graph-link-emoji, .graph-svg.has-focus .graph-node { opacity: .12; }
.graph-svg.has-focus .hl { opacity: 1 !important; }
.graph-svg.has-focus .graph-link.hl { stroke-width: 4; }
.graph-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin: 10px 0 18px; color: var(--text); }
.graph-legend i { display: inline-block; width: 14px; height: 3px; margin-right: 6px; vertical-align: middle; border-radius: 2px; }
.proposals-table-box summary { cursor: pointer; color: var(--text-dim); margin-bottom: 10px; letter-spacing: 1px; text-transform: uppercase; font-size: 12px; }
.table-scroll { overflow-x: auto; }
.status-table th { white-space: nowrap; }
.status-table th img { width: 20px; height: 20px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
.status-table th.is-me { color: var(--accent); }
.game-col { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.game-col a { color: var(--text); text-decoration: none; }
.game-col a:hover { color: var(--accent); }
.status-cell select {
  width: 100%; min-width: 150px; cursor: pointer; padding: 5px 8px; font-size: 13px;
  border-left: 3px solid var(--st);
}
.status-cell.derived select { color: var(--text-dim); }
tr:hover .game-col .icon-btn { opacity: 1; }

@media (max-width: 720px) {
  .slider { grid-template-columns: 1fr 48px; }
  .slider span { grid-column: 1 / -1; }
  .rating-cards { grid-template-columns: 1fr; padding-left: 10px; }
  .proposal-add { flex: 1 1 100%; }
}
