/* =============================================================
   GAME: Phom (Ta la) — felt table, 3 computer seats, cards thrown and melds laid in front of each player.
   Cards are absolutely positioned by phom.js (--cw / --ch).
   ============================================================= */
.board-phom {
  --ph-glow: var(--glow, #ff7ad9);
  --ph-red: #f2335a;
  --ph-black: #1b1736;
  width: 100%; max-width: 860px;
  touch-action: manipulation; -webkit-touch-callout: none;
}
.board-phom .ph-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ph-table {
  position: relative; width: 100%; min-height: 280px; border-radius: 22px; isolation: isolate;
  background:
    radial-gradient(ellipse 62% 50% at 50% 50%, color-mix(in srgb, var(--ph-glow) 16%, transparent), transparent 72%),
    repeating-radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .022) 0 1px, transparent 1px 3px),
    linear-gradient(180deg, color-mix(in srgb, var(--c1, #0c3f4a) 55%, #0b0a1c), color-mix(in srgb, var(--c2, #061018) 85%, #07060f));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ph-glow) 30%, transparent), inset 0 0 50px rgba(0, 0, 0, .5);
}
/* the inner rail of the table */
.ph-table::before {
  content: ""; position: absolute; left: 13%; right: 13%; top: 20%; bottom: 34%; border-radius: 50%; pointer-events: none; z-index: 0;
  border: 1.5px solid color-mix(in srgb, var(--ph-glow) 30%, transparent);
  box-shadow: 0 0 22px color-mix(in srgb, var(--ph-glow) 18%, transparent), inset 0 0 26px color-mix(in srgb, var(--ph-glow) 10%, transparent);
}

/* ---- cards ---- */
.ph-card {
  position: absolute; left: 0; top: 0; width: var(--cw); height: var(--ch); transform-origin: 0 0;
  border-radius: calc(var(--cw) * .09); color: var(--ph-black);
  background: linear-gradient(160deg, #ffffff 0%, #f7f5ff 55%, #e9e5f8 100%);
  box-shadow: 0 1px 1.5px rgba(0, 0, 0, .45), 0 3px 8px rgba(4, 2, 16, .3), inset 0 0 0 1px rgba(40, 30, 90, .2), inset 0 1px 0 #fff;
  transition: transform .34s cubic-bezier(.3, .7, .3, 1), opacity .34s, filter .2s, box-shadow .2s;
  overflow: hidden; will-change: transform;
}
.ph-card.ph-red { color: var(--ph-red); }
.ph-idx {
  position: absolute; left: 7%; right: 7%; top: 3.5%; display: flex; justify-content: space-between; align-items: center;
  font: 800 calc(var(--cw) * .3) / 1 var(--font-body); letter-spacing: -.03em;
}
.ph-ten { letter-spacing: -.1em; margin-left: -.06em; }
.ph-sm { width: calc(var(--cw) * .24); height: calc(var(--cw) * .24); fill: currentColor; flex: none; }
.ph-pips { position: absolute; inset: 0; pointer-events: none; }
.ph-pip { position: absolute; width: calc(var(--cw) * .175); height: calc(var(--cw) * .175); fill: currentColor; transform: translate(-50%, -50%); }
.ph-pip.ph-inv { transform: translate(-50%, -50%) rotate(180deg); }
.ph-ace { position: absolute; left: 50%; top: 60%; width: calc(var(--cw) * .5); height: calc(var(--cw) * .5); fill: currentColor; transform: translate(-50%, -50%); }
.ph-big { display: none; position: absolute; left: 22%; bottom: 8%; width: 56%; height: 48%; fill: currentColor; }
.ph-art { position: absolute; left: 12%; top: 29.5%; width: 76%; height: 66%; }
.ph-compact .ph-pips { display: none; }
.ph-compact .ph-big { display: block; }
.ph-compact .ph-idx { left: 6%; right: 5%; top: 2.5%; font-size: calc(var(--cw) * .36); }
.ph-compact .ph-sm { width: calc(var(--cw) * .28); height: calc(var(--cw) * .28); }
.ph-compact .ph-art { left: 8%; width: 84%; top: 31%; height: 65%; }

/* face down: neon back in the game's colour */
.ph-card.ph-down {
  background:
    radial-gradient(ellipse at 50% 50%, color-mix(in srgb, var(--ph-glow) 32%, transparent), transparent 62%),
    repeating-linear-gradient(45deg, color-mix(in srgb, var(--ph-glow) 18%, transparent) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(-45deg, color-mix(in srgb, var(--ph-glow) 18%, transparent) 0 1px, transparent 1px 5px),
    linear-gradient(155deg, var(--c1, #0c3f4a), var(--c2, #061018));
  box-shadow: 0 1px 2px rgba(0, 0, 0, .6), inset 0 0 0 1.5px color-mix(in srgb, var(--ph-glow) 60%, transparent), inset 0 0 0 3px rgba(0, 0, 0, .3);
}
.ph-card.ph-down > * { display: none; }
.ph-card.ph-down::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: calc(var(--cw) * .34); height: calc(var(--cw) * .34);
  transform: translate(-50%, -50%) rotate(45deg); border-radius: 3px;
  border: 2px solid color-mix(in srgb, var(--ph-glow) 90%, #fff);
  box-shadow: 0 0 10px color-mix(in srgb, var(--ph-glow) 70%, transparent);
}
.ph-card.ph-dim { filter: brightness(.62) saturate(.7); }
.ph-card.ph-gone { opacity: 0; pointer-events: none; }
.ph-card[hidden] { display: none; }

/* your hand */
.ph-card.ph-mine { cursor: pointer; }
.ph-card.ph-mine:hover { box-shadow: 0 1px 1.5px rgba(0, 0, 0, .45), 0 6px 14px rgba(4, 2, 16, .4), inset 0 0 0 1.5px color-mix(in srgb, var(--ph-glow) 70%, transparent); }
.ph-card.ph-sel {
  box-shadow: 0 0 0 2px var(--t-gold), 0 0 18px color-mix(in srgb, var(--t-gold) 70%, transparent), 0 8px 16px rgba(4, 2, 16, .45);
}
.ph-card:focus { outline: none; }
.ph-card:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; z-index: 300 !important; }
.ph-card.ph-wait:not(.ph-sel) { filter: brightness(.9); }
.ph-notrans .ph-card { transition: none !important; }

/* ---- seats ---- */
.ph-seat {
  position: absolute; left: 0; top: 0; width: 96px; z-index: 40;
  display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; pointer-events: none;
}
.ph-ava {
  position: relative; display: block; width: 46px; height: 46px; border-radius: 50%; flex: none;
  box-shadow: 0 0 0 2px var(--seat), 0 0 14px color-mix(in srgb, var(--seat) 45%, transparent);
  transition: box-shadow .25s;
}
.ph-ava > svg, .ph-ava > img { display: block; width: 100%; height: 100%; border-radius: 50%; overflow: hidden; }
.ph-cnt {
  position: absolute; right: -8px; bottom: -4px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px;
  font: 800 .78rem/22px var(--font-body); color: #170d24; background: var(--seat); box-shadow: 0 0 0 2px #120c22;
}
.ph-name { font-weight: 700; font-size: .85rem; color: var(--ink); line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ph-pts { font-size: .74rem; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.1; }
.ph-bubble {
  position: absolute; top: -2px; left: 50%; transform: translate(24px, 0); padding: 1px 8px; border-radius: 999px;
  font: 800 .7rem/1.5 var(--font-body); text-transform: uppercase; letter-spacing: .04em;
  color: #fff; background: rgba(15, 10, 30, .85); box-shadow: 0 0 0 1px var(--line);
}
.ph-bubble[hidden] { display: none; }
/* the right-hand seat shows its bubble on the inner side */
.ph-seat-1 .ph-bubble { left: auto; right: 50%; transform: translate(-24px, 0); }
.ph-turn .ph-ava { box-shadow: 0 0 0 3px var(--seat), 0 0 22px var(--seat); animation: ph-pulse 1.1s ease-in-out infinite alternate; }
@keyframes ph-pulse { to { box-shadow: 0 0 0 3px var(--seat), 0 0 30px var(--seat), 0 0 0 7px color-mix(in srgb, var(--seat) 22%, transparent); } }
.ph-out .ph-ava { filter: grayscale(.6) brightness(.75); }
.ph-winner .ph-ava { box-shadow: 0 0 0 3px var(--t-gold), 0 0 26px var(--t-gold); }

/* who played the top combination */
.ph-cap {
  position: absolute; left: 0; top: 0; z-index: 250; white-space: nowrap; pointer-events: none;
  padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: var(--ink);
  background: rgba(10, 6, 24, .72); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ph-glow) 40%, transparent);
}
.ph-cap[hidden] { display: none; }

/* ---- action bar ---- */
.ph-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.ph-me { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; }
.ph-me .ph-ava { width: 38px; height: 38px; }
.ph-me-t { display: flex; flex-direction: column; min-width: 0; }
.ph-me .ph-bubble { left: 0; top: -8px; transform: translate(26px, 0); }
.ph-btns { display: flex; gap: 8px; margin-left: auto; }
.ph-btns .btn { min-width: 64px; }
.ph-pass.ph-urge:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--t-gold), 0 0 14px color-mix(in srgb, var(--t-gold) 45%, transparent); }

/* inline card names in the status bar */
.ph-ct { display: inline-flex; align-items: center; gap: 1px; font-weight: 800; color: var(--ink); }
.ph-ct.ph-red { color: #ff6b8a; }
.ph-ss { width: .95em; height: .95em; fill: currentColor; }
.ph-msg { color: var(--muted); font-weight: 600; }

@media (max-width: 600px) {
  .ph-table { border-radius: 16px; }
  .ph-table::before { left: 18%; right: 18%; top: 22%; bottom: 36%; }
  .ph-seat { width: 62px; }
  .ph-ava { width: 36px; height: 36px; }
  .ph-cnt { min-width: 19px; height: 19px; line-height: 19px; font-size: .7rem; right: -7px; }
  .ph-name { font-size: .74rem; }
  .ph-pts { font-size: .68rem; }
  .ph-bubble { font-size: .62rem; transform: translate(14px, -4px); }
  .ph-seat-1 .ph-bubble { transform: translate(-14px, -4px); }
  .ph-card { box-shadow: 0 1px 1.5px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(40, 30, 90, .25); }
  .ph-btns { gap: 6px; }
  .ph-btns .btn { min-width: 0; padding-left: 12px; padding-right: 12px; }
  .ph-cap { font-size: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ph-card { transition: none; }
  .ph-turn .ph-ava { animation: none; }
}

/* ---- Phom extras ---- */
.ph-table::before { top: 16%; bottom: 30%; left: 16%; right: 16%; }
/* the deck: a button over the pile while you may draw */
.ph-deck { position: absolute; left: 0; top: 0; z-index: 70; border-radius: 6px; pointer-events: none; }
.ph-deck.ph-can { pointer-events: auto; cursor: pointer; box-shadow: 0 0 0 2px var(--t-gold), 0 0 18px color-mix(in srgb, var(--t-gold) 60%, transparent); animation: ph-glowpulse 1.2s ease-in-out infinite alternate; }
.ph-deck:focus { outline: none; }
.ph-deck:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.ph-deckcnt {
  position: absolute; left: 50%; bottom: -18px; transform: translateX(-50%); padding: 0 7px; border-radius: 999px;
  font: 800 .72rem/1.5 var(--font-body); color: var(--ink); background: rgba(10, 6, 24, .8); box-shadow: 0 0 0 1px var(--line); white-space: nowrap;
}
@keyframes ph-glowpulse { to { box-shadow: 0 0 0 2px var(--t-gold), 0 0 28px var(--t-gold); } }
/* table cards */
.ph-card.ph-eaten { box-shadow: 0 0 0 2px var(--t-gold), 0 0 12px color-mix(in srgb, var(--t-gold) 55%, transparent); }
.ph-card.ph-last { box-shadow: 0 0 0 2px color-mix(in srgb, var(--ph-glow) 85%, #fff), 0 0 12px color-mix(in srgb, var(--ph-glow) 60%, transparent); }
.ph-card.ph-eatable { cursor: pointer; box-shadow: 0 0 0 3px var(--t-gold), 0 0 22px var(--t-gold); animation: ph-eat .9s ease-in-out infinite alternate; }
@keyframes ph-eat { to { filter: brightness(1.12); box-shadow: 0 0 0 3px var(--t-gold), 0 0 34px var(--t-gold); } }
.ph-card.ph-eatable:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
/* hand cards that already form a meld: neon bar along the bottom */
.ph-card.ph-inmeld::after {
  content: ""; position: absolute; left: 8%; right: 8%; bottom: 3%; height: 4px; border-radius: 2px;
  background: var(--ph-glow); box-shadow: 0 0 6px var(--ph-glow);
}
.ph-round { font-size: .78rem; font-weight: 700; color: var(--muted); padding: 2px 9px; border-radius: 999px; background: var(--surface-2); }
.ph-eat.ph-urge:not(:disabled) { box-shadow: inset 0 0 0 1.5px var(--t-gold), 0 0 14px color-mix(in srgb, var(--t-gold) 45%, transparent); }
.ph-btns .btn[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .ph-deck.ph-can, .ph-card.ph-eatable { animation: none; }
}
