:root {
  --bg: #0f1a14;
  --felt: #1b5e3b;
  --felt-dark: #0f3d26;
  --panel: rgba(0, 0, 0, .35);
  --text: #f2f5f3;
  --muted: #9bb3a6;
  --gold: #f5c542;
  --red: #e5484d;
  --card-w: 58px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) { --bg: #0f1a14; }
}
:root[data-theme="dark"] { --bg: #0f1a14; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex; justify-content: center; min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
button, input { font: inherit; }
.hidden { display: none !important; }
.app {
  width: 100%; max-width: 440px; min-height: 100vh; position: relative;
  display: flex; flex-direction: column; padding: 0 0 env(safe-area-inset-bottom);
}
.screen { display: flex; flex-direction: column; flex: 1; padding: 12px; gap: 12px; }

/* ----- общие ----- */
.balance {
  background: rgba(245, 197, 66, .15); border: 1px solid rgba(245, 197, 66, .4);
  color: var(--gold); padding: 4px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; white-space: nowrap;
}
.panel { background: var(--panel); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.panel h2 { font-size: 16px; }
.label { font-size: 12px; color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.check input { width: auto; }
.card.joker { background: linear-gradient(135deg, #fff, #fde68a); }
.primary, .secondary, .ghost, .act {
  border: none; border-radius: 12px; padding: 12px 14px; font-weight: 700; font-size: 14px; color: #fff; cursor: pointer;
}
.primary { background: #16a34a; width: 100%; }
.secondary { background: #2563eb; }
.ghost { background: rgba(255, 255, 255, .08); color: var(--text); border: 1px solid rgba(255, 255, 255, .15); }
.small { padding: 6px 10px; font-size: 12px; }
input {
  background: rgba(0, 0, 0, .3); border: 1px solid rgba(255, 255, 255, .2); border-radius: 10px;
  padding: 10px; color: var(--text); outline: none; width: 100%;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.row2 label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.row2 .code { text-transform: uppercase; letter-spacing: 3px; text-align: center; font-weight: 700; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: rgba(0, 0, 0, .3); border-radius: 12px; padding: 3px; }
.seg button {
  background: transparent; border: none; color: var(--muted); padding: 9px; border-radius: 10px; font-weight: 700; cursor: pointer;
}
.seg button.on { background: #16a34a; color: #fff; }
.head { display: flex; justify-content: space-between; align-items: center; }
.head h1 { font-size: 22px; }
.rules summary { cursor: pointer; font-weight: 700; }
.rules ul { padding-left: 18px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }

/* ----- стол ----- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.roomInfo { text-align: center; flex: 1; }
.roomInfo small { display: block; color: var(--muted); font-size: 11px; }
.felt {
  position: relative; height: 380px; border-radius: 50%/42%;
  background: radial-gradient(ellipse at 50% 40%, var(--felt) 0%, var(--felt-dark) 75%);
  box-shadow: inset 0 0 0 6px #5c3a1e, inset 0 0 0 9px rgba(255, 255, 255, .06), 0 10px 30px rgba(0, 0, 0, .4);
  margin: 4px 6px 0;
}
.bank { position: absolute; left: 50%; top: 48%; transform: translate(-50%, -50%); text-align: center; }
.chips {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto;
  background: radial-gradient(circle at 35% 30%, #ffe68a, #d4a017 60%, #8a6410);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .08), 0 8px 20px rgba(0, 0, 0, .4);
  display: flex; align-items: center; justify-content: center; color: #3b2a05; font-weight: 800; font-size: 16px;
}
.bank small { display: block; margin-top: 6px; color: var(--muted); font-size: 11px; }
.resultBox {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%); background: rgba(0, 0, 0, .8);
  padding: 8px 12px; border-radius: 12px; font-size: 13px; text-align: center; white-space: nowrap; z-index: 3;
}
.seat { position: absolute; width: 92px; text-align: center; font-size: 12px; transform: translate(-50%, -50%); }
.seat .avatar { margin: 0 auto; }
.avatar {
  width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; color: #fff; border: 3px solid var(--felt-dark); box-shadow: 0 0 0 2px rgba(255, 255, 255, .2);
}
.me-av { width: 44px; height: 44px; font-size: 16px; background: #7c3aed; border: none; box-shadow: none; }
.seat .nm { margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .stk { color: var(--gold); font-size: 11px; }
.seat .st { color: var(--muted); font-size: 11px; min-height: 14px; }
.seat.turn .avatar { box-shadow: 0 0 0 3px var(--gold), 0 0 14px var(--gold); }
.seat.out { opacity: .4; }
.seat .mini { display: flex; justify-content: center; gap: 2px; margin-top: 3px; }
.mini .card { width: 18px; height: 26px; font-size: 8px; border-radius: 3px; padding: 1px; }
.dealer {
  position: absolute; right: -4px; top: -6px; background: #fff; color: #000; font-size: 10px; font-weight: 800;
  border-radius: 50%; width: 18px; height: 18px; display: flex; align-items: center; justify-content: center;
}
.timer {
  position: absolute; left: 50%; transform: translateX(-50%); top: -20px; background: var(--gold); color: #222;
  font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; white-space: nowrap;
}
.bet {
  position: absolute; left: 50%; transform: translate(-50%, 0); bottom: -18px; background: rgba(0, 0, 0, .6);
  color: var(--gold); font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 8px; white-space: nowrap;
}

/* карты */
.card {
  width: var(--card-w); height: calc(var(--card-w) * 1.45); border-radius: 8px; background: #fff; color: #111;
  border: 1px solid #ddd; box-shadow: 0 6px 14px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column; justify-content: space-between; padding: 4px 5px; font-weight: 700; font-size: 15px;
}
.card.red { color: var(--red); }
.card .big { align-self: center; font-size: 22px; }
.card .rot { align-self: flex-end; transform: rotate(180deg); }
.card.back { background: repeating-linear-gradient(45deg, #7a1f2b 0 6px, #5e1721 6px 12px); border: 2px solid #fff4; }

/* моя зона */
.me {
  background: var(--panel); border-radius: 18px 18px 0 0; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 10px; margin-top: 4px;
}
.meHead { display: flex; align-items: center; gap: 10px; }
.meInfo { flex: 1; }
.meInfo b { font-size: 14px; display: block; }
.meInfo small { color: var(--muted); font-size: 12px; }
.combo {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; background: rgba(59, 130, 246, .2); color: #93c5fd; border: 1px solid rgba(59, 130, 246, .4);
}
.myCards { display: flex; justify-content: center; gap: 10px; min-height: 90px; }
.actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.act { padding: 12px 6px; }
.act:disabled { opacity: .35; pointer-events: none; }
.fold { background: #6b2c33; }
.call { background: #2563eb; }
.raise { background: #16a34a; }
.raiseRow { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); }
.raiseRow input[type=range] { flex: 1; accent-color: var(--gold); }
.raiseRow b { color: var(--gold); min-width: 56px; text-align: right; }
.sitRow { display: flex; gap: 8px; }
.sitRow .primary { flex: 1; }
.sitRow .ghost { flex: 1; }
.shareRow { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.chat { display: flex; flex-direction: column; gap: 6px; }
.chatLog {
  max-height: 96px; overflow-y: auto; font-size: 12px; display: flex; flex-direction: column; gap: 3px; color: var(--muted);
}
.chatLog b { color: var(--text); }
.chatForm { display: flex; gap: 6px; }
.chatForm input { padding: 8px 10px; font-size: 13px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: rgba(0, 0, 0, .85);
  padding: 10px 16px; border-radius: 12px; font-size: 13px; max-width: 90%; text-align: center; z-index: 10;
}
