/* Fireflies, a night meadow. One fixed dark palette (the same in light and dark OS modes). */
:root {
  --bg: #151b2e;
  --surface: #1f2740;
  --surface2: #2a3352;
  --line: rgba(232, 236, 247, .10);
  --ink: #e8ecf7;
  --muted: #9aa3bd;
  --accent: #f4c95d;          /* lantern light */
  --bad: #ef6f6c;
  --c0: #f2a93b; --c1: #3fbf7f; --c2: #4ba3e3; --c3: #e8638f; --c4: #a57be8;
  /* tutorial kit (tutorial.css): a warm lantern-paper bubble on the night palette */
  --tut-accent: #f4c95d;
  --tut-accent-ink: #1a1f2e;
  --tut-bubble: #fdf6e3;
  --tut-ink: #1a1f2e;
  --tut-muted: #5d6680;
  --tut-dim: rgba(4, 7, 16, .62);
  color-scheme: dark;
}
* { 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;
  background-image: radial-gradient(circle at 12% 8%, rgba(244, 201, 93, .07), transparent 30%), radial-gradient(circle at 88% 30%, rgba(75, 163, 227, .06), transparent 35%); }
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; }

.app { position: relative; max-width: 560px; 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: 48px; }
.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: 700 21px/1 Georgia, "Times New Roman", serif; letter-spacing: .04em; color: var(--accent); text-shadow: 0 0 14px rgba(244, 201, 93, .45); }
.menu { position: absolute; right: 12px; top: 44px; z-index: 45; min-width: 190px; padding: 6px; background: var(--surface2); border-radius: 14px; box-shadow: 0 14px 36px rgba(0, 0, 0, .45); 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: rgba(255, 255, 255, .07); }
@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: 8px; }
.btn:hover:not(:disabled) { background: #343e62; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #231a05; }
.btn.primary:hover:not(:disabled) { background: #f7d77f; }
.btn.danger { background: #3a2a3a; color: #ffd0cf; }
.btn.quiet { background: transparent; }
.btn.small { min-height: 40px; padding: 4px 14px; font-size: 14px; }

/* ---------- tokens ---------- */
.tokens { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 34px; padding: 0 2px; }
.tok { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--muted); }
.tok .ico { width: 15px; height: 17px; }
.tok .ico.on { color: var(--accent); fill: var(--accent); filter: drop-shadow(0 0 3px rgba(244, 201, 93, .6)); }
.tok .ico.off { color: #3b4566; fill: #3b4566; }
.tok .storm.on { fill: var(--bad); color: var(--bad); }
.tok .storm.off { fill: #3b4566; }
.tok b { color: var(--ink); font-size: 16px; margin-right: 3px; }
.tok.score b { font-size: 20px; color: var(--accent); }

/* ---------- jars ---------- */
.jars { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 2px 0 6px; }
.jar { position: relative; height: 72px; border-radius: 14px 14px 18px 18px; background: rgba(255, 255, 255, .04); border: 1.5px solid rgba(255, 255, 255, .14); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.jar::before { content: ''; position: absolute; left: 22%; right: 22%; top: -1px; height: 7px; border-radius: 0 0 5px 5px; background: rgba(255, 255, 255, .18); }
.jar .fill { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(to top, var(--jc), transparent); opacity: .55; transition: height .5s ease; }
.jar .n { position: relative; font: 800 26px/1 system-ui, sans-serif; color: #fff; text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.jar .gl { position: absolute; left: 6px; top: 8px; width: 14px; height: 14px; fill: var(--jc); }
.jar .dots { position: absolute; right: 6px; top: 10px; display: flex; flex-direction: column; gap: 3px; }
.jar .dots i { width: 5px; height: 5px; border-radius: 50%; background: rgba(255, 255, 255, .15); }
.jar .dots i.on { background: var(--jc); box-shadow: 0 0 5px var(--jc); }
.jar.pulse { animation: glow 1.4s ease-out; }
.jar.full { border-color: var(--jc); box-shadow: 0 0 14px -2px var(--jc); }
@keyframes glow { 0% { box-shadow: 0 0 0 0 var(--jc); } 30% { box-shadow: 0 0 22px 4px var(--jc); } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- status ---------- */
.status { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 2px 2px 4px; font-size: 15px; color: var(--muted); }
.status.mine { color: var(--ink); font-weight: 600; }
.status .msg { flex: 1; min-width: 0; }
.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: '...'; } }

/* ---------- hands ---------- */
.team { display: flex; flex-direction: column; gap: 10px; }
.seat { background: rgba(255, 255, 255, .03); border-radius: 16px; padding: 6px 8px 6px; transition: box-shadow .2s; }
.seat.cur { box-shadow: inset 0 0 0 1.5px rgba(244, 201, 93, .55); }
.seat .who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); height: 20px; margin-bottom: 4px; }
.seat .who b { color: var(--ink); font-weight: 650; }
.seat .who .act { margin-left: auto; font-size: 12px; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.hand { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.hand.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0 8%; }
.card { position: relative; border: 0; padding: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; }
.card .face { position: relative; width: 100%; height: 76px; border-radius: 10px; display: flex; align-items: center; justify-content: center; transition: transform .15s, box-shadow .2s; }
.card .face.shown { background: radial-gradient(circle at 50% 38%, #fff8 0, transparent 60%), var(--cc); color: #1a1f2e; box-shadow: 0 0 12px -3px var(--cc), inset 0 0 0 1px rgba(255, 255, 255, .25); }
.card .face .rk { font: 800 30px/1 system-ui, sans-serif; }
.card .face .gl { position: absolute; left: 5px; top: 5px; width: 14px; height: 14px; fill: #1a1f2e; opacity: .7; }
.card .face .gl2 { position: absolute; right: 5px; bottom: 5px; width: 14px; height: 14px; fill: #1a1f2e; opacity: .7; transform: rotate(180deg); }
.card .face.back { background: radial-gradient(circle at 30% 30%, rgba(244, 201, 93, .18) 0 2px, transparent 3px), radial-gradient(circle at 70% 62%, rgba(244, 201, 93, .14) 0 2px, transparent 3px), linear-gradient(160deg, #2a3352, #1b2238); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .12); color: var(--ink); }
.card .face.back.kc { box-shadow: inset 0 0 0 2px var(--cc), 0 0 10px -3px var(--cc); background: linear-gradient(160deg, color-mix(in srgb, var(--cc) 30%, #2a3352), #1b2238); }
.card .face.back .q { font: 700 22px/1 system-ui, sans-serif; color: rgba(232, 236, 247, .28); }
.card .face.back .rk { color: var(--ink); }
.card .face.back .gl { fill: var(--cc); opacity: 1; width: 16px; height: 16px; }
.card .rib { position: absolute; top: -3px; right: 8px; width: 9px; height: 15px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.card .know { width: 100%; height: 15px; display: flex; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 800; color: var(--muted); }
.card .know svg { width: 11px; height: 11px; }
.card.touched .face { box-shadow: 0 0 0 3px var(--accent), 0 0 18px 2px rgba(244, 201, 93, .55); }
.card.sel .face { transform: translateY(-4px); box-shadow: 0 0 0 3px var(--accent); }
.card.idle { cursor: default; }
.card.newc .face { animation: drawn .5s ease-out; }
@keyframes drawn { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }
.mine { margin-top: 12px; background: rgba(244, 201, 93, .05); border-radius: 16px; padding: 6px 8px 8px; }
.mine .who { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); height: 20px; margin-bottom: 4px; }
.mine .who b { color: var(--accent); }
.mine .card .face { height: 84px; }

/* ---------- drawer ---------- */
.drawer-wrap { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(5, 8, 18, .55); }
.drawer { position: relative; width: 100%; max-width: 560px; max-height: 90vh; 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(0, 0, 0, .45); }
@keyframes up { from { transform: translateY(30px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer h3 { font: 700 19px/1.2 Georgia, serif; margin-bottom: 8px; color: var(--accent); }
.drawer p { margin: 6px 0; }
.drawer .actions { display: flex; gap: 8px; margin-top: 14px; }
.drawer .actions .btn { flex: 1 1 0; white-space: nowrap; }
.drawer .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 12px 0 5px; }
.drawer .hand { margin: 6px 0 4px; }
.clue-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.clue-opt { min-height: 64px; border: 0; border-radius: 14px; background: var(--surface2); cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 8px 12px; text-align: left; }
.clue-opt:disabled { opacity: .4; cursor: not-allowed; }
.clue-opt .big { flex: none; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font: 800 22px/1 system-ui, sans-serif; }
.clue-opt .big svg { width: 24px; height: 24px; }
.clue-opt small { display: block; color: var(--muted); font-size: 12px; }
.clue-opt.on { box-shadow: inset 0 0 0 2px var(--accent); }
.poss { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.poss span { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 8px; background: var(--surface2); font-weight: 700; font-size: 13px; }
.poss span.no { opacity: .3; text-decoration: line-through; }
.poss svg { width: 13px; height: 13px; }
.discards { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.discards div { background: var(--surface2); border-radius: 10px; padding: 6px 4px; text-align: center; min-height: 44px; font-weight: 800; font-size: 13px; line-height: 1.5; }
.discards svg { width: 14px; height: 14px; display: block; margin: 0 auto 2px; }
.log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; font-size: 13px; }
.log li { padding: 5px 2px; border-bottom: 1px solid var(--line); color: var(--muted); }
.log li:first-child { 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(--bg); box-shadow: inset 0 0 0 2px var(--accent); color: var(--accent); }

/* ---------- modals ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 40; background: rgba(5, 8, 18, .6); display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0, 0, 0, .5); }
.over-modal { max-width: 440px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; }
.modal-head h2 { font: 700 21px/1.2 Georgia, serif; color: var(--accent); }
.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: var(--accent); 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; }
.cname { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; white-space: nowrap; }
.cname svg { width: 13px; height: 13px; }
.result-banner { font: 800 44px/1 system-ui, sans-serif; margin: 4px 0 8px; color: var(--accent); text-shadow: 0 0 18px rgba(244, 201, 93, .5); }
.result-banner small { font-size: 18px; color: var(--muted); text-shadow: none; }
.over-jars { margin: 12px 0 4px; }

@media (min-width: 700px) {
  .app { max-width: 640px; }
  .card .face { height: 88px; }
  .mine .card .face { height: 96px; }
  .drawer-wrap { align-items: center; }
  .drawer { border-radius: 20px; }
}
@media (max-width: 370px) {
  .card .face { height: 68px; }
  .mine .card .face { height: 76px; }
  .card .face .rk { font-size: 26px; }
  .jar { height: 62px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
svg.x { fill: currentColor; }

/* ---------- online (a table with friends: tables.js) ---------- */
/* a short notice (connection lost, the table was updated, a friend left) floats over the top of the board, so
   nothing moves */
.game { position: relative; }
.net-note { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); z-index: 6; width: max-content; max-width: min(88vw, 360px);
  padding: 5px 12px; border-radius: 12px; background: var(--tut-bubble); color: var(--tut-ink); font-size: 12.5px; font-weight: 700; line-height: 1.3;
  text-align: center; white-space: normal; box-shadow: 0 4px 14px rgba(0, 0, 0, .45); pointer-events: none; animation: pop .25s ease-out; }
/* a friend whose page stopped checking in */
.seat.away .who b { font-style: italic; opacity: .7; }
.seat .who .aw { font-size: 11px; font-style: italic; color: var(--muted); }
/* the table before the deal */
.hand.empty { display: flex; align-items: center; min-height: 44px; padding: 0 4px; }
/* one divider above the online rows */
.menu #menu-online, .menu #menu-leave { margin-top: 4px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; }
.over-modal .team-result { margin: 8px 0 0; }
/* after the game, the kit's Rematch / Leave bar would cover a sheet's buttons: it steps aside while one is open */
body.sheet-open .bp-tables-endbar { display: none !important; }
