/* Общий стиль раздела /games: нейтральная тёмная тема */
:root {
  --bg: #0e1014;
  --surface: #171b23;
  --surface2: #1f242e;
  --border: #2a303c;
  --text: #e7e9ee;
  --muted: #8e97aa;
  --accent: #7c9cff;
  --accent2: #5b7cf0;
  --good: #4ade80;
  --bad: #f87171;
  --warn: #fbbf24;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(1100px 560px at 15% -10%, #19203a 0%, transparent 60%),
    radial-gradient(900px 480px at 100% 0%, #1c1930 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .6em 1.1em; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface2); cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
  user-select: none; -webkit-tap-highlight-color: transparent; text-decoration: none !important; color: var(--text);
}
.btn:hover { background: #262c38; border-color: #3a4254; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent2); border-color: var(--accent2); color: #fff; }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { background: #3a1f24; border-color: #5c2b33; color: #ffb4b4; }
.btn.danger:hover { background: #4a2429; }
.btn.sm { padding: .35em .75em; font-size: .875rem; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible, .input:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.input {
  width: 100%; padding: .7em .85em; border-radius: 10px; border: 1px solid var(--border);
  background: #11141a; transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--accent); }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; margin-bottom: 6px; font-size: .875rem; color: var(--muted); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}

/* ---------- вход ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.brand { text-align: center; margin-bottom: 22px; }
.brand .logo { font-size: 2.6rem; line-height: 1; margin-bottom: 8px; }
.brand h1 { font-size: 1.5rem; }
.tabs { display: flex; gap: 6px; padding: 4px; background: #11141a; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 18px; }
.tabs button {
  flex: 1; padding: .5em; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer;
}
.tabs button.active { background: var(--surface2); color: var(--text); }
.form-error { min-height: 1.4em; color: var(--bad); font-size: .9rem; margin: -4px 0 10px; }
.check { display: flex; align-items: center; gap: 8px; font-size: .875rem; color: var(--muted); margin: -4px 0 14px; cursor: pointer; }

/* ---------- верхняя панель ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1040px; margin: 0 auto; padding: 14px 16px;
}
.topbar h1 { font-size: 1.15rem; white-space: nowrap; }
.user-chip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; min-width: 0; }
.user-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip b { color: var(--text); font-weight: 600; }

/* ---------- список игр ---------- */
.container { max-width: 1040px; margin: 0 auto; padding: 8px 16px 40px; }
.lead { margin: 6px 0 20px; color: var(--muted); }
.games-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.game-card { display: flex; flex-direction: column; gap: 10px; padding: 18px; transition: border-color .15s, transform .15s; }
.game-card:hover { border-color: #3d4660; transform: translateY(-2px); }
.game-card .icon { font-size: 2.2rem; line-height: 1; }
.game-card h3 { font-size: 1.1rem; }
.game-card .tag { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: #232a3a; color: #aab6d6; margin-left: 8px; vertical-align: middle; font-weight: 500; }
.game-card p { margin: 0; color: var(--muted); font-size: .92rem; flex: 1; }
.game-card .best { font-size: .85rem; color: var(--muted); }
.game-card .best b { color: var(--text); }
.game-card .row { display: flex; gap: 8px; }
.game-card .row .btn:first-child { flex: 1; }

/* ---------- шапка внутри игры ---------- */
.gs-header {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; background: rgba(14, 16, 20, .88); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.gs-back { color: var(--muted); white-space: nowrap; }
.gs-title { font-weight: 600; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-actions { display: flex; align-items: center; gap: 8px; }
.gs-user { color: var(--muted); font-size: .85rem; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .gs-user { display: none; } .gs-title { text-align: left; } }

/* ---------- модальные окна и уведомления ---------- */
.modal-ov {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(5, 7, 10, .72); animation: fade .15s ease-out;
}
.modal {
  width: 100%; max-width: 440px; max-height: 88vh; overflow: auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.modal.wide { max-width: 660px; }
.modal h3 { font-size: 1.15rem; margin-bottom: 10px; }
.modal-body { color: #c9cfdd; }
.modal-body p { margin: 0 0 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#gs-toasts { position: fixed; z-index: 200; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast {
  background: #232936; border: 1px solid #343c4d; border-radius: 10px; padding: 10px 14px; font-size: .92rem;
  box-shadow: var(--shadow); animation: toast-in .2s ease-out; text-align: center;
}
.toast.good { border-color: #2f6b49; background: #1b2c24; }
.toast.bad { border-color: #6b2f37; background: #2e1b1f; }
.toast.gold { border-color: #7a6320; background: #2c2716; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- таблица рейтинга ---------- */
.lb { width: 100%; border-collapse: collapse; font-size: .95rem; }
.lb td { padding: 7px 8px; border-bottom: 1px solid #232834; }
.lb td:first-child { width: 2.4em; color: var(--muted); text-align: right; }
.lb td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.lb tr.me td { background: #1b2340; color: #fff; }
.lb tr:nth-child(-n+3) td:first-child { color: var(--warn); font-weight: 700; }
.lb-me { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: #1b2340; font-size: .92rem; }
.lb-empty { padding: 18px 0; text-align: center; color: var(--muted); }

/* Блок «Сейчас играют» на главной */
.online-box { padding: 14px 16px; margin-bottom: 16px; }
.online-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.online-head .dot { width: 9px; height: 9px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.online-list { display: flex; flex-wrap: wrap; gap: 6px; }
.online-list .who { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); font-size: .85rem; }
.online-list .who.me { border-color: #7c9cff; }
.online-list .who small { color: var(--muted); }
.online-list .empty { color: var(--muted); font-size: .9rem; }
