/* ============================================================
   GameWhale · Аркада — соло-игры на тёмной теме портала
   Без сборки: один CSS-файл, общие переменные с /style.css
   ============================================================ */

:root {
  --bg: #080b12;
  --bg-soft: #0b1019;
  --panel: #0f1520;
  --panel-2: #131b28;
  --panel-3: #182231;
  --line: #202b3b;
  --line-strong: #2e3c52;
  --text: #e9eef7;
  --muted: #8e9bb3;
  --muted-2: #66738c;
  --accent: #5ee0d0;
  --accent-2: #3fc9b8;
  --accent-ink: #05201c;
  --danger: #ff6b5a;
  --warn: #ffc266;
  --win: #8ef0a1;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.45);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --maxw: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(900px 600px at 12% -8%, rgba(94, 224, 208, 0.07), transparent 60%),
    radial-gradient(760px 560px at 100% 0%, rgba(255, 194, 102, 0.045), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: rgba(94, 224, 208, 0.25);
}

h1,
h2,
h3,
h4,
p,
dl,
dd,
ol,
li {
  margin: 0;
}

ol,
li {
  list-style: none;
  padding: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
  transition: top 0.15s ease;
}

.skip-link:focus-visible {
  top: 10px;
}

/* ------------------------------------------------------------ верхняя панель */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(8, 11, 9, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: 64px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-link {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.back-link:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
  color: var(--accent);
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-mark {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  color: var(--accent);
  filter: drop-shadow(0 0 14px rgba(94, 224, 208, 0.35));
}

.topbar-title-text {
  min-width: 0;
}

.topbar-title h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.2;
}

.topbar-title p {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
}

.player-chip {
  margin-left: auto;
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 176px;
  max-width: 300px;
  padding: 6px 12px 6px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.avatar {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--panel-3);
  border: 1px solid var(--line-strong);
  color: var(--accent);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.player-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.player-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}

.player-sub {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-chip.is-loading .player-name,
.player-chip.is-loading .player-sub {
  color: transparent;
  border-radius: 5px;
  background: linear-gradient(90deg, #18211b 25%, #24312a 37%, #18211b 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

.player-chip.is-loading .player-name {
  width: 96px;
  height: 12px;
}

.player-chip.is-loading .player-sub {
  width: 62px;
  height: 8px;
}

.skeleton-circle {
  background: linear-gradient(90deg, #18211b 25%, #24312a 37%, #18211b 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-color: #22302a;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* ------------------------------------------------------------ каркас */

.arcade {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 22px 18px 72px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.hero h2 {
  font-size: clamp(24px, 4vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.hero-lead {
  color: var(--muted);
  font-size: 13.5px;
  max-width: 64ch;
}

.stats {
  display: flex;
  gap: 10px;
}

.stat {
  min-width: 96px;
  padding: 9px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 40%), var(--panel);
}

.stat dt {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.stat dd {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

/* ------------------------------------------------------------ карточки-табы */

.games {
  margin-bottom: 16px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  gap: 10px;
}

.game-card {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 78px;
  padding: 11px 13px;
  text-align: left;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 45%), var(--panel);
  color: var(--text);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.game-card:hover {
  border-color: var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 45%), var(--panel-2);
}

.game-card:active {
  transform: translateY(1px);
}

.game-card[aria-selected="true"] {
  border-color: rgba(94, 224, 208, 0.65);
  background:
    linear-gradient(180deg, rgba(94, 224, 208, 0.09), transparent 70%),
    var(--panel-2);
  box-shadow: inset 0 0 0 1px rgba(94, 224, 208, 0.18);
}

.game-icon {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  background: #0b1019;
  border: 1px solid var(--line);
}

.game-card[aria-selected="true"] .game-icon {
  border-color: rgba(94, 224, 208, 0.35);
  background: rgba(94, 224, 208, 0.08);
}

.game-card-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.game-name {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.game-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.3;
}

.game-best {
  margin-top: 3px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------ панели */

.game-panel {
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent 30%), var(--panel);
  box-shadow: var(--shadow);
}

.game-panel[hidden] {
  display: none;
}

.game-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.game-head h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.game-hint {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

.game-tools {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 7px;
}

.metric {
  min-width: 66px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0b1019;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}

.metric-label {
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.metric-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  white-space: nowrap;
}

.board-status {
  margin-top: 12px;
  min-height: 1.45em;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.board-status.is-error {
  color: var(--danger);
}

.board-status.is-win {
  color: var(--win);
}

/* ------------------------------------------------------------ кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.btn:hover:not(:disabled) {
  background: var(--panel-3);
  border-color: #4b5a49;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover:not(:disabled) {
  background: #e6ff6d;
  border-color: #e6ff6d;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.btn-small {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 9px;
  align-self: stretch;
}

/* ------------------------------------------------------------ оверлеи */

.overlay-host {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: 14px;
  background: rgba(5, 8, 6, 0.74);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  width: min(320px, 100%);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 18px 20px;
  text-align: center;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  animation: overlay-in 0.18s ease both;
}

.overlay-card h4 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.overlay-card p {
  font-size: 12.5px;
  color: var(--muted);
}

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

@keyframes overlay-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------------------------------------ 2048 */

.board-2048-host {
  width: min(100%, 460px);
  margin: 0 auto;
  touch-action: none;
}

.grid-2048 {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0b111b;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.4);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.cell-2048 {
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.028);
  font-family: var(--mono);
  font-size: clamp(16px, 5vw, 32px);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  transition: background 0.12s ease, color 0.12s ease;
  position: relative;
}

.cell-2048[data-tier="1"] {
  background: #182231;
  color: #dfe8d8;
}

.cell-2048[data-tier="2"] {
  background: #26332a;
  color: #f1f6ec;
}

.cell-2048[data-tier="3"] {
  background: rgba(94, 224, 208, 0.18);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(94, 224, 208, 0.22);
}

.cell-2048[data-tier="4"] {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 22px rgba(94, 224, 208, 0.28);
}

.cell-2048.is-empty {
  font-size: 0;
}

.cell-2048.pop {
  animation: tile-pop 0.16s ease;
}

.cell-2048.appear {
  animation: tile-appear 0.16s ease;
}

@keyframes tile-pop {
  0% {
    transform: scale(0.88);
  }
  60% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tile-appear {
  0% {
    transform: scale(0.6);
    opacity: 0.35;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ------------------------------------------------------------ сапёр */

.ms-host {
  width: min(100%, 430px);
  margin: 0 auto;
  touch-action: manipulation;
}

.ms-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 4px;
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #0b111b;
  user-select: none;
  -webkit-user-select: none;
}

.ms-cell {
  aspect-ratio: 1;
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid #2a352d;
  background: linear-gradient(180deg, #182231, #141d17);
  color: var(--muted);
  font-family: var(--mono);
  font-size: clamp(11px, 3.2vw, 17px);
  font-weight: 700;
  line-height: 1;
  transition: background 0.08s ease, border-color 0.08s ease;
  -webkit-tap-highlight-color: transparent;
}

.ms-cell:hover:not(.is-revealed) {
  background: #22302a;
  border-color: #3a4a3c;
}

.ms-cell.is-revealed {
  background: #0c120e;
  border-color: #1c2620;
  cursor: default;
}

.ms-cell.is-flagged {
  background: rgba(255, 194, 102, 0.13);
  border-color: rgba(255, 194, 102, 0.35);
  color: var(--warn);
}

.ms-cell.is-mine {
  background: rgba(255, 107, 90, 0.16);
  border-color: rgba(255, 107, 90, 0.4);
  color: var(--danger);
}

.ms-cell.is-exploded {
  background: var(--danger);
  border-color: var(--danger);
  color: #200805;
}

.ms-cell.is-wrong {
  background: rgba(255, 107, 90, 0.12);
  border-color: rgba(255, 107, 90, 0.25);
  color: var(--danger);
  text-decoration: line-through;
}

.ms-cell[data-n="1"] {
  color: #8fc7ff;
}
.ms-cell[data-n="2"] {
  color: #8ef0a1;
}
.ms-cell[data-n="3"] {
  color: #ff9c8c;
}
.ms-cell[data-n="4"] {
  color: #c3b0ff;
}
.ms-cell[data-n="5"] {
  color: #ffc266;
}
.ms-cell[data-n="6"] {
  color: #7fe3dc;
}
.ms-cell[data-n="7"] {
  color: #f3a6ff;
}
.ms-cell[data-n="8"] {
  color: #d5dde0;
}

/* ------------------------------------------------------------ реакция */

.rx-dots {
  display: flex;
  justify-content: center;
  gap: 7px;
  margin: 2px 0 12px;
}

.rx-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--line);
  transition: background 0.15s ease, transform 0.15s ease;
}

.rx-dot.is-done {
  background: var(--accent);
}

.rx-dot.is-current {
  background: var(--warn);
  transform: scale(1.35);
}

.rx-pad {
  width: 100%;
  min-height: clamp(210px, 36vh, 300px);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: #16201a;
  color: var(--text);
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.rx-pad[data-state="waiting"] {
  background: #341a15;
  border-color: #5c2c22;
  color: #ffb4a6;
}

.rx-pad[data-state="ready"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 0 44px rgba(94, 224, 208, 0.3);
}

.rx-pad[data-state="done"] {
  background: #142018;
  border-color: rgba(94, 224, 208, 0.45);
}

.rx-pad-title {
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.rx-pad-sub {
  font-size: 12px;
  color: var(--muted);
  max-width: 40ch;
}

.rx-pad[data-state="waiting"] .rx-pad-sub {
  color: rgba(255, 180, 166, 0.8);
}

.rx-pad[data-state="ready"] .rx-pad-sub {
  color: rgba(16, 21, 2, 0.72);
}

.rx-pad[data-state="done"] .rx-pad-sub {
  color: var(--muted);
}

.rx-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  min-height: 24px;
}

.rx-list li {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0b1019;
  color: var(--muted);
}

.rx-list li.is-penalty {
  color: var(--danger);
  border-color: rgba(255, 107, 90, 0.35);
}

/* ------------------------------------------------------------ слово */

.wd-board {
  width: min(100%, 370px);
  margin: 0 auto 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wd-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.wd-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #0b1019;
  color: var(--text);
  font-size: clamp(17px, 5vw, 25px);
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.wd-cell.is-filled {
  border-color: #4b5a49;
}

.wd-cell.is-correct {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.wd-cell.is-present {
  background: var(--warn);
  border-color: var(--warn);
  color: #1d1503;
}

.wd-cell.is-absent {
  background: var(--panel-3);
  border-color: var(--line);
  color: var(--muted-2);
}

.wd-cell.pop {
  animation: tile-pop 0.16s ease;
}

.wd-keyboard {
  width: min(100%, 560px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wd-krow {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.wd-key {
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  padding: 0 2px;
  border-radius: 8px;
  border: 1px solid #2d3931;
  background: var(--panel-3);
  color: var(--text);
  font-size: clamp(11px, 2.6vw, 13.5px);
  font-weight: 700;
  text-transform: uppercase;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.wd-key:hover:not(:disabled) {
  background: #22302a;
}

.wd-key--wide {
  flex: 1.6 1 0;
  font-size: clamp(10px, 2.3vw, 12px);
  letter-spacing: 0.03em;
  text-transform: none;
}

.wd-key.is-correct {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.wd-key.is-present {
  background: var(--warn);
  border-color: var(--warn);
  color: #1d1503;
}

.wd-key.is-absent {
  background: #10160f;
  border-color: #1f2820;
  color: #566356;
}

.wd-board.shake {
  animation: board-shake 0.22s ease;
}

@keyframes board-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ------------------------------------------------------------ змейка */

.canvas-host {
  width: min(100%, 560px);
  margin: 0 auto;
  touch-action: none;
}

#sn-canvas {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  display: block;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #0b111b;
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.55), 0 18px 40px rgba(0, 0, 0, 0.35);
}

/* ------------------------------------------------------------ тосты */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-in {
  opacity: 1;
  transform: none;
}

.toast.is-out {
  opacity: 0;
  transform: translateY(6px);
}

.toast--achievement {
  border-left-color: var(--warn);
}

.toast--warn {
  border-left-color: var(--warn);
}

.toast--error {
  border-left-color: var(--danger);
}

.toast-icon {
  flex: 0 0 auto;
  font-size: 19px;
  line-height: 1.2;
}

.toast-body {
  min-width: 0;
}

.toast-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.25;
}

.toast-desc {
  margin-top: 1px;
  font-size: 11.5px;
  color: var(--muted);
}

.noscript {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  text-align: center;
  z-index: 70;
}

/* ------------------------------------------------------------ адаптив */

@media (max-width: 900px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    align-items: start;
  }

  .stats {
    width: 100%;
  }

  .stat {
    flex: 1 1 0;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    min-height: 58px;
    padding: 8px 12px;
    gap: 10px;
  }

  .topbar-title p {
    display: none;
  }

  .topbar-mark {
    width: 30px;
    height: 30px;
  }

  .topbar-title h1 {
    font-size: 14.5px;
    letter-spacing: 0.1em;
  }

  .back-link {
    min-height: 34px;
    padding: 6px 11px;
    font-size: 12.5px;
  }

  .player-chip {
    min-width: 0;
    max-width: 172px;
    padding: 5px 10px 5px 5px;
  }

  .avatar {
    width: 28px;
    height: 28px;
  }

  .player-name {
    max-width: 118px;
    font-size: 12.5px;
  }

  .player-sub {
    font-size: 8.5px;
  }

  .arcade {
    padding: 16px 12px 56px;
  }

  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .game-card {
    min-height: 66px;
    padding: 9px 10px;
    gap: 9px;
  }

  .game-icon {
    width: 34px;
    height: 34px;
    font-size: 17px;
    border-radius: 9px;
  }

  .game-desc {
    display: none;
  }

  .game-name {
    font-size: 13px;
  }

  .game-best {
    font-size: 8.5px;
  }

  .game-card:last-child {
    grid-column: 1 / -1;
  }

  .game-panel {
    padding: 13px;
  }

  .game-head {
    margin-bottom: 13px;
    padding-bottom: 10px;
  }

  .game-tools {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .metric {
    min-width: 0;
    padding: 4px 8px;
  }

  .metric-value {
    font-size: 13px;
  }

  .game-tools .btn {
    grid-column: 1 / -1;
    min-height: 36px;
  }

  .grid-2048 {
    gap: 6px;
    padding: 6px;
  }

  .cell-2048 {
    border-radius: 8px;
  }

  .ms-grid {
    gap: 3px;
    padding: 6px;
  }

  .wd-key {
    height: 40px;
  }

  .rx-pad {
    min-height: 200px;
  }
}

@media (max-width: 380px) {
  .arcade {
    padding: 12px 10px 48px;
  }

  .topbar-title h1 {
    font-size: 13.5px;
  }

  .player-chip {
    max-width: 132px;
  }

  .player-name {
    max-width: 86px;
  }

  .stat {
    padding: 7px 10px;
  }

  .stat dd {
    font-size: 16px;
  }

  .metric-value {
    font-size: 12px;
  }

  .game-hint {
    font-size: 10.5px;
  }

  .wd-key {
    height: 37px;
    gap: 0;
  }

  .wd-keyboard,
  .wd-krow {
    gap: 4px;
  }

  .cell-2048 {
    font-size: clamp(14px, 5.4vw, 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   ВИСЕЛИЦА
   ============================================================ */

.hm-host {
  position: relative;
  padding: 18px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    radial-gradient(420px 200px at 50% 0%, rgba(94, 224, 208, 0.06), transparent 65%),
    linear-gradient(180deg, var(--panel), #0b1019);
}

.hm-board {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.hm-gallows {
  width: 100%;
  height: auto;
  max-height: 210px;
}

.hm-frame {
  fill: none;
  stroke: #3c4a3c;
  stroke-width: 6;
  stroke-linecap: round;
}

.hm-part {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hm-part.is-visible {
  opacity: 1;
}

/* На проигрыше фигура краснеет. */
.hm-host.is-lose .hm-part.is-visible {
  stroke: var(--danger);
}

.hm-word {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
}

.hm-letter {
  min-width: 34px;
  height: 44px;
  display: grid;
  place-items: center;
  border-bottom: 3px solid var(--line-strong);
  font-size: clamp(20px, 5vw, 28px);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--muted-2);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.hm-letter.is-open {
  color: var(--accent);
  border-color: var(--accent);
  animation: bunker-pop 0.25s ease;
}

.hm-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}

.hm-keyrow {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

.hm-key {
  min-width: 38px;
  height: 42px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 650;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.hm-key:hover:not(:disabled) {
  border-color: var(--accent);
  background: rgba(94, 224, 208, 0.08);
}

.hm-key:disabled {
  cursor: default;
  opacity: 0.85;
}

.hm-key.is-hit {
  background: rgba(94, 224, 208, 0.16);
  border-color: var(--accent);
  color: var(--accent);
}

.hm-key.is-miss {
  background: rgba(255, 107, 90, 0.08);
  border-color: rgba(255, 107, 90, 0.35);
  color: #c98f88;
  text-decoration: line-through;
}

@media (max-width: 620px) {
  .hm-board {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 12px;
  }
  .hm-gallows {
    max-height: 150px;
    width: 132px;
  }
  .hm-letter {
    min-width: 26px;
    height: 38px;
    font-size: 20px;
  }
  .hm-key {
    min-width: 32px;
    height: 38px;
    font-size: 13px;
  }
}

/* ============================================================
   БЫКИ И КОРОВЫ
   ============================================================ */

.bl-host {
  position: relative;
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), #0b1019);
}

.bl-entry {
  display: flex;
  gap: 10px;
}

.bl-cell {
  width: clamp(44px, 12vw, 58px);
  height: clamp(52px, 14vw, 68px);
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 2px dashed var(--line-strong);
  background: #0b1019;
  font-family: var(--mono);
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 700;
  color: var(--muted-2);
  transition: all 0.15s ease;
}

.bl-cell.is-filled {
  border-style: solid;
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(94, 224, 208, 0.05);
}

.bl-layout {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 18px;
  margin-top: 16px;
  align-items: start;
}

.bl-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

.bl-key {
  height: 48px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.bl-key:hover { border-color: var(--accent); background: rgba(94, 224, 208, 0.07); }
.bl-key:active { transform: scale(0.97); }
.bl-key.is-soft { color: var(--muted); font-size: 16px; }
.bl-key.is-wide {
  grid-column: span 3;
  height: 42px;
  font-family: inherit;
  font-size: 13px;
  letter-spacing: 0.03em;
  background: rgba(94, 224, 208, 0.1);
  border-color: rgba(94, 224, 208, 0.35);
  color: var(--accent);
}

.bl-history {
  display: grid;
  gap: 6px;
  max-height: 330px;
  overflow-y: auto;
  align-content: start;
}

.bl-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  animation: bunker-rise 0.22s ease;
}

.bl-row.is-win {
  border-color: rgba(142, 240, 161, 0.45);
  background: rgba(142, 240, 161, 0.08);
}

.bl-row-digits {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text);
  flex: 1;
}

.bl-badge {
  font-size: 10.5px;
  font-family: var(--mono);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  white-space: nowrap;
}

.bl-badge.is-bull { color: var(--win); border-color: rgba(142, 240, 161, 0.4); }
.bl-badge.is-cow { color: var(--warn); border-color: rgba(255, 194, 102, 0.4); }

.bl-history:empty::before {
  content: "История догадок появится здесь";
  color: var(--muted-2);
  font-size: 12.5px;
}

@media (max-width: 720px) {
  .bl-layout { grid-template-columns: 1fr; }
  .bl-pad { grid-template-columns: repeat(6, 1fr); }
  .bl-key { height: 44px; font-size: 16px; }
  .bl-key.is-wide { grid-column: span 6; }
  .bl-history { max-height: 220px; }
}

/* ============================================================
   ТЕТРИС
   ============================================================ */

#tt-canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: #070b08;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.55), 0 12px 40px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

#panel-tetris .canvas-host {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    radial-gradient(420px 220px at 50% -10%, rgba(94, 224, 208, 0.07), transparent 65%),
    linear-gradient(180deg, var(--panel), #0b1019);
}

@media (max-width: 620px) {
  #tt-canvas {
    max-width: 78vw;
  }
}

/* ============================================================
   СУДОКУ
   ============================================================ */

.sd-host {
  position: relative;
  display: grid;
  place-items: center;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel), #0b1019);
}

.sd-grid {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: min(430px, 100%);
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--line-strong);
  background: #0b111b;
}

.sd-cell {
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #0d1420;
  color: var(--accent);
  font-family: var(--mono);
  font-size: clamp(14px, 3.6vw, 20px);
  font-weight: 700;
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

.sd-cell.edge-r { border-right: 2px solid var(--line-strong); }
.sd-cell.edge-b { border-bottom: 2px solid var(--line-strong); }

.sd-cell.is-given {
  color: var(--text);
  background: #131a15;
  font-weight: 800;
  cursor: default;
}

.sd-cell.is-peer { background: rgba(94, 224, 208, 0.05); }

.sd-cell.is-selected {
  background: rgba(94, 224, 208, 0.18);
  box-shadow: inset 0 0 0 2px var(--accent);
}

.sd-cell.is-error {
  background: rgba(255, 107, 90, 0.16);
  color: #ffb4aa;
  box-shadow: inset 0 0 0 2px rgba(255, 107, 90, 0.55);
}

.sd-cell.is-hint {
  color: var(--violet, #c3b0ff);
  background: rgba(195, 176, 255, 0.1);
}

.sd-pad {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 5px;
  margin-top: 14px;
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.sd-key {
  height: 42px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.sd-key:hover { border-color: var(--accent); background: rgba(94, 224, 208, 0.08); }
.sd-key.is-soft { color: var(--muted); }

@media (max-width: 620px) {
  .sd-pad { grid-template-columns: repeat(5, 1fr); }
  .sd-key { height: 38px; font-size: 15px; }
}

/* ============================================================
   Игры фонового агента (public/arcade/auto/*.js).
   Модули агента рисуют разметку через эти классы.
   ============================================================ */

.auto-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.auto-head b {
  display: block;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.auto-sub {
  display: block;
  font-size: 11px;
  color: var(--muted-2);
  font-family: var(--mono);
  margin-top: 3px;
}

.auto-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-timer {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
  min-width: 38px;
  text-align: right;
}

.auto-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 8px;
  max-width: 520px;
  margin: 0 auto;
}

.auto-grid-square .auto-cell {
  aspect-ratio: 1;
}

.auto-card {
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
  font-size: clamp(18px, 4.5vw, 26px);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.auto-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.auto-card.is-open {
  background: rgba(94, 224, 208, 0.1);
  border-color: rgba(94, 224, 208, 0.45);
  color: var(--accent);
}

.auto-card.is-done {
  background: rgba(142, 240, 161, 0.12);
  border-color: rgba(142, 240, 161, 0.4);
  color: var(--win, #8ef0a1);
}

.auto-cell {
  display: grid;
  place-items: center;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.auto-cell:hover {
  border-color: var(--accent);
  background: rgba(94, 224, 208, 0.07);
}

.auto-cell.is-good {
  background: rgba(142, 240, 161, 0.1);
  border-color: rgba(142, 240, 161, 0.35);
  color: var(--win, #8ef0a1);
  cursor: default;
}

.auto-cell.is-bad {
  background: rgba(255, 107, 90, 0.14);
  border-color: rgba(255, 107, 90, 0.45);
  color: #ffb4aa;
  cursor: default;
}

.auto-reflex {
  display: grid;
  place-items: center;
  width: min(360px, 84vw);
  aspect-ratio: 1;
  margin: 10px auto;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  font-size: clamp(15px, 3.6vw, 20px);
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.08s linear, border-color 0.08s linear, transform 0.08s linear;
}

.auto-reflex.is-wait {
  background: #0b1019;
  color: var(--muted-2);
}

.auto-reflex.is-flash {
  background: var(--accent);
  border-color: #f0ff8f;
  color: var(--accent-ink);
  transform: scale(1.04);
  box-shadow: 0 0 60px rgba(94, 224, 208, 0.45);
}

.auto-reflex.is-done {
  background: rgba(255, 255, 255, 0.03);
}

.auto-status {
  margin-top: 14px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 18px;
}

/* Отметка «от агента» на карточке игры. */
.game-card .auto-tag {
  font-size: 9.5px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(94, 224, 208, 0.3);
  border-radius: 5px;
  padding: 2px 6px;
}

@media (max-width: 560px) {
  .auto-grid {
    gap: 6px;
  }
  .auto-reflex {
    width: 78vw;
  }
}
