/* haf.css: Hand and Foot score keeper. Card-table look: felt green, cream
 * cards, gold accents. Wide by default; stacks on phones. */

:root {
  --felt: #0b3d2c;
  --felt-2: #0f4d38;
  --felt-3: #145c43;
  --felt-line: rgba(255, 255, 255, .12);
  --cream: #fbf7ee;
  --paper: #ffffff;
  --ink: #1d2a24;
  --muted: #5f6f67;
  --line: #e4ddcc;
  --gold: #f2c14e;
  --gold-deep: #c9971c;
  --red: #c4343f;
  --red-soft: #fbe7e8;
  --ok: #1f8a5b;
  --ok-soft: #e1f3ea;
  --seat-1: #e8615a;
  --seat-2: #3d8bd9;
  --seat-3: #e0a21a;
  --seat-4: #8a5cd1;
  --seat-5: #20a58a;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .25);
  --head: 'Fredoka', 'Trebuchet MS', sans-serif;
  --body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--cream);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--felt-3), transparent 70%),
    repeating-linear-gradient(45deg, rgba(255,255,255,.015) 0 2px, transparent 2px 6px),
    var(--felt);
  background-attachment: fixed;
}
button, input { font: inherit; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.h-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px clamp(16px, 3vw, 40px);
  border-bottom: 1px solid var(--felt-line);
}
.h-brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--head); font-weight: 700; font-size: 1.35rem;
  color: var(--cream); text-decoration: none; letter-spacing: .3px;
}
.h-amp { color: var(--gold); }
.h-brand-cards { position: relative; width: 34px; height: 34px; }
.h-brand-cards span {
  position: absolute; width: 22px; height: 30px; border-radius: 4px;
  background: var(--paper); display: grid; place-items: center;
  font-size: 14px; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.h-brand-cards span:first-child { color: var(--red); left: 0; top: 2px; transform: rotate(-12deg); }
.h-brand-cards span:last-child { color: var(--ink); left: 11px; top: 0; transform: rotate(10deg); }
.h-top-right { display: flex; align-items: center; gap: 12px; }
.h-codechip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 7px 12px; border-radius: 999px; border: 1px solid var(--felt-line);
  background: rgba(255,255,255,.08); color: var(--cream);
}
.h-codechip:hover { background: rgba(255,255,255,.14); }
/* Turn-notification bell (js/notify.js): same pill as the code chip, gold when on. */
.h-bell {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border-radius: 999px; border: 1px solid var(--felt-line); background: rgba(255,255,255,.08);
  font-size: 1.15rem; line-height: 1; cursor: pointer; padding: 0; filter: grayscale(1) opacity(.7);
}
.h-bell:hover { background: rgba(255,255,255,.14); }
.h-bell.is-on { filter: none; border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }
.h-bell:disabled { cursor: wait; }
.h-codechip strong { font-family: var(--head); letter-spacing: 2px; color: var(--gold); font-size: 1.05rem; }
.h-codechip-label, .h-codechip-count { font-size: .8rem; opacity: .8; }
.h-me { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }

/* ---------- shared ---------- */
.h-card {
  background: var(--cream); color: var(--ink);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: clamp(18px, 2.2vw, 28px);
}
.h-card h2, .h-card h3 { font-family: var(--head); margin: 0 0 14px; color: var(--felt); }
.h-label { display: block; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin-bottom: 8px; }
.h-field { display: block; margin-bottom: 16px; }
.h-field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.h-field input {
  width: 100%; padding: 12px 14px; font-size: 1.1rem;
  border: 2px solid var(--line); border-radius: 12px; background: var(--paper); color: var(--ink);
}
.h-field input:focus, .h-num input:focus { outline: none; border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(242,193,78,.35); }
.h-code-input { font-family: var(--head); letter-spacing: 6px; text-transform: uppercase; text-align: center; font-size: 1.6rem !important; }

.h-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 22px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--felt); color: var(--cream); font-weight: 700; font-size: 1.02rem;
  transition: transform .08s ease, filter .15s ease;
}
.h-btn:hover { filter: brightness(1.12); }
.h-btn:active { transform: translateY(1px); }
.h-btn:disabled { opacity: .55; cursor: default; }
.h-btn-gold { background: linear-gradient(180deg, var(--gold), var(--gold-deep)); color: #2b2108; }
.h-btn-ghost { background: transparent; color: var(--felt); border: 2px solid var(--line); }
.h-btn-sm { min-height: 38px; padding: 6px 14px; font-size: .92rem; }
.h-link-btn { margin-left: auto; background: none; border: 0; color: var(--red); font-weight: 600; cursor: pointer; text-decoration: underline; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.h-msg { min-height: 1.3em; margin: 12px 0 0; color: var(--red); font-weight: 600; }
.h-msg.is-ok { color: var(--ok); }

.h-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.h-chip {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 14px 6px 6px; min-height: 44px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--paper); color: var(--ink); font-weight: 600;
}
.h-chip[aria-pressed="true"] { border-color: var(--felt); background: var(--felt); color: var(--cream); }
.h-chip-check { color: var(--ok); font-weight: 800; }
.h-chip[aria-pressed="true"] .h-chip-check { color: var(--gold); }

.h-av {
  display: inline-grid; place-items: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%;
  font-family: var(--head); font-weight: 700; color: #fff; font-size: .95rem;
  background: var(--muted);
}
.h-av-big { width: 46px; height: 46px; font-size: 1.3rem; }
.h-seat-1 .h-av, .h-av.h-seat-1 { background: var(--seat-1); }
.h-seat-2 .h-av, .h-av.h-seat-2 { background: var(--seat-2); }
.h-seat-3 .h-av, .h-av.h-seat-3 { background: var(--seat-3); }
.h-seat-4 .h-av, .h-av.h-seat-4 { background: var(--seat-4); }
.h-seat-5 .h-av, .h-av.h-seat-5 { background: var(--seat-5); }

.h-pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #efe8d6; color: var(--muted); }
.h-pill-ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- home ---------- */
.h-home { padding: clamp(20px, 4vw, 56px) clamp(16px, 3vw, 40px); }
.h-hero { text-align: center; margin: 0 auto 32px; max-width: 760px; }
.h-hero h1 { font-family: var(--head); font-size: clamp(2rem, 5vw, 3.2rem); margin: 0 0 10px; color: var(--gold); }
.h-hero p { font-size: 1.1rem; line-height: 1.55; opacity: .9; margin: 0; }
.h-home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(16px, 2.5vw, 32px); max-width: 1100px; margin: 0 auto; }
.h-home-grid .h-btn { width: 100%; }
.h-rejoin { margin-bottom: 16px; }

/* ---------- game layout ---------- */
.h-game { padding: 18px clamp(16px, 3vw, 40px) 48px; }
.h-tabs {
  display: flex; gap: 6px; padding: 6px; margin: 0 auto 22px; width: fit-content; max-width: 100%;
  background: rgba(0,0,0,.25); border-radius: 999px; border: 1px solid var(--felt-line);
}
.h-tabs button {
  border: 0; background: transparent; color: var(--cream); cursor: pointer;
  padding: 10px clamp(14px, 2.4vw, 28px); border-radius: 999px; font-weight: 700; font-size: 1rem; white-space: nowrap;
}
.h-tabs button[aria-selected="true"] { background: var(--gold); color: #2b2108; box-shadow: 0 3px 10px rgba(0,0,0,.25); }

/* enter */
.h-enter-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: clamp(16px, 2vw, 28px); align-items: start; }
.h-step { margin-bottom: 20px; }
.h-round-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.h-round-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
  padding: 10px 6px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper); color: var(--ink);
}
.h-round-btn[aria-pressed="true"] { border-color: var(--felt); background: var(--felt); color: var(--cream); }
.h-round-n { font-family: var(--head); font-weight: 700; font-size: 1.1rem; }
.h-round-meld { font-size: .78rem; opacity: .75; }
.h-round-prog { font-size: .78rem; font-weight: 700; margin-top: 2px; color: var(--muted); }
.h-round-btn.is-done .h-round-prog { color: var(--ok); }
.h-round-btn[aria-pressed="true"] .h-round-prog { color: var(--gold); }

.h-inputs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 6px 0 18px; }
.h-num > span:first-child { display: block; font-weight: 700; margin-bottom: 6px; }
.h-num input {
  width: 100%; min-width: 0; padding: 14px 12px; border: 2px solid var(--line); border-radius: 14px;
  background: var(--paper); color: var(--ink); text-align: center;
  font-family: var(--head); font-size: 1.9rem; font-weight: 600;
}
.h-num-red > span:first-child { color: var(--red); }
.h-num-red input { background: var(--red-soft); }
.h-num-row { display: flex; gap: 6px; }
.h-sign {
  flex: none; width: 46px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper);
  font-size: 1.6rem; font-weight: 700; color: var(--muted); cursor: pointer;
}
.h-sign[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }

.h-math { background: #f1ead8; border-radius: 14px; padding: 12px; margin-bottom: 18px; }
.h-math-row { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 6px 14px; }
.h-math-part { display: flex; flex-direction: column; align-items: center; }
.h-math-part small { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 700; }
.h-math-part b { font-family: var(--head); font-size: 1.35rem; }
.h-math-red b { color: var(--red); }
.h-math-total b { font-size: 1.7rem; color: var(--felt); }
.h-math-op { font-size: 1.4rem; color: var(--muted); font-weight: 700; }
.h-entry-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.h-entry-actions .h-btn-gold { flex: 1 1 200px; }

.h-status-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.h-status-list li {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 12px; background: var(--paper); border: 1px solid var(--line);
}
.h-status-name { font-weight: 600; }
.h-status-val { margin-left: auto; font-family: var(--head); font-weight: 600; color: var(--muted); }
.h-status-list li.is-done .h-status-val { color: var(--felt); font-size: 1.1rem; }
.h-status-note { color: var(--muted); margin: 14px 0 10px; }

/* scoreboard */
.h-board-head { text-align: center; margin-bottom: 22px; }
.h-board-kicker { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--gold); }
.h-board-head h2 { font-family: var(--head); font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 4px 0 0; }
.h-board-head.is-final h2 { color: var(--gold); text-shadow: 0 2px 18px rgba(242,193,78,.45); }
.h-board {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: clamp(14px, 1.8vw, 24px);
}
.h-score {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 12px;
  background: var(--cream); color: var(--ink); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}
.h-seat-1 .h-score-suit { color: var(--seat-1); }
.h-seat-2 .h-score-suit { color: var(--seat-2); }
.h-seat-3 .h-score-suit { color: var(--seat-3); }
.h-seat-4 .h-score-suit { color: var(--seat-4); }
.h-seat-5 .h-score-suit { color: var(--seat-5); }
.h-score.is-lead { background: linear-gradient(180deg, #fff6d8, var(--cream) 60%); box-shadow: 0 0 0 3px var(--gold), var(--shadow); }
.h-score-rank { display: flex; align-items: center; gap: 6px; font-family: var(--head); font-weight: 700; color: var(--muted); font-size: 1.05rem; }
.h-crown { color: var(--gold-deep); font-size: 1.5rem; line-height: 1; }
.h-score-who { display: flex; align-items: center; gap: 12px; }
.h-score-name { font-family: var(--head); font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.h-score-note { font-size: .88rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.h-score.is-lead .h-score-note { color: var(--gold-deep); }
.h-score-total {
  font-family: var(--head); font-weight: 700; font-size: clamp(2.6rem, 4.5vw, 3.4rem); line-height: 1;
  color: var(--felt); font-variant-numeric: tabular-nums;
}
.h-score.is-me .h-score-name::after { content: ' (you)'; font-size: .8rem; color: var(--muted); font-weight: 500; }
.h-bars { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.h-bar { background: #f1ead8; border-radius: 10px; padding: 6px 4px; text-align: center; }
.h-bar.is-empty { opacity: .5; }
.h-bar-r { display: block; font-size: .7rem; font-weight: 700; color: var(--muted); }
.h-bar-v { font-family: var(--head); font-weight: 600; font-size: .95rem; font-variant-numeric: tabular-nums; }
.h-score-suit { position: absolute; right: 12px; top: 4px; font-size: 4rem; opacity: .18; pointer-events: none; }

/* rounds */
.h-rounds { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 560px), 1fr)); gap: clamp(14px, 1.8vw, 24px); }
.h-round-card header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.h-round-card h3 { margin: 0; }
.h-table-wrap { overflow-x: auto; }
.h-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.h-table th, .h-table td { padding: 8px 10px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
.h-table thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.h-table th:first-child { text-align: left; }
.h-table tbody tr:last-child th, .h-table tbody tr:last-child td { border-bottom: 0; }
.h-table tr.is-empty td { color: var(--muted); }
.h-td-earned { color: var(--ok); font-weight: 600; }
.h-td-ded { color: var(--red); font-weight: 600; }
.h-td-total { font-family: var(--head); font-weight: 700; font-size: 1.1rem; color: var(--felt); }
.h-td-run { font-weight: 700; background: #f1ead8; }
.h-rowlink {
  display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; padding: 0;
  font-weight: 600; color: var(--ink); cursor: pointer;
}
.h-rowlink:hover { text-decoration: underline; }

/* dialog */
.h-dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(440px, calc(100vw - 32px)); background: var(--cream); color: var(--ink); box-shadow: var(--shadow); }
.h-dialog::backdrop { background: rgba(5, 25, 18, .7); }
.h-dialog-inner { padding: 24px; text-align: center; }
.h-dialog h2 { font-family: var(--head); margin: 0 0 6px; color: var(--felt); }
.h-dialog p { margin: 0 0 12px; color: var(--muted); }
.h-bigcode { font-family: var(--head); font-size: 2.6rem; font-weight: 700; letter-spacing: 8px; color: var(--felt); margin: 4px 0 14px; }
.h-qr { display: flex; justify-content: center; margin-bottom: 18px; }
.h-qr img, .h-qr canvas { padding: 10px; background: #fff; border-radius: 12px; }
.h-dialog-players { text-align: left; margin-bottom: 18px; }
.h-dialog-actions { display: flex; gap: 10px; }
.h-dialog-actions .h-btn { flex: 1; }

/* ---------- home: mode choice ---------- */
.h-modes { border: 0; padding: 0; margin: 0 0 18px; display: grid; gap: 10px; }
.h-mode {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  padding: 12px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--paper);
}
.h-mode:has(input:checked) { border-color: var(--felt); background: #eef6f1; }
.h-mode input { margin-top: 4px; accent-color: var(--felt); width: 18px; height: 18px; flex: none; }
.h-mode strong { display: block; color: var(--felt); }
.h-mode small { display: block; color: var(--muted); margin-top: 2px; line-height: 1.4; }

/* ---------- play: the table ----------
 * One felt surface. Seats along the top, piles in the middle, your melds in
 * front of you, your hand at the bottom. Nothing boxed inside boxes. */
.h-play { display: grid; gap: 18px; }
.h-lobby { max-width: 760px; margin: 0 auto; }
.h-lobby .h-status-list { margin: 14px 0 18px; }

.h-felt {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: clamp(14px, 2.4vh, 30px);
  min-height: calc(100vh - 150px); padding: clamp(18px, 3vh, 34px) clamp(14px, 3vw, 56px) 0;
  border-radius: 56px; border: 14px solid #4a2f1c;
  background:
    radial-gradient(ellipse at 50% 42%, #1c8058 0%, #136444 45%, #0b4630 80%, #083826 100%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25), inset 0 0 80px rgba(0,0,0,.45), 0 0 0 2px #6b4a2f, 0 24px 50px rgba(0,0,0,.45);
}
.h-felt-round {
  position: absolute; top: 14px; left: 26px;
  font-size: .75rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: rgba(255,255,255,.5);
}
.h-felt-note { margin: 0; color: rgba(255,255,255,.4); font-style: italic; }

/* seats */
.h-seats { display: flex; justify-content: space-around; align-items: flex-start; width: 100%; gap: 8px; }
.h-seat {
  display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0;
  padding: 8px 10px; border: 0; border-radius: 18px; background: none; color: inherit; font: inherit; cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.h-seat:hover, .h-seat:focus-visible { background: rgba(255,255,255,.07); transform: translateY(-2px); }
.h-seat:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.h-seat-cards { display: inline-flex; align-items: flex-end; gap: 10px; }
.h-backs { display: inline-flex; padding: 0 4px; }
.h-back {
  width: 32px; height: 46px; border-radius: 4px; box-sizing: border-box;
  background: repeating-linear-gradient(45deg, #b8323c 0 4px, #9a2730 4px 8px); border: 3px solid #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.35);
  transform: translateY(var(--y)) rotate(var(--a)); transform-origin: 50% 120%;
}
.h-back + .h-back { margin-left: -22px; }
.h-foot-stack {
  width: 24px; height: 34px; border-radius: 4px; box-sizing: border-box; flex: none;
  background: repeating-linear-gradient(45deg, #b8323c 0 4px, #9a2730 4px 8px); border: 2px solid #fff;
  box-shadow: 2px 2px 0 #fff, 3px 3px 0 #c9c1ad, 4px 4px 6px rgba(0,0,0,.35);
}
.h-plate {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%;
  padding: 3px 12px 3px 3px; border-radius: 999px; background: rgba(0,0,0,.3); font-weight: 700; font-size: .92rem;
}
.h-plate-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-plate-n { opacity: .7; font-weight: 600; }
.h-seat.is-turn .h-plate { background: var(--gold); color: #2b2108; box-shadow: 0 0 0 5px rgba(242,193,78,.25); }
.h-seat-melds { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; max-width: 230px; }
.h-tiny { position: relative; }
.h-tiny .h-pc-mini { width: 26px; height: 36px; }
.h-tiny .h-pc-mini .h-pc-r { font-size: 1.2rem; }
.h-tiny .h-pc-mini .h-pc-s { display: none; }
.h-tiny.is-natural .h-pc-mini { box-shadow: 0 0 0 2px var(--gold); }
.h-tiny.is-unnatural .h-pc-mini { box-shadow: 0 0 0 2px #cfd6dd; }
.h-tiny-n {
  position: absolute; right: -5px; bottom: -5px; min-width: 16px; height: 16px; padding: 0 3px; border-radius: 999px;
  background: #1b1b1b; color: #fff; font-size: .66rem; font-weight: 700; line-height: 16px; text-align: center;
}

/* piles, straight on the felt */
.h-piles { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 1.8vw, 22px); }
.h-pile { background: none; border: 0; padding: 4px; border-radius: 12px; cursor: pointer; }
.h-pile:disabled { cursor: default; }
.h-pile:not(:disabled) .h-stack-top > * { box-shadow: 0 0 0 3px var(--gold), 0 6px 14px rgba(0,0,0,.3); }
.h-pile:not(:disabled):hover .h-stack-top { transform: translateY(-3px); }
.h-pile-discard { margin-left: clamp(14px, 3vw, 40px); }
.h-stack { --cw: 74px; --ch: 104px; position: relative; display: block; width: calc(var(--cw) + var(--h-layers) * 1.2px); height: calc(var(--ch) + var(--h-layers) * 1.8px); }
.h-stack.is-empty { width: var(--cw); height: var(--ch); border: 2px dashed rgba(255,255,255,.18); border-radius: 8px; }
.h-stack-edge, .h-stack-top { position: absolute; width: var(--cw); height: var(--ch); transition: transform .1s ease; }
.h-stack-edge { border-radius: 8px; background: #fff; border: 1px solid #c9c1ad; }
.h-pile .h-stack-top > * { display: flex; width: var(--cw); height: var(--ch); }
.h-pile-back {
  border-radius: 8px; box-sizing: border-box;
  background: repeating-linear-gradient(45deg, #b8323c 0 6px, #9a2730 6px 12px); border: 4px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.h-turnline {
  margin: 0; text-align: center; font-family: var(--head); font-size: 1.2rem; font-weight: 500;
  color: rgba(251,247,238,.85); text-shadow: 0 1px 2px rgba(0,0,0,.4);
}
.h-turnline.is-mine { color: var(--gold); font-weight: 600; }

/* playing cards */
.h-pc {
  position: relative; display: inline-flex; flex-direction: column; justify-content: space-between; align-items: flex-start;
  width: 54px; height: 76px; padding: 4px 6px; border-radius: 8px; flex: none;
  background: #fff; color: #1b1b1b; border: 1px solid #cfc8b6; box-shadow: 0 2px 4px rgba(0,0,0,.15);
  font-family: var(--head); cursor: default; user-select: none;
}
button.h-pc { cursor: pointer; transition: transform .1s ease; }
.h-pc.is-red { color: var(--red); }
.h-pc.is-wild { background: linear-gradient(160deg, #fff 60%, #fff1c7); }
.h-pc.is-three { background: linear-gradient(160deg, #fff 60%, #eceff2); }
.h-pc { overflow: hidden; }
/* Rank big in the top-left corner (so it shows when cards overlap); suit in the lower right. */
.h-pc-r {
  position: absolute; top: 1px; left: 4px;
  font-weight: 700; font-size: 2.7rem; line-height: 1; white-space: nowrap; letter-spacing: -2px;
}
.h-pc-s { position: absolute; bottom: 4px; right: 6px; font-size: 1.35rem; line-height: 1; }
.h-pc.is-joker .h-pc-r { font-size: 1.8rem; letter-spacing: -1px; color: #6b3fa0; }
.h-pc-joker { position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%); width: 76%; }
.h-pc-joker svg { display: block; width: 100%; height: auto; }
.h-pc.is-sel { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--gold), 0 8px 14px rgba(0,0,0,.3); }
.h-pc-big { width: 74px; height: 104px; border-radius: 9px; }
.h-pc-big .h-pc-r { top: 2px; left: 6px; font-size: 3.1rem; }
.h-pc-big .h-pc-s { bottom: 6px; right: 8px; font-size: 1.8rem; }
.h-pc-big.is-joker .h-pc-r { font-size: 2.1rem; }
.h-pc-mini { width: 30px; height: 42px; padding: 0; border-radius: 5px; }
.h-pc-mini .h-pc-s { bottom: 2px; right: 3px; font-size: .75rem; }
.h-pc-mini .h-pc-r { top: 0; left: 2px; font-size: 1.45rem; letter-spacing: -1.5px; }
.h-pc-mini.is-joker .h-pc-r { font-size: .95rem; letter-spacing: -.5px; }

/* melds, laid on the felt in front of you */
.h-my-area {
  display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; min-height: 130px;
  padding: 10px; border-radius: 28px; transition: background .15s ease, box-shadow .15s ease;
}
.h-melds-bar { align-self: flex-end; margin: -4px 8px -8px 0; font-size: .85rem; }
.h-my-area.is-drop-over { background: rgba(242,193,78,.1); box-shadow: inset 0 0 0 2px rgba(242,193,78,.55); }
.h-melds { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-start; gap: 14px; }
.h-meld {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px; border-radius: 12px; border: 2px solid transparent; background: none; color: inherit; font: inherit;
}
button.h-meld { cursor: pointer; }
button.h-meld:hover { border-color: rgba(242,193,78,.6); }
.h-meld.is-staged { border-style: dashed; border-color: var(--gold); background: rgba(242,193,78,.08); }
.h-meld.is-book.h-book-natural { background: rgba(242,193,78,.16); border-color: rgba(242,193,78,.7); }
.h-meld.is-book.h-book-unnatural { background: rgba(255,255,255,.08); border-color: rgba(220,228,235,.55); }
.h-meld.is-drop-over { border-color: var(--gold); border-style: solid; background: rgba(242,193,78,.2); }
.h-meld-count { font-size: .8rem; font-weight: 700; color: rgba(255,255,255,.75); }
.h-meld.is-book .h-meld-count { color: var(--gold); }
.h-meld-stack { display: flex; flex-direction: column; }
.h-meld-stack .h-pc + .h-pc { margin-top: -31px; }
.h-meld-add {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 74px; height: 104px; margin-top: 26px; border-radius: 9px; border: 2px dashed rgba(255,255,255,.35);
  background: none; color: rgba(255,255,255,.75); font: inherit; cursor: pointer;
}
.h-meld-add:hover { border-color: var(--gold); color: var(--gold); }
.h-meld-add.is-drop-over { border-color: var(--gold); border-style: solid; background: rgba(242,193,78,.2); color: var(--gold); }
.h-meld-add span { font-size: 2rem; font-weight: 700; line-height: 1; }
.h-meld-add small { font-weight: 600; font-size: .78rem; }
.h-pill-gold { background: var(--gold); color: #2b2108; }
.h-pill-silver { background: #d9dee3; color: #333; }
.h-stagebar { width: fit-content; margin: 0 auto 10px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; padding: 6px 8px 6px 16px; border-radius: 999px; background: rgba(0,0,0,.3); }
.h-stage-pts { font-weight: 700; color: #ffaaa8; }
.h-stage-pts.is-ok { color: #8ee6b9; }
.h-stage-wait { font-size: .85rem; font-style: italic; color: rgba(255,255,255,.7); }
.h-felt .h-btn-ghost { color: var(--cream); border-color: rgba(255,255,255,.35); }

/* your hand, held at the bottom of the table */
.h-hand {
  position: sticky; bottom: 0; z-index: 5; margin-top: auto; width: calc(100% + 2 * clamp(14px, 3vw, 56px));
  padding: 14px clamp(14px, 3vw, 56px) 18px; border-radius: 0 0 42px 42px;
  background: linear-gradient(to top, rgba(8,56,38,.97) 0, rgba(8,56,38,.9) 70%, rgba(8,56,38,0) 100%);
}
.h-hand-bar { display: flex; align-items: center; justify-content: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 6px; }
.h-hand-title { font-family: var(--head); font-weight: 600; font-size: 1.05rem; color: var(--cream); }
.h-hand.is-turn .h-hand-title { color: var(--gold); }
.h-my-books { display: inline-flex; gap: 6px; }
.h-book-n, .h-book-u { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.h-book-n { background: var(--gold); color: #2b2108; }
.h-book-u { background: #d9dee3; color: #333; }
.h-hand-cards { --ov: 19px; display: flex; flex-wrap: wrap; justify-content: center; row-gap: 8px; padding: 16px 0 0 var(--ov); }
.h-hand-cards .h-pc { width: 66px; height: 92px; margin-left: calc(-1 * var(--ov)); box-shadow: -2px 2px 5px rgba(0,0,0,.25); }
.h-hand-cards .h-pc .h-pc-r { font-size: 2.9rem; }
.h-hand-cards .h-pc .h-pc-s { font-size: 1.5rem; }
.h-hand-cards .h-pc.is-joker .h-pc-r { font-size: 1.9rem; }
.h-hand-cards button.h-pc:hover { transform: translateY(-6px); }
.h-hand-cards button.h-pc.is-sel { transform: translateY(-16px); }
.h-felt .h-link-plain { margin-left: 0; color: rgba(255,255,255,.75); }
.h-felt .h-msg { text-align: center; color: #ffb3b0; margin-top: 8px; }
.h-hint { text-align: center; color: rgba(255,255,255,.55); font-size: .88rem; margin: 10px 0 0; }

/* zoom in on another seat */
.h-zoom {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(3,20,13,.6); backdrop-filter: blur(3px);
}
.h-zoom-panel {
  width: min(1100px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 18px clamp(16px, 3vw, 32px) 26px; border-radius: 28px;
  background: radial-gradient(ellipse at 50% 30%, #1c8058, #0b4630 90%); border: 8px solid #4a2f1c;
  box-shadow: 0 30px 70px rgba(0,0,0,.55);
}
.h-zoom-panel.is-opening { animation: h-zoom-in .28s cubic-bezier(.2,.8,.3,1); }
@keyframes h-zoom-in {
  from { opacity: 0; transform: translate(var(--fx), var(--fy)) scale(.2); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .h-zoom-panel.is-opening { animation: none; } }
.h-zoom-head { display: flex; align-items: center; gap: 10px; }
.h-zoom-head h2 { margin: 0; font-family: var(--head); font-size: 1.5rem; margin-right: auto; }
.h-zoom-close {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(0,0,0,.3); color: var(--cream);
  font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.h-zoom-close:hover { background: rgba(0,0,0,.45); }
.h-zoom-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 22px; color: rgba(255,255,255,.85); }
.h-zoom .h-melds { justify-content: flex-start; }

/* Drag and drop: a lifted card follows the pointer; nothing is official until "Play these". */
.h-hand-cards .h-pc { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.h-hand-cards .h-pc.is-lifted { opacity: .3; }
body.h-dragging, body.h-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.h-drag-ghost { position: fixed; top: 0; left: 0; z-index: 100; pointer-events: none; width: 60px; height: 84px; }
.h-drag-ghost .h-pc { position: absolute; top: 0; transform: rotate(-4deg) scale(1.06); box-shadow: 0 12px 24px rgba(0,0,0,.35); }
.h-drag-n { position: absolute; top: -10px; right: -18px; background: var(--gold); color: #1b1b1b; font-weight: 700; border-radius: 999px; min-width: 24px; height: 24px; display: grid; place-items: center; font-size: .85rem; }
.h-drag-caret { position: fixed; top: 0; left: 0; z-index: 99; width: 4px; border-radius: 2px; background: var(--gold); pointer-events: none; }
.h-btn-red { background: var(--red); color: #fff; }
.h-link-plain { margin-left: 0; color: var(--muted); }

.h-rules { background: rgba(0,0,0,.2); border-radius: 14px; padding: 12px 16px; }
.h-lobby .h-rules { background: #f1ead8; margin-top: 18px; }
.h-rules summary { cursor: pointer; font-weight: 700; }
.h-rules ul { margin: 10px 0 0; padding-left: 20px; line-height: 1.6; }

/* round results */
.h-results h2 { font-family: var(--head); font-size: clamp(1.6rem, 3.5vw, 2.4rem); margin: 4px 0 16px; }
.h-results .h-board-kicker { color: var(--gold-deep); }
.h-results .h-entry-actions { margin-top: 18px; }
.h-left-cards { display: flex; flex-wrap: wrap; gap: 2px; justify-content: flex-end; max-width: 420px; margin-left: auto; }
.h-table td.h-td-left { white-space: normal; }

/* ---------- smaller screens ---------- */
@media (max-width: 900px) {
  .h-enter-grid { grid-template-columns: 1fr; }
  .h-home-grid { grid-template-columns: 1fr; max-width: 560px; }
}
@media (max-width: 560px) {
  .h-top { padding: 10px 16px; }
  .h-brand { font-size: 1.1rem; }
  .h-me-name, .h-codechip-label { display: none; }
  .h-game { padding: 14px 12px 40px; }
  .h-tabs { width: 100%; }
  .h-tabs button { flex: 1; padding: 10px 6px; font-size: .92rem; }
  .h-round-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .h-inputs { grid-template-columns: 1fr; gap: 10px; }
  .h-num { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 10px; }
  .h-num > span:first-child { margin: 0; }
  .h-num input { font-size: 1.6rem; padding: 10px; }
  .h-table th, .h-table td { padding: 7px 6px; font-size: .9rem; }
  .h-pc { width: 44px; height: 62px; }
  .h-pc-r { font-size: 2.2rem; }
  .h-pc-s { font-size: 1.1rem; }
  .h-pc.is-joker .h-pc-r { font-size: 1.4rem; }
  .h-pc-mini { width: 26px; height: 36px; }
  .h-pc-mini .h-pc-r { font-size: 1.25rem; }
  .h-meld-stack .h-pc + .h-pc { margin-top: -25px; }

  .h-felt { border-width: 8px; border-radius: 30px; padding: 34px 8px 0; gap: 14px; min-height: calc(100vh - 130px); }
  .h-felt-round { top: 10px; left: 0; right: 0; text-align: center; font-size: .68rem; }
  .h-seats { gap: 2px; }
  .h-seat { padding: 4px 2px; gap: 5px; flex: 1 1 0; }
  .h-seat-cards { gap: 6px; }
  .h-back { width: 20px; height: 29px; border-width: 2px; }
  .h-back + .h-back { margin-left: -15px; }
  .h-seat .h-foot-stack { width: 16px; height: 23px; border-width: 1.5px; }
  .h-plate { font-size: .78rem; padding-right: 8px; gap: 4px; }
  .h-plate .h-av { width: 22px; height: 22px; font-size: .7rem; }
  .h-seat-melds { display: none; }
  .h-piles { zoom: .78; gap: 8px; }
  .h-turnline { font-size: 1.02rem; }
  .h-my-area { min-height: 90px; padding: 6px 0; }
  .h-melds { gap: 8px; }
  .h-meld { padding: 3px; }
  .h-meld-add { width: 50px; height: 70px; margin-top: 22px; }
  .h-meld-add span { font-size: 1.5rem; }
  .h-meld-add small { font-size: .62rem; }
  .h-hand { width: calc(100% + 16px); padding: 10px 8px 12px; border-radius: 0 0 22px 22px; }
  .h-hand-cards { --ov: 14px; max-height: 38vh; overflow-y: auto; }
  .h-hand-cards .h-pc { width: 50px; height: 70px; }
  .h-hand-cards .h-pc .h-pc-r { font-size: 2.3rem; }
  .h-hand-cards .h-pc .h-pc-s { font-size: 1.15rem; }
  .h-hand-cards .h-pc.is-joker .h-pc-r { font-size: 1.5rem; }
  .h-zoom-panel { border-width: 5px; border-radius: 22px; }
}

/* ---------- home: games this browser is already in ---------- */
.h-yours { max-width: 1100px; margin: 0 auto 28px; }
.h-yours h2 { font-family: var(--head); color: var(--gold); margin: 0 0 12px; font-size: 1.4rem; }
.h-yours-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 12px; }
.h-yours-game {
  display: grid; gap: 4px; padding: 14px 18px; border-radius: 16px; text-decoration: none;
  background: var(--cream); color: var(--ink); box-shadow: var(--shadow); transition: transform .12s ease;
}
.h-yours-game:hover, .h-yours-game:focus-visible { transform: translateY(-2px); }
.h-yours-game:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.h-yours-game.is-done { opacity: .85; }
.h-yours-top { display: flex; align-items: center; gap: 10px; color: var(--felt); font-size: 1.05rem; }
.h-yours-code { margin-left: auto; font-family: var(--head); font-weight: 700; letter-spacing: 2px; color: var(--muted); }
.h-yours-who { font-weight: 600; }
.h-yours-meta { font-size: .85rem; color: var(--muted); }

/* ---------- home: optional Google sign-in ---------- */
.h-account { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin-top: 18px; font-size: .95rem; }
.h-account > span { opacity: .9; }
.h-account .h-account-out { margin-left: 0; color: var(--gold); }
.h-account .h-msg { flex-basis: 100%; text-align: center; margin: 0; min-height: 0; color: #ffb3b0; }
.h-account .h-msg:empty { display: none; }

/* ---------- privacy page ---------- */
.h-privacy { max-width: 820px; margin: 0 auto; line-height: 1.6; }
.h-privacy h1 { font-family: var(--head); color: var(--felt); margin: 0 0 12px; }
.h-privacy h2 { font-size: 1.15rem; margin: 22px 0 6px; }
.h-privacy a { color: var(--felt); font-weight: 600; }
.h-account-link { color: var(--gold); font-weight: 600; margin-left: 4px; }
.h-zoom-kick { margin-left: 0; color: #ffb3b0; }
.h-zoom-foot { display: flex; justify-content: flex-end; margin-top: 28px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.15); }

/* ---------- home: archive / remove (each person's own list) ---------- */
.h-yours-item { display: grid; gap: 6px; align-content: start; }
.h-yours-acts { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 0 6px; font-size: .85rem; }
.h-yours-acts .h-link-btn { margin-left: 0; color: rgba(255,255,255,.8); }
.h-yours-archive summary { cursor: pointer; list-style: none; }
.h-yours-archive summary::-webkit-details-marker { display: none; }
.h-yours-archive summary h2 { display: inline-block; margin-bottom: 8px; }
.h-yours-archive summary h2::before { content: "▸ "; }
.h-yours-archive[open] summary h2::before { content: "▾ "; }
.h-yours-note { margin: 0 0 12px; color: rgba(255,255,255,.75); font-size: .9rem; }
.h-yours-msg { max-width: 1100px; margin: 0 auto; }

/* ---------- home: three big buttons, then one screen at a time (2026-11-13) ---------- */
.h-home-title { text-align: center; margin: 0 0 clamp(18px, 3vw, 32px); font-family: var(--head); font-size: clamp(2.2rem, 6vw, 3.4rem); color: var(--gold); }
.h-view[hidden] { display: none; }
.h-view { max-width: 1100px; margin: 0 auto; }
.h-menu-btns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(14px, 2vw, 24px); }
.h-menu-btn {
  display: flex; align-items: center; gap: 18px; padding: clamp(20px, 3vw, 34px) clamp(18px, 2.5vw, 30px);
  border-radius: 24px; background: var(--cream); color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
  transition: transform .12s ease;
}
.h-menu-btn:hover, .h-menu-btn:focus-visible { transform: translateY(-3px); }
.h-menu-btn:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
.h-menu-icon {
  flex: none; display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%;
  background: var(--felt); color: var(--gold); font-size: 2rem;
}
.h-menu-btn strong { display: block; font-family: var(--head); font-size: clamp(1.35rem, 2.2vw, 1.7rem); color: var(--felt); }
.h-menu-btn small { display: block; margin-top: 4px; font-size: 1rem; color: var(--muted); }
.h-menu .h-account { margin-top: clamp(22px, 3vw, 36px); }

.h-back-link {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 16px; padding: 10px 22px; border-radius: 999px;
  background: rgba(0,0,0,.25); color: var(--cream); text-decoration: none; font-family: var(--head); font-weight: 600; font-size: 1.15rem;
}
.h-back-link:hover { background: rgba(0,0,0,.4); }
.h-view[data-view="start"] .h-card, .h-view[data-view="join"] .h-card, .h-empty { max-width: 640px; margin: 0 auto; }
.h-view[data-view="start"] .h-back-link, .h-view[data-view="join"] .h-back-link { margin-left: max(0px, calc((100% - 640px) / 2)); }
.h-view[data-view="mine"] .h-yours { margin: 0 auto 20px; }
.h-empty { text-align: center; display: grid; gap: 12px; justify-items: center; }
.h-empty h2 { margin: 0; font-family: var(--head); color: var(--felt); }
.h-empty p { margin: 0 0 6px; }
.h-empty .h-btn { min-width: 240px; text-decoration: none; }

@media (max-width: 860px) {
  .h-menu-btns { grid-template-columns: 1fr; max-width: 560px; margin: 0 auto; }
  .h-menu-btn { padding: 18px 20px; }
  .h-menu-icon { width: 54px; height: 54px; font-size: 1.6rem; }
}
.h-start .h-btn, .h-join .h-btn { width: 100%; }

/* ---------- table news overlay (js/news.js) ---------- */
.h-news { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,.6); overflow: hidden; animation: h-news-fade .25s ease-out; }
@keyframes h-news-fade { from { opacity: 0; } }
.h-news-card {
  position: relative; z-index: 2; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  padding: 26px clamp(18px, 4vw, 34px) 22px; border-radius: 28px; text-align: center;
  background: var(--cream); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: h-news-pop .4s cubic-bezier(.2,1.4,.4,1);
}
@keyframes h-news-pop { from { transform: scale(.6); opacity: 0; } }
.h-news-card.is-warn { background: #fff4d6; }
.h-news-big { font-size: clamp(3.5rem, 12vw, 5.5rem); line-height: 1; }
.h-news-card h2 { margin: 8px 0 14px; font-family: var(--head); font-size: clamp(1.5rem, 4vw, 2rem); color: var(--felt); }
.h-news-list { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; text-align: left; }
.h-news-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: rgba(11,61,44,.08); font-size: clamp(1.1rem, 3vw, 1.3rem); font-weight: 600; }
.h-news-item.is-party { background: rgba(242,193,78,.28); }
.h-news-item.is-warn { background: rgba(232,80,91,.16); color: #8a1c24; }
.h-news-emoji { flex: none; font-size: 1.6rem; }
.h-news-ok { min-width: 160px; font-size: 1.2rem; }
.h-confetti { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.h-confetti span { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; opacity: .9; animation: h-confetti-fall linear forwards; }
@keyframes h-confetti-fall { to { transform: translateY(110vh) rotate(720deg); } }
@media (prefers-reduced-motion: reduce) {
  .h-news, .h-news-card { animation: none; }
  .h-confetti { display: none; }
}

/* ---------- closed books (2026-11-14): one sideways card per book ----------
   Red = natural, black = unnatural. Each group overlaps sideways so every
   book's corner shows; the gap between groups keeps the two counts apart. */
.h-books { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px 40px; width: 100%; padding: 4px 0; }
.h-books-group { display: flex; align-items: center; padding-right: 0; }
.h-bk {
  position: relative; flex: none; width: 76px; height: 54px; padding: 0; border-radius: 8px; cursor: pointer;
  background: #fff; border: 1px solid #cfc8b6; box-shadow: -3px 2px 6px rgba(0,0,0,.28);
  font-family: var(--head); font-weight: 700; line-height: 1; transition: transform .12s ease;
}
/* Overlap only as far as the next card still leaves this one's whole rank showing. */
.h-bk + .h-bk { margin-left: -24px; }
.h-bk.is-red { color: var(--red); }
.h-bk.is-black { color: #1b1b1b; }
.h-bk:hover, .h-bk:focus-visible { transform: translateY(-4px); z-index: 2; }
/* An upright card (same size and printing as .h-pc) turned on its side. */
.h-bk-face {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 76px;
  transform: translate(-50%, -50%) rotate(-90deg);
}
.h-bk-r { position: absolute; top: 1px; left: 4px; font-size: 2.7rem; line-height: 1; letter-spacing: -2px; white-space: nowrap; }
.h-bk-s { position: absolute; bottom: 4px; right: 6px; font-size: 1.35rem; line-height: 1; }
.h-bk.is-drop-over { box-shadow: 0 0 0 3px var(--gold), -3px 2px 6px rgba(0,0,0,.28); transform: translateY(-4px); z-index: 3; }
.h-bk.is-staged { box-shadow: 0 0 0 3px var(--gold), -3px 2px 6px rgba(0,0,0,.28); }
.h-bk-adds { position: absolute; left: 50%; bottom: -30px; transform: translateX(-50%); display: flex; z-index: 4; }
.h-bk-adds .h-pc-mini + .h-pc-mini { margin-left: -16px; }
.h-books:has(.h-bk-adds) { padding-bottom: 32px; }
.h-zoom .h-books { justify-content: flex-start; margin: 0 0 18px; }

/* A book opened up: its cards fanned in the middle of the screen. */
.h-fan-wrap {
  position: fixed; inset: 0; z-index: 120; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; padding: 16px; background: rgba(3,20,13,.72); backdrop-filter: blur(3px);
}
.h-fan-wrap h2 { margin: 0; font-family: var(--head); color: var(--gold); text-align: center; }
.h-fan { position: relative; width: min(560px, 92vw); height: 190px; }
.h-fan-card {
  position: absolute; left: 50%; bottom: 0; margin-left: -37px;
  transform-origin: 50% 160%; transform: rotate(var(--a)); box-shadow: -2px 2px 6px rgba(0,0,0,.3);
  animation: h-fan-open .35s ease-out both; animation-delay: calc(var(--i) * 25ms);
}
@keyframes h-fan-open { from { transform: rotate(0deg); } }
@media (prefers-reduced-motion: reduce) { .h-fan-card { animation: none; } }
@media (max-width: 560px) {
  .h-bk { width: 62px; height: 44px; }
  .h-bk + .h-bk { margin-left: -20px; }
  .h-bk-face { width: 44px; height: 62px; }
  .h-bk-r { font-size: 2.2rem; }
  .h-bk-s { font-size: 1.1rem; }
  .h-books { gap: 12px 26px; }
}

/* ---------- table talk (js/chat.js, 2026-11-14) ---------- */
.h-chat-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--felt-line); background: rgba(255,255,255,.08); color: var(--cream);
  font: inherit; font-weight: 600; cursor: pointer;
}
.h-chat-btn:hover { background: rgba(255,255,255,.16); }
.h-chat-dot {
  position: absolute; top: -6px; right: -6px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  display: grid; place-items: center; background: #e8505b; color: #fff; font-size: .8rem; font-weight: 700;
}
.h-chat {
  position: fixed; right: 16px; bottom: 16px; z-index: 150; width: min(420px, calc(100vw - 32px)); height: min(560px, calc(100vh - 100px));
  display: flex; flex-direction: column; border-radius: 22px; overflow: hidden;
  background: var(--cream); color: var(--ink); box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
.h-chat[hidden] { display: none; }
.h-chat-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px 10px 18px; background: var(--felt); color: var(--cream); }
.h-chat-head h2 { margin: 0; font-family: var(--head); font-size: 1.3rem; color: var(--gold); }
.h-chat-list { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.h-chat-empty { margin: auto; color: #777; font-style: italic; }
.h-chat-msg { align-self: flex-start; max-width: 85%; padding: 8px 12px; border-radius: 16px 16px 16px 4px; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12); font-size: 1.05rem; line-height: 1.35; overflow-wrap: anywhere; }
.h-chat-msg.is-mine { align-self: flex-end; border-radius: 16px 16px 4px 16px; background: #d8f0e2; }
.h-chat-name { display: block; font-size: .8rem; font-weight: 700; margin-bottom: 2px; }
.h-seat-1-text { color: var(--seat-1); } .h-seat-2-text { color: var(--seat-2); } .h-seat-3-text { color: var(--seat-3); }
.h-seat-4-text { color: var(--seat-4); } .h-seat-5-text { color: var(--seat-5); }
.h-chat-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; border-top: 1px solid #e3dccb; }
.h-chat-chip { padding: 6px 12px; border-radius: 999px; border: 1px solid #cfc6b1; background: #fff; color: var(--ink); font: inherit; font-size: .95rem; cursor: pointer; }
.h-chat-chip:hover { background: #f3ecdc; }
.h-chat-form { display: flex; gap: 8px; padding: 10px 12px 12px; }
.h-chat-input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; border: 1px solid #cfc6b1; font-size: 1.05rem; }
.h-chat-send { flex: none; }
.h-chat-err { margin: 0; padding: 0 12px 10px; color: #b3262e; font-weight: 600; }
.h-chat-err:empty { display: none; }
.h-chat-toast {
  position: fixed; top: 70px; right: 16px; z-index: 140; max-width: min(380px, calc(100vw - 32px)); padding: 12px 16px;
  border: 0; border-radius: 16px; background: var(--cream); color: var(--ink); text-align: left; font: inherit; font-size: 1.05rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); cursor: pointer; animation: h-chat-in .3s ease-out;
}
@keyframes h-chat-in { from { transform: translateY(-12px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .h-chat-toast { animation: none; } }
@media (max-width: 560px) {
  .h-chat { right: 0; bottom: 0; width: 100vw; height: 70vh; border-radius: 22px 22px 0 0; }
  .h-chat-btn-label { display: none; }
  .h-chat-btn { padding: 0 11px; }
  .h-chat-toast { left: 16px; right: 16px; }
}

/* ---------- game screen: no page scrolling (2026-11-14) ----------
   The game page fills the screen exactly: top bar, tabs, then the table.
   On the table only the middle (books and melds) scrolls; the seats and
   piles stay at the top and your hand stays at the bottom. Scoreboard and
   Rounds scroll inside their own panel. */
.h-top-left:empty { display: none; }
.h-top-left { display: flex; align-items: center; }
body[data-code] { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body[data-code] .h-top { flex: none; padding: 8px clamp(12px, 2vw, 28px); }
body[data-code] .h-brand { margin-right: auto; margin-left: 12px; }
body[data-code] .h-game { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 10px clamp(8px, 2vw, 28px) 10px; }
body[data-code] .h-tabs { flex: none; margin: 0 auto 10px; }
body[data-code] .h-panel { flex: 1; min-height: 0; overflow-y: auto; }
body[data-code] #panel-table { overflow: hidden; }
body[data-code] #playRoot { height: 100%; overflow-y: auto; }
body[data-code] #playRoot > .h-play { height: 100%; display: flex; flex-direction: column; gap: 0; }
body[data-code] .h-felt { flex: 1; min-height: 0; height: 100%; overflow: hidden; gap: clamp(8px, 1.6vh, 20px); }
.h-felt-mid {
  flex: 1; min-height: 0; width: 100%; overflow-y: auto; overscroll-behavior: contain;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
body[data-code] .h-hand { position: static; flex: none; }

.h-gear {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 999px; padding: 0; cursor: pointer;
  border: 1px solid var(--felt-line); background: rgba(255,255,255,.08); color: var(--cream); font-size: 1.5rem; line-height: 1;
}
.h-gear:hover, .h-gear[aria-expanded="true"] { background: rgba(255,255,255,.18); }
.h-settings {
  position: fixed; top: 64px; left: 12px; z-index: 160; width: min(380px, calc(100vw - 24px)); max-height: calc(100dvh - 80px); overflow-y: auto;
  padding: 10px 14px 14px; border-radius: 20px; background: var(--cream); color: var(--ink); box-shadow: 0 18px 50px rgba(0,0,0,.5);
  display: grid; gap: 8px;
}
.h-settings-head { display: flex; align-items: center; justify-content: space-between; }
.h-settings-head h2 { margin: 0; font-family: var(--head); color: var(--felt); font-size: 1.3rem; }
.h-settings .h-zoom-close { background: rgba(0,0,0,.08); color: var(--ink); }
.h-settings-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: #fff; font-size: 1.05rem; text-align: left; color: var(--ink); text-decoration: none; }
.h-settings-row small { display: block; font-size: .85rem; color: #666; }
.h-settings-btn { width: 100%; border: 0; font: inherit; cursor: pointer; }
.h-settings-btn:hover { background: #f3ecdc; }
.h-settings-ico { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 50%; background: var(--felt); color: var(--gold); font-size: 1.3rem; font-weight: 700; }
.h-settings-code { letter-spacing: 2px; font-family: var(--head); }
.h-settings .h-bell { filter: none; background: var(--felt); color: var(--cream); width: 40px; height: 40px; }
.h-settings .h-rules { margin: 0; padding: 10px 12px; border-radius: 14px; background: #fff; color: var(--ink); }
.h-settings .h-rules summary { font-weight: 700; cursor: pointer; }
.h-settings .h-rules ul { padding-left: 18px; line-height: 1.45; font-size: .95rem; }

/* ---------- game screen, second pass (2026-11-14) ----------
   Tabs ride in the top bar (moved there by game.js) in place of the logo.
   The hand is never cut off: it shows every card, the middle gives up its
   room first, and only if that is still not enough does the table scroll. */
body[data-code] .h-brand { display: none; }
body[data-code] .h-top { gap: 10px; }
body[data-code] .h-top .h-tabs { margin: 0 auto; padding: 4px; flex: 0 1 auto; min-width: 0; }
body[data-code] .h-top .h-tabs button { padding: 8px clamp(10px, 2vw, 22px); font-size: .95rem; }
body[data-code] .h-felt { overflow-y: auto; }
body[data-code] .h-felt-mid { flex: 1 1 auto; min-height: 90px; }
body[data-code] .h-hand-cards { max-height: none; overflow: visible; }
@media (max-width: 560px) {
  body[data-code] .h-top { padding: 6px 8px; gap: 6px; }
  body[data-code] .h-top .h-tabs button { padding: 7px 9px; font-size: .85rem; }
  body[data-code] .h-gear { width: 38px; height: 38px; font-size: 1.3rem; }
  body[data-code] .h-hand-cards { --ov: 18px; }
  .h-settings { top: 54px; }
}

/* ---------- game screen, third pass (2026-11-14) ----------
   Round number as a corner badge; seats tight against the top edge; the
   middle (books + melds) gives up ALL its room before the hand loses any. */
body[data-code] .h-felt { padding-top: 6px; border-width: 8px; border-radius: 34px; gap: 8px; }
body[data-code] .h-felt-round {
  position: absolute; top: 6px; left: 8px; right: auto; z-index: 3;
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  background: rgba(0,0,0,.35); border: 2px solid rgba(242,193,78,.7); color: var(--gold);
  font-family: var(--head); font-size: 1.6rem; font-weight: 700; letter-spacing: 0; text-transform: none; text-align: center;
}
body[data-code] .h-seats { margin-top: 0; }
body[data-code] .h-seat { padding-top: 2px; padding-bottom: 2px; }
body[data-code] .h-felt-mid { min-height: 0; }
body[data-code] .h-turnline { font-size: 1.05rem; }
@media (max-width: 560px) {
  body[data-code] .h-felt { padding: 4px 6px 0; border-width: 6px; border-radius: 22px; gap: 6px; }
  body[data-code] .h-felt-round { top: 4px; left: 4px; width: 38px; height: 38px; font-size: 1.4rem; }
  body[data-code] .h-piles { zoom: .68; }
  body[data-code] .h-seats { padding-left: 40px; }
  body[data-code] .h-turnline { font-size: .95rem; }
  body[data-code] .h-hand { padding-top: 6px; }
  body[data-code] .h-game { padding: 6px 4px 6px; }
}

/* ---------- game screen, fourth pass (2026-11-14) ----------
   The melds area is only as tall as what is in it (it no longer stretches to
   fill the table), and the hand follows right under it instead of being
   pushed to the bottom edge. When space runs out, the melds area scrolls. */
body[data-code] .h-felt-mid { flex: 0 1 auto; min-height: 0; }
body[data-code] .h-my-area { min-height: 64px; padding: 6px; }
body[data-code] .h-hand { margin-top: 0; }

/* ---------- game screen, fifth pass (2026-11-14) ----------
   Hand back on the bottom edge of the table; the melds area stays its natural
   size, so the spare felt sits between the melds and the hand. Bigger,
   clearer gear and chat icons (line icons instead of emoji). */
body[data-code] .h-hand { margin-top: auto; }
body[data-code] .h-gear, body[data-code] .h-chat-btn {
  width: 50px; height: 50px; padding: 0; justify-content: center; border-radius: 50%;
  background: rgba(255,255,255,.14); border: 2px solid rgba(255,255,255,.35); color: var(--cream);
}
body[data-code] .h-gear:hover, body[data-code] .h-chat-btn:hover,
body[data-code] .h-gear[aria-expanded="true"], body[data-code] .h-chat-btn[aria-expanded="true"] { background: rgba(255,255,255,.26); }
body[data-code] .h-gear svg, body[data-code] .h-chat-ico svg { width: 28px; height: 28px; display: block; }
body[data-code] .h-chat-ico { display: grid; place-items: center; }
body[data-code] .h-chat-btn-label { display: none; }
@media (max-width: 560px) {
  body[data-code] .h-gear, body[data-code] .h-chat-btn { width: 46px; height: 46px; }
  body[data-code] .h-gear svg, body[data-code] .h-chat-ico svg { width: 26px; height: 26px; }
}

/* ---------- game screen: stay clear of the phone's own buttons (2026-11-14) ----------
   The page uses viewport-fit=cover, and Chrome on newer Android draws the page
   edge to edge, BEHIND the system Back / Home / Recents bar. That hid the
   bottom of the table, which is where the hand is. The safe-area inset is the
   height of that bar (0 where there is none), so the game ends just above it. */
body[data-code] {
  box-sizing: border-box;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

/* ---------- game screen: pull-to-refresh works again (2026-11-14) ----------
   overflow:hidden on the page switched off the phone's pull-down-to-refresh.
   The page keeps its one-screen height but is no longer locked, so a pull
   down at the top refreshes as usual. viewport-fit=cover was removed from
   _head.php, so the browser keeps the page above the phone's own buttons. */
body[data-code] { overflow: visible; }

/* ---------- game screen on phones: a guaranteed gap above the system buttons ----------
   Chrome on this Android phone keeps drawing the page under the Back / Home /
   Recents bar and reports no inset for it, so the bottom of the table (the
   hand) was hidden. On phones the game now ends 56px above the screen bottom,
   a little more than that bar's height, or the reported inset if larger. */
@media (max-width: 560px) and (pointer: coarse) {
  body[data-code] { padding-bottom: max(env(safe-area-inset-bottom, 0px), 56px); }
}

/* ---------- game screen height from the phone itself (2026-11-14) ----------
   --app-h is set by game.js to window.innerHeight. Replaces 100dvh, which on
   Android Chrome included the address bar's height, and the fixed 56px gap,
   which is no longer needed. */
body[data-code] { height: var(--app-h, 100vh); padding-bottom: env(safe-area-inset-bottom, 0px); }
@media (max-width: 560px) and (pointer: coarse) {
  body[data-code] { padding-bottom: env(safe-area-inset-bottom, 0px); }
}

/* ---------- game screen, FINAL approach (2026-11-14) ----------
   Fixing the page to one screen height failed on Android Chrome: every height
   the page can read (100dvh, then innerHeight) changes as the address bar
   slides in and out, and the hand kept ending up under the system buttons.
   So the page flows normally again and the HAND IS STICKY to the bottom of
   the screen. The browser keeps sticky items inside what is actually visible,
   whatever the address bar does, and pull-to-refresh works as usual. The
   table is at least one screen tall (100svh = with the address bar showing),
   so with few melds the hand still sits at the bottom. Everything above this
   block that set fixed heights on the game screen is overridden here. */
body[data-code] { height: auto; display: block; overflow: visible; padding-bottom: 0; }
body[data-code] .h-game { display: block; padding: 8px clamp(4px, 2vw, 28px) 8px; }
body[data-code] .h-panel { overflow: visible; }
body[data-code] #panel-table, body[data-code] #playRoot { height: auto; overflow: visible; }
body[data-code] #playRoot > .h-play { height: auto; }
body[data-code] .h-felt { height: auto; overflow: visible; min-height: calc(100vh - 80px); min-height: calc(100svh - 80px); }
body[data-code] .h-felt-mid { flex: 0 0 auto; overflow: visible; }
body[data-code] .h-hand {
  position: sticky; bottom: 0; z-index: 6; margin-top: auto;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
}

/* Hand bar (2026-11-14): foot pile at the upper left of the cards, the
   Sort / Clear / Discard tools on the right. No title or counts. */
body[data-code] .h-hand-bar { justify-content: space-between; min-height: 36px; }
.h-hand-tools { display: inline-flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-left: auto; }
.h-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- chat sizing like a regular chat app (2026-11-14) ----------
   The panel is only as tall as its messages (up to a limit), the newest
   message sits right above the typing box, older ones scroll up. With
   interactive-widget=resizes-content (in _head.php) the page shrinks when the
   keyboard opens, so the panel rides on top of the keyboard. */
.h-chat { height: auto; max-height: min(560px, calc(100% - 90px)); }
.h-chat-list { flex: 1 1 auto; min-height: 0; }
.h-chat-list > :first-child { margin-top: auto; }   /* stack messages at the bottom */
@media (max-width: 560px) {
  .h-chat { height: auto; max-height: calc(100% - 70px); }
}

/* Cards just drawn, shown big until tapped into the hand (2026-11-15).
   Made compact 2026-11-16 so the hand never grows up over the draw piles:
   no title row, no tinted box, smaller cards, "Add all" on the fan's bottom edge. */
.h-drawn { display: flex; flex-direction: column; align-items: center; width: fit-content; max-width: 100%; margin: 2px auto 4px; }
.h-drawn-cards { --ov: 22px; display: flex; flex-wrap: wrap; justify-content: center; row-gap: 6px; padding: 4px 0 0 var(--ov); }
.h-drawn-cards .h-pc { width: 80px; height: 112px; margin-left: calc(-1 * var(--ov)); box-shadow: -3px 3px 8px rgba(0,0,0,.3); transform: rotate(var(--tilt, 0deg)); }
.h-drawn-cards .h-pc:nth-child(odd) { --tilt: -3deg; }
.h-drawn-cards .h-pc:nth-child(even) { --tilt: 3deg; }
.h-drawn-cards .h-pc .h-pc-r { font-size: 3.3rem; }
.h-drawn-cards .h-pc .h-pc-s { font-size: 1.7rem; }
.h-drawn-cards .h-pc.is-joker .h-pc-r { font-size: 2.2rem; }
.h-drawn-cards button.h-pc:hover { transform: translateY(-6px); }
.h-drawn-add { position: relative; z-index: 2; margin: -16px 0 6px; box-shadow: 0 2px 8px rgba(0,0,0,.35); }
@media (max-width: 640px) {
  .h-drawn-cards { --ov: 18px; }
  .h-drawn-cards .h-pc { width: 64px; height: 90px; }
  .h-drawn-cards .h-pc .h-pc-r { font-size: 2.6rem; }
  .h-drawn-cards .h-pc .h-pc-s { font-size: 1.35rem; }
  .h-drawn-cards .h-pc.is-joker .h-pc-r { font-size: 1.8rem; }
  .h-drawn-add { margin-top: -14px; }
}
.h-pop-text { margin: 0 0 18px; font-size: clamp(1.1rem, 3vw, 1.3rem); line-height: 1.45; }
/* Staged (not yet played) cards on the table can be dragged back to the hand (2026-11-15). */
.is-takeback { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.h-pop-ask { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
