/* Project the tabletop and stacks, but keep player controls in the screen plane. */
.scene-3d {
  --indigo:#242858; --pip:clamp(21px,3.15vw,38px); --hand-w:clamp(31px,5.05vw,59px);
  background:#6b2212 url('./felt-3d.svg') center / 100% 100% no-repeat;
  border:0;border-radius:21px;box-shadow:0 18px 34px #080200a1;isolation:isolate;
  overflow:hidden;min-height:0;aspect-ratio:1.94;
  padding:2.9% 5.7% 5%;gap:0;grid-template-columns:22% minmax(0,1fr) 22%;
  grid-template-rows:26% minmax(0,1fr) auto;
}
.scene-3d::before{content:none}
.scene-3d .table-model {position:absolute;inset:0;pointer-events:none;z-index:-1;perspective:690px}
.wall-stack {position:absolute;display:flex;gap:2px;align-items:center;justify-content:center;transform-style:preserve-3d;width:36%;height:26px}
.wall-stack i {
  position:relative;display:block;width:5.15%;height:70%;border-radius:2px;
  background:linear-gradient(152deg,#51558a,#2b3066 77%);border:1px solid #696fac;
  box-shadow:0 3px 0 #303467,0 5px 0 #ded9c8,0 8px 0 #1c214d,0 11px 5px #06170c80;
}
.wall-stack i.one {box-shadow:0 3px 0 #ece4ce,0 6px 0 #222555,0 8px 4px #06170c70}
.wall-stack i[hidden]{display:none}
.stack-0{top:68%;left:32%;transform:rotateX(42deg)}
.stack-2{top:24%;left:32%;transform:rotateX(57deg)}
.stack-1{top:46%;right:0%;transform:rotateZ(71deg) rotateX(47deg)}
.stack-3{top:46%;left:0%;transform:rotateZ(-71deg) rotateX(47deg)}
.scene-3d .bot {
  width:auto;min-width:0;max-width:100%;padding:0 4px;background:none;
  border:1px solid transparent;box-shadow:none;border-radius:9px;text-shadow:0 2px 3px #0f2212;
}
.scene-3d .bot.turn,.scene-3d .player:has(.hand button:not(:disabled)){border-color:#f8d28688}
.scene-3d .bot b{display:block;max-width:100%;overflow-wrap:anywhere;color:#fff9df;font-size:clamp(.86rem,1.55vw,1.14rem);line-height:1.22}
.scene-3d .bot small{color:#f4d398;font-size:clamp(.7rem,1.15vw,.94rem);line-height:1.14}
.scene-3d .bot-1{justify-self:end;transform:rotate(16deg);margin-right:2%}
.scene-3d .bot-3{justify-self:start;transform:rotate(-16deg);margin-left:2%}
.scene-3d .bot-2{align-self:start;min-width:clamp(110px,21vw,245px);margin-top:4%}
.scene-3d .backs{gap:2px;max-width:none;overflow:visible;margin:5px 0 6px;perspective:180px}
.scene-3d .backs i {flex:0 0 clamp(9px,1.48vw,19px);width:clamp(9px,1.48vw,19px);height:clamp(13px,2.07vw,25px);transform:rotateX(-12deg);background:linear-gradient(135deg,#555893,#252a62 67%);border-color:#7b7cb4;border-top-color:#fff3d8;border-radius:3px;box-shadow:0 3px 0 #eadebd,0 5px 0 #1e2149,0 7px 5px #0c160daa}
.scene-3d .bot-1 .backs,.scene-3d .bot-3 .backs{max-width:clamp(36px,7.8vw,92px);margin-inline:auto}
.scene-3d .bot .melds {gap:3px}
.scene-3d .center{min-height:0;padding:0;perspective:570px;align-self:stretch;display:flex;flex-direction:column;align-items:center;justify-content:center}
.scene-3d .plaque{margin:0 0 5px;background:#143823ab;border-color:#ecd49460;font-size:clamp(.7rem,1.2vw,.92rem);padding:1px 7px 1px 3px;text-shadow:0 1px 2px #13221c}
.scene-3d .river{width:100%;max-width:580px;min-height:0;gap:4px;align-content:center;justify-content:center;min-height:46px;margin:0;padding:3px 0 8px;border:0;background:none;transform:rotateX(27deg);transform-origin:50% 92%}
.scene-3d .river-tile{padding-bottom:2px}
.scene-3d .river .tile{--w:var(--pip);height:calc(var(--pip)*1.12);border-radius:3px}
.scene-3d .river .tile img{object-fit:fill}
.scene-3d .empty-river{color:#eee5c9;background:#174128d9;border-radius:20px;padding:3px 10px;text-shadow:0 1px 2px #091a11}
.scene-3d .dot{z-index:1;width:4px;height:4px;bottom:-2px}
.scene-3d .player {
  border:1px solid transparent;border-radius:11px;padding:4px 4px 0;
  align-self:end;background:linear-gradient(transparent,#12392581);text-shadow:0 2px 4px #0a180c;
}
.scene-3d .player-head{color:#ffe9ba;min-height:0;margin-bottom:2px}
.scene-3d .player-head b{color:#fffbed}
.scene-3d .hand {gap:4px 5px;padding:3px 0 6px}
.scene-3d .hand .tile{--w:var(--hand-w);height:calc(var(--w)*1.38);touch-action:manipulation}
.scene-3d .tile{
 border-color:#fff6df;border-top-color:#fffdf3;
 background:#f9f3e1;box-shadow:0 3px 0 #393e74,0 6px 0 #20264e,0 8px 5px #06160ca0;
}
.scene-3d .tile.highlight{outline-color:#ffd177}
.scene-3d .move{min-height:32px}
.scene-3d .move #status{margin:3px 0 2px;color:#fff8df}
.scene-3d .actions{margin:0;gap:4px;text-shadow:none}
@media(max-width:700px) and (orientation:portrait){
 .scene-3d{--pip:clamp(16px,4.45vw,25px);--hand-w:clamp(31px,9vw,44px);aspect-ratio:auto;min-height:446px;
    padding:4.8% 4px 5%;grid-template-columns:23% minmax(0,1fr) 23%;grid-template-rows:90px minmax(150px,1fr) auto;}
 .scene-3d .table-model{overflow:hidden}.scene-3d .bot-1,.scene-3d .bot-3{transform:none;margin-inline:0}
 .scene-3d .bot-2{margin-top:6px}
 .scene-3d .bot b{font-size:.72rem}.scene-3d .bot small{font-size:.62rem}
 .scene-3d .backs{gap:1px}.scene-3d .backs i{flex-basis:8px;width:8px;height:12px;}
 .scene-3d .bot-1 .backs,.scene-3d .bot-3 .backs{max-width:48px}
 .scene-3d .river{gap:4px 3px}
 .scene-3d .hand{row-gap:9px}
 .stack-1{right:-4%}.stack-3{left:-4%}.stack-0{top:64%}
}
@media(orientation:landscape) and (max-height:535px){
 .scene-3d {--pip:clamp(16px,2.65vw,25px);--hand-w:clamp(23px,4.1vw,43px);aspect-ratio:auto;height:auto;min-height:276px;
  grid-template-rows:minmax(55px,11vh) minmax(105px,1fr) auto;padding:10px 6% 12px;}
 .scene-3d .bot-2{margin-top:1%}.scene-3d .bot b{font-size:.79rem}.scene-3d .bot small{font-size:.67rem}
 .scene-3d .backs{margin-block:2px 4px}.scene-3d .backs i{flex-basis:10px;width:10px;height:14px}
 .scene-3d .hand{gap:4px}.scene-3d .move{min-height:22px}.scene-3d .actions .action{min-height:35px}
 .stack-0{top:65%}.stack-2{top:24%}
}
@media(prefers-reduced-motion:reduce){.scene-3d .hand .tile:not(:disabled):hover{transform:none}}
#sound-toggle{white-space:nowrap;color:#fff1db;font-size:.86rem}
@media (max-width:500px){
 .top{padding-inline:8px;gap:6px}.brand span{display:none}.nav{gap:4px}
 .nav .ghost{padding-inline:7px;font-size:.82rem}.top #sound-toggle{font-size:.78rem;padding-inline:6px}
}

/* Full-width playing field, with photo faces mounted on two beveled side planes. */
.immersive main{max-width:1560px;width:100%;padding-inline:4px}
.immersive .heading h1{font-size:clamp(1.4rem,3vw,2.25rem)}
.turn-clock{display:inline-flex;align-items:center;justify-content:center;min-width:58px;padding:3px 7px;margin:0 4px;border-radius:7px;background:#202b16;color:#ffdf99;border:1px solid #ebcb7aa0;font-weight:850;font-variant-numeric:tabular-nums;line-height:1;white-space:nowrap}
.turn-clock[hidden]{display:none!important}.turn-clock.urgent{background:#7b2016;color:#fff1d6;border-color:#ffba63}
.scene-3d .move{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:3px 7px}.scene-3d .move #status{margin:0}.scene-3d .actions:empty{display:none}
.flowers{color:#ffe6b1;white-space:nowrap}.river-tile.claimed{opacity:.57}.river-tile.claimed::after{content:'';position:absolute;border-bottom:1px dashed #fff0b8;inset:auto 0 -3px;pointer-events:none}
.scene-3d .tile{--side:clamp(2px,calc(var(--w)*.15),11px);--base:clamp(3px,calc(var(--w)*.21),14px);
  isolation:isolate;position:relative;overflow:visible;border-radius:4px;box-shadow:1px 4px 8px #0413068c;
  border:1px solid #e3e3cc;background:#f3edd9;margin-right:calc(var(--side)*.44);margin-bottom:calc(var(--base)*.5)}
.scene-3d .tile img{border-radius:3px;clip-path:inset(0 round 3px);box-shadow:inset 0 0 0 1px #ffffff55}
.scene-3d .tile::before,.scene-3d .tile::after{position:absolute;content:'';pointer-events:none;z-index:-1;display:block}
.scene-3d .tile::before{left:calc(100% - .3px);top:0;width:var(--side);height:calc(100% + var(--base));
  clip-path:polygon(0 0, 100% 8%, 100% calc(100% - 3px), 0 100%);
  background:linear-gradient(90deg,#e8dbba 0 21%,#b2a18c 32%,#354962 41%,#1e304a 48%,#111c31 94%)}
.scene-3d .tile::after{left:0;right:calc(0px - var(--side));top:calc(100% - 1px);height:calc(var(--base) + 1px);
  clip-path:polygon(0 0, calc(100% - var(--side)) 0,100% 19%, 100% 78%, calc(100% - var(--side)) 100%, 6% 97%, 0 72%);
  background:linear-gradient(180deg,#ece5c5 0 27%,#a9a892 30%,#465d7b 36%,#233954 49%,#15243c 100%)}
.scene-3d .hand .tile.highlight{margin-left:5px}
.scene-3d .backs i{border-top:2px solid #e8e5c5;box-shadow:3px 2px 0 #151943,3px 4px 0 #cfcab3,4px 5px 5px #132413}
.wall-stack i{height:90%;box-shadow:3px 3px 0 #2b305b,4px 5px 0 #e6ddbd,4px 8px 0 #1c214d,5px 10px 4px #07170c90}
.scene-3d .river{width:100%;max-width:none;transform:rotateX(15deg);gap:3px 4px;display:grid;
  grid-template-columns:repeat(16,max-content);justify-content:center;min-height:28px;max-height:100%;overflow:auto;padding:4px 4px 8px;scrollbar-width:thin}
.scene-3d .river .empty-river{grid-column:1/-1}
.scene-3d .river .tile{--w:clamp(13px,2.6vw,30px);height:calc(var(--w)*1.11)}
.scene-3d .river[data-density=high] .tile{--w:clamp(12px,2.15vw,25px)}
.scene-3d .river[data-density=max] .tile{--w:clamp(11px,1.9vw,23px)}
.scene-3d .center{position:relative;z-index:1}
.scene-3d .player{position:relative;z-index:2}
@media (orientation:landscape){
 .immersive .top{padding-inline:max(8px,env(safe-area-inset-left));}
 .immersive main{padding-left:max(3px,env(safe-area-inset-left));padding-right:max(3px,env(safe-area-inset-right))}
 .immersive .scene-3d{border-radius:9px;aspect-ratio:auto;min-height:min(74dvh,750px);height:auto;
   grid-template-columns:18% minmax(0,1fr) 18%;padding:2.3% 4% 3%;grid-template-rows:23% minmax(110px,1fr) auto}
 .immersive .scene-3d .hand{gap:4px 6px}
}
@media (orientation:landscape) and (max-height:550px){
 .immersive .top{padding-block:2px}.immersive .top .nav .ghost{padding:3px 8px;min-height:32px}
 .immersive .heading{display:none}
 .immersive .scene-3d{padding:8px 4% 9px;min-height:calc(100dvh - 78px);grid-template-rows:49px minmax(94px,1fr) auto}
 .immersive .scene-3d .hand .tile{--w:clamp(25px,4.4vw,43px)}
 .immersive .scene-3d .bot b{font-size:.77rem}
 .immersive footer{padding:3px 4px}.immersive footer .ghost{font-size:.75rem;min-height:27px;padding:3px 6px}
 .scene-3d .river .tile{--w:clamp(13px,2.58vw,23px)}
 .scene-3d .river[data-density=medium] .tile{--w:clamp(12px,2.11vw,19px)}
 .scene-3d .river[data-density=high] .tile,.scene-3d .river[data-density=max] .tile{--w:clamp(10px,1.92vw,16px)}
 .scene-3d .river{gap:2px 3px}
}
@media (orientation:portrait) and (max-width:700px){
 .immersive .scene-3d{min-height:510px}
 .scene-3d .river{grid-template-columns:repeat(10,max-content);gap:3px 2px;transform:rotateX(10deg)}
 .scene-3d .river .tile,.scene-3d .river[data-density=high] .tile,.scene-3d .river[data-density=max] .tile{--w:clamp(11px,3.25vw,21px)}
 .scene-3d .center{justify-content:start;padding-top:5px}
}

/* Each part of the table gets its own lane, so the 3D edges never sit on
   another face. Perspective is drawn into the surfaces, not the hitboxes. */
.immersive .scene-3d{
 --edge-col:15%;--wall-col:4%;--wall-h:24px;
 --back-w:clamp(11px,1.54vw,20px);--back-h:calc(var(--back-w)*1.13);
 grid-template-columns:minmax(0,var(--edge-col)) minmax(0,var(--wall-col)) minmax(0,1fr) minmax(0,var(--wall-col)) minmax(0,var(--edge-col));
 grid-template-rows:auto var(--wall-h) minmax(0,1fr) var(--wall-h) auto;
 grid-template-areas:". north north north ." ". . topwall . ." "west leftwall river rightwall east" ". . bottomwall . ." "player player player player player";
 gap:3px 4px;padding:clamp(8px,1.65vw,24px) 3.5% 12px;height:clamp(375px,77dvh,750px);min-height:0;
}
.scene-3d .table-model{display:contents}
.scene-3d .wall-stack{
 width:100%;height:100%;position:static;transform:none;align-items:start;align-self:center;justify-self:center;gap:2px;
 min-height:0;opacity:.95;padding:2px 3px 7px;pointer-events:none;z-index:0;
}
.scene-3d .wall-stack i{
 height:100%;width:auto;min-width:0;flex:0 1 19px;max-width:6%;
 border-color:#62689d;border-radius:2px;background:linear-gradient(145deg,#515794,#282e64 60%);
 box-shadow:1px 2px 0 #1d244e,1px 3px 0 #e4dec6,1px 5px 0 #171d43,1px 7px 3px #06170c8a;
}
.scene-3d .wall-stack i.one{box-shadow:1px 2px 0 #e4dec6,1px 4px 0 #171d43}
.scene-3d .stack-0{grid-area:bottomwall}
.scene-3d .stack-2{grid-area:topwall;max-width:70%}
.scene-3d .stack-1,.scene-3d .stack-3{
 flex-direction:column;align-items:center;min-width:0;max-height:87%;max-width:30px;padding:2px 4px 5px;
}
.scene-3d .stack-1{grid-area:rightwall}
.scene-3d .stack-3{grid-area:leftwall}
.scene-3d .stack-1 i,.scene-3d .stack-3 i{
 flex:0 1 13px;max-width:none;width:100%;height:auto;min-height:0;
 transform:skewX(9deg);box-shadow:2px 0 #20264f,3px 0 #d8d5be,5px 0 #151c45;
}
.scene-3d .stack-3 i{transform:skewX(-9deg)}
.scene-3d .bot{
 margin:0;width:100%;min-width:0;position:relative;z-index:1;transform:none;
}
.scene-3d .bot-2{align-self:center;max-width:100%;max-height:none;padding:0 3px}
.scene-3d .bot-1,.scene-3d .bot-3{
 align-self:stretch;display:flex;flex-direction:column;justify-content:center;align-items:center;min-height:0;
 overflow:auto;scrollbar-width:thin;padding:3px 0;
}
.scene-3d .bot-1 b,.scene-3d .bot-3 b{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-height:1.25em}
.scene-3d .backs{flex-wrap:nowrap;perspective:none;gap:3px;padding:2px 2px 5px;margin:2px 0;min-height:0}
.scene-3d .backs i{
 width:var(--back-w);height:var(--back-h);flex:0 1 var(--back-w);min-width:0;min-height:0;
 transform:none;box-shadow:1px 2px 0 #eae5cf,2px 4px 0 #252851;
}
.scene-3d .bot-1 .backs,.scene-3d .bot-3 .backs{
 order:2;align-items:center;flex-direction:column;justify-content:safe center;
 flex:0 1 auto;max-width:100%;width:calc(var(--back-w) + 10px);padding:2px 5px;gap:3px;
}
.scene-3d .bot-1 .backs i,.scene-3d .bot-3 .backs i{flex:0 1 8px;width:100%;min-height:3px;height:8px;box-shadow:2px 0 #e7e2ce,4px 0 #242752;transform:skewX(10deg)}
.scene-3d .bot-3 .backs i{transform:skewX(-10deg)}
.scene-3d .bot .melds{margin:3px 2px 0;gap:5px;max-width:100%;justify-content:center}
.scene-3d .bot-1 .melds,.scene-3d .bot-3 .melds{flex:0 0 auto;display:grid;grid-template-columns:repeat(2,max-content);gap:3px 7px}
.scene-3d .bot-1 .meld-group,.scene-3d .bot-3 .meld-group{flex-direction:column;gap:calc(var(--op-meld)*.20 + 2px)}
.scene-3d .bot .tile,.scene-3d .bot .tile-back{--op-meld:clamp(12px,1.4vw,21px);--w:var(--op-meld)}
.scene-3d .bot-1,.scene-3d .bot-3{--op-meld:clamp(12px,1.4vw,21px)}
.scene-3d .meld-group{gap:4px}
.scene-3d .tile,.scene-3d .hand .tile.highlight{
 margin:0 calc(var(--side) + 1px) calc(var(--base) + 1px) 0;
}
.scene-3d .hand .tile.highlight{margin-left:4px}
.scene-3d .hand .tile:hover{transform:none}
.scene-3d .hand .tile:active{filter:brightness(.91)}
.scene-3d .tile-back{
 display:inline-block;width:var(--w,20px);height:calc(var(--w,20px)*1.34);aspect-ratio:auto;
 background:linear-gradient(140deg,#595e9b,#282c66 75%);border:1px solid #8185b3;border-top:2px solid #e8e2c8;
 box-shadow:2px 2px 0 #202347;border-radius:3px;
}
.scene-3d .center{
 justify-content:center;padding:0;min-height:0;overflow:hidden;perspective:none;
}
.scene-3d .center .plaque{flex:0 0 auto;margin:2px 0 3px}
.scene-3d .center .river{
 --discard-w:clamp(25px,3.4vw,46px);
 display:flex;flex-wrap:wrap;
 justify-content:center;align-content:safe center;align-items:start;width:100%;max-height:100%;min-height:0;
 padding:3px 2px 5px;margin:0;gap:3px 3px;overflow:auto;scrollbar-width:thin;transform:none;
}
.scene-3d .center .river:has(.empty-river){display:flex;justify-content:center;min-height:32px}
.scene-3d .river-tile{padding:0}
.scene-3d .center .river .tile{--w:var(--discard-w);height:calc(var(--w)*1.01)}
.scene-3d .river .dot{width:3px;height:3px;bottom:1px;opacity:.8}
.scene-3d .player{overflow:visible}
.scene-3d .player .melds:empty,.scene-3d .bot .melds:empty,.scene-3d .backs:empty{display:none}
.scene-3d .player .hand{flex-wrap:nowrap;row-gap:4px;justify-content:center}
#music-toggle{white-space:nowrap;color:#fff1db;font-size:.86rem}
#music-toggle[aria-pressed=false]{opacity:.72}
.room-code b{font-size:clamp(1.5rem,6vw,2.5rem);color:#ffe1a4;user-select:all;vertical-align:middle}
@media(orientation:landscape) and (max-height:550px){
 .immersive .scene-3d{height:max(288px,calc(100dvh - 75px));--wall-h:14px;--edge-col:14%;--wall-col:4%;padding:6px 3.2% 7px;gap:2px 3px}
 .scene-3d .center .river{--discard-w:clamp(20px,3.25vw,31px)}
 .scene-3d .backs{margin:2px 0;padding-bottom:4px}.scene-3d .bot-2 .backs i{height:12px}
 .scene-3d .bot-1 .backs,.scene-3d .bot-3 .backs{gap:2px}
 .scene-3d .bot-1 .backs i,.scene-3d .bot-3 .backs i{flex-basis:6px}
 .immersive .scene-3d .hand .tile{--w:clamp(21px,3.98vw,41px)}
 .scene-3d .player{padding:2px 3px 0}.scene-3d .player .melds{margin-bottom:0}
 .scene-3d .player .hand{gap:3px;padding:3px 0 2px}
 .scene-3d .move #status{font-size:.76rem}
}
@media(orientation:portrait) and (max-width:700px){
 .immersive .scene-3d{--edge-col:18%;--wall-col:4%;--wall-h:17px;height:clamp(440px,75dvh,730px);min-height:0;gap:3px 2px;padding:8px 2%}
 .scene-3d .center .river{--discard-w:clamp(19px,5.6vw,31px)}
 .scene-3d .player .hand{flex-wrap:wrap;row-gap:7px}
 .scene-3d .bot-2{padding:0;max-width:100%}
 .scene-3d .bot-1 b,.scene-3d .bot-3 b{font-size:.64rem}
 .scene-3d .bot-1 .backs,.scene-3d .bot-3 .backs{gap:3px}
 #music-toggle{padding-inline:6px;font-size:.78rem}
}
.scene-3d .bot-1,.scene-3d .bot-3{justify-content:safe center;scrollbar-width:none}
.scene-3d .bot-1::-webkit-scrollbar,.scene-3d .bot-3::-webkit-scrollbar{display:none}

/* Bonus tiles stay in a separate open rack, outside the hand and the river. */
.scene-3d .flowers-tray{
 display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:1px 2px;
 min-width:0;max-width:100%;padding:2px 3px 0;margin:2px auto 0;width:max-content;
 border-radius:5px;background:#133921a8;
}
.scene-3d .flowers-tray .flower-tile{
 --w:clamp(16px,1.8vw,25px);height:calc(var(--w)*1.17);outline:1px solid #a2bf70;
 flex:0 0 auto;
}
.scene-3d .bot .flowers-tray{flex:0 0 auto}
.scene-3d .player-head .flowers-tray{display:inline-flex;margin-inline:7px;vertical-align:middle}
.scene-3d .bot-1 .flowers-tray,.scene-3d .bot-3 .flowers-tray{order:1}
@media (max-height:550px) and (orientation:landscape){
 .scene-3d .flowers-tray{padding:1px 2px 0;margin-top:0}
 .scene-3d .flowers-tray .flower-tile{--w:clamp(13px,1.7vw,19px)}
 .scene-3d .bot-2 .flowers-tray{display:inline-flex;margin-inline:5px;vertical-align:middle}
}
/* As on a physical table, keep the near seat's exposed flowers at its left. */
.scene-3d .player-head{position:relative}
.scene-3d .player-head .flowers-tray{display:flex;margin:1px 0 1px clamp(5px,8vw,110px)}

/* A stable, top-left river. A claim leaves no visible/interactive tile. */
.scene-3d .center{justify-content:flex-start}
.scene-3d .center .river{
 flex:1 1 auto;align-content:flex-start;justify-content:flex-start;
 gap:3px 4px;padding:3px 4px 7px;scrollbar-gutter:stable;overflow-anchor:none;scroll-behavior:auto;
}
.scene-3d .center .river:has(.empty-river){justify-content:flex-start;min-height:0}
.scene-3d .center .river .empty-river{margin:3px 0}
.scene-3d .center .river .river-tile,
.scene-3d .center .river .river-gap{
 flex:0 0 calc(var(--discard-w) + 4px);height:calc(var(--discard-w)*1.01 + 5px)
}
.scene-3d .river-pending{opacity:0}
.scene-3d .discard-flight{
 position:absolute;left:0;top:0;z-index:12;pointer-events:none;transform-origin:center;
 filter:drop-shadow(0 4px 5px #0b211bb3);
}
.scene-3d .discard-flight .tile{width:100%;height:100%;margin:0;border-color:#fff4c5}
@media (prefers-reduced-motion:reduce){
 .scene-3d .discard-flight{display:none}
 .scene-3d .river-pending{opacity:1}
}

/* Reference layout: face-up rows at the center, a top rack and two slanted side racks. */
.scene-3d .center .river{
 display:grid;grid-template-columns:repeat(var(--river-cols,8),calc(var(--discard-w) + clamp(1px,var(--discard-w)*.08,3px)));
 grid-auto-rows:calc(var(--discard-w)*1.01 + 3px);
 flex:1 1 0;align-items:start;gap:0;
 overflow:clip;scrollbar-gutter:auto;
}
.scene-3d .center .river:has(.empty-river){display:flex}
.scene-3d .center .river>.river-tile,.scene-3d .center .river>.river-gap{height:100%;width:100%}
.scene-3d .center .river .tile{
 --side:clamp(1px,calc(var(--w)*.08),3px);
 --base:clamp(2px,calc(var(--w)*.10),3px); margin:0;
 box-shadow:0 1px 1px #071e1155;
}
.scene-3d .center .river .dot{bottom:2px}
.scene-3d .bot-1{transform:skewX(10deg)}
.scene-3d .bot-3{transform:skewX(-10deg)}
.scene-3d .bot-1 b,.scene-3d .bot-1 small{transform:skewX(-10deg)}
.scene-3d .bot-3 b,.scene-3d .bot-3 small{transform:skewX(10deg)}
.scene-3d .stack-1{transform:skewX(11deg)}
.scene-3d .stack-3{transform:skewX(-11deg)}
/* Reserve most of the felt for discards rather than oversized racks or labels. */
.immersive .scene-3d{--wall-h:clamp(9px,2.7dvh,19px)}
.scene-3d .bot-2{margin-top:0;min-height:0}
.scene-3d .bot-2 b,.scene-3d .bot-2 small{display:inline;margin-inline:3px}
.scene-3d .bot-2 .flowers-tray{display:inline-flex;margin-inline:5px;vertical-align:middle}
.scene-3d .player-head .flowers-tray{display:inline-flex;vertical-align:middle;margin:0 8px}
.scene-3d .player-head .seat-title{display:inline}
.scene-3d .player .move{min-height:26px}
.immersive .scene-3d .hand .tile{
 --w:clamp(17px,min(3.5vw,7.4dvh),43px);
 height:calc(var(--w)*1.27);
}
.scene-3d .center .plaque{font-size:.74rem;margin:1px 0 2px;padding:0 6px 0 1px}
.scene-3d .center .plaque .mark{padding:0 3px}
.scene-3d .center .river{overflow:hidden;overflow:clip}

/* Keep stacks inside their own tracks. Only the brick profile is angled: skewing
   the whole tall stack previously crossed into the first discard on iPhone. */
.scene-3d .stack-1,.scene-3d .stack-3{
 transform:none;overflow:hidden;clip-path:inset(0);padding-inline:5px;max-width:100%;
}
.scene-3d .stack-1 i,.scene-3d .stack-3 i{
 transform:none;width:100%;box-shadow:1px 0 #e7e2ce,2px 0 #242752;
}
.scene-3d .center .river{
 /* Keep the face-up river wide; wall stacks already stay in their own tracks. */
 padding:2px clamp(5px,.75vw,12px) 3px;
}

/* 17 live tiles fit the Taiwan rack without touching adjacent controls. */
.scene-3d .player .hand.taiwan-rack{gap:2px;flex-wrap:wrap}
.scene-3d .player .hand.taiwan-rack .tile{--w:clamp(17px,3.55vw,38px)}
.scene-3d .player .hand.taiwan-rack .highlight{margin-left:2px}
@media(orientation:landscape){.scene-3d .player .hand.taiwan-rack{flex-wrap:nowrap}}

/* Fuzhou: the protected wildcard stays visually distinct without resizing the rack. */
.scene-3d .player .hand .jin-tile,.scene-3d .dora-indicators .jin-tile{outline:2px solid #e9aa39;outline-offset:-2px;}

/* Gameplay countdown: warn without animating size or reserving extra space. */
.turn-clock.urgent{background:#811f18;color:#fff4dd;border-color:#ffc477;animation:mahjong-clock-warning 1.25s ease-in-out infinite}
@keyframes mahjong-clock-warning{
 0%,100%{color:#fff4dd;box-shadow:0 0 0 0 #ff9e5140}
 50%{color:#ffc477;box-shadow:0 0 8px 3px #ff9e5190}
}
@media(prefers-reduced-motion:reduce){.turn-clock.urgent{animation:none}}
