/* ===== Шрифт и палитра ===== */
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(fonts/manrope-cyrillic-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116; }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(fonts/manrope-latin-ext-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Manrope'; font-style: normal; font-weight: 200 800; font-display: swap;
  src: url(fonts/manrope-latin-wght-normal.woff2) format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

/* Тёплый тёмный зал вокруг деревянного стола; акцент — латунь. Цвета меняются только здесь. */
:root {
  --font: 'Manrope', "Segoe UI", system-ui, sans-serif;
  --bg: #1b1917;
  --bg-sunk: #141210;
  --panel: #25211d;
  --raised: #312c26;
  --raised-hover: #3c362e;
  --line: #40382f;
  --line-strong: #5a4f41;
  --text: #f1eadc;
  --text-2: #cfc6b6;
  --muted: #9c9282;
  --faint: #6b6357;
  --accent: #e0a84a;
  --accent-strong: #c98f2e;
  --accent-ink: #241a0a;
  --accent-soft: rgba(224, 168, 74, 0.16);
  --ok: #7fbf7a;
  --ok-text: #b5dcae;
  --bad: #e2685c;
  --bad-text: #f2a79d;
  --warn: #e9a55a;
  --gold: #e8c468;
  --radius: 10px;
  --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  overscroll-behavior-x: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  display: flex;
  height: 100%;
}

#stage {
  flex: 1;
  min-width: 0;
  position: relative;
}

#board {
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.side {
  width: clamp(180px, 17vw, 260px);
  flex-shrink: 0;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

h1 {
  margin: 0;
  font-size: 24px;
}

h2 {
  margin: 4px 0 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.label {
  color: var(--muted);
  margin-bottom: 4px;
}

/* ----- Ход и счёт ----- */
#turn {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel);
  font-size: 15px;
}

#turn .hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.chip {
  display: inline-block;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  border: 1px solid var(--muted);
}

#scoreboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel);
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.card.active {
  border-color: var(--gold);
}

.card .head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 2px;
  font-weight: 600;
}

.card .head small {
  margin-left: 6px;
  font-weight: normal;
  color: var(--muted);
}

.card .head .bat {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  color: var(--bg);
  background: var(--gold);
  border-radius: 4px;
  padding: 1px 6px;
}

.card .big {
  margin-top: 4px;
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.card .big small {
  font-size: 13px;
  font-weight: normal;
  color: var(--muted);
}

.pips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 6px;
}

.pip {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  position: relative;
}

.pip::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  background: var(--panel);
}

.card .sub {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.card .sub b { color: var(--bad-text); }

/* ----- Сила удара и кнопки ----- */
#power {
  height: 12px;
  border-radius: 6px;
  background: var(--panel);
  overflow: hidden;
}

#powerFill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--ok), var(--gold) 60%, var(--bad));
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
}

button {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:hover { background: var(--raised-hover); }
button:disabled { opacity: 0.4; cursor: default; }

/* ----- Последний удар и нарушения ----- */
#lastShot .who {
  font-weight: 600;
  margin-bottom: 6px;
}

#lastShot .empty, #fouls .empty {
  color: var(--muted);
  font-size: 13px;
}

.event {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: var(--panel);
  font-size: 13px;
}

.event .icon {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  font-weight: 700;
}

.event.ok { border-left: 3px solid var(--ok); }
.event.ok .icon { color: var(--ok); }
.event.bad { border-left: 3px solid var(--bad); }
.event.bad .icon { color: var(--bad); }
.event.warn { border-left: 3px solid var(--warn); }
.event.warn .icon { color: var(--warn); }
.event.info { border-left: 3px solid var(--muted); }
.event.info .icon { color: var(--muted); }

.verdict {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
}

.verdict.keep { background: rgba(102, 187, 106, 0.18); color: var(--ok-text); }
.verdict.pass { background: rgba(144, 164, 174, 0.15); color: var(--text-2); }
.verdict.foul { background: rgba(239, 83, 80, 0.18); color: var(--bad-text); }
.verdict.win { background: rgba(255, 193, 7, 0.2); color: var(--gold); }

#fouls table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#fouls th, #fouls td {
  padding: 4px;
  text-align: center;
}

#fouls th:first-child, #fouls td:first-child {
  text-align: left;
  color: var(--text-2);
}

#fouls th {
  font-weight: normal;
  color: var(--muted);
}

#fouls td.hot { color: var(--bad-text); font-weight: 700; }

#fouls .history {
  margin-top: 10px;
  font-size: 12px;
}

#fouls .history div {
  padding: 3px 0;
  border-top: 1px solid #2c3439;
  color: var(--text-2);
}

/* ----- Выдвижная панель ----- */
#drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 92vw);
  padding: 16px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  transition: transform 0.25s ease;
  z-index: 10;
}

#drawer.closed {
  transform: translateX(105%);
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 600;
}

.drawer-head button {
  padding: 2px 10px;
}

.mode {
  display: flex;
  gap: 8px;
}

.mode label {
  flex: 1;
  color: var(--muted);
  font-size: 12px;
}

.mode select, label.select select {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--raised);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

details summary {
  cursor: pointer;
  color: var(--muted);
}

.help {
  margin: 6px 0 0;
  padding-left: 18px;
  font-size: 13px;
}

.help li { margin-bottom: 4px; }

.note {
  margin: 2px 0 4px 22px;
  font-size: 12px;
  color: var(--muted);
}

label.check {
  display: block;
  margin-top: 6px;
}

label.range, label.select {
  display: block;
  margin-top: 8px;
}

label.range span {
  float: right;
  color: var(--muted);
}

label.range input {
  width: 100%;
}

.log {
  flex: 1;
  min-height: 160px;
  display: flex;
  flex-direction: column;
}

#log {
  flex: 1;
  margin: 0;
  padding: 6px 6px 6px 26px;
  background: var(--bg);
  border-radius: 6px;
  overflow-y: auto;
  font-size: 12px;
}

#log li { margin-bottom: 2px; }
#log li.shot { margin-top: 6px; color: #fff; font-weight: 600; }
#log li.foul { color: var(--bad-text); }
#log li.ok { color: var(--ok-text); }
#log li.info { color: var(--muted); }

/* ----- Окна: статистика, игра по сети ----- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.55);
  transition: opacity 0.2s;
}

.modal.closed {
  opacity: 0;
  pointer-events: none;
}

.modal .sheet {
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

#recordsBody h3 {
  margin: 14px 0 6px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

#recordsBody .empty {
  margin-top: 12px;
  color: var(--muted);
}

table.rec {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.rec th, table.rec td {
  padding: 5px 4px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

table.rec th {
  font-weight: normal;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

table.rec th:first-child, table.rec td:first-child { text-align: left; }
table.rec td.w { color: var(--ok-text); }
table.rec td.l { color: var(--bad-text); }
table.rec tr.none td { color: var(--faint); }
table.rec tr.total td { font-weight: 700; border-bottom: none; }

.streak, .duo {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-2);
}

.duo small { color: var(--muted); }

.recent .game {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: var(--bg-sunk);
  border-left: 3px solid var(--muted);
  font-size: 13px;
}

.recent .game.ok { border-left-color: var(--ok); }
.recent .game.bad { border-left-color: var(--bad); }
.recent .res { font-weight: 600; }
.recent .sc { font-weight: 700; text-align: right; }
.recent .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }

.sheet-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.sheet-foot .note { flex: 1; margin: 0; cursor: pointer; }

.modal .sheet.cabinet {
  width: min(560px, 100%);
}

.cab-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 12px 0 0;
  padding: 3px;
  border-radius: 8px;
  background: var(--bg);
}

.cab-tabs button {
  flex: 1 1 18%;
  min-width: 64px;
  min-height: 40px;
  padding: 8px 2px;
  border: none;
  border-radius: 6px;
  background: transparent;
  font-weight: 600;
  font-size: 11px;
}

.cab-tabs button.on {
  background: var(--raised);
  color: var(--gold);
}

.cab-pane { display: none; }
.cab-pane.on { display: block; }

.trace-game {
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #2a3338;
}
.trace-shot {
  margin: 8px 0;
  padding: 8px 10px;
  background: var(--bg-sunk);
  border-radius: 8px;
  font-size: 12px;
}
.trace-shot.hot { border: 1px solid var(--bad); }
.trace-shot .spike { color: var(--bad-text); }
.trace-spikes {
  margin: 6px 0 0;
  padding-left: 18px;
  color: var(--bad-text);
}
#traceLive { max-height: 240px; overflow-y: auto; }

#account .field {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

#account .field input {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 16px;
}

.cab-card {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
}

.cab-id {
  display: flex;
  gap: 12px;
  align-items: center;
}

.cab-who { flex: 1; min-width: 0; }

.cab-rank {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.cab-rank.green { color: var(--ok-text); }
.cab-rank.gold { color: var(--gold); }
.cab-rank-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.xp { margin-top: 12px; }
.xp-top {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
}
.xp-bar {
  height: 8px;
  margin-top: 6px;
  border-radius: 99px;
  background: var(--bg);
  overflow: hidden;
}
.xp-bar > div {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.skins {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.skin {
  padding: 8px;
  border-radius: 10px;
  background: var(--bg-sunk);
  text-align: center;
  border: 2px solid transparent;
}
.skin.on { border-color: var(--gold); }
.skin.locked { opacity: 0.42; filter: grayscale(0.4); }
.skin .sw {
  height: 28px;
  border-radius: 6px;
  margin-bottom: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.skin .name { font-size: 13px; font-weight: 600; }
.skin .need { margin-top: 2px; font-size: 11px; color: var(--muted); }

.cab-sync {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.cab-sync.on { color: var(--ok-text); }

.cab-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 14px;
}

.cab-stats div {
  padding: 10px 4px;
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.cab-stats b {
  display: block;
  font-size: 20px;
  line-height: 1.15;
}

.cab-stats span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
}

.cab-prize-line {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 10px 12px;
  text-align: left;
  background: var(--panel);
}

.cab-prize-line b { color: var(--gold); }

#cabGoAuth { width: 100%; margin-top: 12px; }

.friend-code {
  margin-top: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
}

.fr-add {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin: 12px 0;
}

.fr-add .field { flex: 1; min-width: 0; margin: 0; }
.fr-add button { flex-shrink: 0; min-height: 42px; }
#frAdd { text-transform: uppercase; letter-spacing: 0.1em; }

.friend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
}

.friend-row .name { font-weight: 600; }
.friend-row .hint { font-size: 12px; color: var(--muted); }
.friend-row span { flex: 1; min-width: 0; }
.friend-row > div:first-child { flex: 1; min-width: 0; }
.friend-row button { flex-shrink: 0; padding: 8px 12px; }

.friends-invite {
  margin: 12px 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
}

.friends-invite .head {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.friends-invite .friend-row {
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--panel);
}

#playInvite, #friendAsk { z-index: 30; }
#playInvite .sheet-actions, #friendAsk .sheet-actions { margin-top: 16px; flex-wrap: wrap; }

.cab-section-head {
  margin: 12px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.acc-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.acc-photo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent);
  flex-shrink: 0;
}

.acc-photo.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ok-text);
}

.acc-mail { font-weight: 600; }

.acc-or {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0;
}

.acc-mail-actions { justify-content: stretch; }
.acc-mail-actions button { flex: 1; }

#accountBody { margin-top: 8px; }
#accGoogle { width: 100%; }

#accOut, #accDelete { width: 100%; margin-top: 10px; }
#accOut { margin-top: 16px; }
button.danger {
  background: #4a2424;
  border-color: #7a3a3a;
  color: var(--bad-text);
}
button.danger:hover { background: #5c2a2a; }

.prizes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}

.prize {
  padding: 10px 8px;
  border-radius: 10px;
  background: var(--bg-sunk);
  text-align: center;
}

.prize.off { opacity: 0.42; filter: grayscale(1); }

.prize .ico { font-size: 26px; line-height: 1.2; }
.prize .name { margin-top: 4px; font-size: 13px; font-weight: 600; }
.prize .hint { margin-top: 2px; font-size: 11px; color: var(--muted); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover { background: var(--accent-strong); }

#onlineBody {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

#onlineBody input {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
  font-size: 16px;
}

#onlineBody .field {
  color: var(--muted);
  font-size: 12px;
}

#onlineBody .field input { margin-top: 3px; }

#onlineBody .join {
  display: flex;
  gap: 8px;
}

#onlineBody .join input { flex: 1; min-width: 0; }
#netCode { text-transform: uppercase; letter-spacing: 0.1em; }

.invite {
  display: flex;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--bg-sunk);
}
.invite-qr {
  flex: 0 0 168px;
  width: 168px;
  height: 168px;
  padding: 8px;
  border-radius: 12px;
  background: #f4ead8;
}
.invite-qr svg { display: block; width: 100%; height: 100%; }
.invite-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.invite-actions button { padding: 10px 14px; border-radius: 12px; }
.invite-link {
  width: 100%;
  margin-top: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.invite.compact { align-items: center; }
.invite.compact .invite-qr { flex-basis: 88px; width: 88px; height: 88px; padding: 4px; }
@media (max-width: 560px) {
  .invite { flex-direction: column; align-items: center; }
  .invite-qr, .invite.compact .invite-qr { width: 200px; height: 200px; flex-basis: auto; }
}

#onlineBody .or {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.room-code { font-size: 16px; }
.room-code b { font-size: 26px; letter-spacing: 0.12em; margin-left: 6px; }

.net-error {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(239, 83, 80, 0.18);
  color: var(--bad-text);
  font-size: 13px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 0;
  background: var(--muted);
}

.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.dot.off { background: var(--bad); }
.dot.wait { background: var(--warn); }

#turn .netline {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}

#turn .match, #mini .match, .match-bar b {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
  color: var(--text);
}

.match-bar {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.match-bar b { font-size: 22px; }

#btnOnline { width: 100%; }

#onlineBody .halves {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#onlineBody .half {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
}

#onlineBody .half h3 {
  margin: 0;
  font-size: 15px;
}

#onlineBody .half button { margin-top: auto; }
#online .sheet { width: min(620px, 100%); }

/* ----- Окна «Сложность» и «Новая партия» ----- */
.tip {
  font-size: 12px;
  color: var(--muted);
}

.tip:empty { display: none; }

#levelNetNote {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: rgba(233, 165, 90, 0.16);
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--warn) 50%, transparent);
  font-weight: 600;
  line-height: 1.45;
}

.group {
  margin-top: 16px;
  transition: opacity 0.2s;
}

.group.dim { opacity: 0.4; }
.group.locked { opacity: 0.55; pointer-events: none; }

#onlineBody .rules {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  font-size: 13px;
}

#onlineBody .rules ul { margin: 6px 0 0; padding-left: 18px; color: var(--text-2); }
#onlineBody .rules .head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 600; }
#onlineBody .rules .head button { padding: 4px 10px; font-weight: normal; }
#roomRules label.check { margin-top: 4px; }
.offer-banner {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.offer-banner.wait { border-color: var(--line-strong); background: var(--bg-sunk); color: var(--text-2); }
.offer-banner.play {
  border-color: var(--ok);
  background: rgba(127, 191, 122, 0.14);
}
.offer-banner .kicker, .desk-note .kicker {
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.offer-banner.play .kicker, .desk-note.play .kicker { color: var(--ok-text); }
.desk-note.rules .kicker { color: var(--gold); }
#deskNotes {
  position: fixed;
  z-index: 18;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100% - 24px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
#deskNotes:empty { display: none; }
.desk-note {
  pointer-events: auto;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--accent);
  background: #2a2418;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.desk-note.play { border-color: var(--ok); background: #1c2820; }
.desk-note.wait { border-color: var(--line-strong); background: var(--panel); color: var(--text-2); font-weight: 500; }
.desk-note .offer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
button.attention {
  box-shadow: inset 0 0 0 2px var(--gold);
}
#tabbar button.attention { color: var(--gold); }
.offer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.offer-list { margin: 10px 0 0; padding-left: 18px; color: var(--text-2); font-size: 13px; line-height: 1.45; }
#ruleOffer { z-index: 30; }
#ruleOffer .sheet-actions { margin-top: 16px; }

.group-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.seg {
  display: flex;
  padding: 3px;
  gap: 3px;
  border-radius: 9px;
  background: var(--bg);
  border: 1px solid var(--line);
}

.seg button {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.2;
}

.seg button:hover { background: var(--raised-hover); }

.seg button.on {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.seg + .tip { margin-top: 6px; }

.sheet-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.sheet-actions button { min-width: 110px; padding: 10px 14px; touch-action: manipulation; }
button { touch-action: manipulation; }
#roomRules { z-index: 25; }
#roomRules .sheet-actions {
  position: sticky;
  bottom: 0;
  margin-bottom: 0;
  padding-top: 12px;
  background: var(--panel);
}
.modal .sheet.small { width: min(400px, 100%); }
#confirmNewText { margin: 14px 0 0; font-size: 15px; }

#turn .timer {
  float: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
}

#turn .timer.low { color: var(--bad); }

/* ----- Телефон и планшет ----- */
.short { display: none; }
#touchBar { display: none; }
#tabbar { display: none; }
#mini { display: none; }
#touchBar .undo { display: none; }

/* ----- Реакции в сетевой партии: кнопка встаёт на место «Отменить удар», которое по сети не работает ----- */
.react { display: none; }

/* Быстрый выключатель звука — только на сенсорной нижней панели; на компьютере звук в настройках. */
#touchBar .sound svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
#touchBar .sound.muted { color: var(--muted); }
/* Боком кнопка звука есть в левой колонке, а на узкой правой панели ей не хватает места рядом с поворотом прицела. */
@media (orientation: landscape) {
  #touchBar .sound, body.net #right #touchBar .react { display: none; }
}
.buttons .sound.muted svg { color: var(--bad); }
label.range.off { opacity: 0.5; }
body.net .buttons .undo { display: none; }
body.net .buttons .react { display: block; }

#reactBar {
  position: fixed;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 52px);
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--raised-hover);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#reactBar.closed { display: none; }

#reactBar button {
  height: 48px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 30px;
  line-height: 1;
}

#reactBar button:active { background: var(--raised-hover); }

.float-react {
  position: absolute;
  left: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  animation: react-float 2.4s ease-out forwards;
}

.float-react.peer { top: 14%; }
.float-react.mine { bottom: 14%; }
.float-react .e { font-size: 64px; line-height: 1; filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.45)); }

.float-react .who {
  margin-top: 4px;
  padding: 1px 8px;
  border-radius: 8px;
  background: rgba(20, 24, 27, 0.75);
  font-size: 12px;
  color: var(--text-2);
}

@keyframes react-float {
  0% { opacity: 0; transform: translate(-50%, 12px) scale(0.4); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.15); }
  20% { transform: translate(-50%, 0) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -14px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -30px) scale(0.9); }
}

@media (pointer: coarse) {
  button {
    min-height: 40px;
    touch-action: manipulation;
  }

  #touchBar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  #touchBar span {
    flex: 1;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
  }

  #touchBar button {
    width: 64px;
    min-height: 48px;
    font-size: 24px;
    line-height: 1;
    user-select: none;
    -webkit-user-select: none;
  }

  #touchBar button:active { background: var(--line-strong); }
  body.net #touchBar .react { display: block; font-size: 22px; }

  details summary { padding: 6px 0; }
  label.check { padding: 4px 0; }
}

@media (orientation: portrait) and (max-width: 1024px) {
  :root { --tabbar-h: 58px; }

  body {
    display: flex;
    flex-direction: column;
  }

  #app {
    flex: 1;
    min-height: 0;
    flex-direction: column;
  }

  /* Нижняя панель вкладок, как в приложении. */
  #tabbar {
    display: flex;
    flex-shrink: 0;
    height: var(--tabbar-h);
    background: #20272b;
    border-top: 1px solid var(--line);
  }

  #tabbar button {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 2px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.1;
  }

  #tabbar button:active { background: var(--panel); }
  #tabbar button.on, #tabbar button.live { color: var(--ok); }
  #tabbar button.attention { color: var(--gold); }

  #tabbar svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  #tabbar span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  #left .buttons { display: none; }

  /* Табло в одну строку. */
  #left #turn, #left #scoreboard { display: none; }

  #mini {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    height: 34px;
  }

  #deskNotes { top: 52px; }

  #mini .side-score {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-radius: 8px;
    background: var(--panel);
    border: 2px solid transparent;
    white-space: nowrap;
  }

  #mini .side-score.right { justify-content: flex-end; }
  #mini .side-score.active { border-color: var(--gold); }
  #mini .chip { margin: 0; width: 12px; height: 12px; }
  #mini b { font-size: 18px; line-height: 1; }
  #mini small { color: var(--muted); }

  #mini .who {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    color: var(--muted);
  }

  #mini .side-score:not(.right) .who { margin-left: 2px; }
  #mini .right .who { margin-right: 2px; }
  #mini .debt { font-size: 11px; color: var(--bad-text); }

  #mini .mid {
    flex: 0 0 auto;
    max-width: 30%;
    display: flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-2);
    white-space: nowrap;
  }

  #mini .mid .status { overflow: hidden; text-overflow: ellipsis; }
  #mini .match { font-size: 16px; margin-right: 6px; }
  #mini .timer { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
  #mini .timer.low { color: var(--bad); }
  #mini.timed .status { display: none; }

  #touchBar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  #touchBar .undo {
    display: block;
    flex: 1;
    width: auto;
    font-size: 14px;
  }

  #touchBar span { display: none; }
  body.net #touchBar .undo { display: none; }
  body.net #touchBar .react { flex: 1; width: auto; font-size: 15px; }

  /* Настройки — отдельная вкладка на весь экран над панелью. */
  #drawer {
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    width: auto;
    padding-top: calc(16px + env(safe-area-inset-top));
    border-left: none;
    box-shadow: none;
    background: var(--bg);
    transition: opacity 0.2s, transform 0.2s;
  }

  #drawer.closed {
    transform: translateY(16px);
    opacity: 0;
    pointer-events: none;
  }

  #btnDrawerClose { display: none; }

  /* Окна выезжают снизу. */
  .modal {
    align-items: flex-end;
    padding: 0;
  }

  .modal .sheet, .modal .sheet.small, #online .sheet {
    width: 100%;
    max-height: 92%;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    transition: transform 0.25s ease;
  }

  .modal.closed .sheet { transform: translateY(100%); }

  #onlineBody .halves { grid-template-columns: 1fr; }
  .sheet-actions button { flex: 1; }

  .side {
    width: auto;
    padding: 8px 10px;
    gap: 8px;
  }

  #left {
    flex-direction: row;
    flex-wrap: wrap;
    flex-shrink: 0;
    overflow: visible;
  }

  #left h1, #left .block { display: none; }

  #turn {
    flex: 1 1 100%;
    padding: 6px 10px;
    font-size: 14px;
  }

  #turn .hint {
    display: inline;
    margin: 0 0 0 6px;
  }

  #scoreboard {
    flex: 1 1 100%;
    flex-direction: row;
  }

  .card {
    flex: 1;
    min-width: 0;
    padding: 6px 8px;
  }

  .card .big { font-size: 22px; }
  .card .sub { margin-top: 4px; }

  .buttons {
    flex: 1 1 100%;
    flex-direction: row;
    margin-top: 0;
  }

  .buttons button {
    flex: 1;
    padding: 6px 4px;
  }

  .buttons #btnCabinet, .buttons #btnSound, .buttons #btnDrawer { flex: 0 0 44px; font-size: 18px; }
  .buttons #btnOnline { flex: 1.3; }

  .full { display: none; }
  .short { display: inline; }

  #stage {
    flex: 0 0 auto;
    height: min(calc(100vw + 44px), 66dvh);
  }

  #right {
    flex: 1;
    min-height: 0;
  }
}

/* Телефон в портрете: стол не выше 66% экрана, журнал занимает остаток. */
@media (orientation: portrait) and (max-width: 699px) {
  #stage {
    flex: 0 0 auto;
    height: min(calc(100vw + 44px), 66dvh);
  }
}

/* Планшет в портрете: стол занимает всё свободное место, табло крупнее, последний удар виден. */
@media (orientation: portrait) and (min-width: 700px) and (max-width: 1024px) {
  #stage {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
  }

  #mini { height: 44px; }
  #mini b { font-size: 22px; }
  #mini .timer { font-size: 18px; }

  #touchBar button { width: 72px; min-height: 52px; font-size: 26px; }
  #touchBar .undo, body.net #touchBar .react { font-size: 16px; }

  #right {
    flex: 0 0 auto;
    max-height: 22vh;
    min-height: 0;
    padding-top: 0;
  }

  #right h2:nth-of-type(2), #fouls { display: none; }

  .modal {
    align-items: center;
    padding: 24px;
  }

  .modal .sheet, .modal .sheet.small, #online .sheet {
    width: min(540px, 92vw);
    max-height: 80vh;
    border-radius: 16px;
    padding-bottom: 16px;
  }

  .modal.closed .sheet { transform: scale(0.98); opacity: 0; }
}

/* Планшет лёжа: стол по центру, кнопки слева крупными, без нижней панели вкладок. */
/* Планшет боком (класс ставит ui.js): у планшетов Samsung с пером браузер может считать главным вводом перо,
   поэтому сенсорный экран распознаём не только по (pointer: coarse). Слева кнопки, табло справа. */
body.tablet-side #tabbar { display: none; }

body.tablet-side .side {
  width: clamp(168px, 15vw, 210px);
  padding: 10px;
  gap: 8px;
}

body.tablet-side #left h1, body.tablet-side #left .block { display: none; }

body.tablet-side #turn { padding: 8px 10px; font-size: 14px; }
body.tablet-side .card { padding: 8px 10px; }
body.tablet-side .card .big { font-size: 22px; }

/* Слева только кнопки, сверху вниз и с полными подписями; табло — справа (переносит ui.js). */
body.tablet-side #left { justify-content: flex-start; }
body.tablet-side .buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 0;
}

body.tablet-side #left .buttons button {
  min-height: 48px;
  padding: 8px 10px;
  font-size: 14px;
  line-height: 1.2;
  justify-content: flex-start;
  text-align: left;
}

body.tablet-side #left .buttons button svg { flex-shrink: 0; }
body.tablet-side .full { display: inline; }
body.tablet-side .short { display: none; }

body.tablet-side #touchBar button { width: 68px; min-height: 52px; }
/* Справа места меньше: счёт числом, без ряда кружков. */
body.tablet-side .card .pips { display: none; }
body.tablet-side #touchBar { justify-content: space-between; }
body.tablet-side #touchBar span { display: none; }
body.tablet-side #touchBar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

@media (orientation: landscape) and (max-height: 540px) {
  .side {
    width: clamp(150px, 22vw, 210px);
    padding: 8px;
    gap: 6px;
    font-size: 13px;
  }

  #left h1, #left .block { display: none; }

  #turn { padding: 6px 8px; font-size: 13px; }
  .card { padding: 6px 8px; }
  .card .big { font-size: 20px; }
  .card .head small, .card .pips { display: none; }
  .card .sub { margin-top: 2px; }
  #scoreboard { gap: 6px; }

  .buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .buttons button { padding: 4px; }
  .buttons #btnOnline, .buttons #btnDrawer { grid-column: 1 / -1; }
  .full { display: none; }
  .short { display: inline; }

  .event { padding: 4px 6px; font-size: 12px; }
  #fouls table { font-size: 12px; }
}

/* ----- Обучение в первой партии ----- */
#coach {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 5;
  width: min(440px, calc(100% - 24px));
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(32, 39, 43, 0.96);
  border: 1px solid var(--accent);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s;
}
#coach.closed { opacity: 0; pointer-events: none; }
#coach .coach-step { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
#coach .coach-title { font-weight: 600; font-size: 15px; margin: 2px 0 4px; }
#coach .coach-text { font-size: 13px; color: var(--text-2); }
#coach .coach-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
#coach .coach-actions button { padding: 8px 14px; }


/* ===== Оформление: кнопки, поля, окна ===== */
html, body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::selection { background: var(--accent); color: var(--accent-ink); }

h1 { font-size: 22px; font-weight: 800; letter-spacing: 0.01em; }
h2, .group-title { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; color: var(--muted); }

/* --- Кнопки: обычная, главная, опасная --- */
button {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--raised);
  color: var(--text);
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.06s;
}
button:hover:not(:disabled) { background: var(--raised-hover); border-color: var(--line-strong); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.38; }
button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button.primary {
  border-color: #b98428;
  background: linear-gradient(180deg, #edba5e, #d59b37);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 2px 8px rgba(0, 0, 0, 0.35);
}
button.primary:hover:not(:disabled) { background: linear-gradient(180deg, #f3c56f, #dca544); border-color: #c99234; }
button.danger { border-color: #7a3a33; background: #4a2420; color: var(--bad-text); }
button.danger:hover:not(:disabled) { background: #5c2c27; border-color: #94463d; }

/* Кнопки левой панели: значок и подпись. */
.buttons { gap: 7px; }
.buttons button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; text-align: left; }
.buttons button svg, #btnAccount svg {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.buttons button:not(.primary) svg { color: var(--muted); }
.buttons button:hover:not(.primary) svg { color: var(--accent); }
.buttons button.react { display: none; }
body.net .buttons .react { display: flex; }
#btnAccount { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
@media (max-width: 1024px), (pointer: coarse) {
  .buttons button { justify-content: center; gap: 6px; }
}

/* --- Переключатели --- */
.seg { padding: 4px; gap: 4px; border-radius: 12px; background: var(--bg-sunk); border-color: var(--line); }
.seg button { border-radius: 9px; color: var(--muted); font-weight: 600; }
.seg button:hover:not(:disabled) { background: var(--raised); color: var(--text); }
.seg button.on, .seg button.on:hover {
  background: var(--accent-soft);
  color: #f6d595;
  box-shadow: inset 0 0 0 1px rgba(224, 168, 74, 0.6);
}
.cab-tabs { background: var(--bg-sunk); border-radius: 12px; }
.cab-tabs button { border-radius: 9px; color: var(--muted); }
.cab-tabs button.on { background: var(--accent-soft); color: #f6d595; box-shadow: inset 0 0 0 1px rgba(224, 168, 74, 0.6); }

/* --- Поля ввода --- */
input[type="text"], input[type="email"], input[type="password"], input:not([type]), select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-sunk);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder { color: var(--faint); }
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus, input:not([type]):focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239c9282' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}
input[type="checkbox"] { width: 18px; height: 18px; margin: 0 8px 0 0; vertical-align: -4px; accent-color: var(--accent); }
label.check { line-height: 1.4; }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--raised-hover); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--raised-hover); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--accent-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--accent-ink); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

/* --- Окна --- */
.modal { background: rgba(10, 8, 6, 0.62); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }
.modal .sheet {
  padding: 18px;
  border-radius: var(--radius-lg);
  border-color: var(--line);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal.closed .sheet { transform: translateY(10px) scale(0.985); }
.drawer-head { font-size: 18px; font-weight: 800; }
.drawer-head button, .modal .drawer-head .close {
  width: 34px; height: 34px; min-height: 0; padding: 0;
  border-radius: 50%; border-color: transparent; background: var(--raised); color: var(--muted);
}
.drawer-head button:hover:not(:disabled) { color: var(--text); background: var(--raised-hover); }
.sheet-actions button { border-radius: 12px; }
.tip { color: var(--muted); }
#levelNetNote { border-radius: var(--radius); }

/* --- Панели счёта и карточки --- */
.card { border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(224, 168, 74, 0.18); }
.card .big { font-weight: 800; font-variant-numeric: tabular-nums; }
.card .head .bat { background: var(--accent); color: var(--accent-ink); font-weight: 800; }
#turn { border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
#power { height: 8px; border-radius: 4px; background: var(--bg-sunk); }
#powerFill { border-radius: 4px; }
.event, .verdict, .trace-shot, .recent .game, .cab-card, .cab-stats div, .skin, .prize, #onlineBody .half, #onlineBody .rules {
  border-radius: var(--radius);
}
.skin.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.xp-bar { border-radius: 4px; background: var(--bg-sunk); }
.xp-bar > div { border-radius: 4px; background: linear-gradient(90deg, var(--accent-strong), var(--gold)); }

#coach { border-radius: var(--radius-lg); border-color: var(--accent); background: rgba(37, 33, 29, 0.97); }

/* --- Настройки: раскрывающиеся разделы --- */
details { border-top: 1px solid var(--line); }
details summary { padding: 11px 2px; font-weight: 700; color: var(--text-2); }
details[open] summary { color: var(--text); }
details summary:hover { color: var(--accent); }

/* --- Нижняя панель на телефоне --- */
#tabbar { background: rgba(27, 25, 23, 0.94); border-top: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
#tabbar button { border: none; background: transparent; color: var(--muted); font-weight: 600; box-shadow: none; transform: none; }
#tabbar button.on, #tabbar button.live { color: var(--accent); }
#touchBar button { border-radius: 12px; }
#reactBar { border-radius: var(--radius-lg); }

.tip.warn { color: var(--gold); }
[hidden] { display: none !important; }
button.ghost { border-color: transparent; background: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { background: var(--raised); color: var(--text); border-color: transparent; }

/* ===== Залы: карточки, которые листаются ===== */
.modal .sheet.rooms-sheet { width: min(760px, 100%); padding-left: 0; padding-right: 0; overflow: hidden; }
.rooms-sheet > .drawer-head, .rooms-sheet > .tip { margin-left: 18px; margin-right: 18px; }
.rooms-sheet > .tip.warn { text-align: center; margin-top: 10px; }
.rooms-stage { position: relative; margin-top: 12px; }
#roomsList {
  --card: min(330px, 78vw);
  display: flex;
  gap: 16px;
  padding: 14px calc(50% - var(--card) / 2) 18px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
#roomsList::-webkit-scrollbar { display: none; }

.rc {
  --tone: #e0a84a;
  flex: 0 0 var(--card);
  display: flex;
  flex-direction: column;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: var(--raised);
  overflow: hidden;
  opacity: 0.45;
  transform: scale(0.94);
  transition: opacity 0.25s, transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  cursor: pointer;
}
.rc.cur { opacity: 1; transform: none; cursor: default; box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5); border-color: var(--line-strong); }
.rc.here.cur { border-color: var(--tone); }
.rc[data-card="dacha"] { --tone: #9ccf7a; }
.rc[data-card="yard"] { --tone: #7fc3c9; }
.rc[data-card="club"] { --tone: #e0a84a; }
.rc[data-card="city"] { --tone: #e58f6b; }
.rc[data-card="grand"] { --tone: #f0cf6a; }
.rc.extra { --tone: #b7ad9c; }
.rc.shut { --tone: #8a8275; }

.rc-art {
  position: relative;
  height: 148px;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--tone) 34%, transparent), transparent 70%),
    linear-gradient(180deg, #2f2a24, #211e1a);
  border-bottom: 1px solid var(--line);
}
.rc-art svg {
  width: 168px; height: 106px;
  fill: none; stroke: var(--tone); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--tone) 35%, transparent));
}
.rc-no, .rc-here {
  position: absolute; top: 10px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.rc-no { left: 12px; background: rgba(0, 0, 0, 0.35); color: var(--text-2); }
.rc-here { right: 12px; background: var(--tone); color: #1d1608; }

.rc-body { flex: 1; padding: 14px 16px 6px; }
.rc-body h3 { margin: 0; font-size: 21px; font-weight: 800; letter-spacing: 0.01em; }
.rc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.rc-chips span {
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-sunk); border: 1px solid var(--line);
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.rc-body p { margin: 10px 0 0; min-height: 3.9em; font-size: 13px; line-height: 1.45; color: var(--muted); }
.rc-progress { display: flex; align-items: center; gap: 9px; margin-top: 10px; font-size: 12px; font-weight: 600; color: var(--gold); }
.rc-progress.done { color: var(--ok-text); }
.rc.shut .rc-progress { color: var(--muted); }
.rc-pips { display: inline-flex; gap: 5px; flex-shrink: 0; }
.rc-pips i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid currentColor; opacity: 0.55; }
.rc-pips i.on { background: currentColor; opacity: 1; }

.rc-foot { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; padding: 12px 16px 16px; }
.rc-xp { white-space: nowrap; }
.rc-actions { margin-left: auto; }
.rc-xp { font-size: 11px; line-height: 1.5; color: var(--muted); }
.rc-xp b { color: var(--text-2); font-size: 13px; }
.rc-actions { display: flex; gap: 8px; }
.rc-actions button { padding: 11px 18px; border-radius: 12px; white-space: nowrap; }
.rc:not(.cur) .rc-actions button { pointer-events: none; }
.rc.fresh .rc-art { animation: roomFresh 1.4s ease-out 3; }
@keyframes roomFresh { 50% { filter: brightness(1.6); } }

.rooms-arrow {
  position: absolute; top: 50%; z-index: 2;
  width: 42px; height: 42px; margin-top: -21px; padding: 0;
  border-radius: 50%; background: var(--panel); border-color: var(--line-strong);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
}
.rooms-arrow svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
#roomsPrev { left: 14px; }
#roomsNext { right: 14px; }
.rooms-arrow:disabled { opacity: 0; pointer-events: none; }
.rooms-dots { display: flex; justify-content: center; gap: 4px; }
.rooms-dots button {
  width: 22px; height: 22px; min-height: 0; padding: 0; border: none; background: transparent; position: relative;
}
.rooms-dots button::after {
  content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--line-strong); transition: background 0.2s, transform 0.2s;
}
.rooms-dots button.on::after { background: var(--accent); transform: scale(1.35); }
@media (pointer: coarse), (max-width: 560px) {
  .rooms-arrow { display: none; }
  #roomsList { --card: min(330px, 84vw); gap: 12px; }
}
@media (max-height: 700px) {
  .rc-art { height: 104px; }
  .rc-art svg { width: 130px; height: 82px; }
  .rc-body p { min-height: 0; }
}

/* ===== Итог партии ===== */
.go-sheet { text-align: center; padding: 26px 22px 20px !important; }
.go-room { font-size: 11px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted); }
.go-title { margin-top: 6px; font-size: 30px; font-weight: 800; letter-spacing: 0.01em; }
#gameOver[data-result="win"] .go-title { color: var(--gold); }
#gameOver[data-result="loss"] .go-title { color: var(--text-2); }
.go-score { display: flex; justify-content: center; align-items: baseline; gap: 10px; margin-top: 10px; font-variant-numeric: tabular-nums; }
.go-score b { font-size: 44px; font-weight: 800; line-height: 1; }
.go-score span { font-size: 28px; color: var(--faint); }
.go-xp { display: inline-block; margin-top: 12px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: #f6d595; font-weight: 700; }
.go-line { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; font-weight: 600; color: var(--text-2); }
.go-line.gold { color: var(--gold); font-size: 15px; }
.go-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.go-actions button { padding: 12px; border-radius: 12px; }
.go-actions .go-pct { margin-left: 8px; font-variant-numeric: tabular-nums; }

/* ----- Плашка о новых условиях над столом ----- */
.offer-notice {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 20px);
  padding: 6px 6px 6px 14px;
  border-radius: 12px;
  background: rgba(27, 25, 23, 0.94);
  border: 1px solid var(--line-strong);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}
.offer-notice[hidden] { display: none; }
.offer-notice.incoming { border-color: var(--gold); color: var(--text); }
.offer-notice span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.offer-notice button { flex-shrink: 0; min-height: 36px; padding: 6px 12px; border-radius: 9px; }
.offer-notice.incoming button { background: var(--gold); color: #1b1917; border-color: var(--gold); }
#roomRules [hidden] { display: none !important; }
.offer-notice.inline {
  position: static;
  transform: none;
  max-width: none;
  flex-shrink: 0;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* ----- Телефон и планшет в портрете: круглые кнопки под столом и строка последнего удара ----- */
.shot-summary { display: none; }
#btnAccount[hidden] { display: none; }

@media (orientation: portrait) and (max-width: 1024px) {
  #right #touchBar { gap: 10px; }
  #right #touchBar span { display: none; }
  #right #touchBar button {
    flex: 0 0 auto;
    width: 48px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
  }
  /* Поворот прицела — слева рядом; справа отмена (по сети — реакция) и звук. */
  #right #touchBar .undo { margin-left: auto; }
  #right #touchBar .react { display: none; }
  body.net #right #touchBar .undo { display: none; }
  body.net #right #touchBar .react { display: flex; margin-left: auto; }
  #right #touchBar svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .shot-summary {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    text-align: left;
    color: var(--text-2);
  }
  .shot-summary span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .shot-summary svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s;
  }
  body.details-open .shot-summary svg { transform: rotate(180deg); }
  body:not(.details-open) #right > h2,
  body:not(.details-open) #right #lastShot,
  body:not(.details-open) #right #fouls { display: none !important; }
  body.details-open #right > h2,
  body.details-open #right #lastShot,
  body.details-open #right #fouls { display: block !important; }
}

/* ----- Залы: вход в игру по сети ----- */
.rooms-online {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
}
.rooms-online svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ----- Настройки: раздел для разработчика свёрнут и приглушён ----- */
#drawer details.dev > summary { color: var(--muted); }
#drawer details.dev details { margin-top: 8px; }

/* Телефон боком: кнопки в две колонки не шире панели, подпись прицела не помещается. */
@media (orientation: landscape) and (max-height: 540px) {
  .buttons { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .buttons button { min-width: 0; overflow: hidden; }
  /* Места мало: значки без подписей, «По сети» — с подписью на всю ширину. */
  .buttons button:not(#btnOnline) span { display: none; }
  .buttons button:not(#btnOnline) { justify-content: center; font-size: 18px; }
  #right #touchBar span { display: none; }
  #right #touchBar { justify-content: space-between; }
}

/* Латышский длиннее: переключатели из четырёх кнопок чуть мельче шрифтом, чтобы подписи не переносились. */
html[lang="lv"] #roomRules .seg button { font-size: 12.5px; padding-left: 4px; padding-right: 4px; }

/* ----- Об игре и поддержка автора ----- */
.about-sheet p { margin: 0 0 10px; line-height: 1.5; color: var(--text-2); }
.about-sheet a, .go-support, #accountBody .acc-privacy a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
#drawer #btnAbout { width: 100%; margin-top: 8px; }
.support-btn {
  display: block; margin: 14px 0 4px; padding: 11px 14px; border-radius: 12px; text-align: center;
  background: var(--accent); color: var(--accent-ink) !important; font-weight: 700; text-decoration: none !important;
}
.about-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.go-support { display: block; margin-top: 14px; font-size: 13px; font-weight: 600; color: var(--text-2) !important; }
