/* Игровая станция — тёплый «дачный» стиль. Мобильный вертикальный экран — основной. */
:root {
  --bg: #f6efe3;
  --bg-card: #fffaf1;
  --bg-sunken: #ece2cf;
  --ink: #3a2f21;
  --ink-soft: #8a7a63;
  --accent: #d97b29;       /* тёплая охра */
  --accent-ink: #fff;
  --green: #5b8c51;
  --red2: #c0564a;
  --line: #e0d4bd;
  --shadow: 0 2px 10px rgba(90, 70, 40, .12);
  --radius: 18px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #221c14;
    --bg-card: #2d261b;
    --bg-sunken: #1a150e;
    --ink: #f0e6d6;
    --ink-soft: #a5977e;
    --accent: #e08a3c;
    --accent-ink: #221c14;
    --green: #7fb573;
    --red2: #d97a6c;
    --line: #3d3425;
    --shadow: 0 2px 10px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overscroll-behavior: none;
  touch-action: manipulation;
}
#app { min-height: 100dvh; display: flex; flex-direction: column; }

.screen {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 14px 16px calc(20px + env(safe-area-inset-bottom));
  max-width: 560px; width: 100%; margin: 0 auto;
}
.center { align-items: center; text-align: center; justify-content: center; }

h1, h2 { margin: 0; }
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-top: env(safe-area-inset-top);
}
.top h1 { font-size: 19px; flex: 1; text-align: center; }
.section-title { font-size: 14px; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: .06em; margin: 6px 0 8px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

/* ---------- кнопки ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 18px;
  border: 0; border-radius: var(--radius); padding: 15px 22px;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform .06s ease;
  min-height: 52px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-danger { background: var(--red2); color: #fff; }
.btn-ghost {
  font: inherit; font-size: 16px; background: none; border: 0; color: var(--ink-soft);
  padding: 10px 12px; cursor: pointer; min-height: 44px;
}
.btn-wide { width: 100%; }
.btn-back { font-size: 30px; line-height: 1; padding: 4px 14px; }
.row-gap { display: flex; gap: 10px; justify-content: center; align-items: center; flex-wrap: wrap; }

.input, .select {
  font: inherit; font-size: 18px; width: 100%;
  padding: 14px 16px; border-radius: var(--radius);
  border: 2px solid var(--line); background: var(--bg-card); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--accent); }
.select { width: auto; padding: 8px 12px; }

/* ---------- вход ---------- */
.screen-auth { justify-content: center; align-items: center; text-align: center; }
.logo { font-size: 64px; }
.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.12); } }
.title { font-size: 28px; }
.subtitle { color: var(--ink-soft); margin: 0; }
.error-line { color: var(--red2); min-height: 1.2em; margin: 0; font-weight: 600; }

.account-list { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.account-btn {
  display: flex; align-items: center; gap: 14px;
  font: inherit; font-size: 19px; font-weight: 600; text-align: left;
  background: var(--bg-card); color: var(--ink);
  border: 0; border-radius: var(--radius); padding: 12px 16px;
  box-shadow: var(--shadow); cursor: pointer; min-height: 60px;
}
.auth-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 8px; }

.avatar { display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--bg-sunken); flex-shrink: 0; }
.avatar.lg { font-size: 32px; width: 54px; height: 54px; }
.avatar.xl { font-size: 52px; width: 88px; height: 88px; }

.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; width: 100%; }
.emoji-cell {
  font-size: 24px; padding: 6px 0; background: var(--bg-card); border: 2px solid transparent;
  border-radius: 12px; cursor: pointer;
}
.emoji-cell.sel { border-color: var(--accent); background: var(--bg-sunken); }

/* PIN */
.pin-wrap { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.pin-dots { display: flex; gap: 14px; }
.pin-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--bg-sunken);
  border: 2px solid var(--line); }
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.pin-pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 12px; }
.pin-key {
  font: inherit; font-size: 26px; font-weight: 700; color: var(--ink);
  width: 76px; height: 64px; border: 0; border-radius: var(--radius);
  background: var(--bg-card); box-shadow: var(--shadow); cursor: pointer;
}
.pin-key:active { transform: scale(.94); }

/* ---------- лобби ---------- */
.lobby-top { padding-bottom: 4px; }
.me-chip { display: flex; align-items: center; gap: 8px; font-size: 17px; }
.guest-tag { font-size: 12px; background: var(--bg-sunken); color: var(--ink-soft);
  border-radius: 8px; padding: 2px 8px; }
.players-row { display: flex; gap: 8px; flex-wrap: wrap; }
.player-chip { display: flex; align-items: center; gap: 6px; background: var(--bg-card);
  border-radius: 999px; padding: 5px 12px 5px 6px; box-shadow: var(--shadow); font-size: 15px; }
.player-chip .avatar { width: 28px; height: 28px; font-size: 17px; }
.player-chip.me { outline: 2px solid var(--accent); }

.invite-list { display: flex; flex-direction: column; gap: 10px; }
.invite {
  display: flex; align-items: center; gap: 12px; text-align: left;
  font: inherit; background: var(--bg-card); color: var(--ink); border: 0;
  border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer;
  border-left: 5px solid var(--green);
}
.invite-emoji { font-size: 30px; }
.invite-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.invite-go { color: var(--green); font-weight: 700; white-space: nowrap; }

/* каталог: единый ряд фильтров (жанры + фасеты), одиночный выбор */
.cat-tabs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.cat-tab {
  font: inherit; font-size: 14px; font-weight: 700; white-space: nowrap;
  background: var(--bg-card); color: var(--ink-soft); border: 2px solid var(--line);
  border-radius: 999px; padding: 7px 14px; cursor: pointer; min-height: 38px;
}
.cat-tab.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.game-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.game-tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font: inherit; color: var(--ink); background: var(--bg-card); border: 0;
  border-radius: var(--radius); padding: 18px 10px 14px; box-shadow: var(--shadow); cursor: pointer;
}
.game-tile:active { transform: scale(.97); }
.tile-emoji { font-size: 40px; }
.tile-name { font-size: 16px; }
.tile-meta { font-size: 12.5px; color: var(--ink-soft); }
.tile-badges { display: flex; gap: 4px; margin-top: 2px; }
.badge { font-size: 13px; background: var(--bg-sunken); border-radius: 8px; padding: 2px 6px; }

/* ---------- комната ---------- */
.room-code { font-size: 14px; font-weight: 700; letter-spacing: .12em; color: var(--ink-soft);
  background: var(--bg-sunken); padding: 4px 10px; border-radius: 10px; }
.member-list { display: flex; flex-direction: column; gap: 8px; }
.member { display: flex; align-items: center; gap: 12px; background: var(--bg-card);
  border-radius: var(--radius); padding: 8px 14px; box-shadow: var(--shadow); }
.member-nick { font-size: 18px; font-weight: 600; flex: 1; }
.member.offline { opacity: .55; }
.offline-tag { font-size: 12px; color: var(--red2); }
.host-tag { font-size: 16px; }
.rules-block { background: var(--bg-card); border-radius: var(--radius); padding: 12px 16px; }
.rules-text p { margin: 6px 0; line-height: 1.45; }
.rules-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.room-options { display: flex; flex-direction: column; gap: 8px; }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--bg-card); border-radius: var(--radius); padding: 10px 14px; font-weight: 600; }
.room-actions { margin-top: auto; }

/* ---------- игра ---------- */
.screen-game { padding-bottom: 10px; }
.game-top h1 { font-size: 17px; }
.game-root { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.game-presence { display: none; gap: 4px; justify-content: center; font-size: 14px; }
.game-presence.has-offline { display: flex; }
.presence-dot { opacity: 1; }
.presence-dot.off { opacity: .3; filter: grayscale(1); }

/* ---------- оверлеи, тосты ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(30, 22, 10, .55);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 50;
}
.overlay-card {
  background: var(--bg); border-radius: 22px; padding: 22px;
  width: 100%; max-width: 420px; max-height: 86dvh; overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.toast-box { position: fixed; top: calc(10px + env(safe-area-inset-top)); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 100;
  pointer-events: none; }
.toast {
  background: var(--ink); color: var(--bg); border-radius: 999px; padding: 10px 20px;
  font-size: 15px; font-weight: 600; opacity: 0; transform: translateY(-12px);
  transition: all .3s ease; max-width: 90vw;
}
.toast.show { opacity: 1; transform: none; }
.toast-warn { background: var(--red2); color: #fff; }

.conn-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  background: var(--red2); color: #fff; text-align: center;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px; font-size: 14px; font-weight: 700;
}
.conn-banner.hidden { display: none; }

/* ---------- результаты ---------- */
.results { display: flex; flex-direction: column; gap: 14px; align-items: center; text-align: center; }
.results-emoji { font-size: 60px; }
.score-table { width: 100%; border-collapse: collapse; font-size: 17px; }
.score-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.score-cell { text-align: right !important; font-weight: 700; }
.winner-row { color: var(--accent); font-weight: 700; }

/* ---------- общие игровые утилиты (используются модулями игр) ---------- */
.g-status { text-align: center; font-size: 17px; font-weight: 600; margin: 6px 0; min-height: 1.4em; }
.g-big-btn {
  font: inherit; font-weight: 800; font-size: 26px; color: #fff;
  border: 0; border-radius: 24px; padding: 26px; width: 100%;
  cursor: pointer; box-shadow: var(--shadow);
}
.g-big-btn:active { transform: scale(.97); }
.g-center { flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 16px; text-align: center; }
.g-huge { font-size: 56px; font-weight: 800; }

/* ---------- ТВ ---------- */
body.tv { font-size: 20px; }
.tv-wrap { display: flex; min-height: 100dvh; gap: 30px; padding: 30px; align-items: stretch; }
.tv-side { display: flex; flex-direction: column; gap: 16px; align-items: center;
  justify-content: center; flex: 0 0 340px; text-align: center; }
.tv-side img { width: 300px; height: 300px; border-radius: 20px; background: #fff; padding: 10px; }
.tv-url { font-size: 26px; font-weight: 800; letter-spacing: .02em; }
.tv-main { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.tv-players { display: flex; flex-wrap: wrap; gap: 12px; }
.tv-players .player-chip { font-size: 20px; padding: 8px 18px 8px 8px; }
.tv-game-root { flex: 1; display: flex; flex-direction: column; min-height: 0; }
@media (max-width: 900px) {
  .tv-wrap { flex-direction: column; }
  .tv-side { flex: none; }
}
