/* Westminster Classic — landscape v0.2 game table.
   One fixed 1280px-wide stage, scaled to fit the landscape viewport by app.js.
   All art is original CSS/SVG; no external fonts, images or network requests,
   so the standalone file runs from file:// with nothing installed. */

:root {
  --felt-1: #0f5d63;
  --felt-2: #0a4250;
  --felt-3: #072a38;
  --night: #050d17;
  --gold: #f2c46b;
  --gold-2: #c98d2e;
  --gold-ink: #3a2306;
  --ink: #f3f6fb;
  --ink-dim: #a9bccb;
  --pos: #7ff0b4;
  --neg: #ff8a98;
  --card-face: #fbfaf5;
  --card-ink: #151b29;
  --card-red: #c61f3c;
  --back-1: #7a1630;
  --back-2: #4c0c1e;
  font-family: "Noto Sans Thai", "Leelawadee UI", "Sarabun", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background:
    radial-gradient(120% 90% at 50% 40%, #0d3a4a 0%, #071a28 55%, var(--night) 100%);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.viewport { position: relative; width: 100%; height: 100%; overflow: hidden; }

.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 1280px;
  height: 600px;
  transform-origin: 0 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.3;
  /* on-screen 44px minimum tap size, expressed in unscaled stage pixels */
  --tap: max(46px, calc(44px / var(--scale, 1)));
}

.stage > * { position: absolute; }

button { font: inherit; color: inherit; }
button:focus-visible { outline: 3px solid #9fe7ff; outline-offset: 2px; }

/* ---------------------------------------------------------------- felt */

.felt { inset: 0; z-index: 0; overflow: hidden; }
.felt::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 55% at 50% 0%, rgba(80, 180, 190, 0.18), transparent 70%),
    radial-gradient(60% 50% at 50% 110%, rgba(242, 196, 107, 0.10), transparent 70%);
}
.table-top {
  position: absolute;
  left: 70px;
  right: 70px;
  top: 34px;
  bottom: 18px;
  border-radius: 200px / 150px;
  background:
    radial-gradient(90% 80% at 50% 45%, var(--felt-1) 0%, var(--felt-2) 58%, var(--felt-3) 100%);
  box-shadow:
    inset 0 0 0 3px rgba(242, 196, 107, 0.55),
    inset 0 0 0 12px #0b2430,
    inset 0 0 0 14px rgba(242, 196, 107, 0.25),
    inset 0 30px 80px rgba(0, 0, 0, 0.35),
    0 30px 60px rgba(0, 0, 0, 0.55);
  transform: perspective(1500px) rotateX(16deg);
  transform-origin: 50% 100%;
}
.table-top::after {
  /* woven felt texture */
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: inherit;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.05) 0 2px, transparent 2px 7px);
}
.watermark {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 230px;
  height: 230px;
  transform: translate(-50%, -50%);
  color: rgba(190, 240, 240, 0.10);
}

/* ---------------------------------------------------------------- hud */

.hud {
  top: 10px;
  left: 14px;
  right: 14px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 8;
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud-btn {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 2px solid rgba(242, 196, 107, 0.6);
  background: radial-gradient(circle at 35% 30%, #1d6f78, #0b3442);
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}
.practice-tag {
  display: flex;
  flex-direction: column;
  padding: 4px 14px;
  border-radius: 14px;
  background: rgba(3, 16, 26, 0.62);
  border: 1px solid rgba(242, 196, 107, 0.35);
  font-size: 14px;
  color: var(--ink-dim);
}
.practice-tag b { color: var(--gold); font-size: 16px; }
.chip-pill {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(3, 16, 26, 0.62);
  border: 1px solid rgba(242, 196, 107, 0.35);
  font-weight: 700;
  font-size: 16px;
}
.chip-dot {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe7a6, var(--gold) 45%, var(--gold-2));
  box-shadow: inset 0 0 0 2px rgba(120, 70, 10, 0.5), inset 0 0 0 4px #ffe7a6;
  vertical-align: -3px;
}

/* --------------------------------------------------------------- cards */

.card {
  position: absolute;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.11);
  border: 0;
  padding: 0;
  display: block;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.18);
}
.card.face {
  background: linear-gradient(160deg, #ffffff 0%, var(--card-face) 60%, #ece8dc 100%);
  color: var(--card-ink);
}
.card.face.red { color: var(--card-red); }
.card .corner {
  position: absolute;
  left: 7%;
  top: 4%;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.92;
  font-family: "Noto Sans Thai", "Segoe UI", Roboto, Arial, sans-serif;
}
.card .corner b { font-size: var(--cf); font-weight: 800; letter-spacing: -0.04em; }
.card .corner i { font-style: normal; font-size: calc(var(--cf) * 0.86); }
.card .pip {
  position: absolute;
  right: 8%;
  bottom: 5%;
  font-size: calc(var(--ch) * 0.4);
  line-height: 1;
  opacity: 0.92;
}
.card.back {
  background:
    radial-gradient(circle at 50% 50%, rgba(242, 196, 107, 0.55) 0 9%, transparent 10%),
    repeating-linear-gradient(45deg, rgba(242, 196, 107, 0.22) 0 2px, transparent 2px 9px),
    repeating-linear-gradient(-45deg, rgba(242, 196, 107, 0.22) 0 2px, transparent 2px 9px),
    linear-gradient(160deg, var(--back-1), var(--back-2));
  box-shadow:
    inset 0 0 0 3px #fbf3e2,
    inset 0 0 0 5px rgba(242, 196, 107, 0.7),
    0 2px 4px rgba(0, 0, 0, 0.4);
}

/* fans: three overlapping rows of 3 / 5 / 5 */
.fan { position: relative; width: calc(var(--sx) * 4 + var(--cw)); height: calc(var(--sy) * 2 + var(--ch)); }
.fan-sm { --cw: 56px; --ch: 78px; --cf: 20px; --sx: 25px; --sy: 32px; }
.fan-md { --cw: 70px; --ch: 98px; --cf: 25px; --sx: 32px; --sy: 40px; }
.fan-row { position: absolute; left: 0; height: var(--ch); width: 100%; }
.fan-row.row-front { top: 0; left: var(--sx); }
.fan-row.row-middle { top: var(--sy); }
.fan-row.row-back { top: calc(var(--sy) * 2); }
.fan-row .card:nth-child(1) { left: 0; transform: rotate(-6deg); }
.fan-row .card:nth-child(2) { left: var(--sx); transform: rotate(-3deg); }
.fan-row .card:nth-child(3) { left: calc(var(--sx) * 2); transform: rotate(0deg); }
.fan-row .card:nth-child(4) { left: calc(var(--sx) * 3); transform: rotate(3deg); }
.fan-row .card:nth-child(5) { left: calc(var(--sx) * 4); transform: rotate(6deg); }
.fan-row.row-front .card:nth-child(1) { transform: rotate(-4deg); }
.fan-row.row-front .card:nth-child(3) { transform: rotate(4deg); }
.fan.empty { width: 156px; height: 142px; }

.stage.fresh .fan.dealing .card {
  animation: deal 420ms cubic-bezier(.2, .8, .2, 1) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes deal {
  from { opacity: 0; translate: 0 -60px; scale: 0.4; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}
.stage.fresh .card.flip { animation: flip 460ms cubic-bezier(.3, .7, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 25ms); }
@keyframes flip {
  from { opacity: 0.2; scale: 0.2 1; filter: brightness(0.6); }
  to { opacity: 1; scale: 1 1; filter: none; }
}

/* --------------------------------------------------------------- seats */

.seat { z-index: 2; width: 330px; height: 300px; pointer-events: none; }
.seat .fan-holder { position: absolute; top: 0; }
.seat .avatar { position: absolute; top: 116px; }
.seat .identity { position: absolute; top: 196px; width: 170px; text-align: center; }
.seat .delta-plate { position: absolute; top: 36px; }
.seat .seat-tags { position: absolute; top: 246px; }

.seat-west { left: 70px; top: 64px; }
.seat-west .fan-holder { left: 0; }
.seat-west .avatar { left: 122px; }
.seat-west .identity { left: 75px; }
.seat-west .delta-plate { left: 178px; }
.seat-west .seat-tags { left: 30px; }

.seat-east { right: 70px; top: 64px; }
.seat-east .fan-holder { right: 0; }
.seat-east .avatar { right: 122px; }
.seat-east .identity { right: 75px; }
.seat-east .delta-plate { right: 178px; }
.seat-east .seat-tags { right: 30px; }

.seat-north { left: 562px; top: 58px; width: 420px; }
.seat-north .fan-holder { left: 0; }
.seat-north .avatar { left: -96px; top: 6px; }
/* Right edge = circle's right edge, so a long name / large balance grows LEFT, never onto the north fan. */
.seat-north .identity { left: -180px; top: 84px; width: 162px; align-items: flex-end; text-align: right; }
.seat-north .delta-plate { left: 172px; top: 30px; }
.seat-north .seat-tags { left: 172px; top: 96px; }

.avatar {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  padding: 6px;
  background: radial-gradient(circle at 35% 30%, #fff1c6, var(--gold) 40%, var(--gold-2));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(255, 255, 255, 0.5);
}
.avatar-emblem {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  padding: 10%;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.25);
}
.avatar-south .avatar-emblem { background: radial-gradient(circle at 40% 30%, #2b8b95, #0b3a4d); color: #e9fbff; }
.avatar-west .avatar-emblem { background: radial-gradient(circle at 40% 30%, #8a3f7a, #3c1238); color: #ffe3f3; }
.avatar-north .avatar-emblem { background: radial-gradient(circle at 40% 30%, #3e6fb0, #142a55); color: #e3eeff; }
.avatar-east .avatar-emblem { background: radial-gradient(circle at 40% 30%, #3f8f5e, #133a24); color: #e6ffe9; }
/* Public face crop clipped inside the unchanged gold circle (same box as the emblem). */
.avatar { position: relative; }
.avatar-face { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); border-radius: 50%; object-fit: cover; opacity: 0; }
.avatar.has-face .avatar-face { opacity: 1; }
.avatar.has-face .avatar-emblem { visibility: hidden; }
/* Canonical seat tones (server seat index, identical for every viewer): the same matte shows through transparent face
   pixels and behind the fallback emblem. The gold rim (.avatar background/padding) and face pixels are untouched. */
.avatar.seat-tone-0 { --seat-matte: radial-gradient(circle at 40% 30%, #2a8a86, #0f5f5a); }
.avatar.seat-tone-1 { --seat-matte: radial-gradient(circle at 40% 30%, #3f5fae, #1c2e6e); }
.avatar.seat-tone-2 { --seat-matte: radial-gradient(circle at 40% 30%, #84468a, #4e2256); }
.avatar.seat-tone-3 { --seat-matte: radial-gradient(circle at 40% 30%, #a23c4e, #66192b); }
.avatar[class*='seat-tone-'] .avatar-emblem,
.avatar[class*='seat-tone-'] .avatar-face { background: var(--seat-matte); }

.identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}
.seat-name { font-weight: 700; font-size: 17px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seat-chips {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  font-size: 16px;
  color: #ffe9b8;
  padding: 1px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}

.ready-tag {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) rotate(-4deg);
  font-size: 34px;
  font-weight: 800;
  color: #ffd76e;
  -webkit-text-stroke: 1.4px #5a2b00;
  text-shadow: 0 3px 0 #7a3c00, 0 6px 14px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  z-index: 3;
}
.stage.fresh .pop { animation: pop 420ms cubic-bezier(.2, 1.4, .4, 1) backwards; }
@keyframes pop { from { opacity: 0; scale: 0.4; } to { opacity: 1; scale: 1; } }

.delta-plate {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 74px;
  padding: 6px 12px;
  border-radius: 14px;
  background: rgba(4, 20, 30, 0.72);
  border: 1.5px solid rgba(242, 196, 107, 0.55);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  z-index: 4;
}
.delta-label { font-size: 15px; color: var(--ink-dim); }
.delta-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.delta-plate.pos .delta-num { color: var(--pos); }
.delta-plate.neg .delta-num { color: var(--neg); }

.seat-tags { display: flex; gap: 6px; flex-wrap: wrap; max-width: 260px; }
.tag {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.55);
}
.tag.foul { color: #ffd0d6; border: 1px solid var(--neg); }
.tag.natural { color: #fff1c6; border: 1px solid var(--gold); }

/* -------------------------------------------------------------- banner */

.banner {
  left: 50%;
  top: calc(var(--stage-h, 600px) * 0.37);
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  white-space: nowrap;
}
.banner.info span {
  display: block;
  padding: 10px 26px;
  border-radius: 999px;
  background: rgba(3, 18, 28, 0.72);
  border: 1px solid rgba(242, 196, 107, 0.45);
  font-size: 21px;
  font-weight: 700;
  color: #fff3d6;
}
.banner.big span {
  display: block;
  padding: 12px 70px;
  font-size: 40px;
  font-weight: 800;
  color: #ffe08a;
  -webkit-text-stroke: 1.2px #4b2400;
  text-shadow: 0 3px 0 #6b3300, 0 8px 18px rgba(0, 0, 0, 0.55);
  background: linear-gradient(90deg, transparent, rgba(214, 120, 30, 0.85) 18%, rgba(30, 130, 120, 0.85) 82%, transparent);
}
.stage.fresh .banner.enter { animation: banner-in 480ms cubic-bezier(.2, .9, .2, 1) backwards; }
@keyframes banner-in { from { opacity: 0; translate: 0 18px; scale: 0.92; } to { opacity: 1; translate: 0 0; scale: 1; } }

/* --------------------------------------------------------------- clock */

.clock {
  left: 860px;
  bottom: 300px;
  width: 92px;
  height: 92px;
  z-index: 5;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 40% 30%, #fff6dc, #f7d27a 45%, #c98d2e);
  box-shadow: 0 0 0 5px #fff4d6, 0 0 0 8px rgba(201, 141, 46, 0.8), 0 10px 24px rgba(0, 0, 0, 0.5);
  color: #6b1d10;
}
.clock-num { font-size: 36px; font-weight: 800; line-height: 1; }
.clock-cap { font-size: 13px; font-weight: 700; color: #6b3a10; }
.clock.urgent { animation: urgent 1s steps(2) infinite; }
.clock.urgent .clock-num { color: #c3101f; }
@keyframes urgent { 50% { box-shadow: 0 0 0 5px #ffd6d6, 0 0 0 8px #e0233a, 0 10px 24px rgba(0, 0, 0, 0.5); } }

/* --------------------------------------------------------------- local */

.local { inset: 0; z-index: 3; pointer-events: none; }
.local > * { position: absolute; pointer-events: auto; }

.local-id { left: 50%; bottom: 6px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.local-id .avatar { width: 84px; height: 84px; position: relative; }
.local-id .identity { margin-top: 2px; max-width: 240px; }
/* Shared table only (own circle carries public avatar data, kept even when the face fails): margin-bottom keeps the
   circle anchored where it was with the former 24px inline thumbnail (+1px gap). Solo never had that thumbnail. */
.local-id:has(.avatar[data-avatar]) .identity { margin-bottom: 25px; }
.local-id .seat-tags { justify-content: center; margin-top: 2px; }

.local-fan { left: 50%; bottom: 140px; transform: translateX(-50%); }
.local-fan .ready-tag { font-size: 40px; }
.local.phase-dealing .local-fan { bottom: 140px; }

.join {
  left: 760px;
  bottom: 70px;
  min-width: 220px;
  min-height: max(58px, var(--tap));
  font-size: 22px !important;
}

/* ------------------------------------------------------- arranging editor
   Expanded editor: it dims the whole table and dominates the stage with
   large, non-overlapping 3 / 5 / 5 rows, a row evaluator and validity cue per
   row, the live clock and a prominent Ready. Closing it shows the compact fan. */
.arrange-editor {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(3, 10, 18, 0.88);
  pointer-events: auto;
}
.workspace { position: absolute; inset: 0; }
.editor-board {
  position: absolute;
  left: 16px;
  right: 290px;
  top: 64px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.lanes { display: flex; flex-direction: column; gap: 8px; }
.lane {
  --cw: 84px; --ch: 116px; --cf: 28px;
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  border-radius: 16px;
  background: rgba(6, 30, 42, 0.94);
  border: 2px solid rgba(242, 196, 107, 0.22);
}
.lane.valid { border-color: rgba(127, 240, 180, 0.55); }
.lane.invalid { border-color: var(--neg); background: rgba(80, 8, 20, 0.45); }
.lane.drop-ok { border-color: var(--pos); box-shadow: 0 0 0 4px rgba(127, 240, 180, 0.4), inset 0 0 22px rgba(127, 240, 180, 0.18); }
.lane.drop-full { border-color: var(--neg); box-shadow: 0 0 0 4px rgba(255, 107, 129, 0.4); background: rgba(80, 8, 20, 0.35); }
.hand-row.drop-ok { outline: 2px solid var(--pos); outline-offset: 2px; box-shadow: 0 0 0 6px rgba(127, 240, 180, 0.25), inset 0 0 22px rgba(127, 240, 180, 0.15); }
.lane.drop-rejected { animation: drop-reject 380ms ease; }
@keyframes drop-reject { 0%, 100% { translate: 0 0; } 25% { translate: -6px 0; } 75% { translate: 6px 0; } }
.lane-target {
  position: relative;
  width: 112px;
  height: var(--ch);
  border-radius: 12px;
  border: 1.5px solid rgba(242, 196, 107, 0.45);
  background: linear-gradient(180deg, rgba(13, 70, 80, 0.9), rgba(5, 34, 46, 0.9));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
}
.lane-target:disabled { cursor: default; opacity: 1; }
.lane-target.armed { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(242, 196, 107, 0.35), inset 0 0 18px rgba(242, 196, 107, 0.25); }
.lane-name { font-size: 22px; font-weight: 800; color: var(--gold); }
.lane-cat { font-size: 16px; font-weight: 800; color: #e9fff6; text-align: center; line-height: 1.15; }
.lane-count { font-size: 13px; color: var(--ink-dim); }
.lane-mark {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 900;
}
.lane-mark.ok { background: #1f9d5c; color: #fff; box-shadow: 0 0 0 2px #c9ffe2; }
.lane-mark.bad { background: #c3263f; color: #fff; box-shadow: 0 0 0 2px #ffd3da; }
.lane-cards { display: flex; gap: 8px; width: calc(5 * var(--cw) + 4 * 8px); }
.cell {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  border-radius: 9px;
  padding: 0;
}
.cell.empty {
  border: 2px dashed rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
  cursor: default;
}
.cell.empty.armed { border-color: var(--gold); background: rgba(242, 196, 107, 0.12); cursor: pointer; }
.cell .card { position: absolute; inset: 0; }
.cell.drop-ok { box-shadow: 0 0 0 4px var(--pos), 0 0 18px 4px rgba(127, 240, 180, 0.55); border-radius: 9px; }
.cell.drop-swap { box-shadow: 0 0 0 4px var(--gold), 0 0 18px 6px rgba(242, 196, 107, 0.7); border-radius: 9px; }
.cell.drop-swap .card { translate: 0 6px; filter: brightness(0.8); }
.lane-clear {
  width: var(--tap);
  height: var(--tap);
  border-radius: 50%;
  border: 1.5px solid rgba(242, 196, 107, 0.45);
  background: rgba(3, 18, 28, 0.7);
  font-size: 20px;
  cursor: pointer;
}
.lane-clear:disabled { opacity: 0.3; cursor: default; }

.hand-row {
  --cw: 72px; --ch: 100px; --cf: 25px;
  position: relative;
  flex: none;
  width: calc(12 * 70px + var(--cw) + 12px);
  height: calc(var(--ch) + 10px);
  border-radius: 14px;
  background: rgba(2, 14, 22, 0.55);
  border: 1.5px dashed rgba(242, 196, 107, 0.25);
}
.hand-row .card { position: absolute; left: calc(6px + var(--i) * 70px); top: 5px; }
.hand-row .hand-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink-dim); font-size: 17px; }
.stage.fresh .hand-row .card { animation: deal 360ms cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i) * 30ms); }

.editor-side {
  position: absolute;
  right: 18px;
  top: 172px;
  bottom: 12px;
  width: 256px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 8px;
}
.editor-side .btn { font-size: 15px; }
.side-pair { display: flex; gap: 8px; }
.side-pair .btn { flex: 1; }
.editor-side .confirm { min-height: max(64px, var(--tap)); font-size: 24px; letter-spacing: 0.04em; }
.stage[data-editor-state="open"] .clock { z-index: 7; left: auto; right: 100px; top: 70px; bottom: auto; }
.card.open-slot { background: rgba(255, 255, 255, 0.05); border: 2px dashed rgba(242, 196, 107, 0.45); box-shadow: none; }
.local-fan .unplaced-count {
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -6px);
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(3, 16, 26, 0.85);
  border: 1px solid rgba(242, 196, 107, 0.5);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}
/* Compact own hand: fan above the bottom-centre avatar (as the table seats), edit control alongside to the right. */
.local-fan .editor-open { position: absolute; left: calc(100% + 18px); bottom: 8px; white-space: nowrap; }

button.card { cursor: pointer; transition: translate 120ms ease, box-shadow 120ms ease; }
/* Drag sources only: a finger moving on a card must not become a browser pan
   (which fires pointercancel). Everything else, the menu included, keeps the
   inherited behaviour so it can still scroll. */
.workspace button.card { touch-action: none; cursor: grab; }
#app.is-dragging, #app.is-dragging * { cursor: grabbing !important; }
.status .drag-hint { color: var(--ink-dim); font-size: 14px; }
button.card.selected {
  translate: 0 -12px;
  box-shadow: 0 0 0 3px var(--gold), 0 0 16px 4px rgba(242, 196, 107, 0.6), 0 6px 12px rgba(0, 0, 0, 0.4);
  z-index: 2;
}
.lane-cards button.card.selected { translate: 0 -6px; }
button.card.dragging { opacity: 0.35; }
.drag-ghost {
  position: fixed !important;
  left: 0;
  top: 0;
  z-index: 1000;
  pointer-events: none;
  transform-origin: 0 0;
  opacity: 0.95;
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.55), 0 0 0 3px var(--gold) !important;
}
/* Lifted: larger and tilted, composed with the inline translate/scale. */
.drag-ghost.lifted { scale: 1.14; rotate: -4deg; box-shadow: 0 22px 36px rgba(0, 0, 0, 0.6), 0 0 0 3px var(--gold) !important; }
@media (prefers-reduced-motion: reduce) { .drag-ghost.lifted { rotate: 0deg; } }

.status {
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(3, 16, 26, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 15px;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 96px;
  overflow: hidden;
}
.status strong { font-size: 16px; }
.status.ok { border-color: rgba(127, 240, 180, 0.6); }
.status.ok strong { color: var(--pos); }
.status.warn strong { color: var(--gold); }
.status.bad { border-color: var(--neg); }
.status.bad strong { color: var(--neg); }
.status .notice { color: #ffe3b0; }

.btn {
  min-height: var(--tap);
  padding: 6px 12px;
  border-radius: 14px;
  border: 1.5px solid rgba(242, 196, 107, 0.5);
  background: linear-gradient(180deg, #145a66, #0a3341);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn.ghost { background: rgba(3, 16, 26, 0.72); }
.btn.active { background: linear-gradient(180deg, #7a4bd0, #3a1f78); border-color: #d9c6ff; }
.btn.primary {
  border: 0;
  color: #fff;
  background: linear-gradient(180deg, #ffb24a, #f07a1a 55%, #c9530c);
  box-shadow: 0 4px 0 #8a3405, 0 8px 18px rgba(0, 0, 0, 0.45);
  text-shadow: 0 1px 1px rgba(90, 30, 0, 0.6);
  font-size: 17px;
}
.btn.primary:disabled { background: linear-gradient(180deg, #6f6a62, #4d4943); box-shadow: 0 4px 0 #2a2824; }
.confirm { min-height: max(54px, var(--tap)); }

/* ------------------------------------------------------------ breakdown */

.breakdown {
  right: 24px;
  bottom: 14px;
  width: 262px;
  border-radius: 16px;
  overflow: hidden;
  background: rgba(4, 34, 40, 0.92);
  border: 1.5px solid rgba(242, 196, 107, 0.55);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.5);
  z-index: 5;
}
.bd-row, .bd-chips {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 16px;
  font-size: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.bd-row b, .bd-chips b { font-size: 20px; font-weight: 800; }
.bd-row.head { background: linear-gradient(90deg, #d0631c, #b44a12); border-top: 0; }
.bd-row.total { background: rgba(0, 0, 0, 0.25); }
.bd-row.total b { font-size: 24px; }
.bd-row.pos b, .bd-chips.pos b { color: var(--pos); }
.bd-row.neg b, .bd-chips.neg b { color: var(--neg); }
.bd-row.head.pos b, .bd-row.head.neg b { color: #fff; }
.bd-row.pending b { color: var(--ink-dim); }
.next { right: 302px; bottom: 18px; min-width: 210px; min-height: max(58px, var(--tap)); font-size: 20px !important; }

/* ----------------------------------------------------------------- menu */

.menu-scrim { inset: 0; z-index: 20; background: rgba(2, 8, 14, 0.66); display: flex; align-items: center; justify-content: center; }
.menu-panel {
  position: relative !important;
  width: 760px;
  max-height: calc(var(--stage-h, 600px) - 60px);
  overflow: auto;
  padding: 16px 22px 20px;
  border-radius: 20px;
  background: #0a2532;
  border: 1.5px solid rgba(242, 196, 107, 0.5);
  font-size: 14px;
  user-select: text;
}
.menu-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.menu-head strong { color: var(--gold); font-size: 18px; }
.practice-banner { color: #ffe3b0; margin: 10px 0 4px; }
.manual-note { color: var(--ink-dim); margin: 4px 0; }
.menu-rules h3 { color: var(--gold); font-size: 15px; margin: 12px 0 2px; }
.menu-rules ul { margin: 0; padding-left: 20px; }

/* --------------------------------------------------------- orientation */

.rotate-prompt { display: none; }

@media (orientation: portrait) {
  .viewport { display: none; }
  .rotate-prompt {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    text-align: center;
  }
  .rotate-prompt strong { font-size: 20px; color: var(--gold); }
  .rotate-prompt span { color: var(--ink-dim); }
  .rotate-prompt i {
    width: 70px;
    height: 110px;
    border-radius: 14px;
    border: 4px solid var(--gold);
    animation: rotate-hint 2.4s ease-in-out infinite;
  }
}
@keyframes rotate-hint { 0%, 30% { rotate: 0deg; } 60%, 100% { rotate: -90deg; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* ---- reference layout correction (prefilled-arrange-20261123): tightly packed
   portrait 3/5/5 dominating the centre, labels left, no row boxes, no empty
   tray, compact controls, Ready centred directly below the group. ---- */
.arrange-editor { background: rgba(3, 10, 18, 0.62); }
.editor-board { left: 170px; right: 170px; top: 8px; bottom: 6px; gap: 6px; }
.lanes { gap: 6px; }
.lane { --cw: 92px; --ch: 128px; --cf: 30px; background: transparent; border: 0; padding: 0; gap: 8px; }
.lane.valid, .lane.invalid { border: 0; background: transparent; }
.lane-cards { gap: 6px; width: calc(5 * var(--cw) + 4 * 6px); }
.lane-target { background: transparent; border-color: transparent; box-shadow: none; }
.hand-row.empty { display: none; }
.editor-board .confirm { flex: none; min-width: 180px; min-height: max(48px, var(--tap)); padding: 0 36px; border-radius: 999px; font-size: 22px; }
.editor-side { top: auto; bottom: 10px; right: 10px; width: 150px; gap: 6px; }
.editor-side .btn { font-size: 12px; min-height: 40px; padding: 4px 6px; }
.editor-side .status { font-size: 12px; padding: 4px 6px; }
