/* ==========================================================================
   HOKM — game client (overlay)
   ========================================================================== */

/* ---------- Overlay with circular reveal from the clicked CTA ---------- */
.app {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  color: var(--body);
  clip-path: circle(0px at var(--ox, 50%) var(--oy, 50%));
  visibility: hidden;
  transition: clip-path 760ms var(--ease-in-out), visibility 0s linear 760ms;
}
.app.is-open {
  clip-path: circle(150vmax at var(--ox, 50%) var(--oy, 50%));
  visibility: visible;
  transition: clip-path 760ms var(--ease-in-out), visibility 0s linear 0s;
}
.app-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.app-orb {
  position: absolute;
  left: 50%; bottom: -220px;
  width: 1000px; height: 560px;
  margin-left: -500px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(200, 40, 56, 0.16), rgba(200, 40, 56, 0.05) 55%, transparent);
  animation: orb-breathe 8s ease-in-out infinite alternate;
}
.app-bg::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 40%, transparent 45%, rgba(0, 0, 0, 0.3));
}

.app-chrome {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(49, 35, 37, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.app-logo .logo-mark { width: 28px; height: 28px; border-radius: 8px; }
.app-logo .logo-mark svg { width: 16px; height: 16px; }
.app-logo .logo-word { font-size: 13px; }
.chrome-right { display: flex; align-items: center; gap: 10px; }
.chrome-room {
  padding: 6px 10px; border-radius: 999px;
  font-size: 11px; letter-spacing: 0.12em; color: var(--text);
  border: 1px solid var(--border-subtle); background: var(--surface);
}
.chrome-room b { color: var(--accent); font-weight: 500; margin-right: 6px; }
.conn-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 999px;
  font-size: 10.5px; letter-spacing: 0.1em; color: var(--body);
  border: 1px solid var(--border-subtle); background: var(--surface);
}
.conn-dot { position: relative; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.conn-dot::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--status); opacity: 0; }
.is-live .conn-dot { background: var(--status); }
.is-live .conn-dot::after { animation: dot-ping 1.8s var(--ease-out) infinite; }
.is-live .conn-label { color: var(--accent); }
.is-off .conn-dot { background: var(--alert); }
.is-off .conn-label { color: var(--alert); }
#appExit svg { width: 15px; height: 15px; }

/* ---------- Screens ---------- */
.screens { position: absolute; inset: 0; }
.screen {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: safe center;
  padding: 92px 20px 32px;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 360ms ease, transform 520ms var(--ease-out);
}
.screen.is-active { opacity: 1; transform: none; }
.screen.is-leaving { opacity: 0; transform: translateY(-10px); transition-duration: 200ms; pointer-events: none; }

.panel {
  position: relative;
  width: min(460px, 100%);
  margin: auto 0;
  padding: 40px 36px 32px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-card), 0 30px 80px rgba(0, 0, 0, 0.5);
}
.corner { position: absolute; font-size: 10px; letter-spacing: 0.08em; color: var(--tertiary); }
.corner.tl { top: 14px; left: 16px; }
.corner.br { bottom: 14px; right: 16px; transform: rotate(180deg); }
.panel .label { margin-bottom: 14px; }
.panel-title { font-size: clamp(26px, 3vw, 36px); font-weight: 900; letter-spacing: -0.035em; line-height: 1.05; color: var(--text); text-transform: uppercase; }
.panel-sub { margin-top: 12px; font-size: 15px; }

/* Staggered entrance for panel children */
.stagger > * { animation: deal-in 600ms var(--ease-out) both; animation-delay: calc(var(--i, 0) * 70ms + 120ms); }
@keyframes deal-in { from { opacity: 0; transform: translateY(16px) rotate(-1deg); } }

/* ---------- Lobby ---------- */
.lobby-mark { position: relative; height: 84px; margin-bottom: 18px; }
.lobby-mark .lm-card { position: absolute; left: 0; bottom: 0; transform-origin: 50% 150%; transform: rotate(var(--r)); animation: lm-fan 900ms var(--ease-out) both; }
.lobby-mark .pcard { --cw: 48px; }
.lobby-mark .lm-card:nth-child(1) { --r: -14deg; animation-delay: 200ms; }
.lobby-mark .lm-card:nth-child(2) { --r: 0deg; left: 18px; animation-delay: 290ms; z-index: 2; }
.lobby-mark .lm-card:nth-child(3) { --r: 14deg; left: 36px; animation-delay: 380ms; }
@keyframes lm-fan { from { opacity: 0; transform: translateY(30px) rotate(0deg); } to { opacity: 1; transform: rotate(var(--r)); } }

.conn {
  display: flex; align-items: center; gap: 10px;
  margin-top: 22px;
  font-size: 11px; letter-spacing: 0.08em; color: var(--body);
}
.views { position: relative; margin-top: 24px; transition: height 280ms var(--ease-out); }
.view { display: flex; flex-direction: column; gap: 14px; transition: opacity 220ms ease, transform 320ms var(--ease-out); }
.view.pre { opacity: 0; transform: translateX(14px); }
.view.out { position: absolute; inset: 0 0 auto; opacity: 0; transform: translateX(-14px); pointer-events: none; transition-duration: 160ms; }
.view-btns { display: grid; gap: 10px; }
.back-link {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 6px;
  font: 500 11px/1 var(--mono); letter-spacing: 0.08em; color: var(--body);
  padding: 6px 0;
  transition: color 200ms ease;
}
.back-link svg { width: 14px; height: 14px; transition: transform 220ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .back-link:hover { color: var(--text); }
  .back-link:hover svg { transform: translateX(-3px); }
}
.view-title { font-size: 18px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font: 500 11px/1 var(--mono); letter-spacing: 0.08em; color: var(--tertiary); }
.input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text);
  font: 500 16px/1.3 var(--font);
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
.input::placeholder { color: var(--tertiary); }
.input:focus { border-color: var(--border-accent); box-shadow: 0 0 0 3px rgba(200, 40, 56, 0.12), 0 0 18px rgba(200, 40, 56, 0.1); }
.input.code { font: 600 28px/1 var(--mono); letter-spacing: 0.5em; text-align: center; text-transform: uppercase; padding: 14px 0 14px 0.5em; }
.lobby-rules { display: flex; flex-direction: column; gap: 10px; margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--border-subtle); }
.lobby-rules li { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--body); }
.lobby-rules .ico { width: 16px; height: 16px; color: var(--accent); }

/* ---------- Waiting room ---------- */
.wait-panel { width: min(760px, 100%); padding: 44px 40px 36px; }
.wait-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.code-box { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.code-tiles { display: flex; gap: 8px; }
.code-tile {
  width: 48px; height: 58px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(200, 40, 56, 0.35);
  font: 600 28px/1 var(--mono);
  color: var(--text);
  animation: tile-flip 700ms var(--ease-out) both;
  animation-delay: calc(var(--i) * 90ms + 250ms);
}
@keyframes tile-flip { from { opacity: 0; transform: perspective(300px) rotateX(-80deg) translateY(-6px); } }
.copy-btn { display: inline-flex; align-items: center; gap: 6px; font: 500 11px/1 var(--mono); letter-spacing: 0.08em; color: var(--body); padding: 4px 0; transition: color 200ms ease; }
.copy-btn svg { width: 14px; height: 14px; }
.copy-btn.done { color: var(--accent); }
@media (hover: hover) and (pointer: fine) { .copy-btn:hover { color: var(--text); } }

.teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: center; margin-top: 36px; }
.team { display: flex; flex-direction: column; gap: 10px; }
.team-label { font-size: 11px; letter-spacing: 0.08em; color: var(--text); margin-bottom: 4px; }
.team-label.red { color: var(--accent); }
.vs { font-size: 12px; color: var(--tertiary); letter-spacing: 0.1em; }
.seat-slot {
  position: relative;
  display: flex; align-items: center; gap: 14px;
  min-height: 70px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-subtle);
  transition: box-shadow 300ms ease, background-color 300ms ease;
}
.seat-slot.filled { background: rgba(245, 235, 236, 0.02); box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.07), inset 0 0 0 1px var(--border-subtle); }
.seat-slot.is-you { box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.07), inset 0 0 0 1px var(--border-accent); }
.seat-slot.pop { animation: deal-in 600ms var(--ease-out); }
.seat-slot.empty::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(100deg, transparent 30%, rgba(245, 235, 236, 0.035) 50%, transparent 70%);
  background-size: 250% 100%;
  animation: shimmer 2.4s linear infinite;
  pointer-events: none;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
.avatar {
  flex: none;
  width: 40px; height: 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-weight: 700; font-size: 16px;
  color: var(--text);
  background: var(--card);
  box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.08), inset 0 0 0 1px var(--border-medium), 0 4px 14px rgba(0, 0, 0, 0.45);
}
.avatar.t0 { box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.08), inset 0 0 0 1px var(--border-accent), 0 4px 14px rgba(0, 0, 0, 0.45); }
.avatar.empty { color: var(--tertiary); background: transparent; box-shadow: inset 0 0 0 1px var(--border-subtle); }
.seat-info { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
.seat-name { font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-name.waiting { color: var(--tertiary); font-weight: 500; }
.seat-pos { font: 500 10.5px/1 var(--mono); letter-spacing: 0.08em; color: var(--tertiary); }
.chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 7px; border-radius: 999px;
  font: 600 9.5px/1 var(--mono); letter-spacing: 0.1em;
  color: var(--body);
  border: 1px solid var(--border-medium);
}
.chip.accent { color: var(--accent); border-color: var(--border-accent); }
.chip svg { width: 11px; height: 11px; }
.seat-slot .chips { margin-left: auto; display: flex; gap: 6px; }
.dots::after { content: ""; animation: dots 1.4s steps(4, end) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.wait-foot { display: flex; align-items: center; gap: 20px; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border-subtle); flex-wrap: wrap; }
.meter { display: flex; gap: 6px; }
.meter i { width: 26px; height: 4px; border-radius: 2px; background: var(--border-medium); position: relative; overflow: hidden; }
.meter i::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform 500ms var(--ease-out); box-shadow: 0 0 8px rgba(200, 40, 56, 0.6); }
.meter i.on::after { transform: scaleX(1); }
.meter-text { font-size: 11px; letter-spacing: 0.08em; color: var(--body); }
.wait-action { margin-left: auto; min-width: 220px; display: flex; justify-content: flex-end; }
.wait-hint { font-size: 14px; color: var(--body); }
.wait-hint b { color: var(--text); font-weight: 600; }

/* ---------- Trump selection ---------- */
.trump-panel { width: min(760px, 100%); padding: 44px 40px 36px; text-align: center; }
.trump-panel .panel-sub { max-width: 460px; margin-left: auto; margin-right: auto; }
.trump-meta { display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; margin-top: 18px; font-size: 11px; letter-spacing: 0.08em; color: var(--tertiary); }
.trump-meta b { color: var(--text); font-weight: 500; }
.hand-label { margin-top: 32px; font: 500 11px/1 var(--mono); letter-spacing: 0.1em; color: var(--tertiary); }
.trump-hand { display: flex; justify-content: center; gap: 10px; margin-top: 16px; --cw: clamp(56px, 10vw, 86px); flex-wrap: wrap; }
.suit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-top: 32px; }
.suit-grid .suit-btn { background: var(--surface); padding: 20px 0 16px; }
.suit-grid .suit-btn .pip { width: 34px; height: 34px; }
.suit-grid .suit-btn.is-red .pip { color: var(--accent-bright); }
.suit-grid .suit-btn .count { font: 500 10px/1 var(--mono); color: var(--tertiary); letter-spacing: 0.08em; text-transform: none; }
.suit-grid .suit-btn.chosen { color: var(--text); box-shadow: var(--shadow-card), var(--shadow-featured); }
.suit-grid.locked .suit-btn:not(.chosen) { opacity: 0.35; }
.trump-wait { display: flex; flex-direction: column; align-items: center; gap: 16px; margin-top: 36px; }
.trump-wait p { font-size: 15px; }
.trump-wait b { color: var(--text); font-weight: 600; }
.spin {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--border-medium);
  border-top-color: var(--accent-bright);
  animation: spin 900ms linear infinite;
  box-shadow: 0 0 22px rgba(200, 40, 56, 0.15);
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; flex-direction: column; align-items: center; gap: 18px; margin: auto; font-size: 11px; letter-spacing: 0.1em; color: var(--tertiary); }

/* ==========================================================================
   Table
   ========================================================================== */
.screen-table { padding: 60px 0 0; align-items: stretch; overflow: hidden; }
.table {
  position: relative;
  --cw: clamp(58px, 7vw, 92px);
  --tcw: clamp(50px, 6vw, 80px);
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

/* Scoreboard */
.tb-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px 6px;
}
.tb-team { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tb-team.right { align-items: flex-end; text-align: right; }
.tb-team-label { font: 500 10.5px/1 var(--mono); letter-spacing: 0.1em; color: var(--text); }
.tb-team.t0 .tb-team-label { color: var(--accent); }
.tb-team-label .you { color: var(--tertiary); margin-left: 6px; }
.tb-row { display: flex; align-items: center; gap: 14px; }
.tb-team.right .tb-row { flex-direction: row-reverse; }
.tb-pts { font-size: 30px; font-weight: 800; letter-spacing: -0.04em; color: var(--text); line-height: 1; font-variant-numeric: tabular-nums; display: inline-flex; align-items: baseline; gap: 4px; }
.tb-pts small { font: 500 10px/1 var(--mono); letter-spacing: 0.08em; color: var(--tertiary); }
.tb-pts .num { display: inline-block; }
.tb-pts .num.bump { animation: bump 600ms var(--ease-out); }
@keyframes bump { 30% { transform: scale(1.35); color: var(--accent-bright); } }
.tricks { display: flex; gap: 4px; }
.tricks .tp { width: 12px; height: 12px; color: var(--muted); position: relative; }
.tricks .tp svg { width: 12px; height: 12px; position: absolute; inset: 0; }
.tricks .tp .lit { color: var(--accent-bright); --pip-fill: rgba(200, 40, 56, 0.35); opacity: 0; transform: scale(0.4); transition: opacity 300ms ease, transform 500ms var(--ease-out); }
.tb-team.t1 .tricks .tp .lit { color: var(--text); --pip-fill: rgba(245, 235, 236, 0.25); }
.tricks .tp.on .lit { opacity: 1; transform: none; }
.tb-names { font-size: 12px; color: var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

.tb-hokm {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px 10px 12px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow-card), 0 0 0 1px rgba(200, 40, 56, 0.35);
}
.tb-hokm.pulse::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: 0 0 0 1px var(--accent-bright), 0 0 30px rgba(230, 57, 74, 0.4);
  animation: ind-pulse 1100ms var(--ease-out) both;
  pointer-events: none;
}
.tb-hokm-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-subtle); box-shadow: inset 0 0 0 1px rgba(200, 40, 56, 0.35); color: var(--accent-bright); }
.tb-hokm-icon svg { width: 20px; height: 20px; --pip-fill: rgba(200, 40, 56, 0.14); }
.tb-hokm-icon.black { color: var(--text); }
.tb-hokm-txt { display: flex; flex-direction: column; gap: 4px; }
.tb-hokm-txt span { font: 500 10px/1 var(--mono); letter-spacing: 0.1em; color: var(--accent); }
.tb-hokm-txt b { font-size: 15px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); line-height: 1; }

/* Arena */
.arena {
  position: relative;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  min-height: 0;
  padding: 6px 24px;
  display: grid;
  grid-template-columns: minmax(96px, 1fr) minmax(0, 3.4fr) minmax(96px, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: ". north ." "west felt east" ". south .";
  gap: 6px 12px;
}
.seat { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; min-width: 0; }
.seat-north { grid-area: north; }
.seat-west { grid-area: west; }
.seat-east { grid-area: east; }
.seat-south { grid-area: south; flex-direction: row; gap: 12px; }
.seat .avatar { position: relative; width: 44px; height: 44px; font-size: 17px; transition: box-shadow 300ms ease; }
.seat.is-active .avatar { box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.1), inset 0 0 0 1px var(--accent-bright), 0 0 24px rgba(200, 40, 56, 0.4); }
.seat.is-active .avatar::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit;
  box-shadow: 0 0 0 1px var(--accent-bright);
  animation: turn-ring 1.6s var(--ease-out) infinite;
  pointer-events: none;
}
@keyframes turn-ring { from { transform: scale(1); opacity: 0.9; } to { transform: scale(1.5); opacity: 0; } }
.seat-label { display: flex; align-items: center; justify-content: center; gap: 6px; max-width: 100%; }
.seat-label .nm { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 120px; }
.seat-sub { font: 500 10px/1 var(--mono); letter-spacing: 0.08em; color: var(--tertiary); }
.seat.is-active .seat-sub { color: var(--accent); }
.seat-south .seat-text { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.backs { display: flex; height: 31px; }
.backs .pback { --bw: 20px; }
.backs .pback + .pback { margin-left: -13px; }
.seat-west .backs, .seat-east .backs { height: auto; }

/* Felt */
.felt {
  grid-area: felt;
  position: relative;
  min-height: 200px;
  border-radius: 50%;
  margin: 14px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(230, 57, 74, 0.15), rgba(200, 40, 56, 0.06) 50%, transparent 74%),
    repeating-radial-gradient(ellipse at center, rgba(200, 40, 56, 0.05) 0 1px, transparent 1px 18px),
    #4b2c31;
  box-shadow:
    inset 0 0 0 1px rgba(200, 40, 56, 0.3),
    inset 0 0 80px rgba(0, 0, 0, 0.5),
    0 0 0 10px #402e31,
    0 0 0 11px rgba(200, 40, 56, 0.45),
    0 0 0 18px #37272a,
    0 0 80px 10px rgba(200, 40, 56, 0.16),
    0 30px 80px rgba(0, 0, 0, 0.7);
  transition: box-shadow 300ms ease;
}
.felt::before {
  content: "";
  position: absolute; inset: 16px;
  border-radius: 50%;
  border: 1px solid rgba(245, 235, 236, 0.045);
  transition: border-color 250ms ease, box-shadow 250ms ease;
}
.felt.drop-ready::before { border: 1px dashed rgba(200, 40, 56, 0.5); }
.felt.drop-over::before { border-color: var(--accent-bright); box-shadow: 0 0 40px rgba(200, 40, 56, 0.25), inset 0 0 40px rgba(200, 40, 56, 0.12); }
.felt-mark {
  position: absolute; left: 50%; top: 50%;
  width: min(40%, 200px); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  color: var(--text);
  opacity: 0;
  transition: opacity 900ms ease;
  pointer-events: none;
}
.felt-mark.on { opacity: 0.045; }
.felt-mark svg { width: 100%; height: 100%; }
.slot { position: absolute; left: 50%; top: 50%; width: 0; height: 0; }
.slot .trick-card { position: absolute; --cw: var(--tcw); left: calc(var(--tcw) / -2); top: calc(var(--tcw) * -0.7); transition: transform 400ms var(--ease-out), box-shadow 400ms ease, filter 400ms ease; }
.slot-north { transform: translate(0, calc(var(--tcw) * -0.86)) rotate(3deg); }
.slot-south { transform: translate(0, calc(var(--tcw) * 0.86)) rotate(-2deg); }
.slot-west { transform: translate(calc(var(--tcw) * -1.3), 0) rotate(-7deg); }
.slot-east { transform: translate(calc(var(--tcw) * 1.3), 0) rotate(6deg); }
.trick-card.is-win {
  transform: translateY(-6px) scale(1.08);
  box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.14), 0 0 0 1px rgba(230, 57, 74, 0.8), 0 0 36px rgba(200, 40, 56, 0.4), 0 18px 34px rgba(0, 0, 0, 0.6);
  z-index: 2;
}
.trick-card.is-lose { filter: brightness(0.6) saturate(0.6); }
.led {
  position: absolute; left: 50%; top: 50%;
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(49, 35, 37, 0.8);
  box-shadow: inset 0 0 0 1px var(--border-medium);
  font: 500 9.5px/1 var(--mono); letter-spacing: 0.12em; color: var(--body);
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  transition: opacity 250ms ease, transform 300ms var(--ease-out);
  z-index: 3;
  pointer-events: none;
}
.led.on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.led svg { width: 13px; height: 13px; }
.led.red svg { color: var(--accent-bright); }
.led.black svg { color: var(--text); }

/* Hand */
.hand-area { width: 100%; padding: 0 16px max(14px, env(safe-area-inset-bottom)); }
.hand-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 920px; margin: 0 auto; padding: 4px 4px 0;
  min-height: 38px;
}
.hint { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--body); transition: color 200ms ease; min-width: 0; }
.hint.on { color: var(--text); }
.hint .pip { width: 15px; height: 15px; vertical-align: -2px; display: inline-block; }
.hint .pip-hearts, .hint .pip-diamonds { color: var(--accent-bright); }
.hint .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-bright); box-shadow: 0 0 10px var(--accent-bright); flex: none; }
.hint.flash { animation: hint-flash 500ms ease; }
@keyframes hint-flash { 30% { color: var(--accent-bright); } }
.btn-sort svg { width: 15px; height: 15px; }

.hand {
  position: relative;
  max-width: 1000px;
  height: calc(var(--cw) * 1.4 + 46px);
  margin: 0 auto;
}
.hslot {
  position: absolute;
  left: 50%;
  bottom: 10px;
  width: var(--cw);
  transform-origin: 50% 130%;
  transform: translate(calc(-50% + var(--x, 0px)), var(--y, 0px)) rotate(var(--r, 0deg));
  transition: transform 420ms var(--ease-out);
  touch-action: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}
.hslot .pcard { transition: transform 200ms var(--ease-out), box-shadow 220ms ease, filter 220ms ease; }
.hand.my-turn .hslot:not(.playable) .pcard { filter: brightness(0.55) saturate(0.6); }
.hand.my-turn .hslot.playable { cursor: grab; }
.hand.my-turn .hslot.playable .pcard {
  box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.1), 0 0 0 1px rgba(200, 40, 56, 0.4), 0 8px 24px rgba(0, 0, 0, 0.55);
}
@media (hover: hover) and (pointer: fine) {
  .hand.my-turn .hslot.playable:hover .pcard { transform: translateY(-14px); }
}
.hslot:focus-visible .pcard { transform: translateY(-14px); box-shadow: 0 0 0 2px var(--accent-bright), 0 8px 24px rgba(0, 0, 0, 0.55); }
.hslot.selected .pcard,
.hand.my-turn .hslot.selected:hover .pcard {
  transform: translateY(-30px);
  box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.14), 0 0 0 1px var(--accent-bright), 0 0 30px rgba(200, 40, 56, 0.35), 0 20px 36px rgba(0, 0, 0, 0.6);
}
.hslot.dragging { transition: none; z-index: 200 !important; cursor: grabbing; }
.hslot.dragging .pcard { transform: scale(1.1); box-shadow: inset 0 1px 0 rgba(245, 235, 236, 0.14), 0 0 0 1px var(--accent-bright), 0 32px 64px rgba(0, 0, 0, 0.75); }
.hslot.shake .pcard { animation: shake 360ms ease; }
@keyframes shake { 20% { transform: translateX(-5px); } 45% { transform: translateX(4px); } 70% { transform: translateX(-2px); } }

/* Round-end modal */
.modal-back {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 80px 20px 20px;
  background: rgba(49, 35, 37, 0.62);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 300ms ease;
}
.modal-back.in { opacity: 1; }
.modal {
  position: relative;
  width: min(480px, 100%);
  padding: 40px 36px 32px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-card), 0 40px 100px rgba(0, 0, 0, 0.6);
  text-align: center;
  transform: scale(0.96) translateY(10px);
  opacity: 0;
  transition: transform 420ms var(--ease-out), opacity 300ms ease;
}
.modal.win { box-shadow: var(--shadow-card), var(--shadow-featured), 0 40px 100px rgba(0, 0, 0, 0.6); }
.modal-back.in .modal { transform: none; opacity: 1; }
.modal-icon {
  position: relative;
  width: 64px; height: 64px; margin: 0 auto;
  border-radius: 18px;
  display: grid; place-items: center;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-medium);
  color: var(--body);
}
.modal.win .modal-icon { color: var(--accent-bright); box-shadow: inset 0 0 0 1px var(--border-accent), 0 0 30px rgba(200, 40, 56, 0.25); }
.modal-icon svg { width: 30px; height: 30px; }
.modal-title { margin-top: 22px; font-size: clamp(30px, 4vw, 42px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; color: var(--text); }
.modal-sub { margin-top: 10px; font-size: 15px; }
.kot-badge { display: inline-block; margin-top: 14px; padding: 5px 12px; border-radius: 999px; font: 500 11px/1 var(--mono); letter-spacing: 0.1em; color: var(--accent); border: 1px solid var(--border-accent); box-shadow: 0 0 18px rgba(200, 40, 56, 0.25); }
.result-grid { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; margin-top: 28px; }
.result-team { padding: 18px 12px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-subtle); }
.result-team.won { box-shadow: inset 0 0 0 1px var(--border-accent), 0 0 24px rgba(200, 40, 56, 0.14); }
.result-team .rt-name { font: 500 10.5px/1.3 var(--mono); letter-spacing: 0.08em; color: var(--body); }
.result-team.t0 .rt-name { color: var(--accent); }
.result-team .rt-tricks { margin-top: 10px; font-size: 44px; font-weight: 800; letter-spacing: -0.04em; color: var(--text); line-height: 1; }
.result-team .rt-lbl { margin-top: 4px; font: 500 10px/1 var(--mono); letter-spacing: 0.1em; color: var(--tertiary); }
.result-team .rt-pts { margin-top: 12px; font-size: 13px; color: var(--body); }
.result-vs { font: 500 11px/1 var(--mono); color: var(--tertiary); letter-spacing: 0.1em; }
.award { margin: 22px 0 24px; font-size: 14px; color: var(--body); }
.award b { color: var(--text); }
.spark { position: absolute; left: 50%; top: 50%; width: 12px; height: 12px; margin: -6px; color: var(--accent-bright); pointer-events: none; }
.spark svg { width: 12px; height: 12px; --pip-fill: rgba(200, 40, 56, 0.3); }

/* Toasts — transitions (not keyframes) so rapid notifications retarget cleanly */
.toasts {
  position: absolute; top: 72px; right: 20px; z-index: 30;
  display: flex; flex-direction: column; align-items: flex-end; gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  max-width: 360px;
  padding: 11px 16px 11px 12px;
  border-radius: 12px;
  background: rgba(71, 51, 54, 0.95);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-card), 0 12px 32px rgba(0, 0, 0, 0.5);
  font-size: 13.5px;
  color: var(--text);
  opacity: 0;
  transform: translateX(24px);
  transition: transform 360ms var(--ease-out), opacity 240ms ease;
}
.toast.in { opacity: 1; transform: none; }
.toast.out { opacity: 0; transform: translateX(24px); }
.toast b { font-weight: 600; color: var(--accent-bright); }
.toast .t-meta { font: 500 10.5px/1 var(--mono); letter-spacing: 0.06em; color: var(--tertiary); margin-left: 4px; }
.toast-ic { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-subtle); color: var(--accent-bright); box-shadow: inset 0 0 0 1px rgba(200, 40, 56, 0.3); }
.toast-ic svg { width: 15px; height: 15px; }
.toast-error { box-shadow: var(--shadow-card), 0 0 0 1px rgba(255, 71, 87, 0.35), 0 12px 32px rgba(0, 0, 0, 0.5); }
.toast-error .toast-ic { color: var(--alert); background: rgba(255, 71, 87, 0.08); box-shadow: inset 0 0 0 1px rgba(255, 71, 87, 0.35); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .app-chrome { height: 54px; padding: 0 12px; }
  .app-logo .logo-word, .conn-label { display: none; }
  .screen { padding: 74px 12px 20px; }
  .screen-table { padding: 54px 0 0; }
  .panel, .wait-panel, .trump-panel { padding: 36px 22px 26px; }
  .wait-head { flex-direction: column; align-items: flex-start; }
  .code-box { align-items: flex-start; }
  .teams { grid-template-columns: 1fr; gap: 12px; }
  .vs { text-align: center; }
  .wait-action { margin-left: 0; width: 100%; min-width: 0; }
  .wait-action .btn { width: 100%; }
  .suit-grid { gap: 8px; }
  .toasts { left: 12px; right: 12px; top: 64px; align-items: stretch; }
  .toast { max-width: none; }

  .table { --cw: clamp(52px, 15vw, 64px); --tcw: clamp(44px, 12vw, 56px); }
  .tb-top { padding: 10px 12px 4px; gap: 8px; }
  .tb-names { display: none; }
  .tb-pts { font-size: 24px; }
  .tricks .tp, .tricks .tp svg { width: 9px; height: 9px; }
  .tricks { gap: 3px; }
  .tb-hokm { padding: 7px 10px 7px 7px; gap: 8px; }
  .tb-hokm-icon { width: 30px; height: 30px; }
  .tb-hokm-txt b { font-size: 13px; }
  .arena { padding: 4px 10px; grid-template-columns: 60px minmax(0, 1fr) 60px; gap: 4px 6px; }
  .seat .avatar { width: 36px; height: 36px; font-size: 14px; }
  .seat-west .backs, .seat-east .backs, .seat-north .backs { display: none; }
  .seat-label .nm { max-width: 64px; font-size: 12px; }
  .felt { min-height: 170px; }
  .slot-west { transform: translate(calc(var(--tcw) * -1.05), 0) rotate(-7deg); }
  .slot-east { transform: translate(calc(var(--tcw) * 1.05), 0) rotate(6deg); }
  .hint { font-size: 12.5px; }
  .modal { padding: 32px 22px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .app, .app.is-open { transition: opacity 300ms ease, visibility 0s linear 300ms; clip-path: none; opacity: 0; }
  .app.is-open { opacity: 1; transition: opacity 300ms ease, visibility 0s; }
  .app-orb, .seat.is-active .avatar::after, .seat-slot.empty::after { animation: none; }
  .stagger > *, .lobby-mark .lm-card, .code-tile, .seat-slot.pop { animation-name: fade-only; }
  .screen, .screen.is-leaving { transform: none; }
  .hslot { transition-duration: 1ms; }
}
@keyframes fade-only { from { opacity: 0; } }

/* ---------- Phone table (overrides) ---------- */
@media (max-width: 720px) {
  .table { --cw: clamp(56px, 17.5vw, 74px); --tcw: clamp(46px, 13vw, 58px); }
  .tb-top { padding: 8px 12px 2px; }
  .tb-team-label { font-size: 9.5px; }
  .arena {
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    padding: 2px 8px;
    gap: 2px 4px;
    align-items: center;
  }
  .felt {
    min-height: 0;
    width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1.32;
    align-self: center;
    margin: 10px 2px;
    box-shadow:
      inset 0 0 0 1px rgba(200, 40, 56, 0.3),
      inset 0 0 50px rgba(0, 0, 0, 0.8),
      0 0 0 6px #402e31,
      0 0 0 7px rgba(200, 40, 56, 0.45),
      0 0 0 11px #37272a,
      0 0 40px 4px rgba(200, 40, 56, 0.14);
  }
  .felt::before { inset: 10px; }
  .slot-north { transform: translate(0, calc(var(--tcw) * -0.92)) rotate(3deg); }
  .slot-south { transform: translate(0, calc(var(--tcw) * 0.92)) rotate(-2deg); }
  .slot-west { transform: translate(calc(var(--tcw) * -1.02), 0) rotate(-7deg); }
  .slot-east { transform: translate(calc(var(--tcw) * 1.02), 0) rotate(6deg); }

  .seat .avatar { width: 34px; height: 34px; font-size: 14px; border-radius: 10px; }
  .seat-north { flex-direction: row; gap: 8px; }
  .seat-north .seat-label .nm { max-width: 110px; }
  .seat-west, .seat-east { gap: 4px; }
  .seat-west .seat-label, .seat-east .seat-label { flex-direction: column; gap: 3px; }
  .seat-west .seat-label .nm, .seat-east .seat-label .nm { max-width: 52px; font-size: 11px; }
  .seat-sub { font-size: 9px; letter-spacing: 0.06em; }
  .seat .chip { padding: 2px 5px; font-size: 8.5px; }
  .seat-south { gap: 10px; padding-top: 2px; }

  .hand-area { padding: 0 6px max(8px, env(safe-area-inset-bottom)); }
  .hand-bar { min-height: 34px; padding: 2px 6px 0; }
  .hand { height: calc(var(--cw) * 1.4 + 34px); }
  .hslot { bottom: 14px; }
  .hand { height: calc(var(--cw) * 1.4 + 42px); }

  .toasts { top: 112px; bottom: auto; }
  .toast { padding: 8px 12px 8px 8px; font-size: 12.5px; }
  .toast-ic { width: 24px; height: 24px; }

  .trump-hand { gap: 6px; --cw: clamp(52px, 16vw, 64px); flex-wrap: nowrap; }
  .suit-grid .suit-btn { padding: 14px 0 12px; }
  .suit-grid .suit-btn .pip { width: 28px; height: 28px; }
  .suit-grid .suit-btn span { font-size: 9.5px; }
}

/* Face-down cards (non-Hakem players during the trump call) */
.pcard.pback-card {
  background:
    repeating-linear-gradient(45deg, rgba(200, 40, 56, 0.24) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(-45deg, rgba(200, 40, 56, 0.24) 0 1px, transparent 1px 7px),
    var(--card);
}
.pcard.pback-card::before { border-color: rgba(200, 40, 56, 0.4); }
