/* Внешний вид по утверждённому макету (правила/макет/*.dc.html): зелёное сукно,
   жёлтые кнопки, карты колоды Byron Knoll. Шрифты системные, кроме рукописного Caveat
   для листка и листа счёта — он лежит в клиент/шрифты/ и отдаётся нашим сервером
   (/fonts/), с чужих адресов шрифты не грузятся. */

/* Caveat (SIL Open Font License 1.1, лицензия — клиент/шрифты/OFL.txt), переменная
   толщина 400–700, кириллица и цифры есть. Своё имя семейства — чтобы всегда брался
   этот файл, а не установленный на телефоне. */
@font-face {
  font-family: "Joker Caveat";
  src: url("fonts/Caveat-wght.ttf") format("truetype");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
}
:root {
  --felt: #27A24B;
  --felt2: #1C8A3C;
  --felt3: #136B2D;
  --gold: #F5C518;
  --gold-dark: #B88F00;
  --gold-ink: #3A2A00;
  --green-btn: #4CBF6B;
  --green-btn-dark: #2B8445;
  --mint: #8EDBA5;
  --ink: #13401F;
  --pale: #CDEBD6;
  --panel: rgba(0, 50, 20, 0.6);
  --chip: rgba(0, 50, 20, 0.45);
  --red: #D6262B;
  --black: #111111;
  --safe-top: max(env(safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: var(--felt3);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
#viewport {
  position: fixed; inset: 0;
  background: radial-gradient(ellipse at 50% 45%, var(--felt) 0%, var(--felt2) 55%, var(--felt3) 100%);
  overflow: hidden;
}
#stage {
  position: absolute; left: 0; top: 0; width: 844px; height: 390px;
  transform-origin: 0 0; overflow: hidden;
}
.abs { position: absolute; }
.serif { font-family: Georgia, "Times New Roman", serif; font-weight: 700; }

/* ---------- кнопки */
button {
  font-family: inherit; font-weight: 700; border: 0; cursor: pointer; color: inherit;
}
.btn-gold { background: var(--gold); color: var(--gold-ink); border-radius: 14px; box-shadow: 0 4px 0 var(--gold-dark); }
.btn-green { background: var(--green-btn); color: #fff; border-radius: 14px; box-shadow: 0 4px 0 var(--green-btn-dark); }
.btn-white { background: #fff; color: var(--ink); border-radius: 12px; box-shadow: 0 3px 0 #B9C9BE; }
.btn-ghost { background: var(--chip); color: #fff; border-radius: 12px; }
button:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
button:active:not(:disabled) { transform: translateY(2px); }

/* ---------- карты (Э-0.2): обычные — рисунок колоды Byron Knoll через <img>,
   джокеры — свои, по образцу правила/макет/Table.dc.html */
.card {
  position: absolute; width: 96px; height: 139px; border-radius: 7px; background: #fff;
  box-shadow: -2px 2px 6px rgba(0,0,0,0.35); overflow: hidden;
  transition: top 0.12s, filter 0.12s;
}
.card.small { width: 80px; height: 116px; }
.card.red { color: var(--red); }
.card.black { color: var(--black); }
.card img.face { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.card.joker .jk-frame { position: absolute; inset: 0; border: 1px solid #BDBDBD; border-radius: 7px; }
.card .jk-letters {
  position: absolute; display: flex; flex-direction: column; align-items: center;
  font-family: "PT Serif", Georgia, "Times New Roman", serif; font-weight: 700; font-size: 12px; line-height: 1.02;
}
.card .jk-letters.tl { left: 6px; top: 6px; }
.card .jk-letters.br { right: 6px; bottom: 6px; transform: rotate(180deg); }
.card .jk-jester { position: absolute; left: 23%; top: 26%; width: 56%; height: 46%; }
.card.dim { filter: brightness(0.62); }
.card.sel { outline: 3px solid var(--gold); }
.card.win { box-shadow: 0 0 0 4px var(--gold), 0 8px 18px rgba(0,0,0,0.4); }
.card.tappable { cursor: pointer; }
.card .decl {
  position: absolute; left: 4px; right: 4px; bottom: 4px; padding: 2px 0; border-radius: 6px;
  background: var(--gold); color: var(--gold-ink); font-size: 11px; font-weight: 700; text-align: center;
}
.back {
  position: absolute; width: 30px; height: 42px; border-radius: 4px; background: #B3262D;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.back.big { width: 78px; height: 110px; border-radius: 8px; border-width: 3px; }
.back.big::after { content: ""; position: absolute; left: 8px; top: 8px; right: 8px; bottom: 8px; border: 1.5px solid rgba(255,255,255,0.6); border-radius: 4px; }

/* ---------- игроки */
.player { position: absolute; width: 110px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.avatar-ring { position: relative; width: 66px; height: 66px; border-radius: 33px; background: var(--mint); padding: 5px; box-shadow: 0 3px 8px rgba(0,0,0,0.3); }
.avatar {
  width: 56px; height: 56px; border-radius: 28px; border: 2px solid #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 22px; color: #fff;
}
.pts-badge {
  position: absolute; right: -12px; top: -6px; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 14px;
  background: var(--gold); color: var(--gold-ink); font-size: 13px; font-weight: 700; display: flex;
  align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.dealer-badge {
  position: absolute; left: -10px; top: -6px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: #fff; color: var(--ink); font-size: 11px; font-weight: 700; display: flex; align-items: center;
}
.name-chip { padding: 3px 12px; border-radius: 12px; background: var(--chip); font-size: 13px; font-weight: 700; white-space: nowrap; }
.bid-line { font-size: 12px; font-weight: 600; color: #E3F5E8; white-space: nowrap; }
.bid-line.white { padding: 2px 9px; border-radius: 10px; background: #fff; color: var(--ink); }
.player.offline .avatar-ring { filter: grayscale(1); opacity: 0.7; }
.player.offline .name-chip { color: #aaa; }
.offline-tag { font-size: 11px; color: #FFD0CC; font-weight: 700; }
.wait-tag { font-size: 11px; color: var(--gold); font-weight: 700; white-space: nowrap; }
.backs { position: relative; height: 44px; }

/* ---------- панели */
.panel {
  position: absolute; padding: 14px 16px; border-radius: 16px; background: var(--panel);
  box-shadow: 0 6px 18px rgba(0,0,0,0.3); display: flex; flex-direction: column; gap: 10px;
}
.panel h2 { margin: 0; font-size: 17px; font-weight: 700; }
.panel .hint { font-size: 12px; font-weight: 500; color: var(--pale); line-height: 1.3; }
.row { display: flex; gap: 8px; align-items: center; }
.grid-bids { display: grid; gap: 6px; }
.bid-btn { height: 44px; border-radius: 9px; font-size: 18px; background: var(--green-btn); color: #fff; box-shadow: 0 3px 0 var(--green-btn-dark); }
.bid-btn.pass { font-size: 14px; }
.bid-btn.sel { background: var(--gold); color: var(--gold-ink); box-shadow: 0 3px 0 var(--gold-dark); }
.bid-btn.no { background: rgba(255,255,255,0.12); color: rgba(255,255,255,0.45); text-decoration: line-through; box-shadow: none; }
.suit-btn { width: 56px; height: 52px; border-radius: 10px; background: #fff; font-size: 30px; box-shadow: 0 3px 0 #B9C9BE; }
.suit-btn.red { color: var(--red); }
.suit-btn.black { color: var(--black); }
.suit-btn.sel { outline: 3px solid var(--gold); outline-offset: 2px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 4px; border-radius: 12px; background: rgba(0,0,0,0.25); }
.seg button { height: 40px; border-radius: 9px; background: transparent; color: #fff; font-size: 15px; }
.seg button.on { background: var(--gold); color: var(--gold-ink); }
.choice-btn { min-height: 52px; border-radius: 12px; text-align: left; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
.choice-btn .big { font-weight: 900; font-size: 22px; }
.choice-btn .t { font-size: 15px; font-weight: 700; display: block; }
.choice-btn .sub { font-size: 12px; font-weight: 500; display: block; opacity: 0.8; }

.info-box {
  position: absolute; left: 14px; top: 12px; height: 60px; padding: 0 14px 0 8px; border-radius: 10px;
  background: rgba(0,50,20,0.38); display: flex; align-items: center; gap: 10px; max-width: 360px;
}
.mini-trump {
  width: 34px; height: 46px; border-radius: 5px; background: #fff; display: flex; align-items: center;
  justify-content: center; font-size: 24px; box-shadow: 0 0 0 2px var(--gold); flex-shrink: 0;
}
.mini-trump.red { color: var(--red); }
.mini-trump.black { color: var(--black); }
.mini-trump.none { font-size: 11px; color: var(--ink); text-align: center; line-height: 1.1; font-weight: 700; }
.info-box .l1 { font-size: 12px; font-weight: 500; color: var(--pale); white-space: nowrap; }
.info-box .l2 { font-size: 15px; font-weight: 700; white-space: nowrap; }
.mult { height: 30px; padding: 0 10px; border-radius: 15px; background: var(--gold); color: var(--gold-ink); font-weight: 900; font-size: 16px; display: flex; align-items: center; }

/* ---------- бумага листа счёта (Э-5, Э-12): кремовая, в линейку, красные поля,
   рукописный шрифт синими чернилами — Caveat со своего сервера (@font-face выше);
   пока файл не загрузился — системный рукописный. */
.hand { font-family: "Joker Caveat", "Caveat", "Segoe Print", "Bradley Hand", "Noteworthy", "Chalkboard SE", "Comic Sans MS", cursive; }
.paper { background-color: #FBF6E6; color: #1D3A8A; }
.paper .neg { color: #C0392B; }
.margin-line { position: absolute; left: 14px; top: 0; bottom: 0; width: 1.5px; background: #E58A8A; }
.margin-line.big { left: 88px; width: 2px; z-index: 1; }
.score-mini {
  position: absolute; right: 16px; top: 10px; width: 232px; height: 72px; padding: 6px 12px 0 22px;
  border-radius: 3px; box-shadow: 0 6px 14px rgba(0,0,0,0.35); transform: rotate(2deg); cursor: pointer;
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 10px; align-content: start;
}
.score-mini .mini-line {
  height: 28px; border-bottom: 1px solid #BFD3EA; display: flex; justify-content: space-between; align-items: center;
  gap: 4px; white-space: nowrap; font-size: 17px; font-weight: 700; min-width: 0;
}
.score-mini .nm { color: #6B7FA8; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.score-mini .pt { flex-shrink: 0; }
.overlay.score-ov { background: rgba(0,0,0,0.35); display: block; }
.score-paper {
  position: absolute; left: 40px; top: 10px; width: 764px; height: 370px; padding-top: 8px; border-radius: 4px;
  box-shadow: 0 14px 36px rgba(0,0,0,0.45); overflow: hidden; display: flex; flex-direction: column;
}
.sgrid { display: grid; grid-template-columns: 88px repeat(4, minmax(0, 1fr)); align-items: center; }
.sgrid .lbl { padding-left: 12px; font-size: 20px; font-weight: 700; color: #6B7FA8; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.shead { height: 46px; flex-shrink: 0; border-bottom: 2px solid #8FA6C9; }
.shead .cn { text-align: center; font-size: 26px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 1.5px solid #8FA6C9; line-height: 44px; padding: 0 4px; }
.sbody { flex-grow: 1; min-height: 0; }
/* Высоты строк — под экран 844 × 390 (Э-0.1, Э-12): в окно листа (370 − 8 − 46 = 316)
   целиком входит круг из 8 раздач: 8 строк + «премия» (по 30) + черта 2 + «итого» 42 = 314.
   Те же числа — в app.js (ROW_H, LINE_H, TOTAL_H), тест сверяет. */
.srow { height: 30px; border-bottom: 1px solid #BFD3EA; }
.srow .lbl .nn { font-size: 24px; }
.srow .lbl .dn { font-size: 12px; font-weight: 500; opacity: 0.8; }
.srow .lbl .xk { font-size: 15px; color: #C0392B; border: 1.5px solid #C0392B; border-radius: 10px; padding: 0 4px; line-height: 1.1; }
.sgrid .cell { height: 29px; border-left: 1.5px solid #8FA6C9; display: flex; align-items: center; justify-content: center; gap: 12px; white-space: nowrap; font-size: 23px; font-weight: 700; }
.sgrid .cell.small { font-size: 18px; }
.sgrid .cell.span4 { grid-column: 2 / span 4; }
.sgrid .cell .bid { min-width: 16px; text-align: right; font-size: 18px; font-weight: 500; color: #6B7FA8; }
.sgrid .cell .pts { min-width: 56px; text-align: left; }
.srow.prem .lbl { font-size: 18px; }
.sline { height: 2px; background: #1D3A8A; opacity: 0.7; }
.stot { height: 42px; border-bottom: 1px solid #BFD3EA; }
.stot .cell { height: 41px; }
.stot .sum { font-size: 28px; font-weight: 700; border-bottom: 2px solid currentColor; line-height: 1; }
.score-close {
  position: absolute; right: 8px; top: 2px; width: 44px; height: 44px; border-radius: 22px; background: #fff; color: var(--ink);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 3px 8px rgba(0,0,0,0.35); z-index: 2;
}
.status-pill.intro { max-width: 500px; font-size: 15px; z-index: 45; }

.status-pill {
  position: absolute; left: 20px; top: 222px; max-width: 250px; padding: 7px 12px; border-radius: 12px; background: #fff;
  color: var(--ink); font-size: 13px; font-weight: 700; box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.timer { position: absolute; left: 290px; top: 240px; width: 400px; height: 8px; border-radius: 4px; background: rgba(0,0,0,0.25); overflow: hidden; }
.timer .fill { height: 100%; background: var(--gold); }
.timer.low .fill { background: #E53935; }
.timer-text { position: absolute; left: 698px; top: 233px; font-size: 13px; font-weight: 700; }
.timer-out { position: absolute; left: 290px; top: 222px; width: 400px; text-align: center; font-size: 13px; font-weight: 700; color: var(--gold); }

.action-btn { position: absolute; right: 16px; bottom: 22px; width: 132px; height: 52px; font-size: 16px; }

.toast {
  position: absolute; left: 50%; top: 10px; transform: translateX(-50%); padding: 10px 16px; border-radius: 12px;
  background: #fff; color: var(--ink); font-size: 14px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,0.35); z-index: 50; max-width: 520px; text-align: center;
}
.toast.bad { background: #FFE3E0; color: #8A1C14; }

.overlay {
  position: absolute; inset: 0; background: rgba(0, 30, 12, 0.72); display: flex; align-items: center;
  justify-content: center; z-index: 40;
}
.sheet { width: 600px; max-height: 360px; padding: 14px 16px; border-radius: 16px; background: #1F7A3A; box-shadow: 0 8px 24px rgba(0,0,0,0.4); display: flex; flex-direction: column; gap: 8px; }
.sheet h2 { margin: 0; font-size: 18px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { background: #6CCB86; color: #0F4D25; padding: 4px 6px; font-weight: 700; text-align: center; }
table.tbl td { padding: 4px 6px; text-align: center; border-top: 1px solid rgba(255,255,255,0.12); background: #2E9E52; }
table.tbl td.left, table.tbl th.left { text-align: left; }
table.tbl tr.alt td { background: #3AAE5E; }
table.tbl tr.sum td { background: #14612B; font-weight: 700; }
table.tbl tr.prem td { background: #22803F; font-size: 12px; }
table.tbl tr.empty td { color: rgba(255,255,255,0.4); background: #2A9149; }
table.tbl td.minus { color: #FFD0CC; }
table.tbl td.lead { background: var(--gold); color: var(--gold-ink); }
table.tbl td.removed { text-decoration: line-through; color: #FFE27A; }
.x-chip { font-size: 10px; padding: 1px 5px; border-radius: 6px; background: var(--gold); color: var(--gold-ink); font-weight: 900; margin-left: 4px; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

.vote-bar {
  position: absolute; left: 160px; right: 160px; top: 78px; padding: 8px 12px; border-radius: 12px; background: rgba(120, 20, 10, 0.85);
  display: flex; flex-direction: column; gap: 6px; z-index: 30; font-size: 13px; font-weight: 700;
}
.vote-chip { position: absolute; left: 380px; top: 80px; padding: 4px 10px; border-radius: 10px; background: rgba(120,20,10,0.85); font-size: 12px; font-weight: 700; z-index: 30; cursor: pointer; }

.conn {
  position: absolute; inset: 0; background: rgba(0,0,0,0.55); display: flex; align-items: center; justify-content: center;
  z-index: 60; font-size: 20px; font-weight: 700;
}

#rotate {
  position: fixed; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: var(--felt3); z-index: 100; text-align: center; padding: 24px; font-size: 18px; font-weight: 700;
}
#rotate .phone { width: 46px; height: 80px; border: 4px solid #fff; border-radius: 10px; animation: rot 2s infinite ease-in-out; }
@keyframes rot { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(90deg); } }

.code-big { flex-grow: 1; height: 50px; border-radius: 12px; background: #fff; color: var(--ink); font-weight: 900; font-size: 26px; letter-spacing: 4px; display: flex; align-items: center; justify-content: center; }
input.code {
  flex-grow: 1; min-width: 0; height: 52px; border-radius: 14px; border: 0; background: #fff; color: var(--ink);
  padding: 0 16px; font-family: inherit; font-weight: 700; font-size: 20px; letter-spacing: 3px; text-transform: uppercase;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15); user-select: text; -webkit-user-select: text;
}
.seat-free { width: 66px; height: 66px; border-radius: 33px; border: 3px dashed rgba(255,255,255,0.55); display: flex; align-items: center; justify-content: center; font-size: 26px; color: rgba(255,255,255,0.7); }
.ace-label { font-size: 12px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.err { color: #FFD0CC; font-size: 13px; font-weight: 700; min-height: 16px; }
#rotate button { height: 44px; padding: 0 16px; }
