/* Imperial Crimson shell only: do not recolor or resize the live game table,
   tile skin, seat decorations or room/game state. */
body.ic-core{--page:var(--ic-bg,#160b0d);--text:var(--ic-text,#f6e5ce);--muted:var(--ic-muted,#dbc2b0);--gold:var(--ic-gold,#e6ba72)}
.ic-core :is(dialog,.lobby){
 color:var(--ic-text,#f6e5ce);
 background:linear-gradient(146deg,#30161c 0%,#241217 56%,#1b0d11 100%);
 border-color:var(--ic-line,#986b41);box-shadow:0 16px 56px #080306a6;
}
.ic-core dialog::backdrop{
 background:linear-gradient(#170a10ac,#10070be6) center/cover,
 url('./game-backdrop/mahjong-room-mobile.webp?v=1') center 40%/cover;
}
.ic-core :is(dialog,.lobby) :is(select,input:not([type=checkbox]):not([type=radio])),
.ic-core #setup :is(.solo-rule-trigger,.solo-rule-option){
 background:var(--ic-field,#3b2025);color:var(--ic-text,#f6e5ce);
 border-color:var(--ic-line,#986b41);color-scheme:dark;
}
.ic-core :is(dialog,.lobby) :is(input[type=checkbox],input[type=radio]){accent-color:var(--ic-gold,#e6ba72)}
.ic-core :is(dialog,.lobby) :is(.ghost,.room-seats span){border-color:#986b418f;background:#1c0d11;color:var(--ic-text,#f6e5ce)}
.ic-core :is(dialog,.lobby) .accent{
 background:linear-gradient(#f4d699,#ddad60);border-color:#f2c780;color:#251209;
 box-shadow:inset 0 1px #fff2ce77;
}
.ic-core :is(dialog,.lobby) :is(:focus-visible){outline:2px solid #ffe4a9;outline-offset:2px}
.ic-core :is(dialog,.lobby) :is(a:not(.ghost),.dialog-cap,.room-code b,.lobby-settings){color:var(--ic-gold,#e6ba72)}
.ic-core dialog :is(.deltas span,.river-row,.house-options){
 background:#32161c;border-color:#986b4190;
}
.ic-core .lobby .fine,.ic-core dialog .fine{color:var(--ic-muted,#dbc2b0)}
.ic-core .lobby .room-code{color:var(--ic-muted,#dbc2b0)}
.ic-core #setup{
 --ic-setup-safe-inline:calc(env(safe-area-inset-left,0px) + env(safe-area-inset-right,0px));
 width:min(calc(var(--game-view-w,100vw) - 32px - var(--ic-setup-safe-inline)),960px);
 /* Native modal UA max-width otherwise clamps to physical portrait width. */
 max-width:none;
 max-height:calc(var(--game-view-h,100dvh) - 22px);
 margin-inline:auto;padding:clamp(12px,3.4vw,28px);
 border:1px solid #a37950;border-radius:19px;
 box-shadow:inset 0 0 0 4px #2e161a,inset 0 0 0 5px #ad805179,0 16px 40px #080306a6;
 overflow:auto;overscroll-behavior:contain;
}
.game-landscape-rotated .ic-core #setup[open]{
 --ic-setup-safe-inline:calc(env(safe-area-inset-top,0px) + env(safe-area-inset-bottom,0px));
 margin:0;
}
/* On iOS the native modal backdrop stays in physical portrait coordinates.
   Paint its cinematic room onto the rotated game body, and suppress the
   unrotated copy. Only core modals sharing this room art opt in. */
.game-landscape-rotated body.ic-core:has(dialog:is(#setup,#result,#history,#rules,#river-dialog):modal){
 background:linear-gradient(#170a10ac,#10070be6) center/cover,
  url('./game-backdrop/mahjong-room-mobile.webp?v=1') center 40%/cover;
}
.game-landscape-rotated body.ic-core:has(dialog:is(#setup,#result,#history,#rules,#river-dialog):modal) > :is(main,header,footer):not(:has(dialog[open])){
 visibility:hidden;
}
.game-landscape-rotated .ic-core dialog:is(#setup,#result,#history,#rules,#river-dialog):modal::backdrop{background:transparent}
.ic-core #setup-form{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 align-items:start;column-gap:clamp(12px,3.1vw,34px);row-gap:clamp(6px,1.2vh,14px);
}
.ic-core #setup-form [hidden]{display:none!important}
.ic-core #setup-form > :is(.ic-setup-heading,.ic-setup-footer,fieldset,#setup-mcr-error){grid-column:1/-1}
.ic-core #setup-form > [data-orama-note]{grid-column:1/-1;margin:0;line-height:1.3}
.ic-core #setup-form > :is(label,[data-legacy-round],.ic-setup-heading,.ic-setup-footer){min-width:0}
.ic-core #setup .field{margin:0;font-size:clamp(.83rem,1.8vw,1.03rem);gap:4px}
.ic-core #setup fieldset .field{margin:.28rem 0}
.ic-core #setup .field :is(select,.solo-rule-trigger){min-height:42px;padding:5px 11px;margin:0;width:100%}
.ic-core #setup .solo-rule-menu{margin:0}
.ic-core #setup .solo-rule-trigger{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-inline-end:29px}
.ic-core #setup .solo-rule-choices:not([hidden]){
 background:#221117;border-color:var(--ic-line,#986b41);
}
.ic-core #setup .solo-ruleset-menu .solo-rule-choices:not([hidden]){
 position:absolute;z-index:5;top:100%;inset-inline:0;max-height:min(165px, calc(var(--game-view-h,100dvh) * .46));
 overflow:auto;background:#221117;border-color:var(--ic-line,#986b41);
}
.ic-core #setup .solo-rule-option[aria-pressed="true"]{color:#2a160c;background:#e9bf78}
.ic-core #setup .ic-setup-heading{
 display:flex;justify-content:space-between;align-items:flex-end;gap:12px;
 border-bottom:1px solid #91694186;padding-bottom:7px;
}
.ic-core #setup h2{font-size:clamp(1.32rem,3.6vw,2.45rem);line-height:1.1;margin:.16em 0 0;font-weight:700}
.ic-setup-guide{display:grid;justify-items:end;text-align:end;gap:2px;min-width:0}
.ic-setup-guide span{font-size:.64rem;letter-spacing:.14em;color:var(--ic-gold,#e6ba72);font-weight:750}
.ic-setup-guide a{font-size:clamp(.72rem,1.6vw,1rem);font-weight:700;text-decoration:none;white-space:normal}
.ic-core #setup .ic-setup-rule-count,.ic-core #setup #garuda-bot-help{
 position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);
}
.ic-core #setup .setup-draw{grid-column:2;min-height:24px;font-size:clamp(.77rem,1.8vw,1rem);line-height:1.15}
.ic-core #setup .ic-setup-footer{
 display:grid;grid-template-columns:minmax(0,1fr);gap:6px;
 border-top:1px solid #91694186;padding-top:7px;
}
.ic-core #setup #setup-note{line-height:1.25;margin:0;font-size:.78rem}
.ic-core #setup .setup-tools{width:100%;display:flex;justify-content:space-between;flex-wrap:nowrap;margin:0;gap:8px}
.ic-core #setup .setup-tools button{min-height:40px;min-width:92px}
.ic-core #setup #setup-submit{min-width:120px;margin-inline-start:auto}
.ic-core #setup .ic-round-stepper{
 min-height:42px;display:grid;grid-template-columns:38px minmax(0,1fr) 38px;
 align-items:stretch;border:1px solid var(--ic-line,#986b41);border-radius:8px;background:var(--ic-field,#3b2025);
}
.ic-core #setup .ic-round-stepper input{
 width:100%;max-width:none;min-height:0;border:0;background:transparent;color:inherit;
 text-align:center;padding:0;font-variant-numeric:tabular-nums;appearance:textfield;
}
.ic-core #setup .ic-round-stepper input::-webkit-inner-spin-button,
.ic-core #setup .ic-round-stepper input::-webkit-outer-spin-button{appearance:none;margin:0}
.ic-core #setup .ic-round-stepper button{
 border:0;background:#261218;color:var(--ic-gold,#e6ba72);
 border-radius:6px;margin:3px;padding:0;font-size:1.05rem;font-weight:800;touch-action:manipulation;
}
.ic-core #setup .ic-round-stepper button:focus-visible{outline-offset:-2px}
/* Explicit grid placement follows the approved mockup for this default setup.
   Other rules still show all their own fields, and can overflow if needed. */
.ic-core #setup-form .ic-setup-rules{grid-column:1;grid-row:2}
.ic-core #setup-form #garuda-bot-settings{grid-column:2;grid-row:2}
.ic-core #setup-form:has(#setup-rule option[value="garuda"]:checked) > [data-legacy-round]{grid-column:1;grid-row:3}
.ic-core #setup-form:has(#setup-rule option[value="garuda"]:checked) > label.field[data-legacy-rotation]{grid-column:2;grid-row:3}
.ic-core #setup-form:has(#setup-rule option[value="garuda"]:checked) > .setup-draw{grid-row:4}
.game-landscape-compact .ic-core #setup{padding:12px 19px}
.game-landscape-compact .ic-core #setup-form{row-gap:6px}
.game-landscape-compact .ic-core #setup h2{font-size:clamp(1.3rem,calc(var(--game-view-h) * .080),2rem)}
.game-landscape-compact .ic-core #setup .ic-setup-heading{padding-bottom:6px}
.game-landscape-compact .ic-core #setup .ic-setup-footer{padding-top:6px}
@media(max-width:520px){
 html:not(.game-landscape-rotated) .ic-core #setup-form{grid-template-columns:minmax(0,1fr)}
 html:not(.game-landscape-rotated) .ic-core #setup-form > *,
 html:not(.game-landscape-rotated) .ic-core #setup-form:has(#setup-rule option[value="garuda"]:checked) > *{grid-row:auto;grid-column:1}
}

/* The online lobby lives outside the immersive game camera. Keep the main
   header on the chrome palette while the scene keeps its selected theme. */
body.ic-core[data-mode="mabar"]:not(.immersive){
 background:var(--ic-page,radial-gradient(ellipse at 18% 0%,#3b151e 0%,#160b0d 65%));
}
body.ic-core[data-mode="mabar"] > .top{
 background:#231015; border-color:#986b4170;
}
body.ic-core[data-mode="mabar"] > .top .nav :is(a.ghost,button.ghost,summary){
 background:var(--ic-field,#3b2025);color:var(--ic-gold,#e6ba72);
 border-color:var(--ic-line,#986b41);
}
body.ic-core[data-mode="mabar"] > .top .nav :is(a.ghost,button.ghost,summary):is(:hover,:focus-visible){
 background:#572630;color:#fff0d5;border-color:#efc178;
}

/* During native setup the outside HUD cannot be used: the dialog has its
   own Back control. Don't leave misleading live-game targets behind it. */
body.ic-core:not([data-mode="mabar"]):has(#setup[open]) :is(.mg-back-game,.royal-hud-more){
 visibility:hidden;
}
