/* Liar's Dice, ivory dice and leather cups on a deep blue-green baize. Fixed palette. */
:root {
  color-scheme: light;
  --bg: #f1eee7;
  --card: #fffdf8;
  --ink: #1f2024;
  --muted: #74767d;
  --line: #e1dbcf;
  --felt: #2d5563;
  --felt-2: #24444f;
  --cup: #8a5530;
  --cup-2: #5f3a20;
  --ivory: #fbf8ef;
  --pip: #25262b;
  --gold: #ffc94d;
  --red: #c2412d;
  /* tutorial kit (tutorial.css) */
  --tut-accent: #ffc94d;
  --tut-accent-ink: #1f2024;
  --tut-bubble: #fffdf8;
  --tut-ink: #1f2024;
  --tut-muted: #74767d;
  --tut-dim: rgba(12, 26, 32, .55);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  touch-action: manipulation;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- bar ---------- */
.app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 900px; margin: 0 auto;
  padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(14px, env(safe-area-inset-left));
}
.bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 60px; }
.back { color: var(--muted); text-decoration: none; font-size: 14px; white-space: nowrap; padding: 12px 2px; }
.back:hover, .back:focus-visible { color: var(--ink); }
.bar-actions { display: flex; gap: 8px; }

.btn {
  min-height: 44px; min-width: 44px; padding: 0 18px; border-radius: 22px;
  border: 0; background: var(--card); color: var(--ink);
  font-weight: 650; cursor: pointer; box-shadow: 0 1px 2px rgba(31, 32, 36, .1), 0 0 0 1px var(--line);
  transition: transform .12s, background .15s, color .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.icon { padding: 0; width: 44px; font-size: 22px; line-height: 1; letter-spacing: .04em; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.primary { background: var(--ink); color: var(--card); box-shadow: none; }
.btn.wide { width: 100%; min-height: 50px; font-size: 17px; }
.btn:disabled, .row:disabled { opacity: .35; cursor: default; transform: none; }
.btn:focus-visible, .seg button:focus-visible, .row:focus-visible, .link:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

/* ---------- game ---------- */
.game {
  flex: 1; min-height: 0;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px; padding-bottom: 10px;
}
.turn {
  justify-self: center; display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 16px; border-radius: 999px; background: var(--card);
  box-shadow: 0 0 0 1px var(--line); font-weight: 650; font-size: 16px; min-height: 40px;
}
.turn.thinking #turn-text::after { content: ''; display: inline-block; width: 1.1em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }

/* ---------- table ---------- */
.table {
  min-height: 0; position: relative; overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 6px;
  border-radius: 20px; padding: 12px 10px 14px;
  background: radial-gradient(ellipse at 50% 45%, var(--felt), var(--felt-2) 80%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15), inset 0 2px 14px rgba(0, 0, 0, .22);
  color: #f4f1ea;
}
.seats { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; }
.seat {
  width: 76px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 2px 6px; border-radius: 14px; transition: background .25s, opacity .25s;
}
.seats.many { gap: 4px 2px; }
.seats.many .seat { width: 62px; }
.seats.many .seat .cupbox { width: 56px; }
.seats.many .seat .cup { left: 4px; }
.seats.many .seat .say { font-size: 12px; padding: 1px 5px; gap: 2px; }
.seats.many .seat .say .die { width: 14px; height: 14px; }
.seat.on { background: rgba(255, 255, 255, .1); box-shadow: inset 0 0 0 2px rgba(255, 201, 77, .75); }
.seat.out { opacity: .38; }
.seat .cupbox { position: relative; width: 60px; height: 58px; }
.seat .cup { position: absolute; left: 6px; bottom: 0; width: 48px; height: 52px; transition: transform .55s cubic-bezier(.3, .1, .3, 1), opacity .55s; z-index: 2; }
.seat.lift .cup { transform: translateY(-26px) scale(.9); opacity: 0; }
.seat .under { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-end; gap: 2px; opacity: 0; transition: opacity .4s .25s; }
.seat.lift .under { opacity: 1; }
.seat .under .die { width: 17px; height: 17px; }
.seat .nm { font-size: 13px; font-weight: 700; line-height: 1.2; }
.seat .left { display: flex; gap: 2px; min-height: 6px; }
.seat .left i { width: 6px; height: 6px; border-radius: 1.5px; background: #e9e2d2; }
.seat .left i.gone { background: transparent; box-shadow: inset 0 0 0 1px rgba(233, 226, 210, .4); }
.seat .say { white-space: nowrap; min-height: 22px; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; background: rgba(255, 255, 255, .12); font-variant-numeric: tabular-nums; }
.seat .say:empty { background: transparent; }
.seat .say .die { width: 16px; height: 16px; }
.seat .say.liar { background: var(--red); color: #fff; }
.seat .say.pop { animation: pop .35s cubic-bezier(.2, .9, .3, 1.4); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.center { min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; }
.bid-box { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bid-box .who { font-size: 14px; color: rgba(244, 241, 234, .75); }
.bid-box .what { display: inline-flex; align-items: center; gap: 10px; font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.bid-box .what .die { width: 46px; height: 46px; }
.bid-box .what .x { font-size: 26px; opacity: .7; font-weight: 600; }
.bid-box .sub { font-size: 13px; color: rgba(244, 241, 234, .6); }
.bid-box.pop .what { animation: pop .35s cubic-bezier(.2, .9, .3, 1.3); }
.result { display: flex; flex-direction: column; align-items: center; gap: 10px; animation: pop .3s ease-out; }
.result-text { font-size: 16px; line-height: 1.4; max-width: 300px; }
.result-text b { color: var(--gold); }
.result .btn { min-width: 150px; }

.mine { display: flex; justify-content: center; }
.mine-dice { display: flex; gap: 8px; justify-content: center; min-height: 48px; }
.mine-dice .die { width: 48px; height: 48px; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .3)); }
.mine-dice .die.rolling { animation: roll .6s cubic-bezier(.3, .1, .3, 1) both; }
@keyframes roll { 0% { transform: translateY(-14px) rotate(-160deg) scale(.7); opacity: 0; } 100% { transform: none; opacity: 1; } }
.die.hit { animation: hit .5s ease-out both; }
.die.hit .bgf { fill: #fff1c2; stroke: var(--gold); stroke-width: 1.6; }
@keyframes hit { 0% { transform: scale(1); } 50% { transform: scale(1.18); } 100% { transform: scale(1); } }
.die.miss { opacity: .45; }

/* ---------- controls ---------- */
.controls { width: 100%; max-width: 460px; justify-self: center; display: flex; flex-direction: column; gap: 10px; align-items: stretch; transition: opacity .2s; }
.controls.off { opacity: .4; }
.pickers { display: flex; align-items: center; justify-content: center; gap: 10px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 16px; background: var(--card); box-shadow: 0 0 0 1px var(--line); }
.step { width: 44px; height: 44px; border: 0; border-radius: 12px; background: var(--bg); font-size: 24px; font-weight: 700; line-height: 1; cursor: pointer; }
.step:disabled { opacity: .3; cursor: default; }
.step:active:not(:disabled) { transform: scale(.95); }
.qty { min-width: 2.2ch; text-align: center; font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.face { width: 44px; height: 44px; display: grid; place-items: center; }
.face .die { width: 38px; height: 38px; }
.times { font-size: 22px; color: var(--muted); }
.acts { display: flex; gap: 10px; }
.btn.big { flex: 1; min-height: 50px; font-size: 17px; }
.btn.liar { background: var(--red); color: #fff; box-shadow: none; }
.hint {
  justify-self: center; min-height: 22px; font-size: 15px; color: var(--muted); text-align: center;
  opacity: 0; transform: translateY(3px); transition: opacity .25s, transform .25s;
}
.hint.show { opacity: 1; transform: none; }
.die { display: inline-block; flex: none; overflow: visible; }
.over-mark { display: flex; justify-content: center; gap: 6px; margin-bottom: 10px; }
.over-mark .die { width: 44px; height: 44px; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(31, 32, 36, .36);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 12px;
  animation: fade .2s ease-out;
}
.overlay.soft { background: rgba(241, 238, 231, .55); align-items: center; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet, .card {
  background: var(--card); color: var(--ink);
  width: 100%; max-width: 440px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow: auto; overscroll-behavior: contain;
  border-radius: 24px; padding: 8px 20px 20px;
  box-shadow: 0 20px 50px rgba(31, 32, 36, .22);
  animation: rise .22s ease-out;
}
@keyframes rise { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) { .overlay { align-items: center; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; min-height: 52px; }
.sheet-head h2 { margin: 0; font-size: 20px; }
.row {
  display: block; width: 100%; text-align: left; min-height: 50px; padding: 0 4px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; font-weight: 600; cursor: pointer;
}
.menu-sheet .row:first-of-type { border-top: 1px solid var(--line); }
.caps { font-size: 13px; color: var(--muted); margin: 10px 4px 0; font-variant-numeric: tabular-nums; }
.group { padding: 12px 0 4px; }
.label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.seg { display: flex; gap: 4px; padding: 4px; border-radius: 16px; background: var(--bg); }
.seg button {
  flex: 1 1 0; min-height: 44px; border: 0; border-radius: 12px; background: transparent;
  font-weight: 600; cursor: pointer; color: var(--muted); transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(31, 32, 36, .16); }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.menu-sheet #menu-help { margin-top: 10px; border-top: 1px solid var(--line); }
.menu-sheet .btn.wide { margin-top: 16px; }

.over-card { max-width: 340px; text-align: center; padding: 24px 22px 14px; }
.over-mark { display: flex; justify-content: center; gap: 8px; margin-bottom: 10px; }
.over-mark .stone-icon { width: 52px; height: 52px; box-shadow: 0 4px 10px rgba(0, 0, 0, .18); }
.over-title { font-size: 28px; font-weight: 800; }
.over-title.small { font-size: 22px; }
.over-sub { color: var(--muted); margin: 4px 0 20px; font-variant-numeric: tabular-nums; }
.link { display: block; margin: 8px auto 0; min-height: 44px; padding: 0 16px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }

.help-sheet { max-width: 560px; }
.help-body { padding-bottom: 6px; }
.help-body h3 { font-size: 16px; margin: 18px 0 4px; }
.help-body p, .help-body li { font-size: 15px; margin: 4px 0; }
.help-body ul { padding-left: 20px; }
.fine { font-size: 13px; color: var(--muted); margin-top: 14px; }


/* ---------- small and landscape screens ---------- */
@media (max-width: 380px) {
  .app { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
  .btn { padding: 0 14px; }
  .back { font-size: 13px; }
  .seat { width: 66px; }
  .mine-dice { gap: 6px; }
  .mine-dice .die { width: 44px; height: 44px; }
}
@media (max-height: 700px) {
  .bid-box .what { font-size: 32px; }
  .bid-box .what .die { width: 38px; height: 38px; }
  .mine-dice .die { width: 42px; height: 42px; }
  .seat .cupbox { height: 48px; }
  .seat .cup { width: 40px; height: 44px; left: 10px; }
}
@media (min-aspect-ratio: 1/1) and (max-height: 520px) {
  .bar { min-height: 50px; }
  .game { gap: 6px; padding-bottom: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}

/* The tutorial kit's first-visit chip sits over the turn pill instead of on top of the Bid and Liar! buttons
   (it goes away once you make your first move). */
body > .tut-chip { top: calc(env(safe-area-inset-top, 0px) + 58px); bottom: auto; }

/* ---------- online (a table with friends: tables.js) ---------- */
/* a short notice (connection lost, the table was updated, someone left) floats just under the turn pill,
   over the table's top edge, so the board never moves */
.turn { position: relative; }
.turn .net-note { position: absolute; left: 50%; top: calc(100% + 4px); 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(--card); font-size: 12.5px; font-weight: 700; line-height: 1.3; text-align: center;
  white-space: normal; box-shadow: 0 4px 14px rgba(31, 32, 36, .3); pointer-events: none; animation: fade .25s ease-out; }
.turn .net-note[hidden] { display: none; }
/* people's names can be long: a seat grows a little for one, then keeps it to one line */
body.is-online .seat { width: auto; min-width: 76px; max-width: 108px; }
body.is-online .seat .nm { max-width: 100%; white-space: normal; overflow-wrap: anywhere; line-height: 1.15; }
/* a friend whose page stopped checking in */
.seat.away .nm { font-style: italic; opacity: .7; }
.seat.away .cupbox { opacity: .55; }
.seat.away::after { content: 'away'; font-size: 11px; font-weight: 600; font-style: italic; line-height: 1; opacity: .75; }
body.is-online #btn-new { display: none; }
/* one divider above the online rows (How to play keeps its own) */
.menu-sheet #menu-online, .menu-sheet #menu-leave { margin-top: 10px; border-top: 1px solid var(--line); }
.menu-sheet #menu-help { margin-top: 0; border-top: 0; }
.over-card #over-leave { margin-top: 8px; }
