/* Domino: the other players and the bank on top, the table with the line of tiles in the middle,
   a line about the last move, the bar with the status and the buttons, the viewer's tiles at the bottom. */
.domino{
  position:absolute;inset:0;
  display:grid;grid-template-rows:auto minmax(0,1fr) auto auto auto;grid-template-columns:minmax(0,1fr);
  overflow:hidden;
}

/* ── tiles ───────────────────────────────────────────────────────────── */
.domino-t svg,.domino-h svg,.domino-mini svg,.domino-ghost svg,.domino-target svg{display:block;width:100%;height:100%;overflow:visible}
.dt-face{fill:var(--ivory);stroke:rgba(0,0,0,.28);stroke-width:1.2}
.dt-bar{stroke:var(--ink);stroke-opacity:.42;stroke-width:1.6;stroke-linecap:round}
.dt-pin{fill:var(--gold);stroke:var(--ink);stroke-opacity:.35;stroke-width:.6}
.dt-pip{fill:var(--ink)}
.dt-back{fill:var(--ink);stroke:var(--gold);stroke-opacity:.55;stroke-width:1.6}
.dt-dot{fill:var(--gold);opacity:.8}

/* ── the other players and the bank ──────────────────────────────────── */
.domino-top{
  display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:4px;
  width:100%;max-width:36rem;margin:0 auto;padding:8px 8px 0;
}
.domino-others{display:flex;justify-content:space-evenly;align-items:flex-start;gap:4px;min-width:0}
.domino-seat{
  flex:0 1 112px;min-width:0;
  display:grid;justify-items:center;gap:1px;text-align:center;
}
.domino-others[data-n="3"] .domino-seat:nth-child(even){margin-top:12px}
.domino-seat .ava{width:42px;height:42px;font-size:1.2rem;margin-bottom:3px}
.domino-seat .nm{
  max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  font-size:.82rem;font-weight:600;line-height:1.3;
}
.domino-seat .sub{font-size:.72rem;line-height:1.2;color:var(--mist)}
.domino-seat.off .ava,.domino-seat.off .nm{opacity:.45}
.domino-seat.off .sub{color:var(--gold)}
.domino-seat.turn .ava,.domino-me.turn .ava{
  box-shadow:0 0 0 2.5px var(--gold),0 0 0 8px rgba(255,198,92,.2);
  animation:pulse 1.7s ease-in-out infinite;
}
.domino-fan{display:inline-flex;align-items:center;height:22px}
.domino-back{
  display:inline-block;width:9px;height:18px;margin-left:-4px;border-radius:2.5px;
  background:var(--ink);box-shadow:inset 0 0 0 1px rgba(255,198,92,.55),0 1px 2px rgba(0,0,0,.4);
}
.domino-fan .domino-back:first-child{margin-left:0}
.domino-fan b{margin-left:6px;font:400 1.15rem/1 var(--display)}
.domino-pts{
  display:inline-grid;place-items:center;min-width:34px;height:22px;padding:0 .55em;border-radius:999px;
  background:rgba(0,0,0,.24);color:var(--gold);font-size:.78rem;font-weight:700;white-space:nowrap;
}
.domino-bank{
  position:relative;flex:none;width:52px;height:60px;margin-top:2px;padding:0;
  border:0;border-radius:10px;background:none;
  -webkit-tap-highlight-color:transparent;
}
.domino-bank:disabled{cursor:default}
.domino-pile{position:absolute;left:50%;top:4px;width:22px;height:40px;margin-left:-11px}
.domino-pile .domino-back{position:absolute;left:0;top:0;width:22px;height:40px;margin:0;border-radius:4px}
.domino-pile .domino-back:nth-child(2){translate:3px -3px}
.domino-pile .domino-back:nth-child(3){translate:6px -6px}
.domino-bank.empty .domino-pile{border:1.5px dashed var(--line);border-radius:4px}
.domino-bank.can .domino-back:last-child{box-shadow:inset 0 0 0 1px rgba(255,198,92,.55),0 0 0 2.5px var(--gold)}
.domino-bank.can .domino-pile{animation:domino-nudge 1.5s ease-in-out infinite}
@keyframes domino-nudge{50%{translate:0 -4px}}
.domino-left{
  position:absolute;left:50%;bottom:0;z-index:2;transform:translateX(-50%);
  min-width:28px;height:20px;padding:0 6px;border-radius:999px;
  background:var(--ivory);color:var(--ink);font:700 .78rem/20px var(--ui);text-align:center;
  box-shadow:0 2px 6px rgba(0,0,0,.4);
}

/* ── the table and the line ──────────────────────────────────────────── */
.domino-table{position:relative;min-height:0;margin:4px 6px 0;overflow:hidden}
.domino-line{position:absolute;inset:0}
.domino-t{
  position:absolute;left:0;top:0;display:block;
  filter:drop-shadow(0 1.5px 1.5px rgba(0,0,0,.45));
  transition:transform .4s var(--ease),width .4s var(--ease),height .4s var(--ease);
  will-change:transform;
}
/* the tile laid last glows for a moment */
.domino-t.fresh .dt-face{stroke:var(--gold);stroke-width:3}
.domino-target{
  position:absolute;left:0;top:0;z-index:3;padding:0;
  border:2px dashed var(--gold);border-radius:6px;background:rgba(255,198,92,.18);
  animation:domino-glow 1.2s ease-in-out infinite;
  -webkit-tap-highlight-color:transparent;
}
/* the end drawn as big as a tile may be small: the finger gets a full-size target */
.domino-target::before{content:"";position:absolute;inset:-12px}
@keyframes domino-glow{50%{background:rgba(255,198,92,.42)}}
.domino-peekback{position:absolute;left:50%;top:6px;z-index:4;transform:translateX(-50%)}
.domino-say{
  margin:0 auto;min-height:1.35em;max-width:24rem;padding:2px 12px 0;
  font-size:.88rem;line-height:1.35;text-align:center;color:var(--mist);
}

/* ── the bar ─────────────────────────────────────────────────────────── */
.domino-bar{
  position:relative;z-index:4;
  display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:8px;
  width:100%;max-width:36rem;margin:0 auto;padding:2px 10px 0 12px;min-height:54px;
}
.domino-me{position:relative;flex:none;display:grid;justify-items:center}
.domino-me .ava{width:40px;height:40px;font-size:1.15rem}
.domino-me .domino-pts{margin-top:-6px;position:relative;z-index:1;height:19px;font-size:.72rem;background:var(--ink)}
.domino-status{padding:.45em .9em;font-size:.92rem}
.domino-acts{display:flex;gap:6px}
.domino-acts .btn{min-height:46px;padding:.4em .9em;font-size:.95rem;white-space:nowrap}

/* ── the hand ────────────────────────────────────────────────────────── */
.domino-hand{
  --tw:44px;
  position:relative;z-index:3;
  display:flex;flex-wrap:wrap;justify-content:center;align-content:flex-start;gap:8px 6px;
  width:100%;max-width:36rem;margin:0 auto;padding:12px 6px calc(10px + env(safe-area-inset-bottom,0px));
  min-height:calc(var(--tw)*2 + 24px);
}
.domino-h{
  position:relative;flex:none;width:var(--tw);height:calc(var(--tw)*2);min-width:0;padding:0;
  border:0;border-radius:calc(var(--tw)*.16);background:none;
  filter:drop-shadow(0 2px 2px rgba(0,0,0,.45));
  transition:transform .25s var(--ease),filter .2s,opacity .2s;
  -webkit-tap-highlight-color:transparent;
}
/* a narrow tile still gets a finger-sized target */
.domino-h::before{content:"";position:absolute;inset:-4px -3px}
.domino-h.dim{filter:brightness(.55) saturate(.7) drop-shadow(0 2px 2px rgba(0,0,0,.45))}
.domino-h.sel{transform:translateY(-10px)}
.domino-h.sel .dt-face{stroke:var(--gold);stroke-width:4}
.domino-h.hinted .dt-face{stroke:var(--gold);stroke-width:4;stroke-dasharray:6 4}
.domino-h.new::after{
  content:"";position:absolute;left:50%;top:-7px;width:6px;height:6px;margin-left:-3px;
  border-radius:50%;background:var(--gold);
}
.domino-h.shake{animation:shake .3s}
.domino-ghost{position:fixed;z-index:30;width:22px;height:44px;pointer-events:none}

/* ── between rounds ──────────────────────────────────────────────────── */
.domino-result{
  position:absolute;inset:0;z-index:12;
  display:grid;align-items:center;justify-items:center;
  padding:10px;background:rgba(10,18,12,.66);
  animation:fade .25s both;
}
.domino-box{
  width:100%;max-width:26rem;max-height:100%;overflow:auto;overscroll-behavior:contain;
  padding:1.1rem 1rem .4rem;border-radius:22px;
  background:var(--ivory);color:var(--ink);text-align:center;
  box-shadow:0 10px 40px rgba(0,0,0,.5);
  animation:rise .3s var(--ease) both;
}
.domino-box h3{margin:0;font:400 1.45rem/1.15 var(--display)}
.domino-sub{margin:.2rem 0 0;font-size:.86rem;opacity:.7}
.domino-rows{margin-top:.6rem;text-align:left}
.domino-row{
  display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:3px 10px;
  padding:.5rem .15rem;border-top:1px solid rgba(0,0,0,.12);
}
.domino-row .ava{grid-row:span 2;align-self:start;width:36px;height:36px;font-size:1.05rem;color:var(--ivory);background-color:var(--ink);box-shadow:none}
.domino-row .nm{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-weight:600}
.domino-row.me .nm{font-weight:700}
.domino-row .gain{font:400 1.3rem/1 var(--display);white-space:nowrap}
.domino-row.won .gain{color:var(--cherry)}
.domino-row .left{display:flex;flex-wrap:wrap;gap:3px;min-height:26px;align-items:center}
.domino-row .left i{font-size:.82rem;opacity:.65}
.domino-row .tot{grid-column:3;grid-row:2;align-self:start;justify-self:end;font-size:.76rem;opacity:.7;white-space:nowrap}
.domino-mini{display:inline-block;width:13px;height:26px;filter:drop-shadow(0 1px 1px rgba(0,0,0,.35))}
.domino-mini .dt-face{stroke:rgba(0,0,0,.45);stroke-width:2.5}
.domino-foot{display:grid;justify-items:center}
.domino-box .btn{width:100%;margin-top:.9rem}
.domino-box .btn.primary{background:var(--ink);color:var(--ivory)}
.domino-wait{margin:.9rem 0 0;padding-top:.2rem;min-height:1.4em;font-size:.92rem;font-weight:600}
.domino-box .link{color:inherit;opacity:.7;min-height:44px}
.domino-box :focus-visible{outline-color:var(--ink)}
/* the same rows on the shell's result sheet (no avatars there) */
.domino-sum{margin-top:.6rem}
.domino-sum .domino-sub{margin:0;font-weight:600;opacity:1}
.domino-sum .domino-row{grid-template-columns:minmax(0,1fr) auto}
.domino-sum .domino-row .left{grid-column:1}
.domino-sum .domino-row .tot{grid-column:2}
.domino-sum .domino-mini .dt-face{fill:#fbf7ec}
.domino-sum .domino-mini .dt-pip{fill:#1d1a16}

/* a short screen: everything a little tighter */
@media (max-height:640px){
  .domino-top{padding-top:4px}
  .domino-seat .ava{width:36px;height:36px;font-size:1.05rem;margin-bottom:1px}
  .domino-others[data-n="3"] .domino-seat:nth-child(even){margin-top:6px}
  .domino-bank{height:54px}
  .domino-bar{min-height:50px}
  .domino-hand{padding-top:10px;padding-bottom:6px}
}
/* a narrow phone: the plates give the bank its room */
@media (max-width:359px){
  .domino-seat .nm{font-size:.76rem}
  .domino-status{font-size:.86rem;padding:.4em .7em}
  .domino-acts .btn{padding:.4em .7em}
}
/* phone held sideways: the players in one line */
@media (max-height:480px) and (orientation:landscape){
  .domino-seat{flex:0 1 auto;display:flex;align-items:center;gap:6px}
  .domino-seat .ava{flex:none;width:32px;height:32px;font-size:.95rem;margin:0}
  .domino-seat .nm{max-width:90px}
  .domino-others[data-n="3"] .domino-seat:nth-child(even){margin-top:0}
  .domino-bank{height:44px;width:44px}
  .domino-pile{top:2px;width:16px;height:30px;margin-left:-8px}
  .domino-pile .domino-back{width:16px;height:30px}
  .domino-hand{padding-top:6px;padding-bottom:4px;min-height:calc(var(--tw)*2 + 12px)}
}
