:root {
  --bg: #0b2a20;
  --bg2: #0f3427;
  --card: #144233;
  --card2: #1a5040;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4efe1;
  --muted: #a7b9ad;
  --gold: #e8b64c;
  --gold-ink: #2a1d00;
  --red: #d9534a;
  --blue: #3d8fd6;
  --green: #35b072;
  --pos: #5fd394;
  --neg: #ff7b70;
  --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(120% 80% at 50% 0%, #134a37 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Hebrew", "Arial Hebrew", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
.n { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
[hidden] { display: none !important; }

main {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100%;
  padding: calc(12px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  display: flex;
  flex-direction: column;
}

/* ---------- entry screens ---------- */
.brand { text-align: center; margin: 28px 0 22px; }
.brand img { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.brand h1 { margin: 12px 0 2px; font-size: 34px; letter-spacing: .5px; }
.brand p { margin: 0; color: var(--muted); }
h2 { font-size: 22px; margin: 6px 0 14px; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 15px; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=number], input:not([type]), select {
  width: 100%;
  background: rgba(0,0,0,.28);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 19px;
  outline: none;
}
input:focus, select:focus { border-color: var(--gold); }
input.code { text-align: center; font-size: 30px; letter-spacing: 8px; direction: ltr; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stack-v { display: flex; flex-direction: column; gap: 10px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--card2);
  font-size: 19px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
.btn:active { transform: scale(.98); filter: brightness(1.1); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--gold); color: var(--gold-ink); }
.btn.red { background: var(--red); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.green { background: var(--green); color: #04220f; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.link { background: none; min-height: 44px; color: var(--muted); font-weight: 500; text-decoration: underline; font-size: 16px; }
.btn.sm { min-height: 40px; font-size: 16px; padding: 6px 12px; width: auto; border-radius: 10px; }
.btn .sub { font-weight: 500; opacity: .85; font-size: 15px; }
.or { text-align: center; color: var(--muted); margin: 6px 0; }
.err { color: var(--neg); min-height: 22px; font-size: 15px; margin: 4px 0 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.apk-banner {
  display: flex; align-items: center; gap: 12px;
  background: rgba(232,182,76,.12);
  border: 1px solid rgba(232,182,76,.35);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 10px 0 14px;
}
.apk-banner .t { flex: 1; font-size: 15px; }

/* ---------- top bar ---------- */
.top {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 10px;
}
.top .title { flex: 1; min-width: 0; }
.top .title b { font-size: 18px; }
.top .title .muted { font-size: 14px; display: block; }
.icon-btn {
  position: relative;
  width: 48px; height: 48px;
  border-radius: 14px; border: 0;
  background: var(--card);
  display: grid; place-items: center;
  font-size: 22px; cursor: pointer;
}
.badge {
  position: absolute; top: -4px; left: -4px;
  min-width: 22px; height: 22px; border-radius: 11px;
  background: var(--red); color: #fff; font-size: 13px; font-weight: 700;
  display: grid; place-items: center; padding: 0 5px;
}

/* ---------- lobby ---------- */
.code-big {
  text-align: center;
  font-size: 46px; font-weight: 800; letter-spacing: 10px;
  direction: ltr; color: var(--gold); margin: 2px 0 4px;
}
.prow {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.prow:first-child { border-top: 0; }
.seatno {
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.3); display: grid; place-items: center;
  font-size: 14px; color: var(--muted); flex: none;
}
.pname { flex: 1; min-width: 0; }
.pname b { font-weight: 650; overflow-wrap: anywhere; }
.tag {
  display: inline-block; font-size: 12px; font-weight: 700;
  padding: 2px 7px; border-radius: 8px; margin-inline-start: 6px;
  background: rgba(255,255,255,.1); color: var(--muted); vertical-align: 2px;
}
.tag.gold { background: var(--gold); color: var(--gold-ink); }
.tag.red { background: rgba(217,83,74,.25); color: #ffb3ad; }
.tag.blue { background: rgba(61,143,214,.25); color: #b9dbff; }
.tag.green { background: rgba(53,176,114,.25); color: #a9f0c8; }
.ctrls { display: flex; gap: 6px; flex: none; }
.ctrls .btn.sm { min-width: 40px; padding: 6px 8px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-inline-start: 6px; vertical-align: 2px; }
.dot.off { background: #6b7a72; }

/* ---------- game ---------- */
.table-head {
  text-align: center;
  background: radial-gradient(100% 120% at 50% 0%, #1d6249 0%, #144233 70%);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 12px 12px 14px;
  margin-bottom: 10px;
}
.stage { font-size: 15px; color: var(--muted); }
.stage b { color: var(--text); }
.pot-label { font-size: 14px; color: var(--muted); margin-top: 2px; }
.pot { font-size: 44px; font-weight: 800; line-height: 1.1; color: var(--gold); }
.instr {
  margin-top: 8px; font-size: 18px; font-weight: 700;
  background: rgba(0,0,0,.25); border-radius: 12px; padding: 8px 10px;
}
.waiting-strip {
  display: flex; align-items: center; gap: 10px;
  background: rgba(61,143,214,.18); border: 1px solid rgba(61,143,214,.4);
  border-radius: 14px; padding: 8px 12px; margin-bottom: 10px; font-size: 15px;
}
.waiting-strip span { flex: 1; }

.players { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pl {
  background: var(--card);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "role name stack" "role info bet";
  column-gap: 10px;
  align-items: center;
}
.pl.turn { border-color: var(--gold); background: #1c4f3b; box-shadow: 0 0 0 3px rgba(232,182,76,.18); }
.pl.out { opacity: .55; }
.pl.me .nm::after { content: " (אני)"; color: var(--muted); font-weight: 400; font-size: 14px; }
.pl .role { grid-area: role; display: flex; flex-direction: column; gap: 3px; width: 34px; align-items: center; }
.chip-role {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 800; direction: ltr;
}
.chip-role.d { background: #f4efe1; color: #111; }
.chip-role.sb { background: #2f6f9e; color: #fff; }
.chip-role.bb { background: #8a3d9a; color: #fff; }
.pl .nm { grid-area: name; font-weight: 650; font-size: 18px; min-width: 0; overflow-wrap: anywhere; }
.pl .stk { grid-area: stack; font-weight: 750; font-size: 19px; text-align: left; }
.pl .info { grid-area: info; font-size: 14px; color: var(--muted); min-width: 0; }
.pl .bet { grid-area: bet; text-align: left; font-size: 14px; color: var(--gold); white-space: nowrap; }
.pl .turnlbl { color: var(--gold); font-weight: 700; }

/* ---------- action panel ---------- */
.panel-space { flex: 1; }
.panel {
  position: sticky;
  bottom: 0;
  margin: 0 -16px calc(-16px - var(--safe-b));
  padding: 12px 16px calc(14px + var(--safe-b));
  background: linear-gradient(180deg, rgba(11,42,32,0) 0%, rgba(11,42,32,.96) 14%, var(--bg) 100%);
}
.panel .msg { text-align: center; font-size: 17px; margin-bottom: 10px; }
.panel .msg b { color: var(--gold); }
.your-turn {
  text-align: center; font-weight: 800; color: var(--gold-ink); background: var(--gold);
  border-radius: 12px; padding: 6px; margin-bottom: 10px; font-size: 17px;
}
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.actions .btn { min-height: 62px; font-size: 20px; flex-direction: column; gap: 0; }
.actions .wide { grid-column: 1 / -1; }

.raise .amt-row { display: grid; grid-template-columns: 62px 1fr 62px; gap: 10px; align-items: center; }
.raise .amt-row .btn { min-height: 62px; font-size: 30px; }
.raise input {
  text-align: center; font-size: 36px; font-weight: 800; direction: ltr;
  padding: 8px; color: var(--gold);
}
.raise .hint { text-align: center; font-size: 14px; color: var(--muted); margin: 8px 0; }
.raise .hint.bad { color: var(--neg); }
.raise .quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.raise .quick .btn { min-height: 46px; font-size: 16px; }
.raise-title { text-align: center; font-weight: 700; margin-bottom: 8px; }

/* ---------- sheets, banner, toast ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet {
  position: relative;
  width: 100%; max-width: 520px;
  max-height: 88vh; overflow-y: auto;
  background: var(--bg2);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  padding: 16px 16px calc(18px + var(--safe-b));
  animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
.sheet h3 { margin: 2px 0 12px; font-size: 20px; }
.sheet .menu-sec { font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.opt {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 54px; padding: 10px 14px; margin-bottom: 8px;
  border: 2px solid var(--line); border-radius: 14px;
  background: var(--card); text-align: start; font-size: 18px; cursor: pointer;
}
.opt.sel { border-color: var(--gold); background: #24543f; }
.opt .grow { flex: 1; }
.opt .check {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted);
  display: grid; place-items: center; font-size: 16px; flex: none;
}
.opt[disabled] { opacity: .5; }
.opt.sel .check { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.pay-line { display: flex; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); font-size: 19px; }
.pay-line:first-child { border-top: 0; }
.pay-line b { color: var(--gold); }

.banner {
  position: fixed; z-index: 40;
  top: calc(12px + var(--safe-t)); left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 488px;
  background: var(--gold); color: var(--gold-ink);
  border-radius: 18px; padding: 16px 18px;
  font-size: 22px; font-weight: 800; text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
  animation: drop .25s ease-out;
  pointer-events: none; /* never blocks a tap on what is under it */
}
@keyframes drop { from { transform: translate(-50%, -20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.toast {
  position: fixed; z-index: 50;
  bottom: calc(24px + var(--safe-b)); left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 488px;
  background: #2b0f0c; border: 1px solid var(--red); color: #ffd7d3;
  border-radius: 14px; padding: 12px 14px; font-size: 16px; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.ok { background: #0d2c1d; border-color: var(--green); color: #c9f5dc; }
.conn {
  position: fixed; z-index: 45; top: 0; left: 0; right: 0;
  padding: calc(6px + var(--safe-t)) 10px 6px;
  background: #7a4a00; color: #ffe9bf; text-align: center; font-size: 14px;
}
.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { box-shadow: inset 0 0 0 6px var(--gold); } 100% { box-shadow: inset 0 0 0 0 transparent; } }

/* ---------- final table ---------- */
table.final { width: 100%; border-collapse: collapse; font-size: 16px; }
table.final th { color: var(--muted); font-weight: 500; font-size: 13px; text-align: start; padding: 6px 4px; }
table.final td { padding: 10px 4px; border-top: 1px solid var(--line); }
table.final td.num, table.final th.num { text-align: left; }
table.final tr.total td { font-weight: 700; }
