/* Royal camera: percentages are measured in the board plane, never the phone's
   physical portrait axes. This layer deliberately replaces the old flex/grid
   camera only while the classic table is active in landscape. */
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
body.immersive.royal-play-full .scene-3d{
 container-type:size;
 background-image:url('./felt-reference.svg?v=1');
 --rr-safe:max(var(--royal-safe-l,0px),var(--royal-safe-r,0px));
 --rr-mid-inset:23.5%;
 --rr-front-inset:14%;
 --rr-river-top:24.8%;
 --rr-river-end:39%;
 --rr-rear-start:7.2%;
 --rr-wall-start:18.2%;
 --rr-rail-slant:19deg;
 --rr-side-start:17.5%;
 --rr-side-end:39%;
}
body.immersive.royal-play-full .scene-3d .bot-2 {
 position:absolute;inset:var(--rr-rear-start) auto auto 23%;grid-area:auto;
 width:54%;max-width:none;margin:0;padding:0;border:0;min-height:0;
 gap:2px 5px;align-content:start;
}
body.immersive.royal-play-full .scene-3d .bot-2 .backs{
 flex-basis:100%;width:100%;min-width:100%;padding:1px 0 3px;margin:0;gap:1px;
}
body.immersive.royal-play-full .scene-3d .bot-2 .backs i{
 --rear-w:min(2.63cqw,5.25cqh,3rem);
 flex:0 1 var(--rear-w);width:var(--rear-w);height:calc(var(--rear-w)*1.13);
 background:linear-gradient(171deg,#44578c,#283a67);
 border-radius:1px;box-shadow:0 1px #0d2635;
}
.game-landscape-rotated body.immersive.royal-play-full .scene-3d .bot-2 .backs i{
 --rear-w:min(calc(var(--game-view-w)*.0263),5.25cqh,3rem);
}
body.immersive.royal-play-full .scene-3d .bot-2 :is(.melds,.flowers-tray){
 max-width:100%;margin-block:0;
}
body.immersive.royal-play-full .scene-3d .stack-2{
 position:absolute;
 inset:var(--rr-wall-start) auto auto 27.1%;
 grid-area:auto;width:45.8%;max-width:none;min-width:0;
 height:clamp(7px,5.5cqh,30px);
 margin:0;padding:0 1px 4px;gap:1px;
}
body.immersive.royal-play-full .scene-3d .stack-2 i{
 flex:0 1 6.7%;max-width:6.7%;
 border-radius:1px;transform:skewX(-8deg);
}
body.immersive.royal-play-full .scene-3d .center{
 position:absolute;inset:var(--rr-river-top) var(--rr-mid-inset) var(--rr-river-end);
 grid-area:auto;min-width:0;min-height:0;align-self:stretch;
 display:flex;flex-direction:column;align-items:center;
 padding:0;overflow:hidden;
}
body.immersive.royal-play-full .scene-3d .center .plaque{
 position:relative;padding:0 5px 0 1px;font-size:clamp(.61rem,1.85cqh,.79rem);
 line-height:1.1;margin:0 0 2px;
}
body.immersive.royal-play-full .scene-3d .center .river{--river-preferred-cols:16;--river-face-ratio:.76;grid-auto-rows:calc(var(--discard-w)*var(--river-face-ratio) + 3px);align-content:start;width:100%;padding:1px 3px 4px}
body.immersive.royal-play-full .scene-3d .center .river .tile{
 border:1px solid #f4e6cb;border-radius:1px;
 height:calc(var(--w)*var(--river-face-ratio));
 transform:skewX(-7deg);transform-origin:50% 100%;
}
body.immersive.royal-play-full .scene-3d .center .river .tile::after{
 background:linear-gradient(180deg,#556b8c,#1b2d4b 70%);
}
body.immersive.royal-play-full .scene-3d :is(.stack-1,.stack-3){
 position:absolute;grid-area:auto;
 top:22.3%;bottom:33.7%;
 width:2.8%;min-width:8px;max-width:none;
 height:auto;max-height:none;align-self:stretch;justify-self:stretch;justify-content:flex-start;padding:0 2px 3px;gap:1px;
 transform:skewX(calc(var(--rail-direction)*var(--rr-rail-slant)));
 transform-origin:50% 0;
}
body.immersive.royal-play-full .scene-3d .stack-3{left:20.7%}
body.immersive.royal-play-full .scene-3d .stack-1{right:20.7%}
body.immersive.royal-play-full .scene-3d :is(.stack-1,.stack-3) i{
 flex:0 1 8.7%;box-shadow:0 1px #e5d9b3,0 3px #1c2a4e;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3){
 position:absolute;grid-area:auto;box-sizing:border-box;
 inset-block:var(--rr-side-start) var(--rr-side-end);
 width:calc(21% - var(--rr-safe));height:auto;padding:0;
 border:0;background:none;
}
body.immersive.royal-play-full .scene-3d .bot.bot-3{left:var(--rr-safe)}
body.immersive.royal-play-full .scene-3d .bot.bot-1{right:var(--rr-safe)}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) :is(.backs,.opposed-open){
 top:0;bottom:0;
 transform-origin:50% 0;
 transform:skewX(calc(var(--rail-direction)*var(--rr-rail-slant)));
}
body.immersive.royal-play-full .scene-3d .bot.bot-3 .backs{left:54%;right:auto}
body.immersive.royal-play-full .scene-3d .bot.bot-1 .backs{left:auto;right:54%}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .backs{
 width:17%;padding:1px 2px 2px;gap:1px;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .backs i{
 flex:0 1 12%;border-radius:1px;
 background:linear-gradient(148deg,#49628f,#253456 68%);
}
body.immersive.royal-play-full .scene-3d .bot.bot-3 .opposed-open{left:69%;right:3%}
body.immersive.royal-play-full .scene-3d .bot.bot-1 .opposed-open{left:3%;right:69%}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .opposed-open{
 top:7%;bottom:4%;
 justify-content:center;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .seat-copy{
 bottom:-10%;inset-inline:35% 0;max-height:none;
}
body.immersive.royal-play-full .scene-3d .bot.bot-1 .seat-copy{inset-inline:0 35%}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .seat-copy b{
 display:block;color:#e3ba75;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3).turn .seat-copy b{
 color:#fff1c5;text-decoration:underline;
}
body.immersive.royal-play-full .scene-3d .player{
 position:absolute;grid-area:auto;
 inset:61.5% max(var(--rr-front-inset),var(--rr-safe)) max(3.4%,var(--royal-safe-b));
 width:auto;height:auto;min-height:0;padding:0;
 align-self:stretch;justify-self:stretch;
 display:flex;flex-direction:column;justify-content:space-between;
}
body.immersive.royal-play-full .scene-3d .player-head{
 position:absolute;inset:0 0 auto;
 order:0;margin:0;
 min-height:0;padding:0;gap:0 5px;
}
body.immersive.royal-play-full .scene-3d .player-head .seat-title{
 font-size:clamp(.62rem,2.05cqh,.93rem);line-height:1.1;margin-block-end:1px;
}
body.immersive.royal-play-full .scene-3d .player-head .meld-group .tile,
body.immersive.royal-play-full .scene-3d .player-head .flower-tile{
 --w:clamp(11px,4.2cqh,29px);
 height:calc(var(--w)*.95);
 transform:skewX(-5deg);
}
body.immersive.royal-play-full .scene-3d .player .hand{
 position:absolute;inset:27% 0 32%;
 width:100%;order:1;flex:none;min-height:0;
 padding:0;gap:1px;align-items:center;align-content:center;
}
body.immersive.royal-play-full .scene-3d .player .hand .tile{
 --w:clamp(11px,min(calc((100cqw - 48px)/14),11.5cqh),62px);
 height:min(calc(var(--w)*1.39),13.3cqh,100%);
 border-radius:2px;
 margin:0 1px 3px 0;
}
body.immersive.royal-play-full .scene-3d .player .hand:has(> .tile:nth-child(15)) .tile {
 --w:clamp(9px,min(calc((100cqw - 53px)/17),10.2cqh),55px);
}
body.immersive.royal-play-full .scene-3d .player .hand .highlight{margin-inline-start:3px}
body.immersive.royal-play-full .scene-3d .player .move{position:absolute;inset:auto 0 0;max-height:35%;min-height:0}
body.immersive.royal-play-full .scene-3d .player .move:has(.actions:empty){order:2;min-height:16px}
body.immersive.royal-play-full .scene-3d .player .move:has(.actions:not(:empty)){
 order:2;grid-template-areas:"actions clock";
 grid-template-columns:minmax(0,1fr) auto;
 row-gap:0;align-self:stretch;
}
body.immersive.royal-play-full .scene-3d .player .move:has(.actions:not(:empty)) #status{
 position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
body.immersive.royal-play-full .scene-3d .player .move .actions:not(:empty){
 justify-content:flex-end;flex-wrap:nowrap;max-width:none;margin-block:0;
}
body.immersive.royal-play-full .scene-3d .player .move .actions .action{
 flex:0 1 auto;min-width:clamp(46px,7.4cqw,86px);
 min-height:44px;max-width:min(110px,20%);padding-inline:5px;
}
}

/* More-specific compact adaptation wins the preceding legacy mobile rules. */
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
.game-landscape-compact body.immersive.royal-play-full .scene-3d .player .hand .tile{
 --w:clamp(11px,min(calc((100cqw - 48px)/14),11.5cqh),62px);
}
.game-landscape-compact body.immersive.royal-play-full .scene-3d .player .hand:has(> .tile:nth-child(15)) .tile{
 --w:clamp(9px,min(calc((100cqw - 53px)/17),10.2cqh),55px);
}
.game-landscape-compact body.immersive.royal-play-full .scene-3d .player-head .meld-group .tile,
.game-landscape-compact body.immersive.royal-play-full .scene-3d .player-head .flower-tile{
 --w:clamp(11px,4.2cqh,29px);
}
}

/* Approved iPhone arrangement: concealed / open / badge read toward the
   middle of the table. Preserve the original responsive capacity fitter. */
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
body.immersive.royal-play-full .scene-3d{
 --rr-side-start:17%;
 --rr-side-end:36%;
 --rr-badge-w:clamp(84px,calc(var(--game-view-w,100vw)*.12),130px);
 --rr-badge-h:clamp(17px,calc(var(--game-view-h,100dvh)*.051),26px);
 --rr-wall-start:20.7%;
 --rr-river-top:27%;
}
body.immersive.royal-play-full .top{
 padding-block-start:max(2px,var(--royal-safe-t));
 padding-block-end:2px;
}
body.immersive.royal-play-full .scene-3d .bot-2{
 --rr-far-face:clamp(8px,min(calc(var(--game-view-w,100vw)*.019),3.7cqh),25px);
 display:flex;
 flex-wrap:wrap;
 align-items:center;
 justify-content:center;
 row-gap:0;
}
body.immersive.royal-play-full .scene-3d .bot-2 .backs{
 order:-2;
 padding-block-end:2px;
}
body.immersive.royal-play-full .scene-3d .bot-2 .royal-seat-badge{
 order:2;flex:0 0 var(--rr-badge-w);margin:0 auto;
}
body.immersive.royal-play-full .scene-3d .bot-2:has(.royal-seat-badge)::after{
 content:"";order:1;flex-basis:100%;height:0;
}
body.immersive.royal-play-full .scene-3d .bot-2 :is(.melds,.flowers-tray){
 align-items:center;justify-content:center;gap:3px;margin:0;
}
body.immersive.royal-play-full .scene-3d .bot-2 .flowers-tray:has(+ .melds:not(:empty)),
body.immersive.royal-play-full .scene-3d .bot-2 .melds:not(:empty)+.flowers-tray{
 margin-inline-start:3px;
}
body.immersive.royal-play-full .scene-3d .bot-2 :is(.meld-group,.flowers-tray) :is(.tile,.tile-back){
 --w:var(--rr-far-face);height:calc(var(--w)*.96);
 transform:skewX(-5deg);
 border-radius:1px;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .backs{
 top:0;bottom:0;
 justify-content:center;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .opposed-open{
 /* Single and dense open runs share the same centered inner rail. */
 top:4%;bottom:2%;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .opposed-open .flowers-tray{
 margin-block-start:3px;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .opposed-open:not(:has(.melds:not(:empty))) .flowers-tray{
 margin-block-start:0;
}
body.immersive.royal-play-full .scene-3d .bot:is(.bot-1,.bot-3) .seat-copy:has(.royal-seat-badge){
 top:52%;bottom:auto;
 left:83%;right:auto;
 width:var(--rr-badge-w);max-width:none;
 overflow:visible;z-index:3;
 transform:translate(-50%,-50%) rotate(72deg);
}
body.immersive.royal-play-full .scene-3d .bot.bot-1 .seat-copy:has(.royal-seat-badge){
 left:auto;right:83%;
 transform:translate(50%,-50%) rotate(-72deg);
}
body.immersive.royal-play-full .scene-3d .royal-seat-badge{
 display:flex;
 align-items:center;
 justify-content:space-between;
 width:var(--rr-badge-w);height:var(--rr-badge-h);
 min-width:0;max-width:100%;margin:0 auto;
 gap:3px;padding:0 5px;
 color:#ffeed0;
 background:#15372ded;
 border:1px solid #dfa863;
 border-radius:5px;
 font:700 clamp(.59rem,calc(var(--game-view-h,100dvh)*.0245),.82rem)/1.08 system-ui,sans-serif;
 white-space:nowrap;overflow:hidden;
}
body.immersive.royal-play-full .scene-3d .royal-seat-badge b{
 display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
 margin:0;color:inherit;font-size:inherit;line-height:inherit;
}
body.immersive.royal-play-full .scene-3d .royal-seat-badge :is(small,.seat-wind){
 display:inline-flex;align-items:center;flex:0 0 auto;
 margin:0;color:#f4cb8d;font-size:.87em;line-height:inherit;
}
body.immersive.royal-play-full .scene-3d .player-head .royal-seat-badge,
body.immersive.royal-play-full .scene-3d .bot.turn .royal-seat-badge{
 background:#5b3020ed;border-color:#f4be75;
}
body.immersive.royal-play-full .scene-3d .player-head:has(.royal-seat-badge){
 padding-top:calc(var(--rr-badge-h) + 2px);
}
body.immersive.royal-play-full .scene-3d .player-head .royal-seat-badge{
 position:absolute;top:0;left:50%;transform:translateX(-50%);
}
body.immersive.royal-play-full .scene-3d .player .hand{top:33%}
}

/* Mirror labels around the same table axis as the rendered tile faces. */
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
body.immersive.royal-play-full .scene-3d .bot.bot-3 .seat-copy:has(.royal-seat-badge){transform:translate(-50%,-50%) rotate(109deg)}
body.immersive.royal-play-full .scene-3d .bot.bot-1 .seat-copy:has(.royal-seat-badge){transform:translate(50%,-50%) rotate(-109deg)}
/* A right-hand viewer reads along the lane from the bottom to the top.
   The semantic DOM retains the rules engine's normal (ascending) order. */
body.immersive.royal-play-full .scene-3d .bot.bot-1 .opposed-open .meld-chow{flex-direction:column-reverse}
body.immersive.royal-play-full .scene-3d .royal-seat-badge .seat-wind{gap:3px}
body.immersive.royal-play-full .scene-3d .royal-seat-badge .seat-wind i{
 display:inline-grid;place-items:center;
 width:1.19em;height:1.22em;border-radius:2px;
 padding:0;margin:0;font:700 .99em/1.1 system-ui,sans-serif;
 font-style:normal;color:#193f30;background:#f8e6c4;
}
body.immersive.royal-play-full .scene-3d .royal-seat-badge .seat-points{color:#f1ddab;font-size:.68em}
body.immersive.royal-play-full .scene-3d .bot-2:has(.royal-seat-badge)>.melds{order:-1}
body.immersive.royal-play-full .scene-3d .bot-2:has(.royal-seat-badge)>.flowers-tray{order:0}
}
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
 /* The full score stays in the tooltip and accessible label. Avoid squeezing
    ordinary player names to two letters merely to echo the score. */
 body.immersive.royal-play-full .scene-3d .royal-seat-badge .seat-points{display:none}
}
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
 body.immersive.royal-play-full .scene-3d{
  --rr-badge-font:clamp(.59rem,calc(var(--game-view-h,100dvh)*.0245),.82rem);
  --rr-wall-start:23%;
  --rr-river-top:29.2%;
 }
 body.immersive.royal-play-full .scene-3d :is(.bot,.player-head) .royal-seat-badge>b{
  font-size:var(--rr-badge-font);line-height:1.08;
 }
 body.immersive.royal-play-full .scene-3d .bot-2:has(.royal-seat-badge){
  --rr-rear-start:6.1%;
 }
 body.immersive.royal-play-full .scene-3d .bot-2:has(.royal-seat-badge)>.royal-seat-badge{margin-block-start:1px}
}
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
 body.immersive.royal-play-full .scene-3d .bot.bot-3 .seat-copy:has(.royal-seat-badge){left:74%}
 body.immersive.royal-play-full .scene-3d .bot.bot-1 .seat-copy:has(.royal-seat-badge){right:74%}
 body.immersive.royal-play-full .scene-3d .bot-2:has(.flower-tile:nth-child(9)){
  --rr-far-face:clamp(6px,min(calc(var(--game-view-w,100vw)*.014),2.75cqh),19px);
 }
}
@media (orientation:landscape), (orientation:portrait) and (max-width:600px) {
 body.immersive.royal-play-full .scene-3d .bot.bot-3 .seat-copy:has(.royal-seat-badge){left:78%}
 body.immersive.royal-play-full .scene-3d .bot.bot-1 .seat-copy:has(.royal-seat-badge){right:78%}
 body.immersive.royal-play-full .scene-3d .bot.bot-3 .backs{left:49%;right:auto}
 body.immersive.royal-play-full .scene-3d .bot.bot-1 .backs{right:49%;left:auto}
 body.immersive.royal-play-full .scene-3d .bot.bot-3 .opposed-open{left:63%;right:9%}
 body.immersive.royal-play-full .scene-3d .bot.bot-1 .opposed-open{right:63%;left:9%}
 body.immersive.royal-play-full .scene-3d .bot-2:has(.flowers-tray>.tile:nth-child(9)){
  --rr-far-face:clamp(6px,min(calc(var(--game-view-w,100vw)*.014),2.75cqh),19px);
 }
}
