:root {
  --felt: #1d5c3f; --felt-dark: #17492f; --ink: #f2efe6; --muted: #b9c9bd;
  --panel: #12281d; --accent: #f0c24b; --red: #c62828; --black: #1b1b1b;
  --hint: #7fd4ff;
  --card-w: 52px; --card-h: 74px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.4 system-ui, sans-serif; color: var(--ink);
  background: var(--panel); height: 100vh; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 18px; padding: 8px 16px;
  background: #0c1b13; flex-wrap: wrap; position: relative; }
/* The speed round's clock, in the middle of the header. */
#timer { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); color: var(--accent);
  font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .04em; pointer-events: none; }
#timer.low { animation: hintpulse 1s steps(2, jump-none) infinite; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 0 0 12px; }
h1 { font-size: 18px; margin: 0; letter-spacing: .04em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 8px; }
#levels { font-size: 13px; color: var(--muted); }
.levels-form { display: flex; gap: 20px; margin: 8px 0 12px; flex-wrap: wrap; }
.levels-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input[type="text"] { font: inherit; color: var(--ink); background: #2a4a39; border: 1px solid #456b56;
  border-radius: 6px; padding: 5px 8px; width: 14em; }
select { font: inherit; color: var(--ink); background: #2a4a39; border: 1px solid #456b56;
  border-radius: 6px; padding: 5px 8px; }
/* Settings: a small window that floats under its button, the table still in
   view behind it so a change shows at once. */
#settings { position: fixed; inset: 46px 16px auto auto; margin: 0; z-index: 40; width: 330px;
  max-width: calc(100vw - 32px); padding: 14px 16px; box-shadow: 0 10px 28px rgba(0,0,0,.55); }
.dlghead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.dlghead h2 { margin: 0; }
#settings-close { padding: 0 8px; font-size: 18px; line-height: 1.3; background: none; border-color: transparent; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0;
  border-top: 1px solid #1f3a2c; font-size: 14px; }
.setting small { display: block; font-size: 12px; color: var(--muted); }
.seg { display: flex; flex: none; }
.seg button { border-radius: 0; padding: 5px 10px; font-size: 13px; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; border-left: 0; }
input[role="switch"] { appearance: none; flex: none; width: 38px; height: 22px; margin: 0; border-radius: 11px;
  background: #2a4a39; border: 1px solid #456b56; position: relative; cursor: pointer; transition: background .12s; }
input[role="switch"]::before { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--muted); transition: transform .12s; }
input[role="switch"]:checked { background: var(--accent); border-color: var(--accent); }
input[role="switch"]:checked::before { transform: translateX(16px); background: #222; }
input[role="switch"]:focus-visible { outline: 2px solid var(--hint); outline-offset: 2px; }
.scores span { margin-right: 14px; color: var(--muted); }
.scores b { color: var(--ink); font-size: 17px; }
.spacer { flex: 1; }
button { font: inherit; color: var(--ink); background: #2a4a39; border: 1px solid #456b56;
  border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover:not(:disabled) { background: #36604a; }
button:disabled { opacity: .4; cursor: default; }
button[aria-pressed="true"] { background: var(--accent); color: #222; border-color: var(--accent); }

/* The page fills the window. Top to bottom: the other players, the board
   (deck and floor in a column on the left, both teams' sets as columns of
   cards in the middle), then your hand. */
main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 250px; min-height: 0; }
#table { display: flex; flex-direction: column; background: var(--felt); min-width: 0; min-height: 0; }
.board { flex: 1; display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 0; }
.side { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 16px 8px;
  min-width: 150px; min-height: 0; background: #174a31; border-right: 1px solid #0f3523; }
.sets { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* The two halves share the height in proportion to their longest set (app.js). */
.half { flex: 1 1 0; padding: 6px 12px; display: flex; flex-direction: column; min-height: 0; position: relative; }
.half.them { background: var(--felt-dark); }
/* The other three players across the top: left opponent, partner (opposite
   you), right opponent. */
.seats { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 12px;
  padding: 8px 16px; background: #123b27; border-bottom: 1px solid #0f3523; }
.seats .player { flex-direction: column; gap: 4px; justify-self: center; }
.seats .player:first-child { justify-self: start; align-items: flex-start; }
.seats .player:last-child { justify-self: end; align-items: flex-end; }
.player { display: flex; align-items: center; gap: 8px; }
.who { font-size: 13px; color: var(--muted); padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.player.active .who { background: var(--accent); color: #222; font-weight: 600; }
.player.dealer .who::after { content: "D"; display: inline-block; margin-left: 6px; width: 18px; height: 18px;
  line-height: 18px; border-radius: 50%; background: #000; color: var(--accent); font-size: 11px;
  font-weight: 700; text-align: center; vertical-align: 1px; }
.fan { display: inline-flex; position: relative; }
.fan .card { width: 22px; height: 32px; margin-left: -15px; border-radius: 3px; }
.fan .card:first-child { margin-left: 0; }
.badge { background: #0c1b13; color: var(--accent); border-radius: 10px; padding: 0 7px;
  font-size: 12px; font-weight: 700; }
.fan .badge { margin-left: 6px; align-self: center; }
/* Shared information: the cards a player was seen to pick up and still holds
   lie face up, ahead of the face-down ones. */
.fan .card.known { margin-left: 2px; }
.fan .card.known:first-child { margin-left: 0; }
.fan.tight .card.known + .card.known { margin-left: -8px; }
.fan .card.known + .card.back { margin-left: 4px; }
.fan .card.known .r { top: 2px; left: 2px; font-size: 11px; }
.fan .card.known .r small { font-size: 11px; margin-top: 1px; }
.fan .card.known .s, .fan .card.known .as { display: none; }
.fan .card.known.joker .r { font-size: 0; }
.fan .card.known.joker .r::before { content: "★"; font-size: 12px; }
/* A count on the top right corner of a button (hints left this hand). */
#btn-hint { position: relative; }
.badge.corner { position: absolute; top: -9px; right: -9px; border: 1px solid #456b56; line-height: 17px; }
.badge.corner:empty { display: none; }
/* Each field's name and points sit in its top left corner, over the felt,
   so the cards get the whole height. */
.sidehead { position: absolute; top: 8px; left: 14px; z-index: 1; pointer-events: none;
  font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.sidepoints { text-transform: none; letter-spacing: 0; font-size: 13px; white-space: nowrap; }
.odds { text-transform: none; letter-spacing: 0; font-size: 13px; }
.sidepoints b { color: var(--accent); font-size: 17px; }

/* A set is a column of cards, highest on top, each showing a strip --step
   tall. The columns sit in a centred row that widens both ways. The cards
   are drawn --k times the basic size: app.js makes them as large as fits,
   and smaller as the sets grow longer or more numerous. */
.melds { flex: 1; min-height: 0; display: flex; justify-content: safe center; align-items: flex-start;
  gap: 6px; overflow: auto; --step: 24px; --k: 1; }
.meld { display: flex; flex-direction: column; flex: none; padding: 4px; border-radius: 8px;
  border: 1px dashed transparent; --step: inherit; }
.meld .card { width: calc(var(--card-w) * var(--k)); height: calc(var(--card-h) * var(--k));
  margin-top: calc(var(--step) - var(--card-h) * var(--k)); }
.meld .card .r { font-size: calc(15px * var(--k)); left: calc(5px * var(--k)); }
.meld .card .r small { font-size: calc(13px * var(--k)); }
.meld .card .s { font-size: calc(24px * var(--k)); }
.floorcol .card { margin-top: calc(var(--step) - var(--card-h) * 1.2); }
.meld .card:first-child, .floorcol .card:first-child { margin-top: 0; }
/* In a column only the top strip of a card shows: rank and suit side by side,
   and what a wild card stands for at the right of the strip. */
.meld .card .r, .floorcol .card .r { top: 2px; }
.meld .card .r small, .floorcol .card .r small { display: inline; margin: 0 0 0 2px; }
.meld .card .as { left: auto; bottom: auto; right: 3px; top: calc(5px * var(--k)); font-size: calc(9px * var(--k)); }
.meld .card.joker .r { font-size: 0; }
.meld .card.joker .r::before { content: "★"; font-size: calc(15px * var(--k)); }
/* Runs set to horizontal (Settings): a set is a row of cards, highest on the
   left, each showing a strip --step wide, and the sets wrap onto more rows.
   The room at the left is for the field's name and points. */
body.runs-h .melds { flex-wrap: wrap; align-content: flex-start; padding-left: 130px; }
body.runs-h .half { min-height: 74px; }
body.runs-h .melds .meld { flex-direction: row; }
body.runs-h .melds .meld .card { margin-top: 0; margin-left: calc(var(--step) - var(--card-w) * var(--k)); }
body.runs-h .melds .meld .card:first-child { margin-left: 0; }
body.runs-h .melds .meld .card .r { top: calc(3px * var(--k)); left: calc(4px * var(--k)); }
body.runs-h .melds .meld .card .r small { display: block; margin: calc(2px * var(--k)) 0 0; }
body.runs-h .melds .meld .card .as { right: auto; left: calc(3px * var(--k)); top: calc(35px * var(--k));
  font-size: calc(8px * var(--k)); white-space: nowrap; }
.us .meld.target { border-color: var(--accent); cursor: pointer; }
.us .meld.target:hover { background: rgba(240, 194, 75, .18); }
.empty { color: var(--muted); font-size: 13px; font-style: italic; }

.pile { position: relative; text-align: center; }
.pile .badge { position: absolute; top: -8px; right: -12px; }
.pile.can { cursor: pointer; }
.pile.can .card { outline: 2px solid var(--accent); }
/* The start of your turn: nothing can be played until you have drawn, so the
   deck and the top of the floor glow and a note sits above the deck. */
#drawcue { display: none; background: var(--accent); color: #222; font-weight: 700; font-size: 13px;
  border-radius: 10px; padding: 3px 10px; text-align: center; }
#table.mustdraw #drawcue { display: block; }
#table.mustdraw .pile.can .card, #table.mustdraw #floor .card.top {
  outline: 3px solid var(--accent); animation: drawglow 1.1s ease-in-out infinite; }
@keyframes drawglow { 50% { box-shadow: 0 0 16px 5px rgba(240, 194, 75, .85); } }
@media (prefers-reduced-motion: reduce) { #table.mustdraw .card { animation: none; } }
.pile.out .card { opacity: .25; }
#stock-tip { display: none; position: absolute; left: calc(100% + 18px); top: 0; z-index: 20;
  background: #0c1b13; border: 1px solid #456b56; border-radius: 8px; padding: 8px 12px;
  text-align: left; font-size: 13px; white-space: nowrap; box-shadow: 0 6px 16px rgba(0,0,0,.45); }
.pile:hover #stock-tip:not(:empty) { display: block; }
#stock-tip .tiphead { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
#stock-tip .tiprow { display: grid; grid-template-columns: repeat(4, auto); gap: 2px 14px; }
#stock-tip .tiprow.wild { grid-template-columns: repeat(2, auto); margin-top: 4px; justify-content: start; }
#stock-tip b { font-size: 15px; }
#stock-tip .suit { font-size: 16px; }
#stock-tip .suit.red { color: #ff8a80; }
.caption { font-size: 12px; color: var(--muted); }
.hint { color: var(--accent); }
.side .caption { text-align: center; }
.side .hint { display: block; max-width: 120px; }
/* The floor runs down the side, oldest on top and most recent at the bottom,
   starting a new column when it reaches the bottom (app.js). */
#floor { flex: 1; min-height: 0; align-self: stretch; display: flex; justify-content: center;
  align-items: flex-start; gap: 6px; --step: 28px; }
.floorcol { display: flex; flex-direction: column; }
#floor.can .card { cursor: pointer; }
#floor .card.lift { transform: translateX(8px); outline: 2px solid var(--accent); }
/* The hint line, to the right of the buttons. */
#status { font-size: 13px; line-height: 1.3; color: var(--hint); }

.card { width: var(--card-w); height: var(--card-h); border-radius: 6px; background: #fbfaf5;
  color: var(--black); border: 1px solid #777; box-shadow: 0 1px 2px rgba(0,0,0,.4);
  position: relative; flex: none; user-select: none; transition: transform .08s; }
.card .r { position: absolute; top: 3px; left: 5px; font-weight: 700; font-size: 15px; line-height: 1; }
.card .r small { display: block; font-size: 13px; margin-top: 2px; }
.card .s { position: absolute; bottom: 4px; right: 5px; font-size: 24px; line-height: 1; }
.card.red { color: var(--red); }
.card.joker { background: #fff3c4; color: #6a1b9a; }
.card.joker .r { font-size: 11px; }
.card.two { background: #e6f2ff; }
.card .as { position: absolute; left: 3px; bottom: 3px; font-size: 10px; color: #555; font-weight: 600; }
.card.back { background: repeating-linear-gradient(45deg, #2d4f8f, #2d4f8f 4px, #3a62ad 4px, #3a62ad 8px);
  border-color: #dfe6f5; }
/* Your own cards are larger than the ones on the table, and centred. They
   stay in one row: when there are too many to fit side by side, app.js sets
   --hand-gap negative so they overlap. */
#hand { display: flex; flex-wrap: wrap; justify-content: center; row-gap: 6px; --hand-gap: 5px;
  min-height: calc(var(--card-h) * 1.2 + 14px); padding-top: 14px; }
#hand .card + .card { margin-left: var(--hand-gap); }
#hand .card { cursor: grab; }
/* Your hand, the deck and the floor use a larger card than the sets do. */
#hand .card, .side .card { width: calc(var(--card-w) * 1.2); height: calc(var(--card-h) * 1.2); border-radius: 7px; }
#hand .card .r, .side .card .r { font-size: 18px; top: 4px; left: 6px; }
#hand .card .r small, .side .card .r small { font-size: 15px; }
#hand .card .s, .side .card .s { font-size: 29px; }
#hand .card.joker .r, .side .card.joker .r { font-size: 13px; }
#hand .card.sel { transform: translateY(-12px); outline: 3px solid var(--accent); }
#hand .card.dragging { opacity: .35; }
#hand .card.dropbefore { box-shadow: -4px 0 0 var(--accent); }
/* What the Hint button points at. */
.hinted { outline: 3px solid var(--hint) !important; outline-offset: 1px; animation: hintpulse 1s ease-in-out infinite; }
#floor .card.hinted { transform: translateX(8px); }
.meld.hinted { border-radius: 8px; }
@keyframes hintpulse { 50% { outline-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .hinted { animation: none; } }
#status .hinttext { color: var(--hint); display: block; }
.mine { background: #123b27; border-top: 1px solid #0f3523; padding: 8px 16px 10px; }
/* Your name on the left, the buttons in the middle, the hint on the right. */
.minehead { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px 18px; min-height: 38px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
dialog .actions { margin-top: 8px; }

aside { padding: 12px; overflow-y: auto; max-height: calc(100vh - 50px); }
#log { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#log li { padding: 3px 0; border-bottom: 1px solid #1f3a2c; color: var(--muted); }
#log li b { color: var(--ink); }
#log li.new { color: var(--ink); }

.card.flying { position: fixed; left: 0; top: 0; z-index: 50; margin: 0; pointer-events: none;
  transition: none; will-change: transform; box-shadow: 0 8px 18px rgba(0,0,0,.45); }
body:not(.notes) .note { display: none; }
body.notes #status .note { color: var(--accent); display: block; }
body.notes.busy #status::after { content: "click the table to skip"; color: var(--muted); font-size: 12px; }

.confetti { position: fixed; left: 0; top: 0; width: 9px; height: 14px; border-radius: 2px; z-index: 60;
  pointer-events: none; will-change: transform; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #7a1f1f;
  color: #fff; padding: 8px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
dialog { background: var(--panel); color: var(--ink); border: 1px solid #456b56; border-radius: 10px;
  padding: 18px 22px; max-width: 640px; }
dialog::backdrop { background: rgba(0,0,0,.55); }
#choices { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; --step: 26px; --k: 1.1; }
#choices button { text-align: left; padding: 6px; }
#choices .meld { pointer-events: none; }
#choices .card.placing { outline: 3px solid var(--accent); outline-offset: -3px; }
#choices .back-note { font-size: 13px; color: var(--accent); padding: 0 4px 2px; }
.us .meld.dropover { border-color: var(--accent); background: rgba(240, 194, 75, .28); }
table { border-collapse: collapse; margin: 10px 0; }
td, th { padding: 4px 14px; text-align: right; }
th:first-child, td:first-child { text-align: left; color: var(--muted); }
tr.total td { border-top: 1px solid #456b56; font-weight: 700; }
.left { font-size: 13px; color: var(--muted); margin: 2px 0; }

@media (max-width: 900px), (max-height: 620px) {   /* too small to fit: let the page scroll */
  body { height: auto; min-height: 100vh; }
  .board { min-height: 460px; }
}
@media (max-width: 1150px) {   /* no room in the middle of the header: the clock joins the row */
  #timer { position: static; transform: none; }
}
@media (max-width: 900px) {
  body.runs-h .melds { padding-left: 0; padding-top: 44px; }
  main { grid-template-columns: 1fr; }
  .minehead { grid-template-columns: 1fr; justify-items: center; }
  aside { max-height: 180px; }
  :root { --card-w: 44px; --card-h: 64px; }
}
#history { width: min(640px, calc(100vw - 32px)); }
#history .history-list { max-height: 50vh; overflow: auto; }
#history td:last-child { color: var(--muted); }
#history-close { padding: 0 8px; font-size: 18px; line-height: 1.3; background: none; border-color: transparent; }
.auth-form { display: flex; flex-direction: column; gap: 10px; min-width: min(320px, calc(100vw - 80px)); }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-form input { font-size: 16px; padding: 6px 8px; }
#account, #lobby { width: min(560px, calc(100vw - 32px)); }
#acct-invite-box { margin: 14px 0 6px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
#acct-link input { width: min(460px, calc(100vw - 80px)); font-size: 13px; }
#acct-close, #lobby-close { padding: 0 8px; font-size: 18px; line-height: 1.3; background: none; border-color: transparent; }
#lobby h3 { margin: 12px 0 4px; font-size: 14px; color: var(--muted); }
.lobby-list { list-style: none; padding: 0; margin: 0; }
.lobby-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,.08); }
.lobby-acts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
#btn-lobby { position: relative; }
#account a { color: var(--accent); }
