:root {
  --bg: #0b1411;
  --bg2: #101c18;
  --panel: #13221d;
  --line: #22382f;
  --text: #e8efe9;
  --muted: #8aa197;
  --accent: #e9b949;
  --accent2: #f3cf72;
  --good: #4ed08a;
  --bad: #ff6b6b;
  --felt1: #1d6b47;
  --felt2: #0f3f2a;
  --rail: #3a2412;
  --card: #fbfaf6;
  --c-s: #1b1b1f;
  --c-h: #d0263a;
  --c-d: #1f63d6;
  --c-c: #1c8a3f;
  --r: 14px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: Vazirmatn, system-ui, sans-serif;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, #173327 0%, var(--bg) 60%);
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
small.muted { display: block; margin-top: 4px; font-size: 12px; }
.num, .mono { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
.pos { color: var(--good); } .neg { color: var(--bad); }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(11, 20, 17, .86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 8px; white-space: nowrap; }
.brand .logo { color: var(--accent); font-size: 22px; }
.brand b { font-size: 18px; letter-spacing: .3px; }
.brand .sub { color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; background: var(--bg2); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.tabs button { border: 0; background: none; padding: 6px 12px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 500; }
.tabs button.on { background: var(--accent); color: #1a1405; font-weight: 700; }
@media (max-width: 560px) {
  .top { flex-direction: column; align-items: stretch; gap: 8px; }
  .brand .sub { display: none; }
  .tabs button { flex: 1; padding: 7px 4px; }
}

main { max-width: 1060px; margin: 0 auto; padding: 16px; padding-bottom: 60px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 14px; }
.panel h2 { margin: 0 0 6px; font-size: 18px; }
.panel p { margin: 0 0 12px; line-height: 1.8; font-size: 14px; }
details.panel summary { cursor: pointer; font-weight: 700; }
details.panel[open] summary { margin-bottom: 10px; }

.field { margin: 14px 0; }
.field > label { display: block; margin-bottom: 8px; font-size: 14px; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }

.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.seg button, .presets button {
  border: 1px solid var(--line); background: var(--bg2); border-radius: 10px; padding: 8px 14px; cursor: pointer; min-width: 48px;
}
.seg button.on { background: var(--accent); color: #1a1405; border-color: var(--accent); font-weight: 700; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.presets button { font-size: 13px; padding: 6px 10px; color: var(--muted); }
.presets button:hover { color: var(--text); border-color: var(--accent); }

.seatpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.seatrow { display: flex; align-items: center; gap: 8px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.seatrow .idx { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: 13px; flex: none; }
.seatrow.hero .idx { background: var(--accent); color: #1a1405; font-weight: 700; }
.seatrow select { flex: 1; background: transparent; border: 0; padding: 4px; min-width: 0; }
.seatrow select option { background: var(--bg2); }
.seatrow .info { font-size: 11px; color: var(--muted); }

input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=text], input[type=number] {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%;
}
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.toggle.small { padding: 6px 10px; font-size: 13px; }

.btn { border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 10px 16px; cursor: pointer; font-weight: 600; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(180deg, var(--accent2), var(--accent)); color: #1a1405; border-color: #b98d2b; }
.btn.big { width: 100%; padding: 14px; font-size: 17px; margin-top: 6px; }
.btn.ghost { background: none; }
.btn.danger { background: #3a1717; border-color: #6a2626; color: #ffc9c9; }
.btn:disabled { opacity: .45; cursor: default; }
.err { color: var(--bad); margin-top: 8px; font-size: 14px; }

/* ---------- table ---------- */
.tablebar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.hand-no { color: var(--muted); font-size: 14px; }
.session { font-weight: 700; }
.felt-wrap { position: relative; padding: 0 4px; }
.felt {
  position: relative; margin: 34px auto 84px; width: 100%; max-width: 820px; aspect-ratio: 2 / 1;
  border-radius: 999px;
  background: radial-gradient(ellipse at 50% 40%, var(--felt1) 0%, var(--felt2) 75%);
  box-shadow: 0 0 0 10px var(--rail), 0 0 0 12px #5a3a1d, 0 24px 60px rgba(0, 0, 0, .55), inset 0 0 60px rgba(0, 0, 0, .45);
}
@media (max-width: 640px) {
  .felt { aspect-ratio: 3 / 4.1; max-width: 420px; border-radius: 46% / 34%; margin: 58px auto 92px; width: 74%; }
}
.center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; pointer-events: none; }
.board { display: flex; gap: 5px; min-height: 62px; direction: ltr; }
.pot { font-family: var(--mono); background: rgba(0, 0, 0, .35); padding: 3px 12px; border-radius: 999px; font-size: 14px; }
.banner { background: rgba(0, 0, 0, .7); border: 1px solid var(--accent); color: var(--accent2); padding: 6px 14px; border-radius: 10px; font-weight: 700; text-align: center; max-width: 80%; font-size: 14px; }

.card {
  width: 42px; height: 60px; border-radius: 6px; background: var(--card); color: var(--c-s);
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4); font-family: var(--mono); font-weight: 700; position: relative;
  animation: deal .25s ease-out;
}
.card .r { font-size: 19px; } .card .s { font-size: 18px; margin-top: 2px; }
.card.h { color: var(--c-h); } .card.d { color: var(--c-d); } .card.c { color: var(--c-c); }
.card.back { background: repeating-linear-gradient(45deg, #7c1f2b 0 6px, #94283a 6px 12px); border: 2px solid #f1e6d0; }
.card.sm { width: 32px; height: 45px; } .card.sm .r { font-size: 15px; } .card.sm .s { font-size: 13px; }
@media (max-width: 640px) {
  .card { width: 34px; height: 49px; } .card .r { font-size: 16px; } .card .s { font-size: 14px; }
  .card.sm { width: 26px; height: 37px; } .card.sm .r { font-size: 12px; } .card.sm .s { font-size: 11px; }
  .board { min-height: 50px; gap: 3px; }
}
@keyframes deal { from { transform: translateY(-8px) scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }

.seat {
  position: absolute; transform: translate(-50%, -50%); width: 118px; text-align: center; transition: opacity .2s;
}
.seat .hole { display: flex; justify-content: center; gap: 3px; height: 45px; margin-bottom: -10px; position: relative; z-index: 1; direction: ltr; }
.seat .plate {
  position: relative; background: #0d1714; border: 2px solid var(--line); border-radius: 12px; padding: 6px 6px 5px; box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}
.seat .nm { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat .stk { font-family: var(--mono); font-size: 13px; color: var(--accent2); }
.seat .tag { position: absolute; top: -9px; right: -6px; font-size: 10px; padding: 1px 6px; border-radius: 6px; background: var(--line); color: var(--muted); font-family: var(--mono); }
.seat .dealer { position: absolute; top: -9px; left: -8px; width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #111; font-size: 11px; font-weight: 800; display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .5); }
.seat.turn .plate { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(233, 185, 73, .3), 0 0 22px rgba(233, 185, 73, .4); }
.seat.folded { opacity: .38; }
.seat.out { opacity: .22; filter: grayscale(1); }
.seat.win .plate { border-color: var(--good); box-shadow: 0 0 22px rgba(78, 208, 138, .55); }
.seat.hero .plate { background: #1a2a1f; }
.seat .bubble {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: -24px; white-space: nowrap;
  background: #fff; color: #111; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  animation: pop .2s ease-out;
}
.seat .bubble.f { background: #555; color: #ddd; } .seat .bubble.r { background: var(--accent); }
.seat .bubble.allin { background: var(--bad); color: #fff; }
.betchip { position: absolute; transform: translate(-50%, -50%); font-family: var(--mono); font-size: 12px; background: rgba(0, 0, 0, .55); padding: 1px 8px 1px 6px; border-radius: 999px; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.betchip::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px dashed #fff8; }
.seat .hand { font-size: 11px; color: var(--accent2); margin-top: 2px; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@media (max-width: 640px) {
  .seat { width: 92px; } .seat .nm { font-size: 12px; } .seat .stk { font-size: 12px; }
  .seat .hole { height: 37px; margin-bottom: -8px; }
}

/* ---------- controls ---------- */
.controls { max-width: 820px; margin: 0 auto 12px; }
#watchControls { display: flex; gap: 8px; justify-content: center; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.actions .btn { padding: 14px 6px; font-size: 16px; }
.actions .fold { background: #3a1d1d; border-color: #5e2b2b; }
.actions .call { background: #1d3a2b; border-color: #2c5e44; }
.actions .raise { background: linear-gradient(180deg, var(--accent2), var(--accent)); color: #1a1405; border-color: #b98d2b; }
.raise { margin-top: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.presets-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.presets-row button { flex: 1; border: 1px solid var(--line); background: var(--bg2); border-radius: 9px; padding: 7px 4px; cursor: pointer; font-size: 13px; }
.slider-row { display: flex; align-items: center; gap: 8px; }
.slider-row input[type=number] { width: 86px; flex: none; font-family: var(--mono); direction: ltr; }

.hint { background: #172820; border: 1px dashed #2f5240; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 14px; }
.hint .row { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.hint .k { color: var(--muted); }
.mix { margin-top: 8px; display: grid; gap: 4px; }
.mix .m { display: grid; grid-template-columns: 82px 1fr 44px; gap: 8px; align-items: center; font-size: 12px; }
.mix .bar { height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; direction: ltr; }
.mix .bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.mix .m.f .bar i { background: #8d4b4b; } .mix .m.c .bar i { background: #4c9c72; }

.after { max-width: 820px; margin: 0 auto 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.after-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.coach { font-size: 13px; line-height: 1.7; background: #2a2412; border: 1px solid #5a4a1d; border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; direction: ltr; text-align: left; }
.coach b { color: var(--accent2); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 1060px; margin: 0 auto; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }
.log { max-height: 340px; overflow: auto; font-family: var(--mono); font-size: 12px; line-height: 1.7; direction: ltr; text-align: left; }
.log .st { color: var(--accent2); margin-top: 6px; }
.log .hd { color: var(--muted); border-top: 1px solid var(--line); margin-top: 8px; padding-top: 6px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th, table.t td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.t th { color: var(--muted); font-weight: 500; font-size: 12px; }
table.t td:first-child, table.t th:first-child { text-align: right; }
.scroll { overflow-x: auto; }

/* ---------- eval ---------- */
.evlist { display: grid; gap: 8px; }
.evitem { display: flex; align-items: center; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.evitem:hover, .evitem.sel { border-color: var(--accent); }
.evitem .main { flex: 1; min-width: 0; }
.evitem .lu { font-family: var(--mono); font-size: 12px; direction: ltr; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.evitem .meta { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--line); white-space: nowrap; }
.badge.running, .badge.queued { background: #3c3213; color: var(--accent2); }
.badge.done { background: #163a28; color: var(--good); }
.badge.error, .badge.cancelled { background: #3a1717; color: #ffb4b4; }
.progress { height: 6px; background: var(--bg2); border-radius: 3px; overflow: hidden; margin: 10px 0; direction: ltr; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.chart { width: 100%; height: auto; display: block; direction: ltr; }
.chart text { font-family: var(--mono); font-size: 11px; fill: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; margin: 6px 0 2px; direction: ltr; justify-content: flex-start; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 10px 0; }
.kpi { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.kpi .v { font-family: var(--mono); font-size: 20px; font-weight: 700; direction: ltr; text-align: right; }
.kpi .l { font-size: 12px; color: var(--muted); }
.note { font-size: 13px; color: var(--muted); line-height: 1.8; margin-top: 8px; }
h3 { font-size: 15px; margin: 18px 0 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #3a1717; border: 1px solid #6a2626; color: #ffd6d6; padding: 10px 16px; border-radius: 12px; z-index: 50; max-width: 90vw; }
