:root{
  --bg:#0b0907;
  --panel:#1a1512;
  --panel-2:#241d18;
  --border:#3a2e24;
  --accent:#e0b04a;
  --accent2:#f59e0b;
  --text:#f1ebe2;
  --muted:#a8998a;
  --felt:#0b5c3f;
  --bg2:#2a1d14;
  --accent-text:#2a1a05;
  --mc-face1:#2b2b2f; --mc-face2:#050506; --mc-edge:rgba(214,176,92,0.55); --mc-black:#e9c25a; --mc-red:#eea683;
  --title-font:inherit;
}
*{box-sizing:border-box;}
html, body{height:100%;}
body{
  margin:0;
  height:100dvh;
  overflow:hidden;
  background:radial-gradient(ellipse at 50% 35%, var(--bg2) 0%, var(--bg) 70%);
  transition:background 0.4s;
  color:var(--text);
  font-family:'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  display:flex;
  flex-direction:column;
}
a{color:var(--accent);}
.topbar{
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 22px;
  border-bottom:1px solid var(--border);
}
.topbar .back{
  color:var(--muted);
  text-decoration:none;
  font-size:0.9rem;
}
.topbar h1{
  font-size:1.15rem;
  margin:0;
}
.layout{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  flex-wrap:nowrap;
  gap:20px;
  padding:14px 22px;
  max-width:1320px;
  width:100%;
  margin:0 auto;
  align-items:stretch;
  justify-content:center;
}
.board-wrap{
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:6px;
}
.canvas-frame{
  flex:1 1 auto;
  min-height:0;
  width:100%;
  position:relative;
}
/* fills the whole board area; render.js fits the table to whatever size it gets */
#tableCanvas{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  display:block;
  background:#0a0705;
  border-radius:14px;
  box-shadow:0 20px 60px rgba(0,0,0,0.7), 0 0 0 1px rgba(255,220,170,0.06);
  touch-action:none;
}
.hint{
  flex:0 0 auto;
  color:var(--muted);
  font-size:0.8rem;
  text-align:center;
  max-width:600px;
}
.panel{
  flex:0 0 320px;
  align-self:center;
  min-height:0;
  max-height:100%;
  overflow-y:auto;
  background:linear-gradient(180deg, var(--panel-2), var(--panel));
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:0 12px 36px rgba(0,0,0,0.45);
  padding:18px;
  width:320px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.panel h2{
  margin:0;
  font-size:1.05rem;
}
.setup-tabs{
  display:flex;
  gap:8px;
}
.tab-btn{
  flex:1;
  padding:8px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel-2);
  color:var(--text);
  cursor:pointer;
  font-size:0.85rem;
}
.tab-btn.active{
  border-color:var(--accent);
  color:var(--accent);
}
.setup-panel label{
  display:block;
  font-size:0.8rem;
  color:var(--muted);
  margin-bottom:4px;
  margin-top:10px;
}
input[type="text"]{
  width:100%;
  padding:9px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel-2);
  color:var(--text);
  font-size:0.95rem;
}
input[type="range"]{
  width:100%;
  accent-color:var(--accent);
}
button{
  cursor:pointer;
  font-family:inherit;
}
.primary-btn{
  width:100%;
  padding:11px;
  margin-top:14px;
  border-radius:8px;
  border:none;
  background:linear-gradient(rgba(255,255,255,0.22), rgba(0,0,0,0.15)), var(--accent);
  box-shadow:inset 0 1px 0 rgba(255,255,255,0.3), 0 3px 8px rgba(0,0,0,0.4);
  color:var(--accent-text);
  font-weight:600;
  font-size:0.95rem;
}
.primary-btn:hover{filter:brightness(1.08);}
.primary-btn:disabled{opacity:0.4; cursor:not-allowed;}
.secondary-btn{
  width:100%;
  padding:9px;
  border-radius:8px;
  border:1px solid var(--border);
  background:transparent;
  color:var(--text);
  font-size:0.85rem;
}
#hostPanel[hidden], #joinPanel[hidden], #practicePanel[hidden]{display:none;}
.room-code-box{
  margin-top:14px;
  padding:12px;
  background:var(--panel-2);
  border-radius:8px;
  text-align:center;
}
.room-code-box .code{
  font-size:1.5rem;
  letter-spacing:4px;
  font-weight:700;
  color:var(--accent);
}
.room-code-box .sub{
  font-size:0.75rem;
  color:var(--muted);
  margin-top:4px;
}
.sub{
  font-size:0.75rem;
  color:var(--muted);
}
.link-row{
  display:flex;
  gap:6px;
  margin-top:8px;
}
.link-row input{
  flex:1;
  font-size:0.75rem;
}
.link-row button{
  padding:0 12px;
  border-radius:8px;
  border:1px solid var(--border);
  background:var(--panel-2);
  color:var(--accent);
}
.lobby-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin:8px 0;
}
.lobby-row{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:7px 10px;
  background:var(--panel-2);
  border-radius:8px;
  font-size:0.85rem;
}
.lobby-row .bot-tag{
  font-size:0.7rem;
  color:var(--muted);
}

/* in-game HUD */
#handStatus{
  font-size:0.85rem;
  color:var(--muted);
}
#turnStatus{
  text-align:center;
  padding:10px;
  border-radius:8px;
  background:var(--panel-2);
  font-size:0.92rem;
  min-height:20px;
}
#log{
  flex:1 1 auto;
  min-height:60px;
  overflow-y:auto;
  background:var(--panel-2);
  border-radius:8px;
  padding:8px 10px;
  font-size:0.76rem;
  color:var(--muted);
  display:flex;
  flex-direction:column;
  gap:3px;
}
#gamePanel[hidden], #setupPanel[hidden], .action-bar[hidden], .raise-row[hidden]{display:none;}

/* action bar (betting controls under the table) */
.action-bar{
  flex:0 0 auto;
  width:100%;
  max-width:640px;
  display:flex;
  flex-direction:column;
  gap:8px;
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 14px;
}
.pot-info{
  text-align:center;
  font-size:0.85rem;
  color:var(--accent2);
  font-weight:600;
}
.action-buttons{
  display:flex;
  gap:8px;
}
.act-btn{
  flex:1;
  padding:11px;
  border-radius:9px;
  border:none;
  font-weight:700;
  font-size:0.95rem;
  color:#2a1a05;
}
.act-btn{box-shadow:inset 0 1px 0 rgba(255,255,255,0.25), 0 3px 8px rgba(0,0,0,0.4); text-shadow:0 1px 1px rgba(0,0,0,0.25);}
.act-btn.fold{background:linear-gradient(#c7303f, #8e1622); color:#fff;}
.act-btn.check{background:linear-gradient(#2f9a63, #17683f); color:#fff;}
.act-btn.bet{background:linear-gradient(rgba(255,255,255,0.22), rgba(0,0,0,0.15)), var(--accent); color:var(--accent-text);}
.act-btn:not(:disabled):hover{filter:brightness(1.1);}
.act-btn:disabled{opacity:0.35; cursor:not-allowed;}
.raise-row{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.raise-amount{
  text-align:center;
  font-weight:700;
  font-size:1.1rem;
  color:var(--accent2);
}
.quick-bets{
  display:flex;
  gap:6px;
}
.quick-btn{
  flex:1;
  padding:7px;
  border-radius:7px;
  border:1px solid var(--border);
  background:var(--panel-2);
  color:var(--text);
  font-size:0.78rem;
}

/* the log toggle only exists on small screens */
.status-row{display:flex; gap:6px; align-items:stretch;}
.status-row #turnStatus{flex:1;}
.log-toggle{display:none;}

/* ---------- phones & tablets, portrait ----------
   The table (drawn upright by render.js) gets all the height it can;
   the side panel shrinks to a status strip with a collapsible log. */
@media (max-width: 900px) and (orientation: portrait), (max-aspect-ratio: 6/5) and (orientation: portrait){
  .layout{flex-direction:column; padding:6px 8px; gap:6px;}
  .board-wrap{flex:1 1 auto; min-height:0; gap:6px;}
  .canvas-frame{flex:1 1 auto; min-height:0;}
  .hint{font-size:0.68rem;}
  body.in-game .hint{display:none;}
  .panel{flex:0 0 auto; width:100%; max-height:46dvh; padding:10px 12px; gap:8px; align-self:stretch;}
  /* before a game: the setup panel needs the room, so the table stays smaller */
  body:not(.in-game) .board-wrap{flex:0 0 34dvh;}
  body:not(.in-game) .panel{flex:1 1 auto; max-height:none; min-height:0;}
  #gamePanel{gap:6px;}
  #gamePanel h2, #handStatus, #gamePanel .fun-note{display:none;}
  #turnStatus{padding:8px; font-size:0.85rem; min-height:0;}
  .log-toggle{
    display:block; flex:0 0 auto; padding:0 12px; border-radius:8px;
    border:1px solid var(--border); background:var(--panel-2); color:var(--accent); font-size:0.8rem; font-weight:600;
  }
  #log{display:none; max-height:24dvh; min-height:0;}
  body.log-open #log{display:flex;}
  #leaveBtn{padding:7px; font-size:0.8rem;}
  .action-bar{padding:8px 10px; gap:6px;}
  .act-btn{padding:10px 4px; font-size:0.9rem;}
}

/* ---------- phones & tablets, landscape ----------
   Table uses the full height on the left; a slim column on the right holds
   turn status, the collapsible log and the betting buttons (so they never
   cover a seat - the table is height-limited, so the column costs nothing). */
@media (orientation: landscape) and (max-height: 600px), (orientation: landscape) and (max-width: 1199px) and (min-aspect-ratio: 6/5){
  :root{--side-col:250px;}
  .topbar{padding:4px 12px;}
  .layout{flex-direction:row; padding:4px 8px 6px; gap:8px; position:relative;}
  .board-wrap{flex:1 1 auto; position:relative; gap:0;}
  body.in-game .board-wrap{padding-right:var(--side-col);}
  .canvas-frame{flex:1 1 auto; min-height:0;}
  .hint{display:none;}
  body:not(.in-game) .panel{flex:0 0 300px; width:300px; max-height:100%; align-self:stretch; padding:10px 12px; gap:8px;}
  #gamePanel{
    position:absolute; top:4px; right:8px; z-index:5; width:calc(var(--side-col) - 8px);
    max-height:calc(100% - 140px); padding:8px; gap:6px; border-radius:10px; overflow:auto;
  }
  #gamePanel h2, #gamePanel .fun-note{display:none;}
  #handStatus{font-size:0.72rem;}
  #turnStatus{padding:6px; font-size:0.8rem; min-height:0;}
  .log-toggle{display:block; flex:0 0 auto; padding:0 9px; border-radius:7px; border:1px solid var(--border); background:var(--panel-2); color:var(--accent); font-size:0.74rem; font-weight:600;}
  #log{display:none; max-height:none; flex:1 1 auto; font-size:0.68rem; padding:5px 7px; min-height:0;}
  body.log-open #log{display:flex;}
  #leaveBtn{padding:5px; font-size:0.74rem; margin:0;}
  .action-bar{position:absolute; right:0; bottom:0; z-index:5; width:calc(var(--side-col) - 8px); max-width:none; padding:8px; gap:6px; border-radius:10px;}
  .action-buttons{flex-wrap:wrap;}
  .pot-info{font-size:0.76rem;}
  .act-btn{padding:9px 4px; font-size:0.86rem;}
}
@media (orientation: landscape) and (max-height: 600px){
  :root{--side-col:200px;}
  .topbar h1{font-size:0.95rem;}
  .topbar .back{font-size:0.8rem;}
  .rk-toggle{padding:4px 9px; font-size:0.72rem;}
  #handStatus{display:none;}
  #gamePanel{max-height:calc(100% - 110px); padding:6px; gap:4px;}
  .act-btn{padding:7px 2px; font-size:0.78rem;}
  .action-bar{padding:6px; gap:4px;}
}

/* ---------- hand rankings cheat sheet ---------- */
.rk-toggle{
  padding:6px 12px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--panel-2);
  color:var(--accent);
  font-size:0.8rem;
  font-weight:600;
  white-space:nowrap;
}
@media (max-width: 520px){
  .topbar{padding:10px 12px; gap:8px;}
  .topbar h1{font-size:1rem;}
  .rk-toggle{padding:5px 9px; font-size:0.72rem;}
}
.rk-toggle.active, .rk-toggle:hover{border-color:var(--accent);}
.rankings{
  flex:0 0 290px;
  width:290px;
  align-self:center;
  max-height:100%;
  overflow-y:auto;
  background:linear-gradient(180deg, var(--panel-2), var(--panel));
  border:1px solid var(--border);
  border-radius:14px;
  box-shadow:0 12px 36px rgba(0,0,0,0.45);
  padding:14px 14px 10px;
}
body.rankings-hidden .rankings{display:none;}
.rk-head{display:flex; align-items:center; justify-content:space-between;}
.rk-head h2{margin:0; font-size:1rem; letter-spacing:0.02em;}
.rk-close{
  border:none;
  background:transparent;
  color:var(--muted);
  font-size:1.3rem;
  line-height:1;
  padding:0 4px;
}
.rk-close:hover{color:var(--text);}
.rk-intro, .rk-foot{
  margin:6px 0 8px;
  font-size:0.72rem;
  line-height:1.35;
  color:var(--muted);
}
.rk-foot{margin:6px 0 0;}
.rk-list{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:2px;}
.rk-row{
  display:grid;
  grid-template-columns:auto 1fr;
  grid-template-areas:"title title" "cards blurb";
  column-gap:8px;
  align-items:center;
  padding:5px 7px;
  border-radius:9px;
  border:1px solid transparent;
  transition:background 0.2s, border-color 0.2s;
}
.rk-row.current{
  background:rgba(224,176,74,0.12);
  border-color:rgba(224,176,74,0.65);
  box-shadow:0 0 14px rgba(224,176,74,0.18);
}
.rk-title{
  display:flex;
  align-items:center;
  gap:7px;
  grid-area:title;
  font-size:0.74rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.03em;
}
.rk-num{
  flex:0 0 auto;
  width:18px;
  height:18px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:linear-gradient(#d23a47, #9b1622);
  color:#fff;
  font-size:0.66rem;
}
.rk-you{
  display:none;
  margin-left:auto;
  padding:1px 7px;
  border-radius:999px;
  background:var(--accent);
  color:#2a1a05;
  font-size:0.6rem;
  letter-spacing:0.06em;
}
.rk-row.current .rk-you{display:inline-block;}
.rk-cards{grid-area:cards; display:flex; gap:2px; margin:4px 0 0;}
.mini-card{
  width:22px;
  height:30px;
  border-radius:4px;
  background:linear-gradient(135deg, var(--mc-face1), var(--mc-face2));
  border:1px solid var(--mc-edge);
  box-shadow:0 1px 3px rgba(0,0,0,0.6);
  color:var(--mc-black);
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  font-family:Georgia, "Times New Roman", serif;
  font-weight:700;
  line-height:1;
}
.mini-card.red{color:var(--mc-red);}
.mini-card.kicker{opacity:0.4;}
.mc-rank{font-size:0.72rem; letter-spacing:-0.04em;}
.mc-suit{font-size:0.78rem; margin-top:1px;}
.rk-blurb{grid-area:blurb; margin-top:4px; font-size:0.66rem; line-height:1.25; color:var(--muted);}

/* narrower screens: the chart becomes a slide-over drawer */
@media (max-width: 1199px), (max-aspect-ratio: 6/5){
  .rankings{
    position:fixed;
    top:0;
    left:0;
    bottom:0;
    z-index:50;
    width:min(290px, 86vw);
    max-height:none;
    border-radius:0 14px 14px 0;
    transform:translateX(-105%);
    transition:transform 0.25s ease;
  }
  body.rankings-hidden .rankings{display:block;}
  body.rankings-open .rankings{transform:translateX(0);}
}

/* ---------- wide screens: big table, slim corner panels ----------
   Hand rankings is a slim column on the left. The game log floats in the
   table's top-right corner and the betting controls in its bottom-right
   corner (over the empty room outside the rail), so the table gets almost
   the whole page. */
@media (min-width: 1200px) and (min-aspect-ratio: 6/5){
  .topbar{padding:6px 18px;}
  .layout{max-width:none; padding:8px 14px; gap:12px; position:relative;}
  .board-wrap{position:relative;}
  body:has(#gamePanel:not([hidden])) .hint{display:none;}

  .rankings{
    flex:0 0 212px;
    width:212px;
    align-self:flex-start;
    padding:10px 10px 8px;
    border-radius:12px;
  }
  .rk-head h2{font-size:0.82rem;}
  .rk-close{font-size:1.1rem;}
  .rk-intro, .rk-foot, .rk-blurb{display:none;}
  .rk-list{margin-top:6px; gap:1px;}
  .rk-row{
    grid-template-columns:auto 1fr;
    grid-template-areas:"cards title";
    column-gap:7px;
    padding:3px 5px;
    border-radius:7px;
    cursor:help;
  }
  .rk-cards{margin:0; gap:1px;}
  .mini-card{width:15px; height:21px; border-radius:3px;}
  .mc-rank{font-size:0.52rem; letter-spacing:-0.06em;}
  .mc-suit{font-size:0.56rem; margin-top:0;}
  .rk-title{font-size:0.6rem; gap:4px; letter-spacing:0.01em; white-space:nowrap;}
  .rk-num{width:14px; height:14px; font-size:0.54rem;}
  .rk-row{position:relative;}
  .rk-you{position:absolute; top:-6px; right:4px; margin:0; font-size:0.5rem; padding:0 5px;}

  /* floating glass panels over the table's corners */
  #gamePanel, .action-bar{
    background:rgba(22,17,13,0.78);
    -webkit-backdrop-filter:blur(8px);
    backdrop-filter:blur(8px);
    border:1px solid rgba(255,220,170,0.12);
    box-shadow:0 10px 30px rgba(0,0,0,0.5);
  }
  #gamePanel{
    position:absolute;
    top:8px;
    right:14px;
    z-index:5;
    width:210px;
    max-height:none;
    padding:8px 10px;
    gap:5px;
    border-radius:12px;
  }
  #gamePanel h2{display:none;}
  #handStatus{display:none;}
  #turnStatus{font-size:0.76rem; padding:5px; min-height:0;}
  #log{font-size:0.66rem; padding:5px 8px; min-height:0; max-height:46px; flex:0 0 auto;}
  #leaveBtn{padding:4px; font-size:0.72rem;}

  .action-bar{
    position:absolute;
    right:0;
    bottom:0;
    z-index:5;
    width:300px;
    max-width:none;
    padding:8px 10px;
    gap:6px;
  }
  .pot-info{font-size:0.78rem;}
  .act-btn{padding:8px 4px; font-size:0.85rem;}
}

/* ---------- room picker ---------- */
.room-picker{display:flex; flex-direction:column; gap:6px;}
.rp-label{font-size:0.72rem; color:var(--muted); text-transform:uppercase; letter-spacing:0.08em;}
.rp-label.high{margin-top:6px; color:var(--accent); font-family:Cinzel, Georgia, serif; letter-spacing:0.14em;}
.rooms{display:grid; grid-template-columns:repeat(3, 1fr); gap:6px;}
.rooms.high{grid-template-columns:1fr 1fr;}
.room-tile{
  position:relative; overflow:hidden;
  display:flex; flex-direction:column; align-items:flex-start; gap:1px;
  padding:8px 8px 7px; border-radius:10px; border:1px solid var(--border);
  background:var(--tile-bg); color:#fff; text-align:left; font-size:0.72rem;
  box-shadow:inset 0 0 0 1px rgba(255,255,255,0.04);
  transition:transform 0.15s, box-shadow 0.15s;
}
.room-tile:hover:not(:disabled){transform:translateY(-2px);}
.room-tile .ri{font-size:1rem;}
.room-tile b{font-size:0.8rem; letter-spacing:0.02em;}
.room-tile .buyin{font-weight:700; color:var(--tile-accent);}
.room-tile .blinds{opacity:0.7; font-size:0.64rem;}
.room-tile.active{box-shadow:0 0 0 2px var(--tile-accent), 0 6px 18px rgba(0,0,0,0.45);}
.room-tile:disabled{opacity:0.45; cursor:default;}
.room-tile.active:disabled{opacity:1;}
.rooms.high .room-tile{padding:10px; font-size:0.75rem;}
.rooms.high .room-tile b{font-family:Cinzel, Georgia, serif; font-size:0.95rem; letter-spacing:0.1em;}
.room-note{font-size:0.72rem; color:var(--muted); margin:0;}
body.serif .topbar h1, body.serif .panel h2{font-family:Cinzel, Georgia, serif; letter-spacing:0.08em;}

/* play-money notice */
.fun-note{
  font-size:0.74rem; line-height:1.4; color:var(--text);
  padding:8px 10px; border-radius:9px;
  background:rgba(255,255,255,0.05); border:1px dashed var(--border);
}
.fun-note b{color:var(--accent);}
.fun-note.small{font-size:0.66rem; color:var(--muted); text-align:center; padding:5px 8px;}

/* turn timer in the betting panel */
.pot-row{display:flex; align-items:center; justify-content:center; gap:10px;}
.turn-timer{
  font-weight:800; font-size:0.85rem; padding:2px 10px; border-radius:999px;
  background:rgba(61,220,132,0.15); color:#5ee59a; border:1px solid rgba(61,220,132,0.4);
  font-variant-numeric:tabular-nums;
}
.turn-timer.warn{background:rgba(239,68,68,0.18); color:#ff7a7a; border-color:rgba(239,68,68,0.55); animation:timerPulse 0.5s ease-in-out infinite alternate;}
@keyframes timerPulse{to{transform:scale(1.08);}}

/* zoom controls on the table */
.canvas-frame{position:relative;}
.zoom-tools{position:absolute; left:10px; top:10px; z-index:6; display:flex; flex-direction:column; gap:6px;}
.zoom-tools button{
  width:38px; height:38px; border-radius:11px; font-size:1.2rem; font-weight:700; line-height:1;
  border:1px solid rgba(255,255,255,0.18); background:rgba(10,10,12,0.72); color:#fff;
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
}
.zoom-tools button:active{transform:scale(0.94);}
#zoomOut[disabled]{opacity:0.35;}
@media (orientation: landscape) and (max-height: 600px){
  .zoom-tools{top:6px; left:6px; gap:4px;}
  .zoom-tools button{width:32px; height:32px; font-size:1rem;}
}
