/* Professional Graffiti Domino — felt table, ivory pip tiles, flat hand.
   Sits inside #screen-game; never overlaps the tab bar or order bar. */

#screen-game.is-playing .topbar { display: none; }
#screen-game.is-playing #gameBody,
#screen-game.is-playing .game-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.dom-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Lobby ---------- */
.dom-lobby {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 20px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,138,20,.16), transparent 55%),
    linear-gradient(180deg, #1a1410, #12100e);
}
.lobby-ident { text-align: center; margin: 4px 0 16px; }
.lobby-ident .av-lg {
  width: 72px; height: 72px; margin: 0 auto 8px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 36px;
  background: radial-gradient(circle at 30% 30%, #3a2a1c, #1a120c);
  border: 3px solid #f79622;
  box-shadow: 0 0 0 4px rgba(247,150,34,.2), 0 8px 18px rgba(0,0,0,.45);
}
.lobby-ident b {
  display: block;
  font-family: var(--display, Lalezar, Cairo, sans-serif);
  font-weight: 400;
  font-size: 26px;
  line-height: 1.1;
}
.lobby-ident span { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }

.pref-row { margin: 0 0 12px; }
.pref-row > span {
  display: block;
  font-size: 11px;
  font-weight: 800;
  color: #cbb892;
  margin-bottom: 6px;
  letter-spacing: .04em;
}
.seg { display: flex; background: #1a140f; border-radius: 12px; padding: 3px; border: 1px solid rgba(255,255,255,.06); }
.seg button {
  flex: 1;
  min-height: 36px;
  border-radius: 10px;
  font-weight: 800;
  font-size: 13px;
  color: #b9a894;
}
.seg button.is-on { background: #f79622; color: #1a120c; box-shadow: 0 2px 0 #9a5a10; }

.mode-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: start;
  margin: 0 0 10px;
  padding: 14px 14px;
  border-radius: 16px;
  background: linear-gradient(180deg, #2c221a, #201910);
  border: 1.5px solid rgba(247,150,34,.35);
  box-shadow: 0 6px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
  color: inherit;
}
.mode-card:active { transform: translateY(2px); box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.mode-card .ico {
  width: 52px; height: 52px; flex: 0 0 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-size: 26px;
  background: #1a120c;
}
.mode-card.chef .ico { background: linear-gradient(180deg, #5c2010, #2a1208); }
.mode-card.match .ico { background: linear-gradient(180deg, #0d4a2a, #082618); }
.mode-card.room .ico { background: linear-gradient(180deg, #3a2a08, #1a1406); }
.mode-card b { display: block; font-size: 17px; font-family: var(--display, Lalezar, Cairo, sans-serif); font-weight: 400; }
.mode-card span { display: block; font-size: 12px; color: #b9a894; }
.mode-card .room-row { display: flex; gap: 8px; margin-top: 8px; }
.mode-card input {
  flex: 1; min-height: 42px; text-align: center;
  letter-spacing: .28em; text-transform: uppercase; font-weight: 800;
  background: #140f0c; border: 1px solid #3a2e22; border-radius: 10px; color: #f6efe4; font-size: 16px;
}
.mode-card .join { min-height: 42px; padding: 0 14px; background: #f79622; color: #1a120c; font-weight: 800; border-radius: 10px; }
.mode-card .ghost-link {
  margin-top: 8px; font-size: 12px; font-weight: 800; color: #f79622; background: none;
}
.lobby-status { text-align: center; min-height: 22px; color: #f7c43a; font-size: 13px; font-weight: 700; margin: 6px 0; }
.lobby-note { text-align: center; font-size: 11px; color: var(--muted); margin: 8px 0 0; }

/* ---------- Play table ---------- */
.dom-play {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  background: #0a0705;
  position: relative;
}
.hud-top {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px 6px;
  background: linear-gradient(180deg, #2a1e14, #1a120c);
  border-bottom: 1px solid rgba(247,150,34,.25);
  z-index: 3;
}
.hud-back {
  width: 36px; height: 36px; border-radius: 10px;
  background: rgba(255,255,255,.06);
  color: #f6efe4; font-size: 22px; line-height: 1;
}
.opp-card { display: flex; align-items: center; gap: 8px; min-width: 0; }
.av-ring { position: relative; width: 44px; height: 44px; flex: 0 0 44px; }
.av-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.av-ring .trk { fill: none; stroke: rgba(255,255,255,.12); stroke-width: 3; }
.av-ring .prg { fill: none; stroke: #f79622; stroke-width: 3; stroke-linecap: round; }
.av-ring.is-mine .prg { stroke: #3ddb5d; }
.av-ring .av {
  position: absolute; inset: 5px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 20px;
  background: #1a120c;
}
.opp-meta { min-width: 0; }
.opp-meta b { display: block; font-size: 14px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.opp-meta span { font-size: 11px; color: #b9a894; }
.opp-backs { display: flex; align-items: center; }
.opp-backs .dtile.back {
  width: 16px; height: 28px; margin-inline-start: -8px;
  border-radius: 3px;
}
.opp-backs .dtile.back:first-child { margin: 0; }
.scoreboard {
  display: flex; flex-direction: column; align-items: end; gap: 1px;
  font-size: 11px; font-weight: 800; color: #f6efe4; line-height: 1.25;
}
.scoreboard .you { color: #3ddb5d; }
.scoreboard .them { color: #f7c43a; }
.scoreboard .rnd { color: #b9a894; font-weight: 700; }

.table-wrap {
  flex: 1; min-height: 0;
  margin: 6px 8px 0;
  position: relative;
  border-radius: 16px;
  padding: 10px;
  background:
    linear-gradient(180deg, #5a3a1a, #2a180c);
  box-shadow:
    0 0 0 1px rgba(255,200,80,.15) inset,
    0 10px 18px rgba(0,0,0,.45);
}
.table-felt {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(0,0,0,0) 30%, rgba(0,0,0,.55) 100%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px),
    radial-gradient(circle at 30% 20%, rgba(247,150,34,.08), transparent 40%),
    linear-gradient(160deg, #1c5a32 0%, #124226 40%, #0b2a18 100%);
  box-shadow: inset 0 0 40px rgba(0,0,0,.45);
  touch-action: none;
}
.table-felt .wm {
  position: absolute; left: 50%; top: 50%;
  width: 42%; max-width: 160px;
  transform: translate(-50%, -50%);
  opacity: .12;
  pointer-events: none;
  filter: grayscale(.2);
}
.table-felt .drip {
  position: absolute; pointer-events: none; opacity: .35;
  width: 70px; height: 70px; object-fit: contain;
}
.table-felt .drip-o { top: -8px; inset-inline-start: -6px; }
.table-felt .drip-p { bottom: -10px; inset-inline-end: -8px; width: 80px; }
.table-felt .drip-g { top: 30%; inset-inline-end: -12px; width: 54px; opacity: .22; }

#chain { position: absolute; inset: 0; pointer-events: none; }
.board-tile {
  position: absolute;
  transform-origin: center center;
  /* No scale on the whole chain — scaling shrinks tiles around their
     center and leaves big gaps (what Ali saw on iPhone). */
}
.board-tile.is-new { animation: tileIn .28s cubic-bezier(.22,.8,.24,1) both; }
@keyframes tileIn {
  from { transform: translateY(-4px); opacity: .35; }
  to { transform: none; opacity: 1; }
}

/* Ivory pip tiles */
.dtile {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: linear-gradient(165deg, #fffaf0 0%, #f4e7c9 48%, #e2d0a8 100%);
  border-radius: 6px;
  border: 1px solid rgba(80,50,20,.28);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    inset 0 -2px 3px rgba(80,50,20,.16),
    0 3px 6px rgba(0,0,0,.4);
  overflow: hidden;
  position: relative;
  user-select: none;
}
.dtile.hz { flex-direction: row; }
.dtile .face { flex: 1 1 0; display: grid; place-items: center; min-width: 0; min-height: 0; }
.dtile .pips {
  width: 72%; height: 72%;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
}
.dtile .pips i {
  width: 55%; height: 55%;
  max-width: 10px; max-height: 10px;
  justify-self: center; align-self: center;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 32%, #5a3a22, #1a0c08 70%);
  box-shadow: inset 0 0.5px 0 rgba(255,255,255,.2), 0 1px 1px rgba(0,0,0,.35);
}
.dtile .rail {
  position: relative;
  flex: 0 0 4px;
  background: linear-gradient(#d8c392, #9a7a48);
  display: grid; place-items: center;
  z-index: 1;
}
.dtile.hz .rail { flex: 0 0 4px; width: 4px; align-self: stretch; }
.dtile .pin {
  width: 6px; height: 6px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f6e7b8, #8a6418 62%, #4a3008);
  box-shadow: 0 0 0 1px rgba(60,40,10,.45), 0 1px 1px rgba(0,0,0,.35);
}
.dtile.back {
  background:
    repeating-linear-gradient(45deg, #6a2810 0 5px, #8a3a14 5px 10px);
  border-color: #3a1408;
}
.dtile.back .face, .dtile.back .rail { visibility: hidden; }
.dtile.back .back-mark {
  position: absolute; inset: 12%;
  border: 1.5px solid rgba(247,150,34,.55);
  border-radius: 3px;
  background: rgba(26,18,12,.25);
}

/* Ends / drop zones — glow sits NEXT to the open end, never on a tile */
.end-z {
  position: absolute;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  background: rgba(247,150,34,.16);
  border: 2px solid rgba(247,150,34,.9);
  box-shadow: 0 0 0 5px rgba(247,150,34,.12), 0 0 14px rgba(247,150,34,.55);
  pointer-events: auto;
  z-index: 4;
  padding: 0;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.end-z.is-start { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
.end-z.is-hot, .end-z.is-legal.is-drag {
  background: rgba(247,150,34,.55);
  transform: scale(1.15);
  box-shadow: 0 0 0 7px rgba(247,150,34,.2), 0 0 16px rgba(247,150,34,.7);
}
.end-z.is-legal { animation: pulseEnd 1.4s ease-in-out infinite; }
@keyframes pulseEnd { 50% { box-shadow: 0 0 0 10px rgba(247,150,34,0), 0 0 14px rgba(247,150,34,.15); } }

.yard {
  position: absolute;
  inset-inline-start: 8px; bottom: 8px;
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px 4px 4px;
  background: rgba(0,0,0,.35);
  border-radius: 8px;
  color: #f6efe4; font-size: 11px; font-weight: 800;
  pointer-events: none;
}
.yard .dtile.back { width: 18px; height: 32px; }

.turn-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 0;
  position: relative;
  flex: 0 0 auto;
}
.turn-banner {
  flex: 1; min-width: 0;
  text-align: center;
  font-size: 13px; font-weight: 800;
  padding: 0;
  color: #f7c43a;
  min-height: 20px;
  text-shadow: 0 1px 2px #000;
}
.turn-banner.mine { color: #3ddb5d; }
.react-toggle {
  flex: 0 0 32px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(247,150,34,.35);
  font-size: 16px;
  line-height: 1;
}

.play-bar { display: flex; justify-content: center; padding: 4px 10px 0; min-height: 8px; }
.play-bar .act {
  min-height: 40px; padding: 0 22px;
  border-radius: 999px;
  background: #f79622; color: #1a120c;
  font-weight: 800; font-size: 14px;
  box-shadow: 0 3px 0 #9a5a10;
}
.play-bar .act:disabled { opacity: .4; box-shadow: none; }

.reacts {
  display: none;
  position: absolute;
  inset-inline-end: 8px;
  bottom: 38px;
  background: #1a120c;
  border: 1px solid rgba(247,150,34,.45);
  border-radius: 999px;
  padding: 6px;
  gap: 4px;
  z-index: 8;
  box-shadow: 0 8px 20px rgba(0,0,0,.45);
}
.reacts.is-open, .reacts:not([hidden]) { display: flex; }
.reacts[hidden] { display: none !important; }
.reacts button {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.07);
  font-size: 16px;
}
.reacts button:active { transform: scale(.9); }
.floater {
  position: absolute; font-size: 28px; pointer-events: none; z-index: 6;
  animation: floatUp .9s ease-out forwards;
}
@keyframes floatUp {
  from { transform: translate(-50%, 0) scale(.6); opacity: 0; }
  30% { opacity: 1; }
  to { transform: translate(-50%, -48px) scale(1.2); opacity: 0; }
}

/* Flat upright hand — no fan, no overlap, pips fully visible */
.fan, .hand {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: stretch;
  gap: var(--hand-gap, 8px);
  width: 100%;
  box-sizing: border-box;
  padding: 14px 10px 10px; /* top pad leaves room for the legal-tile lift */
  z-index: 5;
}
.hand-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--hand-gap, 8px);
  width: 100%;
  flex: 0 0 auto;
  min-height: var(--hand-h, 96px);
}
.fan .tile-btn {
  position: relative;
  left: auto; bottom: auto;
  width: var(--hand-w, 48px);
  height: var(--hand-h, 96px);
  flex: 0 0 var(--hand-w, 48px);
  flex-shrink: 0;
  margin: 0;
  background: none; border: 0; padding: 0;
  transform: none;
  transform-origin: center bottom;
  transition: transform .18s cubic-bezier(.22,.8,.24,1), filter .18s ease, opacity .18s ease;
  touch-action: none;
  z-index: 1;
}
.fan .tile-btn .dtile { width: 100%; height: 100%; }
.fan .tile-btn.is-legal {
  z-index: 2;
  transform: translateY(-8px);
  filter: drop-shadow(0 0 6px rgba(247,150,34,.7));
}
.fan .tile-btn.is-legal .dtile { box-shadow: inset 0 1px 0 #fff, 0 0 0 2px #f79622, 0 6px 10px rgba(0,0,0,.4); }
.fan .tile-btn.is-dim { opacity: .62; filter: none; pointer-events: none; }
.fan .tile-btn.is-picked,
.fan .tile-btn.is-legal:active {
  transform: translateY(-12px);
  z-index: 6;
}
.fan .tile-btn.is-drag { opacity: 0; }

.drag-ghost {
  position: fixed;
  width: var(--hand-w, 48px); height: var(--hand-h, 96px);
  margin: 0;
  transform: translate(-50%, -50%) scale(1.05);
  z-index: 40;
  pointer-events: none;
  filter: drop-shadow(0 12px 16px rgba(0,0,0,.5));
}

/* Overlays */
.dom-overlay {
  position: absolute; inset: 0;
  background: rgba(8,6,4,.72);
  z-index: 12;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.dom-card {
  width: 100%; max-width: 320px;
  text-align: center;
  background: linear-gradient(180deg, #2c221a, #1a120c);
  border: 2px solid #f79622;
  border-radius: 20px;
  padding: 22px 18px 18px;
  box-shadow: 0 18px 40px rgba(0,0,0,.5);
  position: relative;
}
.dom-card h2 {
  margin: 8px 0 6px;
  font-family: var(--display, Lalezar, Cairo, sans-serif);
  font-weight: 400; font-size: 28px;
}
.dom-card p { color: #b9a894; font-size: 13px; margin: 0 0 14px; }
.dom-card .cta, .dom-card .ghost {
  width: 100%; justify-content: center; margin-top: 8px; min-height: 46px;
}
.dom-card .ghost {
  background: transparent; border: 1.5px dashed #f79622; color: #f6efe4;
  border-radius: 12px; font-weight: 800;
}
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 20px; }
.confetti i {
  position: absolute; top: -8px; width: 8px; height: 10px; border-radius: 1px;
  animation: fall 1.2s linear forwards;
}
@keyframes fall {
  to { transform: translateY(280px) rotate(280deg); opacity: 0; }
}

#gameBody.waiting .lobby-status { animation: pulse 1.2s ease infinite; }

/* Nick gate, presence, share, offers, reconnect */
.nick-gate { flex: 1; overflow-y: auto; padding: 20px 16px 24px; background: linear-gradient(180deg, #1a1410, #12100e); }
.nick-gate h2 { text-align: center; font-family: var(--display, Lalezar, Cairo, sans-serif); font-weight: 400; font-size: 28px; margin: 8px 0 6px; }
.nick-gate .lead { text-align: center; color: #b9a894; font-size: 13px; margin: 0 0 18px; }
.nick-gate .av-pick { display: flex; justify-content: center; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.nick-gate .av-pick button { width: 44px; height: 44px; border-radius: 50%; font-size: 22px; background: #1a120c; border: 2px solid transparent; }
.nick-gate .av-pick button.is-on { border-color: #f79622; box-shadow: 0 0 0 3px rgba(247,150,34,.25); }
.nick-gate input[type="text"] {
  width: 100%; min-height: 48px; text-align: center; font-size: 18px; font-weight: 800;
  border-radius: 12px; border: 1.5px solid rgba(247,150,34,.4);
  background: #140f0c; color: #f6efe4; margin-bottom: 10px;
}
.nick-gate .hint { text-align: center; font-size: 11px; color: #b9a894; margin: 0 0 12px; }
.nick-gate .cta { width: 100%; justify-content: center; }
.nick-gate .shuffle { width: 100%; margin-top: 8px; background: none; color: #f79622; font-weight: 800; font-size: 13px; }

.presence-pill {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0 0 12px; font-size: 13px; font-weight: 800; color: #c8f0d0;
}
.presence-pill i {
  width: 8px; height: 8px; border-radius: 50%; background: #3ddb5d;
  box-shadow: 0 0 0 4px rgba(61,219,93,.2);
  animation: pulse 1.4s ease infinite;
}
.search-card {
  text-align: center; padding: 14px 12px; margin: 0 0 12px;
  background: #1a140f; border-radius: 14px; border: 1px solid rgba(247,150,34,.3);
}
.search-card .count { font-family: var(--display, Lalezar, Cairo, sans-serif); font-size: 42px; font-weight: 400; color: #f79622; line-height: 1; }
.search-card p { margin: 6px 0 0; color: #b9a894; font-size: 13px; }

.share-row { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }
.share-row .cta, .share-row .ghost-link { justify-content: center; }
.share-url {
  font-size: 11px; color: #cbb892; word-break: break-all; text-align: center;
  background: #140f0c; border-radius: 8px; padding: 8px;
}

.live-banner {
  position: absolute; left: 10px; right: 10px; top: 8px;
  z-index: 8;
  background: rgba(20,14,8,.92);
  border: 1px solid #f7c43a;
  color: #f6efe4;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px; font-weight: 800;
  text-align: center;
  pointer-events: none;
}
.offer-card .opp { font-size: 22px; margin: 0 0 4px; }
.dom-lobby { padding: 8px 14px 18px; }
.lobby-ident { margin: 0 0 10px; }
.lobby-ident .av-lg { width: 64px; height: 64px; font-size: 32px; margin-bottom: 6px; }
.lobby-ident b { font-size: 22px; }
.lobby-ident span { max-width: 280px; margin-inline: auto; }
.mode-card { padding: 12px; margin-bottom: 8px; }
.mode-card .ico { width: 44px; height: 44px; flex-basis: 44px; font-size: 22px; border-radius: 12px; }
.pref-row { margin: 0 0 8px; }
.mode-card .room-row { width: 100%; min-width: 0; }
.mode-card .room-row input { min-width: 0; letter-spacing: .18em; }
.hud-top { padding: 6px 8px 4px; }
.scoreboard { font-size: 10px; }
.mode-card { overflow: hidden; }
.mode-card > div { flex: 1; min-width: 0; }
.mode-card .room-row { min-width: 0; }
.mode-card .join { flex: 0 0 auto; padding: 0 12px; max-width: 40%; }
.over-score { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin: 0 0 8px; }
.over-score span { direction: ltr; unicode-bidi: isolate; }
