/* The play screen. Portrait table, opponents round the edge, piles in the middle, hand fanned at the bottom. */
.table {
  position: relative; flex: 1; min-height: 0; overflow: hidden; --cw: 72px; --hcw: 80px;
  background: radial-gradient(120% 75% at 50% 42%, #14707e 0%, var(--felt) 48%, var(--felt-d) 100%);
}
.table::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(45deg, #ffffff07 0 2px, transparent 2px 6px); }
.table::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 90px #00000066; }
.table > * { z-index: 1; }

/* ---- seats ---- */
.seat { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 5px; z-index: 3; }
.seat.top { top: calc(var(--safe-t) + 10px); left: 50%; transform: translateX(-50%); }
.seat.left { left: 8px; top: 22%; }
.seat.right { right: 8px; top: 22%; }
.plate {
  position: relative; display: flex; align-items: center; gap: 8px; width: 118px; padding: 5px 8px 7px 5px;
  background: #04222ad9; border: 1px solid #ffffff22; border-radius: 9px; transition: box-shadow .2s, opacity .3s, transform .2s;
}
.plate .avatar { width: 34px; height: 34px; border-radius: 7px; position: relative; }
.plate .nm { min-width: 0; flex: 1; }
.plate .nm b { display: block; font-size: 13px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; }
.plate .nm .stars { margin-top: 3px; }
.plate .nm .stars i { width: 8px; height: 8px; }
.plate .cnt { position: absolute; left: 27px; top: -7px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px; background: var(--cream); color: #17211f; font: 800 12px/20px var(--sans); text-align: center; box-shadow: 0 1px 0 #0006; }
.plate .tbar { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 3px; border-radius: 2px; background: #ffffff1c; overflow: hidden; opacity: 0; }
.plate .tbar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
.plate.active { box-shadow: 0 0 0 2px var(--accent), 0 0 18px #7fb24a77; transform: translateY(-1px); }
.plate.active .tbar { opacity: 1; }
.plate.low .tbar i { background: var(--danger); }
.plate.warning { animation: time-warning .36s ease-in-out 1; }
.plate.out { opacity: .38; filter: grayscale(1); }
.plate .tag { position: absolute; right: -6px; top: -8px; font: 900 10px/1 var(--sans); letter-spacing: .04em; padding: 3px 5px; border-radius: 5px; background: var(--gold); color: #2a1f05; box-shadow: 0 1px 0 #0006; }
.plate .tag.skip { background: var(--danger); color: #fff; }
.fan { display: flex; height: 36px; justify-content: center; margin-top: 1px; }
.fan .card { --cw: 24px; }
.pile .card { --cw: 72px; }
.hand .card { --cw: var(--hcw); }
.effect[hidden], .status[hidden] { display: none; }
.fan .card { margin-left: -14px; box-shadow: 0 0 0 1px #0004, 0 1px 3px #0006; }
.fan .card:first-child { margin-left: 0; }
#tbl.four .seat.left .fan, #tbl.four .seat.right .fan { flex-direction: column; height: auto; }
#tbl.four .seat.left .fan .card, #tbl.four .seat.right .fan .card { margin: -20px 0 0; }
#tbl.four .seat.left .fan .card:first-child, #tbl.four .seat.right .fan .card:first-child { margin-top: 0; }
#tbl.four .seat.left .fan .card { transform: rotate(-90deg); }
#tbl.four .seat.right .fan .card { transform: rotate(90deg); }

/* ---- middle of the table ---- */
.center { position: absolute; left: 0; right: 0; top: 45%; transform: translateY(-50%); display: flex; justify-content: center; align-items: center; gap: 34px; z-index: 2; }
.pile { position: relative; width: var(--cw); height: calc(var(--cw) * 1.4); }
.pile .card { position: absolute; left: 0; top: 0; }
.pile .cnt { position: absolute; right: -9px; top: -9px; z-index: 5; min-width: 28px; height: 26px; padding: 0 6px; border-radius: 7px; background: var(--cream); color: #17211f; font: 800 15px/26px var(--sans); text-align: center; box-shadow: 0 2px 0 #0006; }
.pile.empty::before { content: ""; position: absolute; inset: 0; border-radius: 6px; border: 2px dashed #ffffff44; }
.pile.tap { cursor: pointer; }
.pile.glow .card:last-child { box-shadow: 0 0 0 2px var(--gold), 0 0 16px #e3b23caa; }
.pile .lbl { position: absolute; left: 50%; transform: translateX(-50%); top: calc(100% + 6px); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #ffffff99; white-space: nowrap; }

.effect {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(45% - 112px); z-index: 4;
  display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 10px; border-radius: 9px; font-weight: 900; font-size: 17px; letter-spacing: .02em;
  background: #04222af0; border: 2px solid currentColor; color: var(--cream); animation: pop .25s cubic-bezier(.2,1.4,.4,1);
}
.effect.pen { color: #ff8a70; }
.effect.dem { color: var(--gold); }
.effect.q { color: #8cc8ee; }
.effect.jmp { color: #ffb36b; }
.effect .big { font-size: 24px; font-family: var(--serif); line-height: 1; }
.effect .red { color: #ff7a66; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); opacity: 0; } }
.status {
  position: absolute; left: 50%; transform: translateX(-50%); top: calc(45% + 82px); z-index: 3; max-width: 92%;
  padding: 7px 14px; border-radius: 8px; background: #04222abf; color: var(--cream); font-weight: 700; font-size: 14px; text-align: center;
}
.status.you { background: var(--accent); color: #fff; box-shadow: 0 2px 0 var(--accent-d); }
.status b { font-weight: 900; }

/* ---- me ---- */
.hand { position: absolute; left: 0; right: 0; bottom: calc(14px + var(--safe-b)); height: 132px; z-index: 4; }
.hand .card { position: absolute; bottom: 0; left: 50%; margin-left: calc(var(--cw) / -2); --x: 0px; --y: 0px; --r: 0deg; --lift: 0px;
  transform: translate(var(--x), calc(var(--y) - var(--lift))) rotate(var(--r)); transform-origin: 50% 130%; transition: transform .18s ease-out, filter .15s; cursor: pointer; }
.hand .card.sel { --lift: 24px; box-shadow: 0 0 0 2px var(--gold), 0 6px 14px #0008; z-index: 20 !important; }
.hand .card.dim { filter: brightness(.58) saturate(.8); }
.hand .card.ok { box-shadow: 0 0 0 2px #7fb24a99, 0 2px 6px #0006; }
.hand .card.sel.ok { box-shadow: 0 0 0 2px var(--gold), 0 6px 14px #0008; }
.mine { position: absolute; left: 10px; bottom: calc(220px + var(--safe-b)); z-index: 4; }
.bar { position: absolute; left: 10px; right: 10px; bottom: calc(158px + var(--safe-b)); z-index: 6; display: flex; align-items: flex-end; justify-content: flex-end; gap: 10px; pointer-events: none; }
.bar > * { pointer-events: auto; }
.bar .grow { flex: 1; }
.act {
  min-width: 92px; height: 54px; padding: 0 14px; border-radius: 11px; display: flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 900; font-size: 17px; color: #fff; background: #04222ae6; border: 2px solid #ffffff66; transition: transform .08s, opacity .15s, background .15s;
}
.act:active { transform: translateY(2px) scale(.98); }
.act .ic { font-size: 22px; }
.act small { display: block; font-size: 11px; font-weight: 800; opacity: .8; letter-spacing: .05em; }
.act[disabled] { opacity: .35; pointer-events: none; }
.act.go { background: var(--accent); border-color: #a9d878; box-shadow: 0 3px 0 var(--accent-d); }
.act.take.hot { border-color: var(--gold); box-shadow: 0 0 0 2px #e3b23c55; animation: take-pulse 1.15s ease-in-out infinite; }
.act.take.hot:active { animation: none; transform: translateY(2px) scale(.98); }
.act.nk { background: linear-gradient(180deg, #49d7bd, #159c8a); color: #fff; border-color: #c8fff3; text-shadow: 0 1px 1px #07584f88; box-shadow: 0 3px 0 #087768; }
.act.nk:not(.off) { animation: nk 1.1s ease-in-out infinite; }
.act.nk.done { animation: none; background: #04222ae6; color: var(--gold); border-color: var(--gold); box-shadow: none; }
@keyframes nk { 50% { transform: scale(1.05); } }
@keyframes take-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 2px #e3b23c55; }
  50% { transform: scale(1.035); box-shadow: 0 0 0 5px #e3b23c33; }
}
@keyframes time-warning {
  0%, 100% { transform: translateY(-1px); }
  25% { transform: translate(-3px, -1px); }
  75% { transform: translate(3px, -1px); }
}
.menu {
  position: absolute; right: 10px; top: calc(var(--safe-t) + 10px); z-index: 8; width: 48px; height: 48px; border-radius: 12px;
  border: 2px solid #ffffff66; display: grid; place-items: center; font-size: 26px; color: #fff; background: #04222a66;
}
.hint { position: absolute; left: 10px; top: calc(var(--safe-t) + 12px); z-index: 8; width: 44px; height: 44px; border-radius: 12px; border: 2px solid #ffffff44; display: grid; place-items: center; font-size: 24px; color: #ffffffcc; background: #04222a55; }

/* sheets inside the table */
.pickgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.pickgrid.six { grid-template-columns: repeat(6, 1fr); gap: 8px; }
.pick { height: 60px; border-radius: 10px; background: #fbf7ec; color: #1d1c1a; font-size: 34px; font-weight: 800; display: grid; place-items: center; border: 3px solid transparent; box-shadow: 0 3px 0 #0006; }
.pick.red { color: #c0352a; }
.pick.on { border-color: var(--accent); background: #eaf5d9; }
.pick.num { font: 800 24px var(--serif); height: 52px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; margin-top: 10px; border-radius: 10px; background: var(--surface2); text-align: left; font-weight: 800; font-size: 16px; }
.opt small { display: block; color: var(--muted); font-weight: 500; font-size: 13px; margin-top: 2px; }
.opt .ic { font-size: 26px; color: var(--gold); }

/* result */
.result { text-align: center; }
.result .trophy { font-size: 54px; color: var(--gold); display: block; margin: 0 auto 6px; width: 1em; }
.result h2 { font-size: 32px; }
.result .delta { font: 800 22px var(--sans); margin: 10px 0 4px; }
.result .delta.up { color: var(--accent); }
.result .delta.down { color: var(--danger); }
.result .who { display: flex; justify-content: center; gap: 10px; margin: 14px 0 4px; }
.reveal { display: flex; justify-content: center; gap: 6px; margin: 14px 0 4px; --cw: 54px; }

@media (max-height: 700px) {
  .table { --cw: 60px; --hcw: 68px; }
  .pile .card { --cw: 60px; }
  .hand { height: 112px; }
  .bar { bottom: calc(134px + var(--safe-b)); }
  .mine { bottom: calc(188px + var(--safe-b)); }
  .seat.left, .seat.right { top: 19%; }
  .status { top: calc(45% + 46px); padding: 5px 10px; font-size: 12px; line-height: 1.2; }
}
@media (max-height: 620px) {
  .table { --cw: 56px; --hcw: 64px; }
  .pile .card { --cw: 56px; }
  .center { top: 41%; }
  .effect { top: calc(41% - 98px); }
  .status { top: calc(41% + 44px); }
  .hand { height: 96px; bottom: calc(6px + var(--safe-b)); }
  .bar { bottom: calc(102px + var(--safe-b)); }
  .mine { bottom: calc(158px + var(--safe-b)); }
}
@media (max-height: 520px) {
  .table { --cw: 52px; --hcw: 58px; }
  .pile .card { --cw: 52px; }
  .center { top: 36%; }
  .effect { top: calc(36% - 90px); }
  .status { top: calc(36% + 42px); }
  .seat.top { top: calc(var(--safe-t) + 4px); }
  .seat.top .fan { height: 28px; }
  .hand { height: 78px; }
  .bar { bottom: calc(84px + var(--safe-b)); }
  .mine { bottom: calc(140px + var(--safe-b)); }
}
@media (max-height: 440px) {
  .table { --cw: 48px; --hcw: 54px; }
  .pile .card { --cw: 48px; }
  .seat.left, .seat.right { top: 16%; }
  .center { top: 30%; }
  .effect { top: calc(30% - 80px); }
  .status { top: calc(30% + 42px); }
  .hand { height: 64px; bottom: calc(4px + var(--safe-b)); }
  .bar { bottom: calc(68px + var(--safe-b)); }
  .mine { bottom: calc(122px + var(--safe-b)); }
}
@media (max-width: 380px) {
  .bar { gap: 6px; }
  .act { min-width: 70px; padding: 0 8px; font-size: 14px; }
  .act .ic { font-size: 18px; }
  .act small { font-size: 9px; }
}
@media (max-width: 340px) {
  .bar { left: 6px; right: 6px; gap: 4px; }
  .act { min-width: 60px; padding: 0 5px; font-size: 13px; }
}

/* ---- dragging cards ---- */
.hand .card, .pile.tap, #drawP, #dispP, #deadP { touch-action: none; }
.hand .card.dragging { opacity: .25; }
.drag-ghost { position: fixed; z-index: 90; pointer-events: none; margin: 0 !important; transform: scale(1.1) rotate(-3deg); box-shadow: 0 14px 28px #000a, 0 0 0 1px #0004 !important; transition: none; }
.drag-ghost.back { animation: none; }
.drag-ghost.home { transition: left .18s ease-out, top .18s ease-out, transform .18s ease-out, opacity .18s; transform: scale(1) rotate(0); opacity: .4; }
.drop-hi { outline: 3px dashed var(--accent); outline-offset: 8px; border-radius: 14px; }
.hand.drop-hi { outline-offset: -6px; background: color-mix(in srgb, var(--accent) 12%, transparent); }

/* ---- Parlour (default): the table is the painted backdrop with a faint gold-edged mat ---- */
body[data-felt="parlour"] .table { background: none; }
body[data-felt="parlour"] .table::after { box-shadow: none; background: linear-gradient(transparent 76%, color-mix(in srgb, var(--bg) 70%, transparent)); }
body[data-felt="parlour"] .table::before {
  inset: 12% 7% 27% 7%; border-radius: 26px; background: radial-gradient(closest-side, #5a9a3e2e, #5a9a3e18 70%, #5a9a3e0c);
  border: 2px solid #c9a65cb0; box-shadow: inset 0 0 0 7px #fffaf044, inset 0 0 0 8px #c9a65c55, 0 0 40px #fffaf055;
}
body[data-mode="dark"][data-felt="parlour"] .table::before { box-shadow: inset 0 0 0 7px #ffffff10, inset 0 0 0 8px #c9a65c44, 0 0 40px #0006; }
body[data-felt="parlour"] .pile .lbl { color: var(--muted); }
body[data-felt="parlour"] .pile.empty::before { border-color: color-mix(in srgb, var(--ink) 35%, transparent); }
body[data-felt="parlour"] .table .card:not(.back) { background: #fffdf6; box-shadow: 0 0 0 1px #5b45304d, 0 3px 8px #4b36206b; }
body[data-felt="parlour"] .table .card.back { box-shadow: 0 0 0 1px #3a2f2466, 0 3px 8px #4b36206b; }
body[data-felt="parlour"] .hand .card.ok { box-shadow: 0 0 0 2px var(--accent), 0 3px 8px #4b36206b; }
body[data-felt="parlour"] .hand .card.sel, body[data-felt="parlour"] .hand .card.sel.ok { box-shadow: 0 0 0 2px var(--gold), 0 8px 16px #4b362088; }
body[data-felt="parlour"] .plate { background: var(--glass); border: 1px solid var(--glass-line); box-shadow: 0 2px 6px var(--shadow); }
body[data-felt="parlour"] .plate .nm b { color: var(--ink); }
body[data-felt="parlour"] .plate .stars i.off { background: #00000026; }
body[data-felt="parlour"] .plate .tbar { background: #0000001a; }
body[data-felt="parlour"] .plate.active { box-shadow: 0 0 0 2px var(--accent), 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent); }
body[data-felt="parlour"] .status { background: var(--glass); color: var(--ink); border: 1px solid var(--glass-line); box-shadow: 0 2px 6px var(--shadow); }
body[data-felt="parlour"] .status.you { background: var(--accent); color: #fff; border-color: var(--accent-d); }
body[data-felt="parlour"] .effect { background: var(--glass); color: var(--ink); box-shadow: 0 3px 10px var(--shadow); }
body[data-felt="parlour"] .effect.pen { color: #c4452c; }
body[data-felt="parlour"] .effect.dem { color: #a9791a; }
body[data-felt="parlour"] .effect.q { color: #2f6f93; }
body[data-felt="parlour"] .effect.jmp { color: #b9641a; }
body[data-felt="parlour"] .effect .red { color: #c0352a; }
body[data-mode="dark"][data-felt="parlour"] .effect.pen { color: #ff9a82; }
body[data-mode="dark"][data-felt="parlour"] .effect.dem { color: #f0c050; }
body[data-mode="dark"][data-felt="parlour"] .effect.q { color: #7cc0ea; }
body[data-mode="dark"][data-felt="parlour"] .effect.jmp { color: #ffb36b; }
body[data-felt="parlour"] .menu, body[data-felt="parlour"] .hint { background: var(--glass); color: var(--ink); border: 2px solid var(--glass-line); box-shadow: 0 2px 6px var(--shadow); }
body[data-felt="parlour"] .act { background: #2a4a43f2; border-color: #fffaf0cc; box-shadow: 0 3px 0 #1a2f2a, 0 6px 12px #3a2a1033; }
body[data-felt="parlour"] .act.go { background: var(--accent); border-color: #ffffffaa; box-shadow: 0 3px 0 var(--accent-d), 0 6px 12px #3a2a1033; }
body[data-felt="parlour"] .act.nk.done { background: #2a4a43f2; }
/* ---- Wood: dark walnut planks ---- */
body[data-felt="wood"] .table { background: #2a170c url(../img/wood.webp) center / cover no-repeat; }
body[data-felt="wood"] .table::before { content: none; }
body[data-felt="wood"] .table::after { box-shadow: inset 0 0 110px #000b; }
body[data-felt="wood"] .table .card:not(.back) { background: #fffdf6; box-shadow: 0 0 0 1px #0005, 0 5px 10px #000b; }
body[data-felt="wood"] .table .card.back { box-shadow: 0 0 0 1px #0006, 0 5px 10px #000b, inset 0 0 0 .22em #f1e8cf, inset 0 0 0 .3em #1d5a6b; }
body[data-felt="wood"] .plate { background: #1c110adc; border-color: #ffffff22; }
body[data-felt="wood"] .status:not(.you) { background: #1c110acc; }
body[data-felt="wood"] .effect { background: #1c110af2; }
body[data-felt="wood"] .act { background: #1c110aee; }
body[data-felt="wood"] .act.go { background: var(--accent); }
.act.nk.off { animation: none; opacity: 1; background: linear-gradient(180deg, #e6f4ee, #cce4d9); color: #456b5c; border-color: #f5fff9; text-shadow: none; box-shadow: 0 3px 0 #a9caba; }
