:root {
  --felt-1: #0b3d2e;
  --felt-2: #0a3326;
  --ink: #0c1311;
  --card-bg: #fbfbf7;
  --card-back: #14513c;
  --line: rgba(255, 255, 255, 0.10);
  --slot-empty: rgba(255, 255, 255, 0.06);
  --gold: #e8c878;
  --win: #36d399;
  --tie: #f0c14b;
  --lose: #5b6b66;
  --red: #d5342b;
  --black: #16201d;
  --text: #eef3f0;
  --muted: #9fb3ac;
  --radius: 14px;
  --sheet-h: 320px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background:
    radial-gradient(120% 80% at 50% 0%, #0f4a37 0%, var(--felt-1) 45%, var(--felt-2) 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 520px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 16px calc(env(safe-area-inset-bottom) + 24px);
  padding-top: max(env(safe-area-inset-top), 10px);
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 2px 14px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.brand-mark {
  color: var(--gold);
  font-size: 22px;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.4));
}
.brand-name { letter-spacing: .5px; font-size: 19px; }
.reset-btn {
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .08s;
}
.reset-btn:active { transform: scale(.95); background: rgba(255,255,255,.14); }

/* ---------- Result ---------- */
.result {
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 18px 16px;
  margin-bottom: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.result-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.equity-value {
  font-size: 58px;
  line-height: .92;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--win);
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.equity-value .pct { font-size: 26px; font-weight: 700; margin-left: 2px; color: var(--muted); }
.equity-label { color: var(--muted); font-size: 13px; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
.result-side { display: flex; gap: 18px; padding-bottom: 6px; }
.side-stat { text-align: right; font-variant-numeric: tabular-nums; }
.side-stat span { display: block; font-size: 22px; font-weight: 700; }
.side-stat small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }

.bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0 10px;
  background: rgba(0,0,0,.25);
}
.bar > div { transition: width .35s cubic-bezier(.2,.8,.2,1); }
.bar-win  { background: var(--win); }
.bar-tie  { background: var(--tie); }
.bar-lose { background: var(--lose); }

.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  gap: 10px;
}
.timing { font-variant-numeric: tabular-nums; white-space: nowrap; }
.result.calculating .equity-value { opacity: .55; }

/* ---------- Groups ---------- */
.group { margin-bottom: 18px; }
.group-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin: 0 0 10px 2px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.board-legend { font-size: 10px; letter-spacing: .5px; color: rgba(159,179,172,.6); text-transform: none; }

/* ---------- Card slots ---------- */
.slots { display: flex; gap: 10px; }
.slots.board { gap: 7px; }
.slots.board .slot:nth-child(4) { margin-left: 10px; }
.slots.board .slot:nth-child(5) { margin-left: 0; }

.slot {
  flex: 1;
  aspect-ratio: 5 / 7;
  border-radius: var(--radius);
  border: 1.5px dashed rgba(255,255,255,.20);
  background: var(--slot-empty);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: transform .08s, border-color .15s, box-shadow .15s;
  user-select: none;
  min-width: 0;
}
.slots.board .slot { font-size: .92em; }
.slot:active { transform: scale(.96); }
.slot.empty::after { content: "+"; font-size: 26px; color: rgba(255,255,255,.30); font-weight: 300; }
.slot.active {
  border-style: solid;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(232,200,120,.25);
}
.slot.filled {
  border: none;
  background: var(--card-bg);
  box-shadow: 0 6px 14px rgba(0,0,0,.3);
}
.slot .card-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.slot .card-rank { font-size: clamp(22px, 7vw, 34px); font-weight: 800; letter-spacing: -1px; }
.slot .card-suit { font-size: clamp(18px, 6vw, 28px); margin-top: 2px; }
.card-face.red { color: var(--red); }
.card-face.black { color: var(--black); }

/* ---------- Opponents ---------- */
.opp-row {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
}
.opp-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.05);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 0;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .12s, transform .08s, color .12s;
  font-variant-numeric: tabular-nums;
}
.opp-btn:active { transform: scale(.92); }
.opp-btn.active {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}

/* ---------- Text entry ---------- */
.text-entry {
  width: 100%;
  background: rgba(255,255,255,.06);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 13px 14px;
  font-size: 16px;
  letter-spacing: 1px;
  outline: none;
  transition: border-color .15s;
}
.text-entry:focus { border-color: var(--gold); }
.hint { color: var(--muted); font-size: 11.5px; margin: 7px 2px 0; }

/* ---------- Pot odds ---------- */
.collapse-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.collapse-toggle .chev { transition: transform .2s; color: var(--muted); }
.collapse-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.pot-panel {
  border: 1px solid var(--line);
  border-top: none;
  border-radius: 0 0 12px 12px;
  margin-top: -1px;
  padding: 14px 16px 16px;
  background: rgba(0,0,0,.12);
}
.pot-inputs { display: flex; gap: 12px; }
.pot-inputs label {
  flex: 1;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pot-inputs input {
  background: rgba(255,255,255,.07);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 11px 12px;
  font-size: 16px;
  outline: none;
}
.pot-inputs input:focus { border-color: var(--gold); }
.pot-verdict {
  margin-top: 14px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  padding: 11px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  color: var(--muted);
}
.pot-verdict.plus { background: rgba(54,211,153,.15); color: var(--win); }
.pot-verdict.minus { background: rgba(213,52,43,.15); color: #ff7b72; }

/* ---------- AI advice ---------- */
.advice-btn {
  width: 100%;
  background: linear-gradient(180deg, #4a7c64, #2f5a45);
  color: #fff;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  padding: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .08s, opacity .15s;
}
.advice-btn:active { transform: scale(.98); }
.advice-btn:disabled { opacity: .4; cursor: not-allowed; }
.advice-btn.loading { opacity: .7; }
.advice-panel {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  background: rgba(0,0,0,.14);
}
.advice-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.advice-action {
  font-size: 22px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
}
.advice-action.fold { color: #ff7b72; }
.advice-action.call, .advice-action.check { color: var(--tie); }
.advice-action.raise { color: var(--win); }
.advice-size { font-size: 15px; color: var(--text); font-weight: 700; }
.advice-conf { margin-left: auto; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.advice-reason { margin-top: 8px; font-size: 13.5px; line-height: 1.5; color: var(--text); }

.foot { text-align: center; color: rgba(159,179,172,.5); font-size: 11px; margin-top: 22px; }

/* ---------- Bottom sheet picker ---------- */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: #103f2f;
  border-top: 1px solid rgba(255,255,255,.12);
  border-radius: 22px 22px 0 0;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 18px);
  box-shadow: 0 -12px 40px rgba(0,0,0,.4);
  animation: slideup .24s cubic-bezier(.2,.9,.2,1);
  max-width: 520px;
  margin: 0 auto;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; font-weight: 700; font-size: 15px;
}
.sheet-close {
  background: rgba(255,255,255,.08); border: none; color: var(--text);
  width: 30px; height: 30px; border-radius: 50%; font-size: 14px; cursor: pointer;
}
.picker-step + .picker-step { margin-top: 12px; }
.step-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 0 2px 8px; }

.rank-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.rank-btn {
  aspect-ratio: 1 / 1.15;
  border: 1px solid var(--line);
  background: var(--card-bg);
  color: var(--black);
  border-radius: 10px;
  font-size: 19px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .07s, box-shadow .12s, opacity .12s;
}
.rank-btn:active { transform: scale(.9); }
.rank-btn.selected { box-shadow: 0 0 0 3px var(--gold); }
.rank-btn:disabled { opacity: .28; cursor: not-allowed; }

.suit-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.suit-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  padding: 13px 0;
  border: 1px solid var(--line);
  background: var(--card-bg);
  border-radius: 12px;
  font-size: 26px;
  cursor: pointer;
  transition: transform .07s, box-shadow .12s, opacity .12s;
}
.suit-btn small { font-size: 10px; color: #6b6b66; font-weight: 700; }
.suit-btn:active { transform: scale(.92); }
.suit-btn.red { color: var(--red); }
.suit-btn.black { color: var(--black); }
.suit-btn:disabled { opacity: .28; cursor: not-allowed; }
.suit-btn.disabled-armed { animation: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 20px);
  transform: translateX(-50%);
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 13px; z-index: 60;
  animation: fade .2s ease;
}
