/* Bluff Masks, a plum-and-gold ballroom, fixed palette (the same in light and dark OS modes). */
:root {
  --bg: #f2edf3;
  --surface: #fdfbfd;
  --surface2: #e7dfe9;
  --line: rgba(58, 30, 54, .13);
  --ink: #34203a;
  --muted: #7d6a82;
  --accent: #c8475f;           /* you (rose) */
  --gold: #d9a23a;
  --felt: #5a2d56;
  --felt2: #47203f;
  --good: #3d8a55;
  --bad: #b8323a;
  /* tutorial kit (tutorial.css) */
  --tut-accent: #e0ac3e;
  --tut-accent-ink: #34203a;
  --tut-bubble: #fffcf6;
  --tut-ink: #34203a;
  --tut-muted: #7d6a82;
  --tut-dim: rgba(40, 18, 38, .55);
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; touch-action: manipulation; min-height: 100vh; overflow-x: hidden; }
button { font: inherit; color: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ico { width: 22px; height: 22px; display: inline-block; vertical-align: middle; flex: none; }

.app { position: relative; max-width: 760px; margin: 0 auto; padding: 0 12px 16px; padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }

/* ---------- top bar + menu ---------- */
.topbar { display: flex; align-items: center; gap: 4px; height: 50px; }
.back, .iconbtn { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 12px; color: var(--muted); text-decoration: none; font-size: 22px; background: none; border: 0; cursor: pointer; padding: 0; }
.back:hover, .iconbtn:hover, .iconbtn[aria-expanded="true"] { color: var(--ink); background: var(--surface2); }
.brand { flex: 1; text-align: center; font: italic 700 21px/1 Georgia, "Times New Roman", serif; letter-spacing: .04em; color: #6a2f5c; }
.menu { position: absolute; right: 12px; top: 46px; z-index: 45; min-width: 190px; padding: 6px; background: var(--surface); border-radius: 14px; box-shadow: 0 14px 36px rgba(58, 30, 54, .25); display: flex; flex-direction: column; animation: pop .14s ease-out; }
.menu button { min-height: 46px; text-align: left; padding: 0 14px; border: 0; background: none; border-radius: 10px; cursor: pointer; font-weight: 600; }
.menu button:hover, .menu button:focus-visible { background: var(--surface2); }
@keyframes pop { from { transform: translateY(-4px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- buttons ---------- */
.btn { min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 0; background: var(--surface2); color: var(--ink); cursor: pointer; font-weight: 650; transition: background .15s, transform .1s, opacity .15s; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover:not(:disabled) { background: #dcd1de; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #b53a52; }
.btn.quiet { background: transparent; }
.btn.small { min-height: 40px; padding: 4px 14px; font-size: 14px; }
.btn.round { width: 46px; padding: 0; font-size: 22px; }

/* ---------- status ---------- */
.status { min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 0 4px 6px; font-size: 15px; color: var(--muted); text-align: center; }
.status.mine { color: var(--ink); font-weight: 600; }
.status .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.thinking::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- the table ---------- */
.ballroom { position: relative; width: 100%; aspect-ratio: 1 / 1.02; max-height: 56vh; min-height: 300px; margin: 0 auto 30px; }
.table-oval { position: absolute; left: 13%; right: 13%; top: 17%; bottom: 16%; border-radius: 50%; background: radial-gradient(ellipse at 50% 40%, var(--felt) 0%, var(--felt2) 100%); box-shadow: 0 0 0 6px #d9b56a, 0 0 0 9px #a7853f, 0 18px 30px rgba(58, 30, 54, .25); }
.center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; color: #f6e9c8; pointer-events: auto; width: 56%; }
.center .big { font: 800 34px/1 Georgia, serif; }
.center .small { font-size: 12.5px; opacity: .85; margin-top: 3px; }
.center .res { font: 700 22px/1.2 Georgia, serif; }
.center .res.win { color: #f7d774; }
.center .res.fail { color: #f4b3bf; }
.center .btn { margin-top: 8px; min-height: 40px; background: rgba(255, 255, 255, .15); color: #fff; }
.center .shown { display: flex; justify-content: center; gap: 2px; margin-top: 6px; flex-wrap: wrap; }
.center .shown svg { width: 22px; height: 22px; }

.seat { position: absolute; transform: translate(-50%, -50%); width: 96px; border: 0; background: var(--surface); border-radius: 16px; padding: 6px 4px 5px; box-shadow: 0 2px 6px rgba(58, 30, 54, .15); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: box-shadow .2s, opacity .2s, transform .2s; }
.seat.cur { box-shadow: 0 0 0 3px var(--pc), 0 4px 10px rgba(58, 30, 54, .2); }
.seat.out { opacity: .4; }
.seat.target { box-shadow: 0 0 0 3px var(--accent), 0 0 16px 2px rgba(200, 71, 95, .5); animation: throb 1.2s ease-in-out infinite; }
@keyframes throb { 0%, 100% { transform: translate(-50%, -50%); } 50% { transform: translate(-50%, -52%); } }
.seat .nm { font-size: 12px; font-weight: 700; max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.15; display: flex; align-items: center; gap: 4px; text-align: center; justify-content: center; }
.seat .nm i { width: 9px; height: 9px; border-radius: 50%; background: var(--pc); flex: none; }
.pile { display: flex; align-items: flex-end; justify-content: center; min-height: 30px; }
.pile svg { width: 26px; height: 26px; margin-left: -12px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.pile svg:first-child { margin-left: 0; }
.pile svg.up { width: 28px; height: 28px; }
.pile svg.own { opacity: .6; }            /* your own face-down masks: only you see them */
.pile svg.fresh { animation: drop .4s ease-out; }
.pile .none { width: 24px; height: 24px; margin: 3px 0; border-radius: 50%; border: 2px dashed rgba(58, 30, 54, .2); }
@keyframes drop { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.meta { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.pips { display: inline-flex; gap: 2px; }
.pips i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .25; }
.pips i.on { opacity: 1; background: var(--ink); }
.stars { color: var(--gold); font-size: 12px; letter-spacing: 1px; }
.stars .off { color: var(--surface2); }
.tag { position: absolute; top: -10px; right: -6px; padding: 1px 7px; border-radius: 9px; font-size: 12px; font-weight: 800; background: var(--pc); color: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.tag.pass { background: #a89aac; }
.tag.fresh { animation: pop .3s ease-out; }

/* ---------- you ---------- */
.you { background: var(--surface); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.you.turn { box-shadow: inset 0 0 0 2px rgba(200, 71, 95, .35); }
.hand { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.seat.me { cursor: default; }
.mask-btn { border: 0; background: var(--bg); border-radius: 14px; padding: 4px; cursor: pointer; display: grid; place-items: center; transition: transform .15s, box-shadow .2s, opacity .2s; }
.mask-btn svg { width: 46px; height: 46px; display: block; }
.mask-btn.can { box-shadow: 0 0 0 2.5px var(--accent); }
.mask-btn.can:hover { transform: translateY(-2px); }
.mask-btn:disabled { cursor: default; opacity: .7; }
.controls { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; min-height: 44px; }
.stepper { display: flex; align-items: center; gap: 4px; background: var(--bg); border-radius: 14px; padding: 2px; }
.stepper .n { min-width: 40px; text-align: center; font: 800 22px/1 Georgia, serif; }
.controls .hint { font-size: 13px; color: var(--muted); }

/* ---------- sheet ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(58, 30, 54, .38); }
.sheet { position: relative; width: 100%; max-width: 520px; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .18s ease-out; box-shadow: 0 -10px 40px rgba(58, 30, 54, .2); }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet h3 { font: italic 700 19px/1.2 Georgia, serif; margin-bottom: 8px; color: #6a2f5c; }
.sheet p { margin: 6px 0; }
.sheet .actions { display: flex; gap: 8px; margin-top: 14px; }
.sheet .actions .btn { flex: 1 1 0; }
.sheet .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 12px 0 5px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 240px; overflow-y: auto; font-size: 13px; }
.log li { padding: 5px 2px; border-bottom: 1px solid var(--line); color: var(--muted); }
.log li:first-child, .log li.mine { color: var(--ink); }
.setup-sheet .field { margin: 12px 0; }
.setup-sheet .label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 6px; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1 1 0; min-width: 0; min-height: 46px; border-radius: 12px; border: 0; background: var(--surface2); cursor: pointer; font-weight: 650; }
.seg button.on { background: var(--surface); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.results { width: 100%; border-collapse: collapse; font-size: 14px; }
.results th, .results td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.results th:first-child, .results td:first-child { text-align: left; }
.results th { color: var(--muted); font-size: 12px; font-weight: 600; }
.results tr.me td { font-weight: 700; color: var(--accent); }

/* ---------- modals ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(58, 30, 54, .42); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(58, 30, 54, .3); }
.over-modal { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.modal-head h2 { font: italic 700 21px/1.2 Georgia, serif; color: #6a2f5c; }
.modal-body { padding: 0 18px 14px; overflow-y: auto; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; }
.modal-foot .btn { flex: 1 1 110px; }
.rules h3 { font-size: 15px; margin: 16px 0 4px; color: #6a2f5c; font-family: Georgia, serif; }
.rules p, .rules li { font-size: 14px; }
.rules ol, .rules ul { padding-left: 20px; margin: 4px 0; }
.rules li { margin: 4px 0; }
.result-banner { font: italic 800 26px/1.2 Georgia, serif; margin: 0 0 10px; }
.result-banner.win { color: var(--accent); }

@media (min-width: 700px) {
  .ballroom { max-height: 60vh; }
  .seat { width: 112px; }
}
@media (max-width: 370px) {
  .seat { width: 84px; }
  .pile svg { width: 22px; height: 22px; margin-left: -10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- online (a table with friends: tables.js) ---------- */
/* a short notice (connection lost, the table was updated, someone left) floats just under the status line,
   over the table's top edge, so the board never moves */
.game { position: relative; }
.net-note { position: absolute; left: 50%; top: 38px; transform: translateX(-50%); z-index: 6; width: max-content; max-width: min(88vw, 360px);
  padding: 4px 12px; border-radius: 12px; background: var(--ink); color: var(--surface); font-size: 12.5px; font-weight: 700; line-height: 1.3; text-align: center;
  white-space: normal; box-shadow: 0 4px 14px rgba(58, 30, 54, .3); pointer-events: none; animation: pop .25s ease-out; }
/* a friend whose page stopped checking in */
.seat.away .nm { font-style: italic; opacity: .7; }
.seat.away .pile { opacity: .55; }
.seat.away::after { content: 'away'; font-size: 11px; font-weight: 600; font-style: italic; line-height: 1; color: var(--muted); }
/* the waiting table: an open seat */
.seat.open { background: transparent; box-shadow: inset 0 0 0 2px rgba(58, 30, 54, .18); color: var(--muted); cursor: default; }
.seat.open .nm i { background: transparent; }
/* one divider above the online rows */
.menu #menu-online, .menu #menu-leave { border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
/* the kit's end bar (Rematch / Leave after the game) makes room while a bottom sheet (a guest, game info) is open */
.sheet-wrap:not([hidden]) ~ .bp-tables-endbar { display: none !important; }
