/* Shithead — workshop table. Mobile-first, portrait. */
@font-face {
  font-family: "Archivo";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../assets/fonts/Archivo-Variable.woff2") format("woff2-variations"),
       url("../assets/fonts/Archivo-Variable.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --ink: #0c0c0d;
  --cloth-hi: #242528;
  --cloth: #161719;
  --cloth-lo: #101113;
  --steel: #9aa0a6;
  --steel-hi: #d8dbdf;
  --line: rgba(216, 219, 223, .14);
  --line-strong: rgba(216, 219, 223, .32);
  --rust: #d85a2a;
  --rust-hi: #f07840;
  --rust-lo: #8e3514;
  --text: #ececea;
  --muted: #8a8c90;
  --cream: #f4f3ef;
  --red-suit: #c62b24;
  --black-suit: #161718;
  --ok: #b6c2b4;
  --radius: 6px;

  --hand-w: clamp(54px, min(18.5vw, 11.6dvh), 96px);
  --table-w: clamp(42px, min(14vw, 8.6dvh), 74px);
  --opp-w: clamp(24px, min(8.2vw, 5.3dvh), 44px);
  --pile-w: clamp(56px, min(24vw, 12.5dvh), 118px);
  --ratio: 1.4;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font-ui: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 450;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
select { font: inherit; }

/* ---------- concrete / steel yard ---------- */
.cloth {
  position: fixed; inset: 0; z-index: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), transparent 28%),
    radial-gradient(90% 60% at 50% 0%, rgba(255,255,255,.04), transparent 55%),
    linear-gradient(180deg, var(--cloth-hi) 0%, var(--cloth) 42%, var(--cloth-lo) 100%);
}
.cloth::before { /* fine grit */
  content: ""; position: absolute; inset: 0; opacity: .22; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .55  0 0 0 0 .55  0 0 0 0 .55  0 0 0 .85 0'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}
.cloth::after { /* hairline plate edges */
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.04), inset 0 0 80px 20px rgba(0,0,0,.45);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(rgba(255,255,255,.03) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center;
  opacity: .35;
  pointer-events: none;
}

#app {
  position: relative; z-index: 1;
  height: 100vh; height: 100dvh;
  max-width: 640px; margin: 0 auto;
  padding: calc(var(--safe-t) + 4px) calc(var(--safe-r) + 10px) calc(var(--safe-b) + 8px) calc(var(--safe-l) + 10px);
  display: flex; flex-direction: column;
}

/* ---------- playing cards ---------- */
.card {
  --w: var(--hand-w);
  position: relative; flex: none;
  width: var(--w); height: calc(var(--w) * var(--ratio));
  border-radius: calc(var(--w) * .06);
  background: linear-gradient(180deg, #fafaf7 0%, var(--cream) 100%);
  color: var(--black-suit);
  box-shadow: 0 0 0 1px rgba(0,0,0,.28), 0 2px 6px rgba(0,0,0,.35);
  overflow: hidden;
  font-family: var(--font-display);
  padding: 0; border: 0;
  transition: transform .16s ease, box-shadow .16s ease, opacity .2s ease, filter .2s ease;
}
.card.red { color: var(--red-suit); }
.card svg { display: block; fill: currentColor; }
.card .ix {
  position: absolute; left: 6%; top: 4%;
  display: flex; flex-direction: column; align-items: center;
  line-height: .9; width: 30%;
}
.card .ix b { font-size: calc(var(--w) * .30); font-weight: 700; letter-spacing: -.04em; }
.card .ix svg { width: calc(var(--w) * .19); height: calc(var(--w) * .19); margin-top: 2px; }
.card .ix.br { display: none; }
.card .pip {
  position: absolute; left: 56%; top: 58%; transform: translate(-50%, -50%);
  width: calc(var(--w) * .52); height: calc(var(--w) * .52);
}
.card.ace .pip { width: calc(var(--w) * .58); height: calc(var(--w) * .58); filter: none; }
.card.ace .pip::after { content: none; }
.card .court {
  position: absolute; left: 34%; right: 9%; top: 14%; bottom: 9%;
  border-radius: 2px;
  border: 1px solid currentColor;
  background: repeating-linear-gradient(-45deg, rgba(0,0,0,.06) 0 2px, transparent 2px 5px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: none;
}
.card .court b { font-size: calc(var(--w) * .40); font-style: normal; font-weight: 800; line-height: 1; letter-spacing: -.04em; }
.card .court svg { width: calc(var(--w) * .18); height: calc(var(--w) * .18); }
.card .role {
  position: absolute; left: 50%; bottom: 5%; transform: translateX(-50%);
  font-family: var(--font-ui); font-weight: 700; text-transform: uppercase;
  font-size: max(8px, calc(var(--w) * .105)); letter-spacing: .08em;
  padding: 1px 5px; border-radius: 2px; white-space: nowrap;
  background: var(--rust); color: #fff7f2;
}
.card.ace .role, .card.court-card .role { bottom: 3%; }

/* mini card faces (opponents) */
.card.mini { --w: var(--opp-w); border-radius: 3px; }
.card.mini .ix, .card.mini .pip, .card.mini .court, .card.mini .role { display: none; }
.card.mini .mini-face {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: .9;
}
.card.mini .mini-face b { font-size: calc(var(--w) * .48); font-weight: 700; }
.card.mini .mini-face svg { width: calc(var(--w) * .36); height: calc(var(--w) * .36); margin-top: 2px; }
.card:not(.mini) .mini-face { display: none; }
.card.mini.special { box-shadow: 0 0 0 1.5px var(--rust), 0 2px 5px rgba(0,0,0,.4); }

/* card back */
.card.back {
  background:
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.04) 0 1px, transparent 1px 8px),
    linear-gradient(180deg, #2a2c30 0%, #1a1b1e 100%);
  box-shadow: inset 0 0 0 calc(var(--w) * .055) #1a1b1e, inset 0 0 0 calc(var(--w) * .07) var(--steel), 0 0 0 1px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.4);
}
.card.back::after {
  content: "S"; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: calc(var(--w) * .4); height: calc(var(--w) * .4); border-radius: 2px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-style: normal; font-weight: 800;
  font-size: calc(var(--w) * .24); letter-spacing: -.02em; color: var(--steel-hi);
  background: #141517;
  box-shadow: 0 0 0 1px var(--steel), 0 0 0 calc(var(--w) * .03) #141517;
}
.card.mini.back::after { font-size: calc(var(--w) * .28); width: calc(var(--w) * .48); height: calc(var(--w) * .48); }

/* interactive card states */
button.card { cursor: pointer; }
.card.playable { box-shadow: 0 0 0 2px var(--steel-hi), 0 4px 10px rgba(0,0,0,.45); }
.card.dim { filter: brightness(.62) saturate(.6); }
.card.selected { transform: translateY(-16%); box-shadow: 0 0 0 2px var(--rust-hi), 0 0 16px rgba(216,90,42,.45), 0 10px 18px rgba(0,0,0,.5); }
.card.swap-pick { transform: translateY(-12%) rotate(-2deg); box-shadow: 0 0 0 2px #7eb8c9, 0 0 16px rgba(126,184,201,.45), 0 10px 18px rgba(0,0,0,.5); }
.card.swappable { box-shadow: 0 0 0 2px rgba(126,184,201,.8), 0 4px 10px rgba(0,0,0,.45); }
.card.shake { animation: shake .32s ease; }
@keyframes shake { 20%,60% { transform: translateX(-5px); } 40%,80% { transform: translateX(5px); } }
.card.blind-ready { animation: blindpulse 1.2s ease-in-out infinite; cursor: pointer; }
@keyframes blindpulse { 50% { box-shadow: inset 0 0 0 calc(var(--w) * .055) #1a1b1e, inset 0 0 0 calc(var(--w) * .07) var(--steel), 0 0 0 2px var(--rust-hi), 0 0 18px rgba(216,90,42,.5); } }

/* ---------- header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; height: 44px; flex: none; }
.icon-btn {
  width: 44px; height: 44px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: rgba(0,0,0,.28);
  display: grid; place-items: center; cursor: pointer; color: var(--steel-hi);
}
.icon-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wordmark {
  font-family: var(--font-display); font-style: normal; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text);
  background: none;
  -webkit-background-clip: unset; background-clip: unset;
  filter: none;
}
.topbar .wordmark { font-size: 15px; }

/* ---------- opponents ---------- */
.opponents { display: flex; justify-content: space-around; gap: 6px; flex: none; padding-top: 2px; }
.seat {
  position: relative; flex: 1 1 0; max-width: 200px; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px 8px; border-radius: var(--radius);
  background: rgba(0,0,0,.22);
  border: 1px solid var(--line);
  transition: background .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.seat.active { background: rgba(216,90,42,.08); border-color: var(--rust); box-shadow: none; }
.seat.out { opacity: .55; }
.seat-name { display: flex; align-items: center; gap: 6px; font-weight: 650; font-size: 15px; max-width: 100%; }
.seat-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar {
  width: 22px; height: 22px; border-radius: 2px; display: grid; place-items: center; flex: none;
  font-family: var(--font-display); font-style: normal; font-weight: 800; font-size: 12px;
  letter-spacing: 0; background: #2a2c30; color: var(--steel-hi); border: 1px solid var(--line-strong);
}
.seat-row { display: flex; align-items: flex-end; gap: 8px; }
.opp-hand { position: relative; display: flex; align-items: center; }
.opp-hand .card { --w: var(--opp-w); }
.opp-hand .card + .card { margin-left: calc(var(--opp-w) * -.78); }
.count-badge {
  position: absolute; right: -8px; bottom: -6px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 2px; background: var(--ink); color: var(--steel-hi); border: 1px solid var(--steel);
  font-size: 12px; font-weight: 750; display: grid; place-items: center;
}
.opp-table { display: flex; gap: 3px; }
.stack { position: relative; width: var(--w); height: calc(var(--w) * var(--ratio) + var(--w) * .18); }
.stack > .card { position: absolute; left: 0; }
.stack > .card.down { top: 0; }
.stack > .card.up { top: calc(var(--w) * .18); }
.stack.empty-slot { border-radius: 4px; }
.opp-table .stack { --w: var(--opp-w); }
.seat-status { font-size: 12.5px; color: var(--muted); min-height: 16px; white-space: nowrap; }
.seat.active .seat-status { color: var(--rust-hi); }
.dots::after { content: "…"; display: inline-block; animation: dots 1s steps(4) infinite; width: 1.1em; overflow: hidden; vertical-align: bottom; }
@keyframes dots { from { width: 0; } to { width: 1.1em; } }
.place-pill { font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); background: var(--ok); padding: 1px 7px; border-radius: 2px; }

/* ---------- centre ---------- */
.centre { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; gap: 4px; position: relative; }
.felt-row { display: flex; align-items: center; justify-content: center; gap: clamp(14px, 6vw, 34px); width: 100%; }
.deck-spot { display: flex; flex-direction: column; align-items: center; gap: 6px; width: calc(var(--table-w) + 10px); }
.deck-spot .card { --w: var(--table-w); }
.deck-spot .lbl { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.2; letter-spacing: .08em; text-transform: uppercase; font-weight: 650; }
.deck-pile { position: relative; width: var(--table-w); height: calc(var(--table-w) * var(--ratio)); }
.deck-pile .card { position: absolute; left: 0; top: 0; }
.deck-pile .card:nth-child(2) { transform: translate(-2px, -2px); }
.deck-pile .card:nth-child(3) { transform: translate(-4px, -4px); }
.slot-empty { width: var(--table-w); height: calc(var(--table-w) * var(--ratio)); border-radius: 4px; border: 1px dashed var(--line-strong); }
.burnt .card { filter: grayscale(.6) brightness(.55); }

#pile { position: relative; width: calc(var(--pile-w) * 1.25); height: calc(var(--pile-w) * var(--ratio) * 1.04); display: grid; place-items: center; }
#pile .card { --w: var(--pile-w); position: absolute; left: 50%; top: 50%; }
#pile .pile-empty {
  width: var(--pile-w); height: calc(var(--pile-w) * var(--ratio)); border-radius: 4px;
  border: 1px dashed var(--line-strong); display: grid; place-items: center; text-align: center;
  color: var(--muted); font-size: 11px; padding: 6px; letter-spacing: .08em; text-transform: uppercase; font-weight: 650;
}
.pile-count { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.mirror-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--steel-hi); background: rgba(0,0,0,.4); border: 1px solid var(--line-strong);
  padding: 2px 8px; border-radius: 2px;
}
.pile-info { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 30px; }
.need {
  font-weight: 700; font-size: 13px; color: var(--steel-hi); text-align: center;
  letter-spacing: .06em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 2px; background: rgba(0,0,0,.4); border: 1px solid var(--line);
}
.need.restrict { color: #ffd0a8; background: rgba(142,53,20,.55); border-color: rgba(216,90,42,.55); }
.centre-top { width: 100%; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; min-height: 18px; }
.direction { font-size: 12px; flex: none; color: var(--muted); display: flex; align-items: center; gap: 4px; letter-spacing: .04em; text-transform: uppercase; font-weight: 650; }
.direction svg { width: 18px; height: 18px; stroke: var(--steel); fill: none; stroke-width: 2; transition: transform .4s ease; }
.direction.anti svg { transform: scaleX(-1); }
.lastmove { max-width: 60%; text-align: right; font-size: 12.5px; color: var(--muted); line-height: 1.25; }

/* ---------- me ---------- */
.me { flex: none; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.status {
  width: 100%; text-align: center; font-size: 15px; font-weight: 650; line-height: 1.25;
  padding: 8px 12px; border-radius: var(--radius); background: rgba(0,0,0,.35);
  border: 1px solid var(--line); min-height: 38px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.status.yours { background: rgba(216,90,42,.12); border-color: var(--rust); color: var(--text); box-shadow: none; }
.status.warn { background: rgba(142,53,20,.55); border-color: rgba(255,190,160,.45); box-shadow: none; }
.status small { font-weight: 500; color: var(--muted); }
.my-table { display: flex; gap: 10px; justify-content: center; }
.my-table .stack { --w: var(--table-w); }
.my-table .lbl { display: none; }
.hand {
  width: 100%; display: flex; justify-content: center; align-items: flex-end;
  padding: 18px 4px 4px; min-height: calc(var(--hand-w) * var(--ratio) + 22px);
  overflow-x: auto; overflow-y: visible; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.hand::-webkit-scrollbar { display: none; }
.hand.scrolls { justify-content: flex-start; }
.hand .card { --w: var(--hand-w); }
.hand-empty { color: var(--muted); font-style: normal; letter-spacing: .04em; text-transform: uppercase; font-size: 12px; font-weight: 650; align-self: center; }
.actions { display: flex; gap: 10px; width: 100%; flex: none; padding-top: 4px; }
.btn {
  flex: 1; min-height: 52px; border-radius: var(--radius); border: 0; cursor: pointer;
  font-weight: 750; font-size: 16px; letter-spacing: .06em; text-transform: uppercase; padding: 0 14px;
  transition: transform .1s ease, opacity .2s ease, filter .2s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: 1; cursor: default; filter: none; }
.btn-primary:disabled,
.btn-danger:disabled {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
  border: 1px solid var(--line);
}
.btn-primary { background: var(--rust); color: #fff7f2; box-shadow: 0 1px 0 var(--rust-hi) inset, 0 2px 0 var(--rust-lo), 0 4px 12px rgba(0,0,0,.35); }
.btn-secondary { background: transparent; color: var(--text); box-shadow: none; border: 1px solid var(--line-strong); }
.btn-danger { background: var(--rust-lo); color: #fff0e0; box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 2px 0 #5c200c, 0 4px 12px rgba(0,0,0,.35); }
.btn.pulse { animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 1px 0 rgba(255,255,255,.12) inset, 0 2px 0 #5c200c, 0 0 0 4px rgba(216,90,42,.22), 0 4px 12px rgba(0,0,0,.35); } }
.btn .sub { display: block; font-size: 11px; font-weight: 600; letter-spacing: .04em; opacity: .8; text-transform: none; }

/* ---------- toasts & fx ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
#fx .card { position: fixed; left: 0; top: 0; margin: 0; will-change: transform, opacity; }
#toasts { position: fixed; left: 0; right: 0; top: 38%; z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  max-width: 86vw; padding: 10px 16px; border-radius: 2px; font-weight: 750; font-size: 15px; text-align: center;
  letter-spacing: .04em; text-transform: uppercase;
  background: rgba(12,12,13,.94); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong), 0 10px 30px rgba(0,0,0,.5);
  animation: toastIn .22s ease-out, toastOut .3s ease-in forwards; animation-delay: 0s, var(--life, 1.6s);
}
.toast.big { font-family: var(--font-display); font-style: normal; font-weight: 800; font-size: 28px; letter-spacing: .08em; padding: 8px 22px; background: var(--rust); color: #fff7f2; box-shadow: 0 0 0 1px var(--rust-hi), 0 0 32px rgba(216,90,42,.45); }
.toast.info { color: var(--text); box-shadow: 0 0 0 1px var(--line-strong), 0 10px 30px rgba(0,0,0,.5); font-weight: 600; font-size: 15px; letter-spacing: 0; text-transform: none; border-radius: var(--radius); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }
.flash { position: fixed; border-radius: 50%; pointer-events: none; background: radial-gradient(circle, rgba(240,120,64,.9) 0%, rgba(216,90,42,.5) 35%, rgba(216,90,42,0) 70%); mix-blend-mode: screen; }

/* ---------- sheets / overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.68); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s ease; }
.overlay.center { align-items: center; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #18191c; border-radius: 8px 8px 0 0;
  border: 1px solid var(--line-strong); border-bottom: 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
  padding: 18px 18px calc(18px + var(--safe-b));
  animation: sheetUp .26s cubic-bezier(.2,.9,.3,1);
  user-select: text; -webkit-user-select: text;
}
.overlay.center .sheet { border-radius: 8px; margin: 16px; width: calc(100% - 32px); border-bottom: 1px solid var(--line-strong); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 4px; font-family: var(--font-display); font-style: normal; font-weight: 800; font-size: 22px; letter-spacing: .08em; text-transform: uppercase; color: var(--text); }
.sheet h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--steel); font-weight: 700; }
.sheet p, .sheet li { color: var(--text); line-height: 1.5; font-size: 16px; }
.sheet .muted { color: var(--muted); font-size: 14.5px; }
.sheet ul { padding-left: 20px; margin: 6px 0; }
.sheet .btns { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.seg { display: flex; background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 46px; border: 0; border-radius: 3px; background: transparent; font-weight: 700; font-size: 14px; letter-spacing: .04em; text-transform: uppercase; cursor: pointer; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--rust); color: #fff7f2; }
.role-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.role-row .txt { flex: 1; min-width: 0; }
.role-row .txt b { display: block; font-size: 16px; }
.role-row .txt span { display: block; font-size: 14px; color: var(--muted); line-height: 1.35; }
.role-row select {
  min-width: 92px; min-height: 46px; border-radius: var(--radius); padding: 0 12px; font-weight: 700; font-size: 16px;
  background: #101113; color: var(--text); border: 1px solid var(--line-strong);
}
.switch { position: relative; width: 58px; height: 34px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 2px; background: rgba(255,255,255,.12); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 28px; height: 28px; border-radius: 1px; background: #ececea; transition: transform .2s; }
.switch input:checked + span { background: var(--rust); }
.switch input:checked + span::after { transform: translateX(24px); }
.preset-tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: 3px 7px; border-radius: 2px; background: var(--steel-hi); color: var(--ink); vertical-align: middle; margin-left: 6px; font-style: normal; font-family: var(--font-ui); }
.preset-tag.custom { background: var(--rust); color: #fff7f2; }
.note { font-size: 14px; color: var(--muted); margin-top: 10px; }

/* ---------- title screen ---------- */
.title-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; padding: 10px 6px; }
.title-cards { position: relative; height: calc(var(--hand-w) * 1.55); width: 100%; display: flex; justify-content: center; margin-bottom: 4px; }
.title-cards .card { --w: clamp(64px, 20vw, 100px); position: absolute; top: 0; transform-origin: 50% 120%; animation: fanIn .7s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes fanIn { from { transform: rotate(0deg) translateY(30px); opacity: 0; } }
.title-screen .wordmark { font-size: clamp(42px, 13vw, 72px); line-height: .95; margin: 0; padding: 0; letter-spacing: .1em; }
.tagline { margin: -6px 0 0; color: var(--muted); font-size: 14px; font-family: var(--font-ui); font-style: normal; font-weight: 450; letter-spacing: .02em; }
.aka { color: var(--steel); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; margin-top: -8px; font-weight: 650; }
.title-menu { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.title-menu .lbl { font-size: 11px; color: var(--muted); text-align: left; margin-bottom: -4px; padding-left: 2px; letter-spacing: .1em; text-transform: uppercase; font-weight: 650; }
.stats { color: var(--muted); font-size: 14px; }
.foot { color: var(--muted); font-size: 12px; letter-spacing: .04em; }

/* ---------- game over ---------- */
.result h2 { font-size: 32px; line-height: 1.05; letter-spacing: .08em; text-transform: uppercase; }
.result .verdict { font-size: 17px; margin: 8px 0 4px; }
.finish-list { list-style: none; padding: 0 !important; margin: 14px 0 0; display: flex; flex-direction: column; gap: 6px; }
.finish-list li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); background: rgba(0,0,0,.3); border: 1px solid var(--line); font-weight: 650; }
.finish-list li .pos { width: 40px; color: var(--steel); font-weight: 800; letter-spacing: .06em; }
.finish-list li.loser { background: rgba(142,53,20,.45); border-color: rgba(216,90,42,.4); }
.finish-list li.loser .pos { color: var(--rust-hi); }
.crown { margin-left: auto; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--steel-hi); }

/* compact seats for 3 opponents */
.opponents.compact .seat-row { gap: 0; }
.opponents.compact .avatar { display: none; }
.opponents.compact .seat-name { gap: 5px; font-size: 14.5px; }
.opponents.compact .opp-table { gap: 4px; }
.opponents.compact { --opp-w: clamp(24px, min(9.2vw, 5.4dvh), 44px); }
.opp-chip { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 750; color: var(--steel-hi); background: var(--ink); border: 1px solid var(--steel); border-radius: 2px; padding: 0 7px 0 4px; height: 22px; }
.opp-chip .card { --w: 12px; border-radius: 2px; box-shadow: inset 0 0 0 1px var(--cream); }
.opp-chip .card::after { display: none; }

/* ---------- responsive ---------- */
@media (max-height: 640px) {
  :root { --hand-w: clamp(50px, min(18vw, 10.6dvh), 96px); --table-w: clamp(40px, min(14vw, 7.6dvh), 74px); --pile-w: clamp(52px, min(24vw, 11dvh), 118px); --opp-w: clamp(24px, min(8.2vw, 5dvh), 44px); }
  .seat-status { display: none; }
  .seat.out .seat-name::after { content: "Out"; font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink); background: var(--ok); padding: 1px 6px; border-radius: 2px; }
  .pile-count { display: none; }
  .pile-info { min-height: 0; }
  .need { font-size: 12px; padding: 2px 8px; }
  .me { gap: 4px; }
  .centre-top { min-height: 16px; }
  .topbar { height: 38px; }
  .icon-btn { width: 40px; height: 40px; }
  .topbar .wordmark { font-size: 14px; }
  .seat { padding: 4px 4px 6px; gap: 2px; }
  .status { min-height: 34px; padding: 6px 10px; font-size: 14px; }
  .hand { padding-top: 14px; }
  .btn { min-height: 48px; }
}
@media (min-width: 700px) {
  :root { --hand-w: clamp(54px, min(13vw, 11.6dvh), 100px); --pile-w: clamp(62px, 13dvh, 118px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* =====================================================================
   Online play, table rules, presets, trial
   ===================================================================== */
.btn-ghost { background: transparent; color: var(--muted); border: 0; box-shadow: none; min-height: 40px; font-size: 14px; }
.btn.small { flex: none; min-height: 38px; font-size: 13px; padding: 0 12px; letter-spacing: .05em; }
.linkish { background: none; border: 0; padding: 0; color: var(--rust-hi); font-weight: 650; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.trial { color: var(--muted); font-size: 13px; letter-spacing: .02em; }
.muted.small, .small { font-size: 13px; }
.center { text-align: center; }
.lbl { display: block; font-size: 11px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }

/* lastmove becomes a tappable play-log button */
button.lastmove { background: none; border: 0; padding: 0; cursor: pointer; font: inherit; font-size: 12.5px; }

/* Table rules chip in the top bar */
.rules-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-width: 0; max-width: 58%; height: 44px; padding: 0 14px; cursor: pointer;
  border-radius: var(--radius); border: 1px solid var(--line-strong); background: rgba(0,0,0,.28);
}
.rules-chip .lbl { font-size: 9.5px; letter-spacing: .16em; }
.rules-chip .nm { font-weight: 800; font-size: 13.5px; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.rules-chip.custom { border-color: var(--rust); background: rgba(216,90,42,.10); }
.rules-chip.custom .nm { color: var(--rust-hi); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 2px; }
.rchip { display: inline-flex; align-items: baseline; gap: 6px; padding: 5px 9px; border-radius: 3px; background: rgba(0,0,0,.35); border: 1px solid var(--line-strong); font-size: 12.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--steel-hi); }
.rchip b { font-size: 15px; color: var(--text); letter-spacing: 0; }
.rchip.changed { border-color: var(--rust); background: rgba(216,90,42,.14); }
.rchip.changed b { color: var(--rust-hi); }

/* presets */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.preset { border: 1px solid var(--line-strong); background: rgba(0,0,0,.3); border-radius: 3px; padding: 8px 12px; font-weight: 700; font-size: 13.5px; cursor: pointer; color: var(--text); }
.preset.on { background: var(--rust); border-color: var(--rust); color: #fff7f2; }
.save-row { display: flex; gap: 8px; margin-top: 10px; }
.save-row input, .field input, .join-row input {
  flex: 1; min-width: 0; min-height: 44px; border-radius: var(--radius); border: 1px solid var(--line-strong);
  background: rgba(0,0,0,.4); color: var(--text); padding: 0 12px; font: inherit; font-size: 16px; user-select: text; -webkit-user-select: text;
}
.save-row input:focus, .field input:focus, .join-row input:focus { outline: 2px solid var(--rust); outline-offset: 1px; }
.share-code { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--radius); font-size: 14px; color: var(--muted); }
.share-code b { color: var(--text); letter-spacing: .14em; font-size: 16px; margin-left: 6px; }

/* timers */
.tbar { width: 100%; height: 3px; background: rgba(255,255,255,.08); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.tbar i { display: block; height: 100%; width: 100%; background: var(--rust); transform-origin: left center; animation-name: tdrain; animation-timing-function: linear; animation-fill-mode: forwards; }
.tbar.mine { height: 4px; margin-top: -2px; }
@keyframes tdrain { from { transform: scaleX(1); } 80% { background: var(--rust); } to { transform: scaleX(0); background: var(--rust-hi); } }

.badge { display: inline-block; font-size: 9.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; padding: 1px 5px; border-radius: 2px; background: var(--steel-hi); color: var(--ink); vertical-align: middle; flex: none; }
.badge.bot { background: rgba(255,255,255,.14); color: var(--steel-hi); }
.badge.off { background: var(--rust-lo); color: #fff0e0; }
.badge.you { background: var(--rust); color: #fff7f2; }

.net-banner { margin: 4px 0; padding: 8px 12px; border-radius: var(--radius); background: rgba(142,53,20,.5); border: 1px solid rgba(255,190,160,.35); font-size: 13.5px; font-weight: 600; text-align: center; flex: none; }
.net-banner.reconnecting, .net-banner.connecting { background: rgba(0,0,0,.45); border-color: var(--line-strong); }

.emoji-strip { display: flex; justify-content: space-between; gap: 4px; padding: 6px; margin: 4px 0; border-radius: var(--radius); background: rgba(0,0,0,.5); border: 1px solid var(--line-strong); flex: none; }
.emoji-strip button { flex: 1; min-height: 40px; border: 0; background: transparent; font-size: 22px; cursor: pointer; border-radius: 4px; }
.emoji-strip button:active { background: rgba(255,255,255,.08); }
.emoji-pop { position: fixed; z-index: 90; font-size: 40px; transform: translate(-50%, -50%); pointer-events: none; animation: emojiUp 1.9s ease-out forwards; text-shadow: 0 4px 16px rgba(0,0,0,.6); }
@keyframes emojiUp { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); } 15% { opacity: 1; transform: translate(-50%, -60%) scale(1.15); } 70% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -160%) scale(1); } }

/* online hub / join / lobby panels */
.panel { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 10px 2px 16px; -webkit-overflow-scrolling: touch; }
.panel h3 { margin: 10px 0 0; font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--steel); font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 11px; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-weight: 700; }
.join-row { display: flex; gap: 8px; }
.join-row input { text-transform: uppercase; letter-spacing: .4em; font-weight: 800; text-align: center; font-size: 20px; }
.join-row .btn { flex: none; width: 110px; }
.fine { color: var(--muted); font-size: 12.5px; text-align: center; margin: 4px 0 0; }

.friends { list-style: none; padding: 0; margin: 6px 0 0; display: flex; flex-direction: column; gap: 6px; }
.friends li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: rgba(0,0,0,.3); border: 1px solid var(--line); }
.friends li.off { opacity: .6; }
.friends li.empty { border-style: dashed; background: transparent; color: var(--muted); }
.friends .fname { flex: 1; min-width: 0; font-weight: 700; display: flex; flex-direction: column; gap: 2px; }
.friends .fname small { font-weight: 500; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.friends .x { background: none; border: 0; color: var(--muted); font-size: 22px; cursor: pointer; width: 32px; }
.friends .ok { color: var(--ok); font-weight: 700; }
.friends .lock { color: var(--rust-hi); font-weight: 650; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.2); display: inline-block; }
.dot.on { background: #63c46f; box-shadow: 0 0 0 3px rgba(99,196,111,.18); }

.big-code { display: flex; gap: 6px; margin-top: 4px; }
.big-code span { width: 44px; height: 54px; display: grid; place-items: center; font-family: var(--font-display); font-weight: 900; font-size: 30px; border-radius: 4px; background: var(--cream); color: var(--ink); box-shadow: 0 2px 0 rgba(0,0,0,.5); }
.big-code.small span { width: 34px; height: 42px; font-size: 22px; }
.sheet .big-code { justify-content: center; margin: 14px 0 4px; }
.room-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.room-head .btn { flex: none; width: 120px; }

.rules-card, .table-card { padding: 12px; border-radius: var(--radius); background: rgba(0,0,0,.32); border: 1px solid var(--line-strong); display: flex; flex-direction: column; gap: 6px; }
.rules-card { border-color: var(--rust); background: linear-gradient(180deg, rgba(216,90,42,.10), rgba(0,0,0,.3)); }
.rc-head { display: flex; align-items: center; gap: 10px; }
.rc-head b { flex: 1; font-size: 18px; font-weight: 850; letter-spacing: .06em; text-transform: uppercase; }
.rc-head .lbl { flex: none; }
.rc-foot { font-size: 13px; color: var(--muted); }
.table-card .seg button { min-height: 42px; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.table-card .seg button small { font-size: 10px; opacity: .75; letter-spacing: .04em; }
.table-card .lbl { margin-top: 4px; }
.table-card .role-row { border-bottom: 0; padding-bottom: 0; }
.lobby-actions { display: flex; gap: 10px; flex: none; padding-top: 8px; border-top: 1px solid var(--line); }
.lobby-actions .wait { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-weight: 650; font-size: 14px; }
.quick-note { padding: 14px; text-align: center; font-weight: 700; border-radius: var(--radius); background: rgba(216,90,42,.12); border: 1px solid var(--rust); }

.invite-card { padding: 14px; border-radius: var(--radius); background: rgba(0,0,0,.35); border: 1px solid var(--line-strong); display: flex; flex-direction: column; gap: 10px; }
.invite-card .who { display: flex; flex-direction: column; gap: 3px; }
.invite-card .who b { font-size: 20px; font-weight: 850; letter-spacing: .04em; }
.invite-card .who span, .invite-card .tr { color: var(--muted); font-size: 14px; }
.invite-card .tr b { color: var(--text); }
.invite-card .tr .lbl { display: inline; }
.invite-card .names { display: flex; gap: 6px; }

.paywall-inline { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: var(--radius); border: 1px solid var(--rust); background: rgba(216,90,42,.12); }
.paywall-inline span { color: var(--muted); font-size: 14px; line-height: 1.4; }
.ticks { list-style: none; padding: 0 !important; }
.ticks li { padding-left: 26px; position: relative; margin: 6px 0; }
.ticks li::before { content: ""; position: absolute; left: 4px; top: 8px; width: 10px; height: 5px; border-left: 2.5px solid var(--rust-hi); border-bottom: 2.5px solid var(--rust-hi); transform: rotate(-45deg); }
.log { padding-left: 0 !important; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.log li { font-size: 14.5px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.log li:first-child { color: var(--rust-hi); font-weight: 650; }

/* six-player tables: tighter opponents, wrapping onto two rows */
.opponents.many { flex-wrap: wrap; row-gap: 4px; --opp-w: clamp(20px, min(7vw, 4.4dvh), 36px); }
.opponents.many .seat { padding: 4px 6px; min-width: 30%; }
.opponents.many .seat-name { font-size: 13px; }
.friends .nmrow { display: flex; align-items: center; gap: 6px; min-width: 0; }
.panel > .btn, .panel > .field, .panel > .join-row { flex: none; }
.paywall .ticks li { text-align: left; }

/* web unlock: the restore code, shown big and selectable */
.unlock-code { font-weight: 800; font-size: 21px; letter-spacing: .08em; text-align: center; white-space: nowrap; padding: 14px 8px; margin: 4px 0 12px; border: 1px dashed var(--muted); border-radius: var(--radius); user-select: all; -webkit-user-select: all; }
