/* Bluff Momo — mobile-first table UI.
   No web fonts on purpose: this runs on a hotspot with no internet, so we lean
   on system faces. Devanagari needs an explicit fallback chain because the
   default UI face on some platforms has no Devanagari coverage. */

/* Palette sampled from the five character illustrations:
     मन्त्री's navy coat        #385470  -> surfaces
     आमा's rose shawl          #A81C54  -> primary / danger
     चोर's gold + the momo      #E0A81C  -> momo, highlights
     हन्ते's sky blue           #54A8C4  -> cool accent
     मन्त्री's sage / poison     #8CC454  -> positive
     the momo's dough           #E0E0C4  -> text
   Shared warm skin tone        #E08C70  -> losses / secondary  */
:root {
  --bg:        #13172a;
  --bg-2:      #191e35;
  --panel:     #212845;
  --panel-2:   #2b3355;
  --line:      #3a4468;
  --beige:     #ece4cf;
  --text:      #ece4cf;
  --muted:     #98a2c2;
  --red:       #c82a60;   /* आमा rose */
  --red-ink:   #fff0f5;   /* text on rose */
  --yellow:    #e8b23c;   /* चोर gold / momo */
  --green:     #96c47e;   /* मन्त्री sage */
  --blue:      #7fb8d4;   /* हन्ते sky */
  --salmon:    #e08c70;
  --radius:    14px;
  --tap:       46px;
}

* { box-sizing: border-box; }

/*
 * The `hidden` attribute means hidden.
 *
 * Any explicit `display` rule beats the browser's own `[hidden] { display: none }`,
 * so a flex container marked hidden in JS stays visible. That bug shipped twice
 * here — the share box showed during offline solo play, and the watcher count
 * showed with nobody watching. One rule removes the whole class of it.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.np {
  font-family: "Nirmala UI", "Noto Sans Devanagari", "Mangal", "Kohinoor Devanagari",
               "Devanagari Sangam MN", system-ui, sans-serif;
}

button, input { font: inherit; color: inherit; }

/* ------------------------------------------------------------- screens */

.screen { display: none; }
.screen.active { display: block; }

.join-wrap, .lobby-wrap, .over-wrap {
  max-width: 460px;
  margin: 0 auto;
  padding: 28px 18px calc(28px + env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

/* ------------------------------------------------------------ momo / art */

.momo-ic {
  width: 1.3em;
  height: 1.3em;
  object-fit: contain;
  vertical-align: -0.25em;
  flex: none;
}
.deck-ic { width: 13px; height: 18px; border-radius: 2px; object-fit: cover; flex: none; }
.tgt-momo { color: var(--yellow); white-space: nowrap; }
.st-cards { color: var(--muted); font-size: 12.5px; }
.rv-ic { width: 15px; height: 15px; object-fit: contain; vertical-align: -3px; }

.brand { text-align: center; }
.brand-momo { width: 78px; height: 79px; object-fit: contain; }
.brand h1 {
  font-size: 40px;
  margin: 6px 0 4px;
  letter-spacing: -0.5px;
  color: var(--yellow);
}
.tagline { color: var(--muted); margin: 0; line-height: 1.5; font-size: 15px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
}
.card-title {
  font-size: 16px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.count-pill {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 9px;
  font-size: 13px;
  color: var(--muted);
}

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}
/* Every text-like field, not just type=text. Hanging this on one type left the
   password field and the server-address field (type=url) completely unstyled. */
input[type=text],
input[type=password],
input[type=url],
input[type=email],
input[type=search],
input[type=number] {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 13px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
input[type=text]:focus,
input[type=password]:focus,
input[type=url]:focus,
input[type=email]:focus,
input[type=search]:focus,
input[type=number]:focus { border-color: var(--yellow); }

.code-input {
  text-align: center;
  letter-spacing: 6px;
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
}

.or {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  margin: 16px 0 12px;
}
.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.join-row { display: flex; gap: 8px; }
.join-row .code-input { flex: 1; min-width: 0; }

/* -------------------------------------------------------------- buttons */

.btn {
  min-height: var(--tap);
  padding: 10px 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s, background .15s, border-color .15s;
  touch-action: manipulation;
}
.btn:hover:not(:disabled) { background: #39426a; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-primary {
  background: var(--red);
  border-color: var(--red);
  color: var(--red-ink);
}
.btn-primary:hover:not(:disabled) { background: #d8396f; border-color: #d8396f; }

.btn-big { width: 100%; font-size: 16px; min-height: 52px; }
.btn-small { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn-ghost { background: transparent; }
.btn-danger { border-color: var(--red); color: var(--red); }
.btn-ok { border-color: var(--green); color: #dcecd0; }

.link-btn {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 10px;
  font-size: 14px;
}
.link-btn.danger { color: var(--red); }

.icon-btn {
  width: 38px;
  height: 38px;
  flex: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
}

.error { color: var(--red); font-size: 14px; min-height: 20px; margin: 10px 0 0; }
.note { color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ---------------------------------------------------------------- lobby */

.code-hero { text-align: center; }
.code-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}
.code-big {
  font-size: 56px;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--yellow);
  margin: 2px 0 6px;
  text-indent: 10px;
}
.code-hint { color: var(--muted); font-size: 14px; margin: 0; }
.code-hint strong { color: var(--beige); word-break: break-all; }

.seat-list { list-style: none; margin: 0 0 12px; padding: 0; }
.seat-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.seat-list li:last-child { border-bottom: 0; }
.seat-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  flex: none;
}
.tag.host { color: var(--yellow); border-color: #7a5f22; }
.tag.you { color: var(--green); border-color: #4d6b40; }
.tag.off { color: var(--red); border-color: #75234a; }

.lobby-actions { display: flex; justify-content: center; gap: 8px; }

/* ---------------------------------------------------------------- table */

/* The table is designed for a phone; on a laptop it stays a centred column
   rather than stretching a two-player game across 1500px. */
#screen-game.active {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  /* Anchors the beat overlay to the table rather than the document. */
  position: relative;
  max-width: 780px;
  margin: 0 auto;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
  flex: none;
}
.topbar-mid { flex: 1; display: flex; justify-content: center; gap: 10px; }
.steamer, .deckinfo {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 14px;
}
.steamer b { color: var(--yellow); }
.deckinfo { color: var(--muted); }

.opponents {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  flex: none;
}

.opp {
  /* Capped so a single opponent does not become a full-width slab. */
  flex: 1 1 140px;
  max-width: 230px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 10px;
  position: relative;
  transition: border-color .2s, background .2s;
}
.opp.turn { border-color: var(--yellow); background: #273052; }
.opp.out { opacity: .42; }
.opp.target { border-color: var(--red); }
.opp.selectable { cursor: pointer; border-style: dashed; border-color: var(--blue); }
.opp.selectable:hover { background: var(--panel-2); }

.opp-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.opp-name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opp-momo { font-size: 13px; color: var(--yellow); flex: none; }
.opp-bottom { display: flex; align-items: center; gap: 8px; }

.minicards { display: flex; gap: 3px; }
.minicard {
  width: 15px;
  height: 21px;
  border-radius: 3px;
  background: url("/img/card-back.webp") center/cover, linear-gradient(150deg, #3a4468, #232a44);
  border: 1px solid #55628f;
}
.minicard.gone { background: none; border-style: dashed; border-color: var(--line); }

.opp-state { font-size: 11px; color: var(--muted); margin-left: auto; }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); flex: none;
}
.dot.off { background: var(--red); }

/* ------------------------------------------------------- stage + prompt */

.stage {
  flex: none;
  padding: 4px 12px 0;
  min-height: 62px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stage-banner {
  text-align: center;
  font-size: 15px;
  line-height: 1.45;
  color: var(--beige);
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.stage-banner .who { font-weight: 800; }
.stage-banner .claim { color: var(--yellow); font-weight: 800; }
.stage-banner .small { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }

/* The phase clock. Quiet until it matters, then hard to miss: a 3px line going
   from yellow to red was not enough warning to act on. */
.timer {
  position: relative;
  height: 4px;
  background: var(--line);
  border-radius: 3px;
  margin: 6px 2px 0;
}
.timer.hidden { visibility: hidden; }
.timer i {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 3px;
  background: var(--yellow);
}
.timer.urgent i { background: var(--red); animation: timer-pulse .9s ease-in-out infinite; }
@keyframes timer-pulse { 50% { opacity: .4; } }
/* The count sits above the bar, so the bar needs no room for it. */
.timer b {
  position: absolute;
  right: 2px;
  top: -17px;
  font-size: 12px;
  font-weight: 700;
  color: var(--red);
  font-variant-numeric: tabular-nums;
}

.prompt {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 10px 12px;
  -webkit-overflow-scrolling: touch;
}
.prompt-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin: 0 0 9px;
}
.actions { display: grid; gap: 7px; }
.action-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 10px 13px;
  min-height: var(--tap);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}
.action-btn:hover:not(:disabled) { background: var(--panel-2); border-color: #4b5789; }
.action-btn:disabled { opacity: .35; cursor: not-allowed; }
.action-btn.free { border-left: 3px solid var(--green); }
.action-btn.claimed { border-left: 3px solid var(--yellow); }
.action-btn .ab-main { flex: 1; min-width: 0; }
.action-btn .ab-name { display: block; font-weight: 700; font-size: 15px; }
.action-btn .ab-desc {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.4;
}
.action-btn .ab-cost {
  flex: none;
  font-size: 12px;
  color: var(--yellow);
  background: var(--bg-2);
  border-radius: 999px;
  padding: 3px 8px;
}

.choice-row { display: flex; flex-wrap: wrap; gap: 7px; }
.choice-row .btn { flex: 1 1 auto; min-width: 120px; }

.waiting-line { color: var(--muted); font-size: 14px; text-align: center; padding: 12px 0; }
.pass-chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 8px; }
.chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.chip.passed { color: var(--green); border-color: #4d6b40; }

/* ----------------------------------------------------------------- hand */

.hand-area {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
}
.hand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13px;
}
.you-name { font-weight: 700; display: flex; align-items: center; min-width: 0; }
.you-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.you-momo { color: var(--yellow); display: flex; align-items: center; gap: 5px; }
.hand { display: flex; gap: 8px; justify-content: center; }

.card-face {
  flex: 0 1 150px;
  max-width: 172px;
  aspect-ratio: 5 / 7;
  border-radius: 11px;
  background: linear-gradient(160deg, #2c3452, #1b2138);
  border: 1px solid #4a5680;
  padding: 9px 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.card-face.pick { cursor: pointer; border-color: var(--red); border-style: dashed; }
.card-face.pick:hover { background: #38416a; }
.card-face.new { border-color: var(--green); }
.card-face .cf-head { flex: none; }
.card-face .cf-np { font-size: 18px; font-weight: 700; line-height: 1.2; }
.card-face .cf-roman {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
/* Tumlet's character illustration fills the middle of the card. */
.card-face .cf-art {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  margin: 4px 0 2px;
  pointer-events: none;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45));
}
.card-face .cf-power { flex: none; font-size: 10.5px; color: var(--muted); line-height: 1.3; }
.card-face .cf-badge {
  position: absolute;
  top: 6px; right: 7px;
  font-size: 9px;
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: .5px;
}
.card-face.empty {
  border-style: dashed;
  border-color: var(--line);
  background: none;
  align-items: center;
  justify-content: center;
  color: var(--line);
}

/* ------------------------------------------------------------ log panel */

.logpanel {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(370px, 88vw);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
  z-index: 40;
  padding-top: env(safe-area-inset-top);
}
.logpanel.open { transform: none; }
.logpanel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.log { flex: 1; overflow-y: auto; padding: 10px 12px; font-size: 13.5px; }
.log-line { padding: 5px 0; border-bottom: 1px solid #2a3350; line-height: 1.45; }
.log-line:last-child { border-bottom: 0; }
.log-line.kind-claim { color: var(--yellow); }
.log-line.kind-challenge { color: var(--red); font-weight: 600; }
.log-line.kind-truth { color: var(--blue); }
.log-line.kind-bluff { color: var(--red); }
.log-line.kind-block { color: var(--blue); }
.log-line.kind-loss, .log-line.kind-out { color: var(--salmon); }
.log-line.kind-win { color: var(--green); font-weight: 700; }
/* `allow`, `timeout` and `draw` were all `sys` until the bots needed to tell
   them apart. They are still incidental to read, so they still look it. */
.log-line.kind-sys, .log-line.kind-peek,
.log-line.kind-allow, .log-line.kind-timeout,
.log-line.kind-draw { color: var(--muted); }
.log-line.kind-chat { color: var(--beige); }
.log-line.kind-chat b { color: var(--yellow); }
.log-line.kind-private { color: var(--green); font-style: italic; }

.chatbox { display: flex; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); }
.chatbox input { flex: 1; min-width: 0; min-height: 38px; }

.counted { padding: 10px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.counted > strong { display: block; margin-bottom: 7px; }
.revealed { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.revealed span {
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.revealed span.some { border-color: var(--yellow); color: var(--yellow); }
.revealed span.all { border-color: var(--red); color: var(--red); }

/* --------------------------------------------------------------- sheets */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.sheet.open { display: flex; }
.sheet-inner {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
  width: min(560px, 100%);
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body {
  overflow-y: auto;
  padding: 16px calc(16px + env(safe-area-inset-left)) calc(24px + env(safe-area-inset-bottom));
  font-size: 14.5px;
  line-height: 1.6;
}
.sheet-body h3 {
  font-size: 15px;
  margin: 22px 0 7px;
  color: var(--yellow);
}
.sheet-body h3:first-child { margin-top: 0; }
.sheet-body p { margin: 0 0 10px; color: #d8d2c0; }
.sheet-body ul { margin: 0 0 10px; padding-left: 20px; color: #d8d2c0; }
.sheet-body li { margin-bottom: 5px; }
.sheet-body table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; font-size: 13.5px; }
.sheet-body th, .sheet-body td {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.sheet-body th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.sheet-body .ch { color: var(--yellow); font-weight: 700; white-space: nowrap; }
/* Illustrated character entries in the rules sheet. */
.charlist { display: grid; gap: 10px; margin-bottom: 12px; }
.charrow {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.charrow-art {
  width: 74px;
  flex: none;
  align-self: center;
  object-fit: contain;
  max-height: 92px;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45));
}
.charrow-txt { min-width: 0; }
.charrow-name { font-size: 17px; font-weight: 800; color: var(--yellow); }
.charrow-roman {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.charrow-txt p { margin: 3px 0 0; font-size: 13px; line-height: 1.45; }

.callout {
  border-left: 3px solid var(--red);
  background: #2e1a2c;
  padding: 10px 12px;
  border-radius: 0 10px 10px 0;
  margin: 0 0 12px;
}

/* ---------------------------------------------------------- misc / over */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 14px);
  background: var(--panel-2);
  border: 1px solid var(--yellow);
  color: var(--beige);
  padding: 10px 15px;
  border-radius: 11px;
  font-size: 14px;
  max-width: 84vw;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 70;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.banner-offline {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--red);
  color: var(--red-ink);
  text-align: center;
  padding: 7px;
  font-size: 13px;
  font-weight: 700;
  z-index: 80;
  display: none;
}
.banner-offline.show { display: block; }

.over-momo { width: 88px; height: 89px; object-fit: contain; margin: 0 auto; display: block; }
#over-title { text-align: center; font-size: 30px; margin: 8px 0 4px; color: var(--yellow); }
.over-wrap .tagline { text-align: center; }
.standings { display: grid; gap: 7px; }
.standings div {
  display: flex;
  gap: 9px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 14px;
}
.standings .rank { color: var(--muted); width: 20px; flex: none; }
.standings .nm { flex: 1; font-weight: 600; }
.standings .win { border-color: var(--yellow); }

@media (min-width: 640px) {
  .opponents { padding: 12px; }
  .stage-banner { font-size: 16px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .prompt-title { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------------------------------------------------------------- bots */

.botbar {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.botbar.hidden { display: none; }
.botpick { display: block; margin-bottom: 8px; }
.botpick > span {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  margin-bottom: 6px;
}
.botbar select {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.botbar select:focus { border-color: var(--yellow); }
.botbar .btn { width: 100%; }
.bot-blurb { margin: 9px 0 0; min-height: 34px; }

.tag.bot { color: var(--blue); border-color: #3f5d75; }
.tier { font-size: 10px; color: var(--muted); }

.opp.bot .opp-name::after {
  content: "bot";
  font-size: 9px;
  color: var(--blue);
  border: 1px solid #3f5d75;
  border-radius: 999px;
  padding: 0 5px;
  margin-left: 5px;
  vertical-align: 1px;
  font-weight: 600;
}

/* -------------------------------------------------- sharing & spectating */

.join-extra { text-align: center; margin-top: 2px; }

.sharebox { display: flex; gap: 6px; margin-top: 14px; }
.sharebox input {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  color: var(--beige);
}
.sharebox .btn { flex: none; }
.share-note { margin: 8px 0 0; text-align: center; }

.watchers {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px;
  color: var(--muted);
}
.watchers b { color: var(--blue); }

.spectator-strip {
  flex: none;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  text-align: center;
}
.spectator-strip strong { color: var(--blue); display: block; margin-bottom: 3px; }
.spectator-strip .note { font-size: 12.5px; }

.tag.watching { color: var(--blue); border-color: #3f5d75; }
.log-line.kind-chat b.spec { color: var(--blue); }
.watch-list { margin-top: 10px; font-size: 13px; color: var(--muted); }

/* ------------------------------------------------------------ leaving */

.exitbox {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 7px;
}
.exitbox > strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
}
.exitbox .btn[data-armed="1"] {
  background: var(--red);
  border-color: var(--red);
  color: var(--red-ink);
}
.exitbox .note { margin: 2px 0 0; }

/* --------------------------------------------------- installable app bits */

.solo-note { margin: 8px 0 0; text-align: center; }

.installbar {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
}
.installbar[hidden] { display: none; }
.ios-hint { text-align: center; }
.ios-hint[hidden] { display: none; }

.offline-badge {
  background: var(--panel);
  border: 1px solid #4d6b40;
  color: var(--green);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.offline-badge[hidden] { display: none; }

/* In standalone mode there is no browser chrome, so respect the notch. */
@media (display-mode: standalone) {
  .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }
}

/* --------------------------------------------- native build: server address */

.serverrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.serverrow[hidden], .servedit[hidden] { display: none; }
.serverrow strong { color: var(--beige); overflow-wrap: anywhere; }
.servedit { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.servedit .field { margin-bottom: 10px; }

/* ------------------------------------------------------- table score record */

.record-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.record-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 11px;
  font-size: 14px;
}
.record-list li.leader { border-color: var(--yellow); }
.record-list li.gone { opacity: .55; }
.record-list .rank { color: var(--muted); width: 18px; flex: none; font-size: 12px; }
.record-list .who { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.record-list .wins { color: var(--yellow); font-weight: 700; flex: none; }
.record-list .wins small { color: var(--muted); font-weight: 400; }
.record-head {
  font-size: 15px;
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}
#record-card[hidden], #over-record[hidden] { display: none; }

/* ------------------------------------------------------- keyboard shortcuts */

.kbd {
  flex: none;
  margin-left: auto;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--bg-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}
.action-btn .kbd { align-self: center; }
/* On a card the badge sits in the corner rather than in the flow. */
.card-face .kbd {
  position: absolute;
  top: 6px;
  left: 6px;
  margin: 0;
}
/* Touch devices have no keyboard, so the hints are only noise there. */
@media (hover: none) and (pointer: coarse) {
  .kbd { display: none; }
}

/* Key hints are opt-in: clutter once learned, useless on a phone. */
.kbd { display: none; }
body.show-hints .kbd { display: inline-block; }
body.show-hints .card-face .kbd { display: block; }
@media (hover: none) and (pointer: coarse) {
  body.show-hints .kbd { display: none; }
}
.prefs { padding: 10px 12px; border-top: 1px solid var(--line); text-align: center; }

/* ------------------------------------------- purse, public rooms, tips, style */

.purse {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
}
.purse[hidden] { display: none; }
.purse-name { font-weight: 700; }
.purse-mohar b { color: var(--yellow); font-size: 15px; }
.purse-record { color: var(--muted); }

.room-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 7px; }
.room-list li {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
}
.room-list .rc { font-weight: 800; letter-spacing: 2px; color: var(--yellow); }
.room-list .rmeta { flex: 1; color: var(--muted); font-size: 12.5px; }
.room-list .btn { min-height: 34px; padding: 5px 12px; font-size: 13px; }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.check[hidden] { display: none; }
.check input { width: 17px; height: 17px; accent-color: var(--red); }

.tipbar {
  flex: none;
  margin: 0 12px 4px;
  padding: 8px 12px;
  border-left: 3px solid var(--blue);
  background: var(--panel);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.tipbar[hidden] { display: none; }
.tipbar b { color: var(--blue); }

.stylecard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--yellow);
  border-radius: 0 12px 12px 0;
  padding: 14px;
  margin-bottom: 14px;
  text-align: left;
}
.stylecard[hidden] { display: none; }
.stylecard h3 { margin: 0 0 4px; font-size: 19px; color: var(--yellow); }
.stylecard p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.5; color: #d8d2c0; }
.stylecard .facts { font-size: 12.5px; color: var(--muted); }
.stylecard .advice {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--beige);
}
.stylecard .earned { color: var(--yellow); font-weight: 700; }
.stylecard .earned small { color: var(--muted); font-weight: 400; display: block; margin-top: 3px; }

/* A card you can play right now, and the actions it points at. */
.card-face.tappable { cursor: pointer; }
/*
 * The "tap to play" badge below is absolutely positioned, so the card has to
 * leave it room in the flow. Without the padding it is written straight over the
 * power line — मन्त्री's is the longest and wraps to two lines on a narrow card,
 * which is exactly where the two collided.
 */
.card-face.playable { border-color: var(--yellow); padding-bottom: 24px; }
.card-face.playable:hover { background: #38416a; }
.card-face.playable::after {
  content: "tap to play";
  position: absolute;
  bottom: 4px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--yellow);
  opacity: .75;
}
.action-btn.spotlight {
  border-color: var(--yellow);
  background: #2c2418;
  box-shadow: 0 0 0 1px var(--yellow) inset;
}
.action-btn.dimmed { opacity: .4; }

/* --------------------------------------------------------------- insights */

.insights { margin: 0 0 12px; display: grid; gap: 7px; }
.insights > div {
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}
.insights dt { flex: none; color: var(--muted); font-size: 12.5px; min-width: 9.5em; }
.insights dd { margin: 0; flex: 1; }
.insights .val { font-weight: 700; color: var(--beige); }
.insights .why { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ------------------------------------------------ pictures: players & actions

   A picture is one of the five character illustrations over a colourway, set as
   --from/--to on the element. The art is portrait and the head sits in the top
   third of it, so `cover` plus a high object-position frames the face rather
   than the chest. See lib/avatars.js for why there are no uploads. */

.avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: block;
  background: linear-gradient(150deg, var(--from, #3a4468), var(--to, #232a44));
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .35);
}
.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: 50% 4%;
  /* Zoomed a little so the head fills the circle instead of floating in it. */
  transform: scale(1.5);
  transform-origin: 50% 22%;
}
.avatar-sm { width: 24px; height: 24px; }
.avatar-lg { width: 68px; height: 68px; }

/* A bot wears a mark, so a picture never passes for a person. */
.avatar.is-bot { box-shadow: inset 0 0 0 2px var(--blue); }

.opp-top .avatar { margin-right: 1px; }
.record-list .avatar, .seat-list .avatar { margin-right: 2px; }
.hand-head .avatar { margin-right: 7px; }
.btn-target .avatar { display: inline-block; vertical-align: -9px; margin-right: 6px; }

.purse-face {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  border-radius: 50%;
  flex: none;
}
.purse-face:hover .avatar { box-shadow: inset 0 0 0 1px rgba(0,0,0,.35), 0 0 0 2px var(--yellow); }
.purse-who { display: flex; align-items: center; gap: 6px; min-width: 0; }
.purse-tag { font-size: 10px; }
.create-note { text-align: center; margin: 10px 0 2px; }
.create-note b { color: var(--yellow); }

/* The picker. */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.avatar-pick {
  background: none;
  border: 2px solid transparent;
  border-radius: 50%;
  padding: 2px;
  cursor: pointer;
  line-height: 0;
}
.avatar-pick .avatar { width: 100%; height: auto; aspect-ratio: 1; }
.avatar-pick:hover { border-color: var(--line); }
.avatar-pick.on { border-color: var(--yellow); }

.me-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.me-who { min-width: 0; }
.me-name { font-size: 19px; font-weight: 700; }

.authtabs { display: flex; gap: 6px; margin: 10px 0 14px; }
.tabbtn {
  flex: 1;
  padding: 9px 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.tabbtn.on { background: var(--panel-2); color: var(--text); border-color: #4b5789; font-weight: 700; }

/* Action pictures: whose move this is, at a glance, before reading a word. */
.action-btn .ab-art {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 8px;
  object-fit: cover;
  object-position: 50% 8%;
  background: linear-gradient(150deg, #2f3859, #1d2440);
}
.stage-art {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 6%;
  vertical-align: -9px;
  margin-right: 7px;
  background: linear-gradient(150deg, #2f3859, #1d2440);
}
.btn-block .ab-art, .claim-art {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 6%;
  vertical-align: -6px;
  margin-right: 5px;
}

/* ------------------------------------------- a crowded table on a small phone

   The table screen is one fixed-height column, so every pixel the opponents and
   the hand take is a pixel the action list loses. With five opponents at 375px
   the tiles wrapped to three rows and the prompt was left 147px — two of five
   actions visible, the rest reachable only by scrolling a narrow strip.

   Three tiles to a row instead of two, and slightly smaller cards, give the
   actions back most of that height. */
@media (max-width: 520px) {
  .opponents { gap: 6px; padding: 8px 8px 6px; }
  .opp { flex: 1 1 102px; padding: 7px 8px; border-radius: 10px; }
  .opp-top { gap: 4px; margin-bottom: 4px; }
  .opp-name { font-size: 13px; }
  .opp .avatar-sm { width: 20px; height: 20px; }
  .card-face { flex: 0 1 124px; max-width: 142px; }
}

/* When the action list does still overflow, say so. An inset shadow at the foot
   of the scroller is the difference between "that is all" and "there is more". */
.prompt.more { box-shadow: inset 0 -15px 13px -13px rgba(0, 0, 0, .7); }

/* The beat between the last move and the standings. */
.over-hold {
  text-align: center;
  font-size: 17px;
  padding: 14px 0 4px;
  margin: 0;
}
.over-hold b { color: var(--yellow); }
.over-hold .note { display: block; margin-top: 8px; font-size: 13px; }

/* ------------------------------------------------------------------ the beat

   A turning point, held over the table for a moment. Never interactive — a tap
   during a beat still reaches the game underneath. */

.beat {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px 14px 16px;
  border-radius: 14px;
  background: rgba(10, 13, 26, .93);
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px -18px rgba(0, 0, 0, .9);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.9);
  transition: opacity .18s ease, transform .18s ease;
  max-width: min(92vw, 420px);
}
.beat.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.beat:empty { display: none; }

.beat-art {
  width: 58px;
  height: 74px;
  flex: none;
  object-fit: cover;
  object-position: 50% 8%;
  border-radius: 8px;
  background: linear-gradient(150deg, #2f3859, #1d2440);
}
.beat-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.beat-title { font-weight: 800; font-size: 17px; line-height: 1.2; }
.beat-sub { font-size: 12.5px; color: var(--muted); line-height: 1.35; }

/* The colour says what it meant before the words do. */
.beat.tone-bad    { border-color: var(--red); }
.beat.tone-bad    .beat-title { color: var(--red); }
.beat.tone-good   { border-color: var(--green); }
.beat.tone-good   .beat-title { color: var(--green); }
.beat.tone-secret { border-color: var(--yellow); }
.beat.tone-secret .beat-title { color: var(--yellow); }

/* A caught bluff is the one moment worth a flinch. */
.beat.tone-bad.show { animation: beat-jolt .32s ease-out; }
@keyframes beat-jolt {
  0%   { transform: translate(-50%, -50%) scale(.9); }
  40%  { transform: translate(-50%, -50%) scale(1.04) rotate(-1.2deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0); }
}
/* A secret leans in rather than lands. */
.beat.tone-secret.show { animation: beat-lean .4s ease-out; }
@keyframes beat-lean {
  0%   { transform: translate(-50%, -50%) scale(.82); }
  100% { transform: translate(-50%, -50%) scale(1); }
}

/* Momo moving, marked where the eye already is. */
.you-momo b { display: inline-block; }
.momo-up   { animation: momo-up .55s ease-out; }
.momo-down { animation: momo-down .55s ease-out; }
@keyframes momo-up {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.35); color: var(--green); }
  100% { transform: scale(1); }
}
@keyframes momo-down {
  0%   { transform: scale(1); }
  35%  { transform: scale(.82); color: var(--red); }
  100% { transform: scale(1); }
}

/* Cards settle in, so a swap or a loss is something you see happen. */
.hand .card-face { animation: card-in .26s ease-out; }
@keyframes card-in {
  0%   { opacity: 0; transform: translateY(9px) scale(.97); }
  100% { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .beat, .beat.show { transition: none; animation: none; }
  .momo-up, .momo-down, .hand .card-face { animation: none; }
}
