:root {
  --bg: #0f1a15;
  --panel: #16261f;
  --panel-2: #1d3229;
  --line: #2b4438;
  --text: #e9f0eb;
  --muted: #9ab0a4;
  --accent: #e8c15a;
  --ok: #5cc28a;
  --felt: #1f7049;
  --felt-dark: #13492f;
  --rail: #4b3423;
  --card-face: #fdfcf7;
  --card-red: #c62f2f;
  --card-black: #1b1d1c;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  min-height: 48px;
  min-width: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
button:hover:not(:disabled) { border-color: #4a6b5b; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button[aria-pressed="true"] { background: #284a3a; border-color: var(--ok); }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; margin: 0; margin-right: auto; font-weight: 650; }
.topbar-buttons { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  grid-template-areas: "table side" "controls side";
  grid-template-rows: auto auto;
  gap: 12px;
  padding: 12px max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}
@media (max-width: 899px), (orientation: portrait) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "table" "controls" "side";
  }
}

/* ---------- table ---------- */
.table-area { grid-area: table; container-type: inline-size; }
.table {
  position: relative;
  margin: 7cqw 7cqw 11cqw;
  aspect-ratio: 2 / 1;
  --cw: clamp(26px, 4.6cqw, 60px);      /* bot card width */
  --cw-me: clamp(40px, 7cqw, 86px);     /* my card width */
  --cw-board: clamp(36px, 6.6cqw, 80px);/* community card width */
}
.felt {
  position: absolute;
  inset: 0;
  border-radius: 50% / 50%;
  background: radial-gradient(ellipse at 50% 45%, var(--felt) 0%, var(--felt) 45%, var(--felt-dark) 100%);
  border: clamp(8px, 1.8cqw, 22px) solid var(--rail);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06), inset 0 8px 30px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.45);
}
.center {
  position: absolute;
  left: 50%;
  top: 49%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1cqw;
  width: 60%;
}
.pot { font-size: clamp(13px, 1.9cqw, 20px); color: #f3f6ef; background: rgba(0, 0, 0, 0.25); padding: 2px 12px; border-radius: 999px; }
.board { display: flex; gap: 0.8cqw; }
.board .card { --w: var(--cw-board); }
.slot { width: var(--cw-board); height: calc(var(--cw-board) * 1.4); border: 2px dashed rgba(255, 255, 255, 0.18); border-radius: 8px; }
.banner { min-height: 1.4em; font-size: clamp(12px, 1.7cqw, 18px); text-align: center; color: #fff6d8; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }

/* ---------- seats ---------- */
.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: clamp(96px, 17cqw, 190px);
  z-index: 2;
}
.seat .cards { display: flex; justify-content: center; gap: 3px; min-height: calc(var(--cw) * 1.4); }
.seat .card { --w: var(--cw); }
.seat.me .cards { min-height: calc(var(--cw-me) * 1.4); }
.seat.me .card { --w: var(--cw-me); }
.plate {
  width: 100%;
  background: rgba(10, 20, 15, 0.88);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px 8px 5px;
  text-align: center;
  font-size: clamp(12px, 1.5cqw, 15px);
  transition: box-shadow 0.2s, border-color 0.2s;
}
.name-row { display: flex; justify-content: center; align-items: center; gap: 5px; flex-wrap: wrap; }
.name { font-weight: 650; }
.style-tag { font-size: 0.8em; color: var(--muted); }
.stack { font-variant-numeric: tabular-nums; color: #f5e7b8; }
.seat-status { min-height: 1.3em; font-size: 0.9em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat.turn .plate { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(232, 193, 90, 0.35); }
.seat.turn .seat-status { color: var(--accent); }
.seat.folded .cards, .seat.folded .plate { opacity: 0.45; }
.seat.out .plate { opacity: 0.5; }
.seat.winner .plate { border-color: var(--ok); box-shadow: 0 0 0 3px rgba(92, 194, 138, 0.35); }
.seat.winner .seat-status { color: var(--ok); font-weight: 600; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
}
.badge.dealer { background: #f4f1e6; color: #222; }
.badge.sb { background: #3d6fb0; color: #fff; }
.badge.bb { background: #a8452e; color: #fff; }

.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.bet {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px 2px 3px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-size: clamp(12px, 1.5cqw, 15px);
  font-variant-numeric: tabular-nums;
  z-index: 1;
}
.chip { width: 1.1em; height: 1.1em; border-radius: 50%; background: #d8b24a; border: 2px dashed #fff8dc; }

/* ---------- cards ---------- */
.card {
  --w: 50px;
  position: relative;
  width: var(--w);
  height: calc(var(--w) * 1.4);
  border-radius: calc(var(--w) * 0.12);
  background: var(--card-face);
  color: var(--card-black);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  font-weight: 700;
  flex: none;
}
.card.red { color: var(--card-red); }
.card .corner { position: absolute; top: 6%; left: 9%; line-height: 0.95; text-align: center; font-size: calc(var(--w) * 0.34); }
.card .corner .s { display: block; font-size: 0.85em; }
.card .pip { position: absolute; right: 8%; bottom: 4%; font-size: calc(var(--w) * 0.55); line-height: 1; }
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.12) 0 3px, transparent 3px 7px),
    linear-gradient(135deg, #2c4f8a, #1b335d);
  border: 2px solid #f0f0f0;
}
.card.win { box-shadow: 0 0 0 3px var(--ok), 0 1px 3px rgba(0, 0, 0, 0.45); }
.card.dim { opacity: 0.55; }

/* ---------- controls ---------- */
.controls {
  grid-area: controls;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.status { min-height: 1.4em; font-weight: 600; }
.raise-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick { display: flex; gap: 6px; }
.quick button { padding: 0 10px; }
.slider-row { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 240px; }
.slider-row button { font-size: 22px; padding: 0; width: 48px; }
input[type="range"] { flex: 1; height: 48px; margin: 0; background: transparent; -webkit-appearance: none; appearance: none; }
input[type="range"]::-webkit-slider-runnable-track { height: 8px; border-radius: 4px; background: #2e4a3d; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 32px; height: 32px; margin-top: -12px; border-radius: 50%; background: var(--accent); border: 3px solid #fff3cc; }
input[type="range"]::-moz-range-track { height: 8px; border-radius: 4px; background: #2e4a3d; }
input[type="range"]::-moz-range-thumb { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); border: 3px solid #fff3cc; }
input[type="range"]:disabled { opacity: 0.4; }

.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.act { min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 18px; font-weight: 650; padding: 4px 8px; }
.act .caption { font-size: 12px; font-weight: 400; color: var(--muted); display: none; }
.beginner .act .caption { display: block; }
.act.fold { background: #3a2626; }
.act.call { background: #1f4232; }
.act.raise { background: #4b3e17; }
.act.hint { background: #22344a; }
.act.next { width: 100%; background: #2a5a42; border-color: var(--ok); font-size: 20px; }
.keys { margin: 0; font-size: 12px; color: var(--muted); }
@media (hover: none) { .keys { display: none; } }

/* ---------- side panel ---------- */
.side { grid-area: side; display: flex; flex-direction: column; gap: 12px; }
@media (min-width: 900px) and (orientation: landscape) {
  .side { position: sticky; top: 12px; max-height: calc(100vh - 90px); overflow-y: auto; }
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.hand-label { margin-top: 8px; }
.hand-label .main { font-size: 18px; }
.hand-label .draw { margin-top: 4px; color: #bfe6cf; }
.hint-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.hint-grid .stat { background: var(--panel-2); border-radius: 10px; padding: 6px 10px; }
.hint-grid .stat b { display: block; font-size: 22px; }
.hint-grid .stat small { color: var(--muted); }
.suggest { font-size: 18px; margin: 4px 0; }
.suggest b { color: var(--accent); }
.hint-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.log { margin: 0; padding-left: 20px; font-size: 14px; color: #cddbd2; max-height: 220px; overflow-y: auto; }
.log li { margin: 2px 0; }
.pots-list { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }

/* ---------- terms and tooltips ---------- */
.term { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
.term-pop {
  position: fixed;
  z-index: 50;
  max-width: 290px;
  background: #f7f3e6;
  color: #1c1c1c;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.term-pop b { display: block; margin-bottom: 3px; }
.term-pop p { margin: 0; }

/* ---------- dialogs ---------- */
dialog {
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--text);
  padding: 16px 20px 20px;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dlg-head h2 { font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--text); margin: 0; }
.rankings { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.rankings li { display: grid; grid-template-columns: 2em 1fr auto; align-items: center; gap: 10px; background: var(--panel-2); border-radius: 12px; padding: 8px 12px; }
.rankings .num { font-size: 20px; color: var(--muted); }
.rankings .title { font-weight: 650; }
.rankings .desc { font-size: 14px; color: var(--muted); }
.rankings .cards { display: flex; gap: 3px; }
.rankings .card { --w: 34px; }
@media (max-width: 560px) { .rankings li { grid-template-columns: 2em 1fr; } .rankings .cards { grid-column: 2; } }
.glossary dt { font-weight: 650; margin-top: 12px; }
.glossary dd { margin: 2px 0 0; color: #cddbd2; }

/* ---------- tool-site additions ---------- */
.summary-text { margin: 0; }
.summary-pot { margin: 4px 0 0; }
.back { color: var(--muted); text-decoration: none; min-height: 48px; display: inline-flex; align-items: center; }
.back:hover { color: var(--text); }
