/* Dominoes: the page around the table. Phone upright first; the board takes
   whatever space the bars leave. System fonts only. */
:root{ --ink:#f6eedb; --muted:#c9c2ad; --brass:#e9c77a; --panel:rgba(10,32,26,.82); --line:rgba(246,238,219,.18); --warn:#ffcf9a; }
*{ box-sizing:border-box; }
html,body{ margin:0; height:100%; background:#123a30; color:var(--ink); overflow:hidden; overscroll-behavior:none;
  font:15px/1.35 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif; -webkit-tap-highlight-color:transparent; touch-action:manipulation; }
body{ display:grid; grid-template-rows:auto auto minmax(0,1fr) auto auto; grid-template-columns:minmax(0,1fr); height:100dvh; font-variant-numeric:lining-nums tabular-nums;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.vh{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.hidden{ display:none !important; }
#table{ position:fixed; inset:0; z-index:0; display:block; }
#top,#seats,#board,#status,#hand{ position:relative; z-index:1; }
#top{ grid-row:1; } #seats{ grid-row:2; } #board{ grid-row:3; } #status{ grid-row:4; } #hand{ grid-row:5; }   /* fixed rows: #seats leaves the flow on short screens */
button{ font:inherit; color:inherit; }
button:focus-visible{ outline:3px solid var(--brass); outline-offset:2px; }

#top{ min-width:0; display:flex; align-items:center; gap:8px; padding:8px 10px 4px; min-height:52px; }
#realmSlot{ flex:0 0 auto; min-width:0; }
.brand{ flex:1; min-width:0; display:flex; flex-direction:column; line-height:1.1; }
.brand b{ font:700 19px Georgia,"Iowan Old Style",serif; letter-spacing:.01em; }
.brand span{ font-size:12px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tools{ display:flex; gap:6px; flex:0 0 auto; margin-left:auto; }
#modeTag{ position:absolute; left:50%; top:6px; transform:translateX(-50%); font-size:12px; color:var(--muted); background:rgba(10,32,26,.6); padding:3px 10px; border-radius:999px; white-space:nowrap; pointer-events:none; }
@media (max-width:560px){ .brand{ display:none; } }
.ic{ width:44px; height:44px; border-radius:12px; border:1.5px solid var(--line); background:var(--panel); display:grid; place-items:center; cursor:pointer; padding:0; }
.ic svg{ width:22px; height:22px; fill:none; stroke:var(--ink); stroke-width:2; stroke-linecap:round; stroke-linejoin:round; }
#sndBtn svg path:first-child{ fill:var(--ink); stroke:none; }
#sndBtn .off{ display:none; } #sndBtn.muted .off{ display:inline; } #sndBtn.muted .on{ display:none; }

#seats{ display:flex; justify-content:center; gap:8px; padding:2px 10px 0; flex-wrap:wrap; }
.seat{ position:relative; display:flex; align-items:center; gap:8px; padding:6px 12px; min-height:40px; border-radius:12px; background:var(--panel); border:1.5px solid var(--line); }
.seat .nm{ font-weight:600; font-size:14px; }
.seat b{ font:700 18px system-ui,-apple-system,sans-serif; color:var(--brass); min-width:2ch; text-align:right; }
.seat.turn{ border-color:var(--brass); box-shadow:0 0 0 3px rgba(233,199,122,.25); }
.seat.turn .nm::after{ content:" ●"; color:var(--brass); font-size:10px; vertical-align:2px; }
.backs{ display:flex; align-items:center; gap:2px; }
.backs i{ width:7px; height:14px; border-radius:2px; background:#b9a57e; box-shadow:inset 0 0 0 1px rgba(0,0,0,.25); }
.backs em{ font-style:normal; font-size:12px; color:var(--muted); margin-left:4px; }
.bub{ position:absolute; left:50%; top:100%; transform:translate(-50%,4px); background:#f6eedb; color:#1d1a14; font-size:13px; font-weight:700;
  padding:3px 10px; border-radius:10px; opacity:0; pointer-events:none; transition:opacity .2s; white-space:nowrap; z-index:3; }
.bub.on{ opacity:1; }

#board{ pointer-events:none; min-height:0; }
#board .chip{ pointer-events:auto; position:absolute; display:flex; align-items:center; gap:6px; padding:4px 10px; border-radius:10px; background:var(--panel); border:1px solid var(--line); font-size:13px; }
#pile{ left:10px; bottom:6px; min-height:44px; cursor:pointer; }
#pile i{ width:12px; height:22px; border-radius:3px; background:#b9a57e; box-shadow:3px -3px 0 -1px #a08c64, inset 0 0 0 1px rgba(0,0,0,.25); }
#pile span{ font-weight:700; font-size:16px; }
#pile small{ color:var(--muted); }
#pile.go{ border-color:var(--brass); box-shadow:0 0 0 3px rgba(233,199,122,.35); }
#board #ends{ right:10px; bottom:6px; min-height:44px; pointer-events:none; }
#ends b{ color:var(--brass); font-size:16px; }
#ends .sum{ color:var(--ink); font-weight:600; }

#status{ display:flex; align-items:center; gap:8px; padding:6px 10px; min-height:56px; }
#hint{ flex:1; margin:0; font-size:14px; line-height:1.3; min-width:0; }
#hint.warn{ color:var(--warn); }
.act{ min-height:44px; padding:0 16px; border-radius:12px; border:0; background:var(--brass); color:#1d1a14; font-weight:700; cursor:pointer; box-shadow:0 3px 0 #8a6a2c; white-space:nowrap; }
.seat.me{ flex:0 0 auto; }

#hand{ display:flex; flex-wrap:wrap; justify-content:center; gap:6px; padding:4px 10px 12px; max-width:920px; margin:0 auto; width:100%; }
.tile{ width:var(--tw); padding:0; border:0; background:none; cursor:pointer; border-radius:10px; transition:transform .15s, filter .15s, opacity .15s; touch-action:none; }
.tile canvas{ display:block; filter:drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.tile.live{ transform:translateY(-6px); }
.tile.live canvas{ filter:drop-shadow(0 0 6px rgba(255,227,154,.75)) drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
.tile.dead{ opacity:.5; filter:saturate(.6); }
.tile.sel{ transform:translateY(-14px); }
.tile.sel canvas{ filter:drop-shadow(0 0 8px #ffe39a); outline:3px solid #ffe39a; border-radius:8px; }
.tile.lifted{ opacity:.25; }
.tile.fresh{ animation:fresh .5s ease-out; }
@keyframes fresh{ from{ transform:translateY(-30px); opacity:0; } }
#drag{ position:fixed; left:0; top:0; z-index:20; pointer-events:none; filter:drop-shadow(0 10px 10px rgba(0,0,0,.45)); }
#drag canvas{ width:100%; height:100%; }

#scrim{ position:fixed; inset:0; z-index:30; background:rgba(6,20,16,.55); }
.sheet{ position:fixed; z-index:31; left:50%; bottom:0; transform:translateX(-50%); width:min(560px,100%); max-height:92dvh; overflow:auto;
  background:#16392f; border:1.5px solid #8a6a3a; border-bottom:0; border-radius:18px 18px 0 0; padding:18px 18px calc(18px + env(safe-area-inset-bottom));
  box-shadow:0 -10px 40px rgba(0,0,0,.45); animation:up .22s ease-out; }
@keyframes up{ from{ transform:translate(-50%,30px); opacity:0; } }
@media (min-width:700px) and (min-height:560px){ .sheet{ bottom:auto; top:50%; transform:translate(-50%,-50%); border-radius:18px; border-bottom:1.5px solid #8a6a3a; animation:none; } }
.sheet h2{ font:700 24px/1.15 Georgia,"Iowan Old Style",serif; margin:2px 0 8px; }
.sheet h3{ font:700 17px Georgia,serif; margin:20px 0 6px; color:var(--brass); }
.sheet label{ display:block; font-size:13px; color:var(--muted); margin:10px 0 4px; }
.sheet p{ margin:6px 0; }
.sheet .kick{ text-transform:uppercase; letter-spacing:.14em; font-size:12px; color:var(--brass); margin:0; }
.sheet .note{ font-size:13px; color:var(--muted); }
.sheet .big{ font:700 34px system-ui,sans-serif; margin:6px 0; } .sheet .big small{ font-size:16px; color:var(--muted); }
.sheet .er-btn{ min-height:46px; }
.sheet .block{ display:block; width:100%; margin-top:12px; }
.row{ display:flex; gap:12px; align-items:center; justify-content:space-between; padding:12px; border-radius:12px; background:rgba(246,238,219,.06); border:1px solid var(--line); }
.row small{ display:block; color:var(--muted); font-size:13px; margin-top:2px; }
.row .er-btn{ flex:0 0 auto; }
.row2{ display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-top:10px; }
.seg{ display:flex; gap:4px; background:rgba(0,0,0,.2); border-radius:12px; padding:4px; }
.seg button{ flex:1; min-height:44px; border:0; border-radius:9px; background:none; cursor:pointer; font-weight:600; font-size:14px; padding:4px 6px; }
.seg button.on{ background:var(--brass); color:#1d1a14; }
.seg button.on::before{ content:"✓ "; }
.stats{ font-size:14px; }
.looks{ display:grid; grid-template-columns:repeat(4,1fr); gap:8px; }
.look{ display:flex; flex-direction:column; align-items:center; gap:3px; padding:6px 4px; border-radius:12px; border:1.5px solid var(--line); background:rgba(246,238,219,.05); cursor:pointer; min-height:44px; }
.look canvas{ width:100%; max-width:96px; height:auto; border-radius:6px; }
.look span{ font-size:12px; font-weight:600; text-align:center; }
.look small{ font-size:12px; color:var(--brass); }
.look.on{ border-color:var(--brass); }
.rules{ padding-left:18px; margin:6px 0; } .rules li{ margin:6px 0; }
table.score{ width:100%; border-collapse:collapse; margin:10px 0; font-size:14px; }
table.score th{ text-align:left; font-weight:600; padding:6px 4px; white-space:nowrap; }
table.score td{ padding:6px 4px; } table.score td:last-child{ text-align:right; font:700 17px system-ui,sans-serif; color:var(--brass); }
table.score td:nth-child(3){ color:var(--muted); white-space:nowrap; font-size:13px; }
table.score tr{ border-top:1px solid var(--line); }
table.score tr.w th::after{ content:" ★"; color:var(--brass); }
.mini{ display:flex; flex-wrap:wrap; gap:2px; } .mini canvas{ width:13px; height:24px; }

@media (min-width:900px){ #status{ max-width:920px; margin:0 auto; width:100%; } }
@media (max-height:520px) and (orientation:landscape){
  #top{ min-height:44px; padding-top:4px; } .brand span{ display:none; }
  #status{ min-height:46px; padding:2px 10px; } #hand{ padding-bottom:6px; }
  #seats{ position:absolute; top:4px; right:max(110px, calc(env(safe-area-inset-right) + 110px)); left:auto; padding:0; z-index:2; flex-wrap:nowrap; gap:4px; }
  #seats .seat{ min-height:44px; padding:4px 8px; gap:6px; }
  #seats .backs i{ display:none; }
  #status{ min-height:40px; } #you{ padding:4px 10px; min-height:36px; }
  #board .chip{ padding:2px 6px; font-size:12px; }
  .tile{ width:calc(var(--tw) + 8px); padding:0 4px; } #hand{ gap:0; }
  #pile,#board #ends{ bottom:auto; top:50%; transform:translateY(-50%); flex-direction:column; gap:0; max-width:64px; text-align:center; }
  #modeTag{ display:none; }
}
@media (prefers-reduced-motion: reduce){ *{ animation:none !important; transition:none !important; } }

body.about-room #hand{ padding-bottom:64px; }
