:root {
  --bg: #07090a;
  --panel: rgba(12, 22, 16, .86);
  --panel-solid: #0f1a14;
  --line: rgba(255, 255, 255, .09);
  --text: #eef3ee;
  --muted: #93a79a;
  --gold: #f2c14e;
  --green: #2ecc71;
  --green-d: #1a8f4a;
  --blue: #2f80ed;
  --blue-d: #1d5bb8;
  --red: #e5484d;
  --red-d: #a82529;
  --radius: 12px;
  font-family: Rubik, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 18px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
kbd { font: 600 10px/1 monospace; opacity: .6; margin-right: 6px; }

input, select {
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; outline: none; width: 100%;
}
input:focus, select:focus { border-color: var(--gold); }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: 14px; padding: 5px 0; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--green); }

.btn {
  border: 0; border-radius: 9px; padding: 9px 14px; cursor: pointer; font-weight: 500;
  background: rgba(255, 255, 255, .08); transition: filter .15s, transform .05s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.18); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); }
.btn.green { background: linear-gradient(#35d27a, #1a8f4a); }
.btn.blue { background: linear-gradient(#4a93f0, #1d5bb8); }
.btn.red { background: linear-gradient(#ef5a5f, #a82529); }
.btn.gold { background: linear-gradient(#f7d06a, #c8901e); color: #2a1b00; font-weight: 700; }
.btn.big { padding: 13px 18px; font-size: 16px; font-weight: 700; }
.btn.tiny { padding: 4px 9px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.logo { font-weight: 800; font-size: 22px; letter-spacing: .3px; display: flex; align-items: center; gap: 8px; }
.logo span { color: var(--gold); font-size: 26px; }
.logo b { color: var(--gold); }

.tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.tabs button { flex: 1; background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 8px; cursor: pointer; color: var(--muted); }
.tabs button.on { color: var(--text); border-color: var(--gold); }
.tabs.small { margin: 0; }
.tabs.small button { padding: 6px 4px; font-size: 13px; }

/* ---------- экраны ---------- */
.screen { position: fixed; inset: 0; }
#auth, #lobby {
  background: radial-gradient(ellipse at 50% 35%, #174d2c 0%, #0b2616 45%, #050806 100%);
  overflow: auto;
}
#auth { display: grid; place-items: center; padding: 16px; }
.auth-card {
  width: min(400px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 18px; padding: 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, .5); backdrop-filter: blur(8px);
}
.auth-card .logo { justify-content: center; font-size: 28px; }
.auth-card > p { text-align: center; }
#authForm { display: flex; flex-direction: column; gap: 14px; }
.err { color: #ff8a8a; min-height: 18px; font-size: 14px; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, .25); position: sticky; top: 0; z-index: 2; backdrop-filter: blur(6px); }
.me { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.lobby-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 18px; padding: 22px; max-width: 1400px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 20px; min-width: 0; }
.panel h2 { margin: 0 0 14px; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--line); background: rgba(242, 193, 78, .1); color: var(--gold); border-radius: 99px; padding: 6px 12px; cursor: pointer; font-size: 13px; }
.chip-btn:hover { background: rgba(242, 193, 78, .2); }
.list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow: auto; }
.trow { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(0, 0, 0, .2); }
.trow .info { flex: 1; min-width: 0; }
.trow .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .info span { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: rgba(46, 204, 113, .18); color: var(--green); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: rgba(0, 0, 0, .25); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }
.pos { color: var(--green); } .neg { color: var(--red); }
table.top { width: 100%; border-collapse: collapse; font-size: 14px; }
table.top td, table.top th { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.top th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.top td.num { text-align: right; font-variant-numeric: tabular-nums; }
.hist { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.hist .cards { display: inline-flex; gap: 2px; }
.empty { color: var(--muted); padding: 20px 0; text-align: center; }

/* ---------- мини-карты в HTML ---------- */
.mc { display: inline-grid; place-items: center; width: 22px; height: 30px; border-radius: 4px; background: #fbfaf6; color: #111; font: 700 11px/1 Rubik, sans-serif; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.mc.r { color: #d0141e; } .mc.b4 { color: #1f5fd0; } .mc.g4 { color: #1b7a2a; }
.mc.dim { opacity: .35; }

/* ---------- игра ---------- */
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
#plates, #labels, #center { pointer-events: none !important; }
.gamebar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: linear-gradient(rgba(0, 0, 0, .65), transparent); }
.tname { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.tname b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tname span { font-size: 12px; }

.plate {
  position: absolute; transform: translate(-50%, -50%); width: 150px;
  background: linear-gradient(rgba(10, 18, 13, .92), rgba(5, 10, 7, .92)); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px; padding: 7px 9px 8px; display: grid; grid-template-columns: 38px 1fr; gap: 1px 8px; align-items: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45); transition: opacity .3s, box-shadow .3s, border-color .3s;
}
.plate .avatar { grid-row: span 2; width: 38px; height: 38px; font-size: 16px; position: relative; }
.plate .avatar i { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid #0a120d; background: var(--green); }
.plate .avatar i.off { background: #777; }
.plate .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate .st { color: var(--gold); font-weight: 700; font-size: 14px; font-variant-numeric: tabular-nums; }
.plate .act {
  position: absolute; left: 50%; top: -12px; transform: translateX(-50%); font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 99px; background: #2b3a31; white-space: nowrap; letter-spacing: .3px; text-transform: uppercase;
}
.plate .act.fold { background: #5b2226; } .plate .act.raise { background: #1a8f4a; } .plate .act.call { background: #1d5bb8; } .plate .act.allin { background: #c8901e; color: #231500; }
.plate .bl { position: absolute; right: -8px; top: -8px; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font: 700 9px/1 Rubik; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.plate .bl.sb { background: #2f80ed; } .plate .bl.bb { background: #f2c14e; color: #2a1b00; }
.plate .timer { position: absolute; left: 8px; right: 8px; bottom: 3px; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.plate .timer b { display: block; height: 100%; background: var(--gold); transform-origin: left; }
.plate.turn { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242, 193, 78, .5), 0 0 30px rgba(242, 193, 78, .35); }
.plate.folded, .plate.out { opacity: .5; }
.plate.win { border-color: var(--green); box-shadow: 0 0 0 2px rgba(46, 204, 113, .6), 0 0 36px rgba(46, 204, 113, .5); }
.plate.you { background: linear-gradient(rgba(24, 44, 30, .95), rgba(8, 18, 11, .95)); }
.plate .hn { grid-column: 1 / -1; font-size: 11px; color: var(--green); text-align: center; margin-top: 2px; }
.plate .net { font-size: 10px; font-weight: 500; margin-left: 4px; }
.bubble { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -8px); font-size: 30px; animation: pop 2.2s ease forwards; }
@keyframes pop { 0% { transform: translate(-50%, 10px) scale(.4); opacity: 0; } 15% { transform: translate(-50%, -8px) scale(1.15); opacity: 1; } 80% { opacity: 1; } 100% { transform: translate(-50%, -30px); opacity: 0; } }

.betlbl { position: absolute; transform: translate(-50%, 12px); font-size: 12px; font-weight: 700; color: #fff; background: rgba(0, 0, 0, .55); padding: 2px 7px; border-radius: 99px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#center { position: absolute; inset: 0; }
#potLabel { position: absolute; transform: translate(-50%, 0); font-weight: 700; font-size: 15px; color: var(--gold); text-shadow: 0 2px 6px rgba(0, 0, 0, .8); white-space: nowrap; text-align: center; }
#potLabel small { display: block; color: #cfe3d4; font-weight: 500; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
#banner { position: absolute; left: 50%; top: 70px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; width: min(640px, 92vw); }
#banner .line { background: rgba(0, 0, 0, .72); border: 1px solid rgba(46, 204, 113, .4); padding: 8px 16px; border-radius: 12px; font-weight: 600; text-align: center; animation: fadein .35s ease; }
#banner .line.warn { border-color: rgba(242, 193, 78, .5); color: var(--gold); }
@keyframes fadein { from { opacity: 0; transform: translateY(-6px); } }
#centerActions { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); pointer-events: auto; display: flex; flex-direction: column; gap: 10px; align-items: center; }

.box { position: absolute; bottom: 12px; width: 270px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; backdrop-filter: blur(6px); }
#leftBox { left: 12px; }
#rightBox { right: 12px; height: 250px; display: flex; flex-direction: column; }
.rt { flex: 1; min-height: 0; padding: 8px 10px; font-size: 12.5px; }
.scroll { overflow: auto; }
#rtLog div { padding: 2px 0; color: #cfe0d4; }
#rtLog div.h { color: var(--gold); margin-top: 6px; }
#rtChat { display: flex; flex-direction: column; gap: 6px; }
#chatList { flex: 1; min-height: 0; }
#chatList div { padding: 2px 0; } #chatList b { color: var(--gold); font-weight: 600; }
#chatDot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); vertical-align: middle; visibility: hidden; }
#chatDot.on { visibility: visible; }
.emotes { display: flex; gap: 4px; }
.emotes button { flex: 1; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-size: 17px; padding: 3px 0; }
#rtChance .eq { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; }
#rtChance .eq b { font-size: 20px; color: var(--green); }
.bar { display: grid; grid-template-columns: 96px 1fr 40px; gap: 6px; align-items: center; margin: 3px 0; }
.bar i { display: block; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #1a8f4a, #35d27a); }
.bar em { font-style: normal; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
#handsRef { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 8px 10px 10px; }
.href { font-size: 10.5px; color: var(--muted); padding: 3px; border-radius: 6px; }
.href .cs { display: flex; gap: 1px; margin-bottom: 2px; }
.href .mc { width: 17px; height: 23px; font-size: 9px; }
.href.on { background: rgba(46, 204, 113, .18); color: var(--text); outline: 1px solid rgba(46, 204, 113, .5); }

#actions { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: 300px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
#myHand { text-align: center; font-weight: 700; color: var(--green); text-shadow: 0 1px 4px #000; min-height: 20px; }
#actWrap { display: flex; flex-direction: column; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.betrow { display: flex; gap: 6px; }
.betrow input { flex: 1; font-weight: 700; font-size: 16px; padding: 7px 10px; }
#betSlider { padding: 0; accent-color: var(--gold); }
.quick { display: flex; gap: 4px; }
.quick button { flex: 1; background: rgba(255, 255, 255, .06); border: 1px solid var(--line); border-radius: 7px; padding: 4px 0; cursor: pointer; font-size: 12px; }
.act { border: 0; border-radius: 11px; padding: 10px; cursor: pointer; font-weight: 700; font-size: 16px; color: #fff; display: flex; align-items: center; justify-content: center; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 3px 10px rgba(0, 0, 0, .35); text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.act.green { background: linear-gradient(#35d27a, #1a8f4a); }
.act.blue { background: linear-gradient(#4a93f0, #1d5bb8); }
.act.red { background: linear-gradient(#ef5a5f, #a82529); }
.act:hover { filter: brightness(1.12); }
.act:disabled, .act.locked { filter: grayscale(.7) brightness(.7); cursor: not-allowed; }
.act span { display: flex; flex-direction: column; line-height: 1.15; }
.act span small { font-size: 12px; font-weight: 500; opacity: .9; }
#waitWrap { display: flex; flex-direction: column; gap: 8px; align-items: center; }
#waitWrap .note { background: rgba(0, 0, 0, .55); padding: 7px 14px; border-radius: 10px; font-size: 14px; text-align: center; }
#peekBtn { user-select: none; -webkit-user-select: none; }

/* ---------- модалка ---------- */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 10; padding: 16px; }
.modal-card { width: min(760px, 100%); max-height: 90vh; display: flex; flex-direction: column; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.modal-card header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-card h2 { margin: 0; font-size: 18px; }
.settings-body { display: grid; grid-template-columns: 180px 1fr; min-height: 380px; overflow: auto; }
.side { display: flex; flex-direction: column; padding: 10px; gap: 2px; border-right: 1px solid var(--line); }
.side button { text-align: left; background: transparent; border: 0; padding: 10px; border-radius: 8px; cursor: pointer; }
.side button.on { background: var(--blue-d); }
.sec { padding: 18px; display: flex; flex-direction: column; gap: 10px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
#toast div { background: #1b2a21; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: fadein .25s; }

/* ---------- узкие экраны ---------- */
@media (max-width: 1100px) {
  #leftBox { display: none; }
  #rightBox { width: 230px; height: 200px; }
}
#boxBtn { display: none; position: relative; }
#boxBtn.dot::after { content: ''; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); }
@media (max-width: 760px) {
  .gamebar { padding: 8px; gap: 5px; }
  .gamebar .btn { padding: 7px 8px; font-size: 14px; }
  #inviteBtn { font-size: 0; } #inviteBtn::before { content: '🔗'; font-size: 15px; }
  #boxBtn { display: block; }
  #sitBtn, #pauseBtn { font-size: 12px; }
  .tname b { font-size: 14px; }
  .tname span { display: block; max-width: 44vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
  #rightBox { display: none !important; }
  #rightBox.open { display: flex !important; top: 54px; bottom: auto; left: 8px; right: 8px; width: auto; height: 46vh; z-index: 4; }
  #banner { top: 56px; }
  #banner .line { font-size: 13px; padding: 6px 12px; }
  #actions { width: calc(100% - 16px); bottom: 8px; }
  #actWrap { display: grid; grid-template-columns: 1fr 1fr 1fr; }
  #actWrap .betrow, #actWrap #betSlider, #actWrap .quick { grid-column: 1 / -1; }
  #actWrap .act { padding: 12px 4px; font-size: 14px; order: 5; }
  #foldBtn { order: 1 !important; } #callBtn { order: 2 !important; } #raiseBtn { order: 3 !important; }
  .act kbd { display: none; }
  .plate { width: 112px; grid-template-columns: 28px 1fr; padding: 5px 6px 6px; }
  .plate .avatar { width: 28px; height: 28px; font-size: 12px; }
  .plate .nm { font-size: 11px; } .plate .st { font-size: 12px; }
  .settings-body { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .form-grid { grid-template-columns: 1fr; }
  .lobby-grid { padding: 12px; grid-template-columns: 1fr; }
  .topbar { padding: 10px 14px; }
}

/* ---------- конец игры ---------- */
#gameOver { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(rgba(0, 0, 0, .35), rgba(0, 0, 0, .75)); z-index: 5; padding: 16px; }
.go-card { width: min(460px, 100%); background: linear-gradient(#13261a, #0a140e); border: 1px solid rgba(242, 193, 78, .45); border-radius: 20px; padding: 26px 24px 20px; text-align: center; box-shadow: 0 30px 90px rgba(0, 0, 0, .6), 0 0 60px rgba(242, 193, 78, .15); animation: goin .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes goin { from { transform: scale(.8); opacity: 0; } }
.go-card .trophy { font-size: 64px; line-height: 1; filter: drop-shadow(0 6px 16px rgba(242, 193, 78, .5)); }
.go-card h2 { margin: 10px 0 4px; font-size: 26px; color: var(--gold); }
.go-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.standings { margin-bottom: 18px; font-size: 14px; text-align: left; }
.srow { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.srow .place { width: 28px; flex: none; font-size: 18px; text-align: center; }
.srow .sname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .sval { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }
.srow.me .sname, .srow.me .sval { color: var(--green); font-weight: 600; }
.srow:first-child .sval { color: var(--gold); font-weight: 700; }
.go-card .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.confetti { position: absolute; top: -10px; width: 9px; height: 14px; border-radius: 2px; animation: fall linear forwards; pointer-events: none; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* ---------- подтверждение ---------- */
#confirm { z-index: 15; }
.confirm-card { width: min(460px, 100%); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 16px; padding: 20px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, .6); animation: fadein .2s; }
.confirm-card h2 { margin: 0 0 12px; font-size: 19px; }
#cfBody { font-size: 14px; line-height: 1.5; color: #d7e3da; }
#cfBody ul { margin: 8px 0 0; padding-left: 20px; }
#cfBody li { margin: 5px 0; }
#cfBody .warn { margin-top: 10px; padding: 8px 12px; border-radius: 10px; background: rgba(242, 193, 78, .12); color: var(--gold); }
.confirm-card .btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
