*{box-sizing:border-box}
body{
  margin:0;
  font-family:"Segoe UI",system-ui,-apple-system,Roboto,sans-serif;
  background:radial-gradient(ellipse at 50% 25%,#16263f 0%,#0b1322 70%,#050912 100%);
  color:#f4efe6;
  overflow-x:hidden;
  -webkit-font-smoothing:antialiased;
}
.hidden{display:none!important}
button{
  font:inherit;
  padding:.5em 1.05em;
  border-radius:10px;
  border:1px solid #c8a45c;
  background:linear-gradient(180deg,#253652 0%,#162136 100%);
  color:#f7eccf;
  cursor:pointer;
  margin:2px;
  font-weight:600;
  box-shadow:0 3px 10px #0008,inset 0 1px 0 #ffffff28;
  transition:transform .12s,filter .12s,box-shadow .12s;
}
button:hover{filter:brightness(1.12);transform:translateY(-1px)}
button:active{transform:translateY(0)}
button.primary{
  background:linear-gradient(180deg,#f5cf6b 0%,#d19a22 100%);
  border-color:#ffe394;
  color:#1c1304;
  font-weight:700;
  box-shadow:0 4px 14px #d19a2266,inset 0 1px 0 #fff9;
}
button.secondary{
  background:linear-gradient(180deg,#1f3554 0%,#132238 100%);
  border-color:#6ca6d9;
  color:#e4f1ff;
}
button.hu{
  background:linear-gradient(180deg,#ff5640 0%,#b8170c 100%);
  color:#fff;
  font-weight:800;
  border-color:#ffb299;
  box-shadow:0 0 18px #ff4028aa,inset 0 1px 0 #fff6;
}
button.blocked{
  background:linear-gradient(180deg,#444a57 0%,#2b303a 100%);
  color:#ccc;
  border-style:dashed;
  border-color:#888;
}
button:disabled{opacity:.5;cursor:default}
input{
  font:inherit;
  padding:.48em .65em;
  border-radius:8px;
  border:1px solid #c8a45c88;
  background:#0f192b;
  color:#f9f1de;
  outline:none;
}
input:focus{border-color:#f5cf6b;box-shadow:0 0 0 2px #f5cf6b44}

/* Lobby Card */
.card{
  background:linear-gradient(165deg,#16233acc 0%,#0e1728f2 100%);
  backdrop-filter:blur(10px);
  color:#f4efe6;
  border-radius:18px;
  border:1.5px solid #c8a45caa;
  padding:22px 26px;
  box-shadow:0 16px 48px #000c,inset 0 0 0 1px #ffffff14;
}
.lobby-card{max-width:500px;margin:6vh auto}
.lobby-head{display:flex;align-items:center;justify-content:space-between;gap:10px;border-bottom:1px solid #c8a45c44;padding-bottom:10px;margin-bottom:8px}
.brand-tag{font-size:.68em;letter-spacing:2.5px;color:#e8c166;font-weight:700}
.lobby-head h1{margin:2px 0 0;font-size:1.65em;color:#fff8e6;text-shadow:0 2px 10px #000}
.lobby-card label{display:block;margin:12px 0;font-weight:600;color:#e6d5b8}
.lobby-card input#name{width:100%;margin-top:4px}
.row{display:flex;gap:8px;margin:10px 0;align-items:center;flex-wrap:wrap}
.code{font-family:monospace;background:#0a111f;color:#f5cf6b;border:1px solid #c8a45c;padding:3px 10px;border-radius:8px;letter-spacing:3px}
.sub,.hint{color:#b6c2d9;font-size:.9em;line-height:1.45}
.err{color:#ff6b6b;min-height:1.2em;font-weight:600}
#members li{margin:4px 0;color:#f4efe6}
.rules{margin-top:12px;font-size:.88em;color:#cad4e6;background:#0a122088;padding:8px 12px;border-radius:10px;border:1px solid #ffffff14}
.rules summary{cursor:pointer;color:#f5cf6b;font-weight:600}

/* Topbar & Sound / 3D / Sidebar Toggles */
#topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:4px;
  background:linear-gradient(180deg,#16233a 0%,#0f1829 100%);
  border:1px solid #c8a45c66;
  border-radius:12px;
  padding:5px 7px;
  box-shadow:0 4px 14px #0008;
  flex-wrap:wrap;
}
.sound-btn,.view-btn,.leave-btn{
  font-size:.77em;
  padding:.35em .55em;
  border-radius:7px;
  font-weight:600;
  margin:0;
}
.sound-btn{
  background:linear-gradient(180deg,#1c4b3f 0%,#113028 100%);
  color:#ecfff8;
  border:1px solid #48b899;
}
.sound-btn.muted{
  background:linear-gradient(180deg,#472529 0%,#2b1518 100%);
  border-color:#b85d66;
  color:#f0d6d9;
}
.view-btn{
  background:linear-gradient(180deg,#25406b 0%,#152642 100%);
  color:#e3f0ff;
  border:1px solid #63a4ff;
}
.leave-btn{
  background:linear-gradient(180deg,#25324a 0%,#172030 100%);
  color:#d9e2f2;
  border:1px solid #6b7d9e;
}
.expand-side-btn{
  position:absolute;
  top:10px;
  right:10px;
  z-index:10;
  background:linear-gradient(180deg,#f5cf6b 0%,#c78d18 100%);
  color:#1c1100;
  border:1.5px solid #fff2b2;
  font-weight:800;
  padding:6px 12px;
  border-radius:10px;
  box-shadow:0 4px 14px #000a;
}

/* Right Side Panel (Asisten 8 Poin) */
#side{grid-column:2;grid-row:1/3;display:flex;flex-direction:column;gap:6px;min-height:0}
#game.side-collapsed{grid-template-columns:minmax(0,1fr)}
#game.side-collapsed #side{display:none}
.panel{
  background:linear-gradient(180deg,#131e33ee 0%,#0b1322f5 100%);
  border:1px solid #c8a45c66;
  border-radius:12px;
  padding:10px 11px;
  overflow:auto;
  flex:1;
  display:flex;
  flex-direction:column;
  gap:6px;
  box-shadow:0 8px 24px #0009;
}
.panel h3{
  margin:0 0 4px;
  font-size:.98em;
  color:#f5cf6b;
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:1px solid #c8a45c44;
  padding-bottom:6px;
}
.tog{font-weight:400;font-size:.84em;color:#cfd9ea}
.pname{font-weight:700;color:#fff8e8}
.badge{font-size:.72em;background:#ffffff1c;color:#e6eefc;border:1px solid #ffffff24;border-radius:5px;padding:1px 5px;margin-left:2px}
.badge.dealer-b{background:#d19a2244;color:#ffe28a;border-color:#f5cf6b88}
.wind{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:21px;
  height:21px;
  background:linear-gradient(180deg,#f5cf6b 0%,#c78d18 100%);
  color:#1b1102;
  border-radius:5px;
  padding:0 5px;
  font-weight:800;
  margin-right:4px;
  box-shadow:0 1px 4px #0008;
}
.meld{display:inline-flex;gap:1.5px;background:#00000048;padding:2px 3px;border-radius:5px;border:1px solid #f5cf6b33;box-shadow:0 3px 8px #0008}

/* ================= WIDESCREEN 1160x880 HD MAHJONG SOUL TABLE LAYOUT ================= */
#game{
  display:grid;
  grid-template-columns:minmax(0,1fr) 295px;
  grid-template-rows:minmax(0,1fr) auto;
  height:100vh;
  gap:5px;
  padding:5px;
}
#tablewrap{grid-column:1;grid-row:1;position:relative;min-height:0;overflow:hidden}
#board{
  position:absolute;
  top:0;
  left:0;
  width:1160px;
  height:880px;
  transform-origin:0 0;
  perspective:1350px;
}
#bar{
  grid-column:1;
  grid-row:2;
  background:linear-gradient(180deg,#121e33e6 0%,#0b1322f2 100%);
  border:1px solid #c8a45c55;
  border-radius:12px;
  padding:4px 12px;
  min-height:44px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
}
#actions{min-height:36px;display:flex;flex-wrap:wrap;align-items:center;gap:6px}

/* 2.5D Tabletop Plane (tilts subtly in 3D mode while bottom hand & HUD pills stay crisp flat in foreground) */
.table-plane{
  position:absolute;
  inset:0;
  transform-origin:50% 62%;
  transition:transform .35s cubic-bezier(.2,.8,.2,1);
}
#board.mode3d .table-plane{
  transform:rotateX(13deg) scale(1.015, 1.03);
}

/* HD Velvet Felt Table Mat + Studio Spotlight + Ornate Gold Inlay Frame */
.felt{
  position:absolute;
  inset:0;
  border-radius:26px;
  background-color:#0e4739;
  background-image:
    radial-gradient(ellipse at 50% 45%,#22856d55 0%,#11544522 45%,#06261ee6 85%,#031410fa 100%),
    repeating-linear-gradient(45deg,#ffffff06 0px,#ffffff06 1px,transparent 1px,transparent 6px),
    repeating-linear-gradient(-45deg,#00000018 0px,#00000018 1px,transparent 1px,transparent 6px);
  border:6px solid #2b1a0c;
  box-shadow:inset 0 0 85px #000e,inset 0 0 0 2px #d9b25f99,0 14px 36px #000d;
}
/* Outer Gold Inlay Line + Corner Lattice Accents */
.felt::before{
  content:"";
  position:absolute;
  inset:13px;
  border-radius:18px;
  border:1.5px solid #f0cb7555;
  box-shadow:inset 0 0 0 3px #06211b,inset 0 0 0 4px #f0cb7526;
  pointer-events:none;
}
/* Inner River/Compass Arena Frame with Ambient Occlusion */
.felt::after{
  content:"";
  position:absolute;
  left:172px;right:172px;top:122px;bottom:188px;
  border-radius:16px;
  border:1.5px solid #f0cb7540;
  background:radial-gradient(circle at 50% 50%,#196b5724 0%,#051c1666 100%);
  box-shadow:inset 0 0 36px #00000066,0 0 0 1px #0006;
  pointer-events:none;
}
/* Decorative Gold Chinese Corner Brackets on Arena */
.arena-corner{
  position:absolute;
  width:26px;
  height:26px;
  border-color:#f0cb7588;
  border-style:solid;
  pointer-events:none;
  z-index:1;
}
.arena-corner.tl{left:178px;top:128px;border-width:2.5px 0 0 2.5px;border-top-left-radius:8px}
.arena-corner.tr{right:178px;top:128px;border-width:2.5px 2.5px 0 0;border-top-right-radius:8px}
.arena-corner.bl{left:178px;bottom:194px;border-width:0 0 2.5px 2.5px;border-bottom-left-radius:8px}
.arena-corner.br{right:178px;bottom:194px;border-width:0 2.5px 2.5px 0;border-bottom-right-radius:8px}

/* ================= HD 3D MULTI-LAYERED PORCELAIN-IVORY TILES ================= */
.tile{
  display:inline-flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  width:42px;
  height:56px;
  /* Multi-layered warm porcelain-ivory body with top golden-amber resin layer & bottom 3D bevel */
  background:
    linear-gradient(145deg,#ffffffcc 0%,#ffffff00 42%),
    linear-gradient(180deg,#ffffff 0%,#fcf9f0 78%,#ede2ca 100%);
  border-radius:7px;
  border:1.2px solid #968565;
  border-top:4px solid #e5a328;
  box-shadow:
    0 4px 0 #c4b494,
    0 5px 0 #8a7858,
    0 8px 12px #000b,
    inset 0 1.5px 0 #ffffff,
    inset 0 -1px 2px #d5c7ab;
  color:#0f172a;
  font-weight:800;
  line-height:1;
  user-select:none;
  position:relative;
  overflow:hidden;
}
/* Inner carved recess frame + glossy specular sheen */
.tile:not(.back)::after{
  content:"";
  position:absolute;
  inset:2px;
  border-radius:5px;
  border:1px solid #e6dcc688;
  background:linear-gradient(135deg,#ffffff66 0%,#ffffff00 36%);
  pointer-events:none;
  z-index:2;
}
/* High-definition vector face image (FluffyStuff / Botanical SVG) */
.tile .tface{
  width:86%;
  height:86%;
  margin-top:6%;
  object-fit:contain;
  display:block;
  filter:drop-shadow(0 0.6px 0.5px rgba(0,0,0,0.22));
  pointer-events:none;
  z-index:1;
}
/* Crisp High-Contrast Top-Left Corner Index Badge */
.tile .tbadge{
  position:absolute;
  top:2px;
  left:2.5px;
  padding:1px 3.5px;
  border-radius:3.5px;
  font-size:11px;
  font-weight:900;
  line-height:1;
  font-family:system-ui,-apple-system,sans-serif;
  background:#ffffffeb;
  box-shadow:0 1px 2px #0004;
  z-index:3;
  pointer-events:none;
}
/* Heroic Bottom Hand Tiles (68px x 94px in board coords -> huge on screen!) */
.tile.th{
  width:68px;
  height:94px;
  border-radius:10px;
  border:1.5px solid #8f7e5e;
  border-top:6px solid #e8a72b;
  box-shadow:
    0 6px 0 #c9bba0,
    0 7.5px 0 #857456,
    0 12px 20px #000d,
    inset 0 2px 0 #ffffff,
    inset 0 -2px 3px #d4c6aa;
}
.tile.th .tbadge{
  top:3px;
  left:3.5px;
  font-size:15px;
  padding:1.5px 4.5px;
  border-radius:4.5px;
}
.tile.big{
  width:54px;
  height:74px;
  border-radius:8px;
  border-top:4.5px solid #e5a52c;
  box-shadow:0 4.5px 0 #c9bba0,0 7px 12px #000b;
}
.tile.big .tbadge{font-size:13px}
/* Exposed Melds & Flowers */
.tile.tmh{
  width:38px;
  height:52px;
  border-radius:5px;
  border-top:3px solid #e5a52c;
  box-shadow:0 3px 0 #c7b99b,0 5px 8px #000a;
}
.tile.tmh .tbadge{font-size:10px;padding:1px 2.5px}
.tile.tm{
  width:25px;
  height:34px;
  border-radius:4px;
  border-top:2.5px solid #e5a52c;
  box-shadow:0 2px 0 #c7b99b,0 3px 5px #000a;
}
.tile.tm .tbadge{font-size:7.5px;padding:0.5px 1.5px;top:1px;left:1px}
/* Discard River Tiles — Crisp 34px x 44px & Upright (0deg) so 4 rows (24 tiles) fit with zero overlap! */
.tile.tp{
  width:34px;
  height:44px;
  border-radius:5px;
  border:1.1px solid #968565;
  border-top:3px solid #e5a52c;
  box-shadow:0 2.5px 0 #c4b494,0 4px 6px #000c;
}
.tile.tp .tbadge{font-size:9.5px;padding:0.5px 2px;top:1.5px;left:1.5px}
/* Helper / Asisten & Modal Preview Tiles — 38px x 52px */
.tile.small{
  width:38px;
  height:52px;
  border-radius:5px;
  border-top:3px solid #e5a52c;
  box-shadow:0 2.5px 0 #c7b99b,0 4px 6px #0008;
}
.tile.small .tbadge{font-size:10px;padding:1px 2.5px}

/* Opponent Standing Tile Backs */
.tile.back{
  background:linear-gradient(165deg,#ffd768 0%,#e09b1f 58%,#ad6e08 100%);
  border:1px solid #633c02;
  border-top:2.5px solid #fff0b3;
  box-shadow:0 4px 0 #825004,0 6px 9px #000b;
}
.tile.back::after{
  content:"";
  position:absolute;
  inset:2.5px;
  border-radius:2.5px;
  border:1px solid #ffe9a866;
}
.tile.tb{width:26px;height:35px;border-radius:4px}
.tile.tb-v{width:28px;height:20px;border-radius:3.5px}

.tile.claimed{opacity:.35}
.tile.drawn{margin-left:14px}
.tile.fresh{animation:tileDrawIn .4s cubic-bezier(.2,.9,.25,1)}
.tile.drawn-v{margin-top:12px}

/* Smooth Tile Draw & Discard Animations */
.tile.fresh{animation:tileDrawIn .4s cubic-bezier(.2,.9,.25,1)}
@keyframes tileDrawIn{
  0%{transform:translateY(-85px) scale(.92);opacity:.15}
  70%{transform:translateY(3px) scale(1.02);opacity:1}
  100%{transform:none;opacity:1}
}
.tile.last{
  outline:3px solid #38f2ff;
  box-shadow:0 3.5px 0 #c4b494,0 0 20px #38f2ff,0 0 8px #ffffff;
  z-index:4;
  animation:discardLand .32s cubic-bezier(.2,.85,.3,1);
}
@keyframes discardLand{
  0%{transform:translateY(-28px) scale(1.18);filter:brightness(1.25)}
  100%{transform:none;filter:none}
}
.tile.last::before{
  content:"▼";
  position:absolute;
  top:0px;
  right:2px;
  font-size:12px;
  color:#0284c7;
  text-shadow:0 0 4px #fff;
  line-height:1;
  z-index:5;
}

/* Wall Stacks (compact 2-high golden-amber stacks with ambient shadow) */
.stack{position:absolute;width:26px;height:38px;filter:drop-shadow(0 4px 5px #0009)}
.wt{
  position:absolute;
  left:1px;
  width:24px;
  height:31px;
  border-radius:3.5px;
  background:linear-gradient(165deg,#f5c24c 0%,#d8961c 58%,#b0720c 100%);
  border:1px solid #6b4204;
}
.wt::after{content:"";position:absolute;inset:2px;border-radius:2px;border:1px solid #ffe9a655}
.wt.bot{top:6px;box-shadow:0 2.5px 0 #ede4ce,0 4px 4px #000a}
.wt.top{top:0;box-shadow:0 2.5px 0 #fff9ea,0 4px 5px #000b;background:linear-gradient(165deg,#ffd76b 0%,#e09f24 60%,#bc7b0e 100%)}
.stack.v{width:34px;height:26px}
.stack.v .wt{width:31px;height:21px}
.stack.v .wt.bot{top:5px}
.stack.v .wt.top{top:0}
.stack.nextf .wt.top,.stack.nextf .wt.bot:only-child{
  outline:2px solid #54f5ff;
  box-shadow:0 0 10px #54f5ffaa,0 2.5px 0 #fff9ea;
}
.stack.nextb .wt.top,.stack.nextb .wt.bot:only-child{
  outline:2px dashed #ff9a52;
}

/* Widescreen Discard Rivers (All tiles upright 0deg for instant readability!) */
.pond{
  position:absolute;
  border-radius:8px;
  background:#00000018;
  box-shadow:inset 0 2px 8px #00000044;
  transition:box-shadow .2s,background .2s;
}
.pond.active{
  background:#ffd86b14;
  box-shadow:inset 0 0 18px #f5cf6b33,0 0 0 1.5px #f5cf6b66;
}
.pond .tile{position:absolute}
/* Bottom, Top, Left & Right Rivers: 6 columns x up to 4 rows (214 x 182), zero overlap with center or walls! */
.pond.p0{left:473px;top:492px;width:214px;height:178px}
.pond.p2{left:473px;top:138px;width:214px;height:178px}
.pond.p3{left:250px;top:318px;width:214px;height:172px}
.pond.p1{left:696px;top:318px;width:214px;height:172px}

/* Bottom Player Area: Unified Mahjong Soul Bottom Rack (Standing Hand on Left/Center + Exposed Melds on Right!) */
.flw0{
  position:absolute;
  right:24px;
  top:718px;
  height:48px;
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:4px;
  pointer-events:none;
  z-index:5;
}
.rack0{
  position:absolute;
  left:20px;
  right:20px;
  top:772px;
  height:102px;
  display:flex;
  justify-content:center;
  align-items:flex-end;
  gap:18px;
  pointer-events:none;
  z-index:6;
}
.hrow0{
  display:flex;
  justify-content:center;
  align-items:flex-end;
  gap:3.5px;
  pointer-events:auto;
}
#hand.hrow0{flex-wrap:nowrap;margin:0}
.mrow0{
  display:flex;
  justify-content:flex-end;
  align-items:flex-end;
  gap:7px;
  pointer-events:none;
  padding-bottom:2px;
}

/* Opponent Hands & Melds (Top, Left, Right — strictly isolated between outer edge and walls) */
.hrow2{position:absolute;left:280px;width:600px;top:10px;height:38px;display:flex;justify-content:center;align-items:center;gap:2px}
.mrow2{position:absolute;left:230px;width:700px;top:50px;height:38px;display:flex;justify-content:center;align-items:center;gap:6px}
.hrow3{position:absolute;left:8px;top:170px;width:28px;height:460px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:2px}
.mrow3{position:absolute;left:50px;top:165px;width:94px;height:470px;display:flex;flex-direction:column;justify-content:center;align-items:flex-start;gap:5px}
.hrow1{position:absolute;right:8px;top:170px;width:28px;height:460px;display:flex;flex-direction:column;justify-content:center;align-items:center;gap:2px}
.mrow1{position:absolute;right:50px;top:165px;width:94px;height:470px;display:flex;flex-direction:column;justify-content:center;align-items:flex-end;gap:5px}
.flw{display:inline-flex;gap:2px;background:#00000044;padding:2px 4px;border-radius:6px;border:1px solid #e8c36a44}

/* Hand Tile Interactivity & Indicators */
.hrow0 .tile{
  cursor:pointer;
  transition:transform .13s cubic-bezier(.2,.8,.2,1),box-shadow .13s;
}
.hrow0 .tile:hover{
  transform:translateY(-12px);
  box-shadow:0 6px 0 #c9bba0,0 18px 26px #000e,0 0 16px #f5cf6baa;
}
.hrow0 .tile.sel{
  transform:translateY(-20px);
  outline:3.5px solid #ffd454;
  box-shadow:0 6px 0 #c9bba0,0 22px 30px #000f,0 0 22px #ffd454ee;
}
.hrow0 .tile.hint{
  box-shadow:0 6px 0 #c9bba0,0 12px 18px #000c,0 0 0 3px #28f596,0 0 18px #28f596aa;
}
.hrow0 .tile.hint::before{
  content:"";
  position:absolute;
  top:4px;
  right:4px;
  width:9px;
  height:9px;
  border-radius:50%;
  background:#10d978;
  box-shadow:0 0 8px #10d978;
  z-index:4;
}

/* ================= SLEEK ELECTRONIC CENTER COMPASS (176x176 at center 580,415) ================= */
.center{
  position:absolute;
  left:497px;
  top:322px;
  width:166px;
  height:166px;
  border-radius:20px;
  background:radial-gradient(circle at 50% 50%,#1d2f4a 0%,#0d1524 72%,#060b14 100%);
  border:2.5px solid #d9b25f;
  box-shadow:0 12px 28px #000d,inset 0 0 18px #000c,0 0 0 4px #061c17;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  z-index:2;
}
.center::before{
  content:"";
  position:absolute;
  inset:5px;
  border-radius:14px;
  border:1px solid #f5cf6b55;
  pointer-events:none;
}
.compass-core{
  width:104px;
  height:104px;
  border-radius:13px;
  background:radial-gradient(circle at 50% 38%,#223a5e 0%,#0b1424 100%);
  border:1.5px solid #d9b25f99;
  box-shadow:inset 0 0 12px #000b;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:1px;
  padding:3px;
  z-index:2;
}
.compass-round{
  display:flex;
  align-items:center;
  gap:4px;
  color:#f5cf6b;
  font-weight:800;
  font-size:13px;
  letter-spacing:.4px;
  text-shadow:0 0 10px #f5cf6b55;
}
.compass-round .rw-char{
  font-size:22px;
  line-height:1;
  color:#ffd86b;
}
.compass-wall{
  font-size:16px;
  font-weight:800;
  color:#6bf2ff;
  text-shadow:0 0 10px #38d9ff66;
  line-height:1.15;
}
.compass-wall small{
  font-size:10px;
  color:#a8bed9;
  font-weight:600;
}
.compass-meta{
  font-size:10px;
  color:#c9d6ea;
  opacity:.92;
  max-width:96px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.center .timer{
  font-size:13px;
  font-weight:800;
  color:#ffd454;
  min-height:15px;
  text-shadow:0 0 8px #ffa60088;
}

/* 4 Directional Seat Bars on Compass Edges */
.cseat{
  position:absolute;
  width:104px;
  height:30px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  font-size:12px;
  font-weight:700;
  color:#cbd7ea;
}
.cseat.cs0{bottom:2px;left:31px}
.cseat.cs2{top:2px;left:31px}
.cseat.cs1{top:68px;right:-35px;transform:rotate(-90deg)}
.cseat.cs3{top:68px;left:-35px;transform:rotate(90deg)}
.cseat .cw{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:20px;
  height:20px;
  border-radius:4px;
  background:#1f304d;
  border:1px solid #758eb5;
  color:#dce8fa;
  font-weight:800;
  font-size:12px;
}
.cseat .cscore{
  font-family:monospace;
  font-size:13px;
  color:#f5ead2;
}
.cseat .led{
  position:absolute;
  bottom:-1px;
  left:12px;
  right:12px;
  height:3.5px;
  border-radius:3px;
  background:#ffffff14;
}
.cseat.active .cw{
  background:linear-gradient(180deg,#ffd86b 0%,#cf8e15 100%);
  border-color:#fff2b2;
  color:#1c1100;
  box-shadow:0 0 10px #ffd86baa;
}
.cseat.active .cscore{
  color:#ffd86b;
  text-shadow:0 0 8px #ffd86b66;
}
.cseat.active .led{
  background:linear-gradient(90deg,#38f2ff,#ffd86b,#38f2ff);
  box-shadow:0 0 12px #4ef2ff,0 0 6px #ffd86b;
}

/* ================= STYLIZED PLAYER AVATARS & POLISHED HUD CARDS ================= */
.plabel{
  position:absolute;
  width:194px;
  padding:7px 10px;
  background:linear-gradient(160deg,#15243ef0 0%,#09101df8 100%);
  border-radius:14px;
  font-size:13.5px;
  line-height:1.3;
  border:1.5px solid #d9b25f88;
  box-shadow:0 8px 20px #000b,inset 0 1px 0 #ffffff22;
  display:flex;
  align-items:center;
  gap:8px;
  z-index:6;
}
.plabel.active{
  border-color:#ffd454;
  box-shadow:0 0 20px #ffd454aa,0 8px 20px #000b;
}
.plabel.c0{left:16px;top:672px}
.plabel.c1{right:16px;top:12px}
.plabel.c2{left:16px;top:12px}
.plabel.c3{left:16px;top:82px}
.pavatar{
  width:44px;
  height:44px;
  border-radius:50%;
  flex-shrink:0;
  border:2px solid #f5cf6b;
  box-shadow:0 2px 8px #000a;
  overflow:hidden;
  background:#101c30;
}
.pavatar svg{width:100%;height:100%;display:block}
.pinfo{flex:1;min-width:0}
.plabel .phead{display:flex;align-items:center;gap:3px}
.plabel .pname{
  display:inline-block;
  max-width:96px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:14.5px;
}
.plabel .pmeta{margin-top:3px;display:flex;flex-wrap:wrap;gap:2px;align-items:center}

/* ================= CALLIGRAPHIC VFX SPLASH BANNER (CHI / PUNG / KONG / HU / BUNGA) ================= */
#vfx-layer{
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:15;
  overflow:hidden;
}
.vfx-banner{
  position:absolute;
  transform:translate(-50%,-50%);
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 28px;
  border-radius:999px;
  border:2.5px solid #ffe48a;
  background:radial-gradient(ellipse at 50% 50%,#1b2d4ef2 0%,#091224f8 100%);
  box-shadow:0 0 36px #f5cf6bcc,0 10px 30px #000d,inset 0 0 18px #ffffff33;
  animation:vfxPop 1.15s cubic-bezier(.18,.88,.28,1) forwards;
}
.vfx-banner.hu{
  background:radial-gradient(ellipse at 50% 50%,#b8170cf5 0%,#4f0703fa 100%);
  border-color:#ffdf85;
  box-shadow:0 0 48px #ff3b24ee,0 0 20px #ffd86b,0 12px 32px #000e;
}
.vfx-banner.pung{
  background:radial-gradient(ellipse at 50% 50%,#184e8cf5 0%,#0a2142fa 100%);
  border-color:#82c8ff;
  box-shadow:0 0 38px #38b6ffcc,0 10px 28px #000d;
}
.vfx-banner.kong{
  background:radial-gradient(ellipse at 50% 50%,#5f259cf5 0%,#280c47fa 100%);
  border-color:#dfb0ff;
  box-shadow:0 0 42px #b566ffdd,0 10px 28px #000d;
}
.vfx-banner.chi{
  background:radial-gradient(ellipse at 50% 50%,#146b42f5 0%,#08301dfa 100%);
  border-color:#7bf2b3;
  box-shadow:0 0 38px #28f596cc,0 10px 28px #000d;
}
.vfx-banner .vfx-kanji{
  font-size:48px;
  font-weight:900;
  line-height:1;
  color:#ffd86b;
  text-shadow:0 0 16px #ffae00,0 3px 6px #000c;
  font-family:"Noto Serif SC","Songti SC","SimSun",serif;
}
.vfx-banner .vfx-text{
  display:flex;
  flex-direction:column;
  text-align:left;
}
.vfx-banner .vfx-title{
  font-size:22px;
  font-weight:900;
  letter-spacing:1.5px;
  color:#ffffff;
  text-shadow:0 2px 6px #000;
}
.vfx-banner .vfx-sub{
  font-size:12px;
  font-weight:700;
  color:#f5cf6b;
}
@keyframes vfxPop{
  0%{opacity:0;transform:translate(-50%,-50%) scale(.45)}
  18%{opacity:1;transform:translate(-50%,-50%) scale(1.12)}
  30%{opacity:1;transform:translate(-50%,-50%) scale(1.0)}
  78%{opacity:1;transform:translate(-50%,-50%) scale(1.02)}
  100%{opacity:0;transform:translate(-50%,-58%) scale(.92)}
}

/* Mahjong Soul Calligraphic Action Emblems */
.act-emblem{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 14px;
  border-radius:999px;
  font-weight:800;
  font-size:.95em;
  letter-spacing:.3px;
  border:1.5px solid #ffd875;
  box-shadow:0 4px 14px #000a,inset 0 1px 0 #fff6;
}
.act-emblem .kanji{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:26px;
  height:26px;
  border-radius:50%;
  background:#00000044;
  border:1px solid #ffffff44;
  font-size:1.05em;
}
.act-emblem.chi{background:linear-gradient(180deg,#268a56 0%,#155735 100%);border-color:#7bf2b3;color:#f2fff8}
.act-emblem.pung{background:linear-gradient(180deg,#2568b5 0%,#143d73 100%);border-color:#82c0ff;color:#f0f7ff}
.act-emblem.kong{background:linear-gradient(180deg,#7c3bbd 0%,#481d78 100%);border-color:#d29eff;color:#fbf5ff}
.act-emblem.hu{
  background:linear-gradient(180deg,#ff4d36 0%,#a81205 100%);
  border-color:#ffdf85;
  color:#fff;
  box-shadow:0 0 20px #ff3b24cc,0 4px 14px #000a;
}
.act-emblem.pass{
  background:linear-gradient(180deg,#3a4659 0%,#222a36 100%);
  border-color:#8c9bb3;
  color:#e2e9f5;
}

/* Modal & Helper Table Styling */
.modal{position:fixed;inset:0;background:#000b;backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;z-index:20}
.modal .card{max-width:760px;max-height:90vh;overflow:auto}
table.fans{border-collapse:collapse;width:100%;margin:8px 0}
table.fans td,table.fans th{border-bottom:1px solid #ffffff22;padding:4px 6px;text-align:left;color:#f4efe6}
table.fans th{color:#f5cf6b}
table.fans td.p{text-align:right;font-weight:700;color:#ffd86b}
.helper-msg{margin:4px 0;font-size:.9em;line-height:1.4;color:#dce5f5}
.helper table{font-size:.85em;width:100%;border-collapse:collapse;margin-top:6px}
.helper td{border-bottom:1px solid #ffffff1a;padding:4px 4px;vertical-align:middle;color:#e6eefc}
.short{background:linear-gradient(90deg,#b82323,#7d1616);border:1px solid #ff8080;color:#fff;border-radius:8px;padding:6px 10px;font-weight:700;margin:4px 0}
.okv{background:linear-gradient(90deg,#157a46,#0e522f);border:1px solid #5ce69b;color:#fff;border-radius:8px;padding:6px 10px;font-weight:700;margin:4px 0}
.hrow{display:flex;gap:3px;flex-wrap:wrap;align-items:center}

@media (max-width:900px){
  #game{grid-template-columns:1fr;grid-template-rows:auto auto auto;height:auto}
  #tablewrap{height:78vw}
  #side{grid-column:1;grid-row:3}
}

/* ================= MENTOR CHAT BUBBLES (DOCKED IN BOTTOM BAR & SIDEBAR) ================= */
.tile.tmini{
  width:20px;
  height:27px;
  border-radius:3px;
  border-top:2px solid #e5a52c;
  box-shadow:0 1.5px 0 #c4b494,0 2px 3px #0008;
  vertical-align:middle;
  margin:0 2px;
}
.tile.tmini .tbadge{
  font-size:6.5px;
  padding:0.5px 1.5px;
  top:1px;
  left:1px;
}

/* Compact Docked Coach Chat Bubble inside #bar (100% outside green table!) */
#coach-slot{
  display:flex;
  align-items:center;
  margin-left:auto;
  max-width:56%;
}
.coach-bubble{
  display:inline-flex;
  align-items:center;
  gap:8px;
  background:linear-gradient(160deg,#172a4ae8 0%,#0d182cf5 100%);
  border:1.5px solid #f5cf6baa;
  border-radius:999px;
  padding:4px 10px 4px 6px;
  box-shadow:0 4px 14px #000a,inset 0 1px 0 #ffffff28;
  color:#f8f3e8;
  pointer-events:auto;
  max-width:100%;
  animation:coachFloatIn .22s cubic-bezier(.2,.85,.3,1);
}
@keyframes coachFloatIn{
  from{opacity:0;transform:translateY(4px) scale(.98)}
  to{opacity:1;transform:none}
}
.coach-ava{
  width:24px;
  height:24px;
  border-radius:50%;
  background:linear-gradient(135deg,#f5cf6b,#b45309);
  border:1.5px solid #fff3c4;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-size:13px;
  flex-shrink:0;
  box-shadow:0 1px 4px #0008;
}
.coach-tag{
  font-size:10px;
  padding:1.5px 6px;
  border-radius:999px;
  background:#f5cf6b24;
  border:1px solid #f5cf6b66;
  color:#ffe596;
  font-weight:700;
  white-space:nowrap;
  flex-shrink:0;
}
.coach-body{
  font-size:12px;
  line-height:1.3;
  color:#eef4ff;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.coach-body b{color:#ffd86b}
.coach-btn{
  font-size:11px;
  padding:3px 9px;
  border-radius:999px;
  background:linear-gradient(180deg,#f5cf6b 0%,#d19a22 100%);
  color:#1c1202;
  border:1px solid #fff0b8;
  font-weight:800;
  cursor:pointer;
  white-space:nowrap;
  flex-shrink:0;
  margin:0;
}
.coach-min-btn{
  font-size:10.5px;
  padding:2px 6px;
  border-radius:999px;
  background:#ffffff18;
  color:#cbd5e1;
  border:1px solid #ffffff28;
  cursor:pointer;
  margin:0;
  flex-shrink:0;
}
.coach-min-btn:hover{background:#ffffff30;color:#fff}
.coach-pill-restore{
  font-size:11.5px;
  padding:4px 10px;
  border-radius:999px;
  background:linear-gradient(160deg,#172a4ae8 0%,#0d182cf5 100%);
  border:1.5px solid #f5cf6b99;
  color:#ffd86b;
  font-weight:700;
  cursor:pointer;
  margin:0;
}

/* Sidebar Visual 8-Point Progress Card & Chat-Bubble Feed */
.helper{
  display:flex;
  flex-direction:column;
  gap:7px;
}
.pts-card{
  background:linear-gradient(160deg,#182946 0%,#0f1a2e 100%);
  border:1.5px solid #c8a45c88;
  border-radius:11px;
  padding:7px 9px;
  box-shadow:inset 0 1px 0 #ffffff1c,0 4px 12px #0006;
}
.pts-card.ready{
  border-color:#38f29c;
  background:linear-gradient(160deg,#0f3828 0%,#092118 100%);
}
.pts-top{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
  margin-bottom:5px;
}
.pts-title{
  font-size:.84em;
  font-weight:800;
  color:#f5ead2;
}
.pts-pill{
  font-size:.76em;
  font-weight:800;
  padding:1.5px 7px;
  border-radius:999px;
  background:#b82323;
  border:1px solid #ff8a8a;
  color:#fff;
}
.pts-card.ready .pts-pill{
  background:#109655;
  border-color:#6bffb8;
}
.pts-segs{
  display:grid;
  grid-template-columns:repeat(8,1fr);
  gap:3px;
  margin-bottom:5px;
}
.pts-seg{
  height:6px;
  border-radius:4px;
  background:#ffffff1a;
  border:1px solid #ffffff18;
}
.pts-seg.on{
  background:linear-gradient(90deg,#f5cf6b,#ffae00);
  border-color:#ffe89e;
  box-shadow:0 0 6px #f5cf6b88;
}
.pts-card.ready .pts-seg.on{
  background:linear-gradient(90deg,#28f596,#10b981);
  border-color:#a7f3d0;
  box-shadow:0 0 6px #28f59688;
}
.pts-step{
  font-size:.8em;
  color:#d2def2;
  line-height:1.3;
}

/* Sidebar Chat Bubble Container */
.chat-msg{
  display:flex;
  align-items:flex-start;
  gap:6px;
}
.chat-ava{
  width:24px;
  height:24px;
  border-radius:50%;
  background:linear-gradient(135deg,#f5cf6b,#b45309);
  border:1.5px solid #ffe79e;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:13px;
  flex-shrink:0;
  margin-top:2px;
  box-shadow:0 2px 6px #0009;
}
.chat-bub{
  flex:1;
  min-width:0;
  position:relative;
  background:linear-gradient(165deg,#1a2c4a 0%,#111e34 100%);
  border:1px solid #c8a45c77;
  border-radius:4px 12px 12px 12px;
  padding:7px 9px;
  box-shadow:0 4px 12px #0007,inset 0 1px 0 #ffffff18;
  font-size:.82em;
  line-height:1.35;
  color:#ebf2ff;
}
.chat-bub.warn{
  border-color:#ff8080aa;
  background:linear-gradient(165deg,#3b1a22 0%,#241016 100%);
}
.chat-bub.good{
  border-color:#4ef2a8aa;
  background:linear-gradient(165deg,#123829 0%,#0b231a 100%);
}
.bub-title{
  font-weight:800;
  color:#ffd86b;
  font-size:.9em;
  margin-bottom:3px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:4px;
}

/* Interactive Discard Suggestion Cards inside Chat Bubble */
.discard-list{
  display:flex;
  flex-direction:column;
  gap:4px;
  margin-top:4px;
}
.discard-choice{
  display:flex;
  align-items:center;
  gap:6px;
  padding:4px 6px;
  border-radius:8px;
  background:#0b1424b8;
  border:1px solid #ffffff1f;
  cursor:pointer;
  transition:transform .1s,border-color .1s,background .1s;
}
.discard-choice:hover{
  transform:translateX(2px);
  border-color:#f5cf6b;
  background:#152542;
}
.discard-choice.best{
  border-color:#28f59688;
  background:#0d2b22cc;
}
.dc-info{
  flex:1;
  min-width:0;
}
.dc-top{
  display:flex;
  align-items:center;
  gap:4px;
  flex-wrap:wrap;
  font-weight:800;
  color:#fff;
  font-size:.92em;
}
.dc-tag{
  font-size:.72em;
  padding:1px 5px;
  border-radius:999px;
  background:#10b98133;
  border:1px solid #34d399;
  color:#a7f3d0;
}
.dc-desc{
  font-size:.82em;
  color:#c4d3eb;
  margin-top:1px;
  line-height:1.25;
}

/* Visual Fan Recipe Cards inside Chat Bubble */
.recipe-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:4px;
}
.fan-recipe{
  background:#0a1322cc;
  border:1px solid #c8a45c55;
  border-radius:9px;
  padding:6px 7px;
}
.fr-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:5px;
  margin-bottom:2px;
}
.fr-name{
  font-weight:800;
  color:#fff6dc;
  font-size:.92em;
  line-height:1.2;
}
.fr-pts{
  flex-shrink:0;
  background:linear-gradient(180deg,#f5cf6b,#c78d18);
  color:#1c1100;
  font-weight:900;
  font-size:.8em;
  padding:1px 5px;
  border-radius:5px;
}
.fr-badge{
  display:inline-block;
  font-size:.73em;
  font-weight:700;
  padding:1px 5px;
  border-radius:999px;
  margin-bottom:3px;
}
.fr-badge.near{background:#10b98128;border:1px solid #34d39988;color:#86efac}
.fr-badge.mid{background:#f59e0b28;border:1px solid #fbbf2488;color:#fde68a}
.fr-badge.far{background:#64748b33;border:1px solid #94a3b866;color:#cbd5e1}
.fr-desc{
  font-size:.8em;
  color:#b6c6e0;
  margin-bottom:3px;
  line-height:1.25;
}
.fr-step{
  font-size:.82em;
  color:#eef5ff;
  background:#ffffff0d;
  border-left:2.5px solid #f5cf6b;
  padding:2.5px 5px;
  border-radius:0 4px 4px 0;
  line-height:1.28;
}
.fr-tiles{
  margin-top:4px;
  display:flex;
  align-items:center;
  gap:3px;
  flex-wrap:wrap;
  font-size:.78em;
  color:#ffd86b;
  font-weight:700;
}

/* Secured Fan Pills */
.sec-pills{
  display:flex;
  flex-wrap:wrap;
  gap:4px;
  margin-top:3px;
}
.sec-pill{
  font-size:.78em;
  font-weight:700;
  padding:2px 6px;
  border-radius:999px;
  background:#10b98124;
  border:1px solid #34d39988;
  color:#bbf7d0;
}

/* =====================================================================
   AUTOMATIC MOBILE LAYOUT — every rule is scoped under body.mobile
   (set by client.js only on touch phones), so the PC view is untouched.
   ===================================================================== */
.m-only{display:none}
body.mobile{
  -webkit-user-select:none;
  user-select:none;
  -webkit-touch-callout:none;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
  overscroll-behavior:none;
}
body.mobile *{touch-action:manipulation}
body.mobile input,body.mobile textarea{-webkit-user-select:text;user-select:text;font-size:16px}
body.mobile button{min-height:40px}

/* ---- Lobby ---- */
body.mobile .lobby-card{
  max-width:min(520px,calc(100vw - 16px));
  margin:max(10px,env(safe-area-inset-top)) auto max(14px,env(safe-area-inset-bottom));
  padding:16px 16px 18px;
}
body.mobile .lobby-head h1{font-size:1.45em}
body.mobile .lobby-card .row{gap:8px}
body.mobile .lobby-card .row > button{flex:1 1 100%;min-height:48px;font-size:16px;margin:0}
body.mobile .lobby-card .row > input{flex:1 1 auto;min-height:46px}
body.mobile .lobby-card .row > input#code{flex:0 0 7.5em}
body.mobile .lobby-card .row > input#code + button{flex:1 1 0}
body.mobile .lobby-card .row > #shareLink + button{flex:0 0 auto}
body.mobile #lobby .sound-btn{min-height:40px}

/* ---- Game shell: full-screen Mahjong Soul style table (no side columns) ---- */
body.mobile #game,
body.mobile #game.side-collapsed{
  display:block;
  position:fixed;
  inset:0;
  height:auto;
  padding:0;
  gap:0;
  overflow:hidden;
  background:#04110d;
}
body.mobile #tablewrap{
  position:absolute;
  top:env(safe-area-inset-top,0px);right:env(safe-area-inset-right,0px);
  bottom:env(safe-area-inset-bottom,0px);left:env(safe-area-inset-left,0px);
  height:auto;min-height:0;overflow:hidden;
}
body.mobile #btnExpandSide,body.mobile #btnToggleSide{display:none!important}
/* own hand: big row across the bottom, melds bottom-right */
body.mobile #mhand{
  display:flex;
  position:absolute;z-index:8;
  left:env(safe-area-inset-left,0px);right:env(safe-area-inset-right,0px);bottom:env(safe-area-inset-bottom,0px);
  justify-content:center;align-items:flex-end;
  min-width:0;pointer-events:none;
  background:linear-gradient(180deg,#00000000 0%,#0000003d 55%,#00000066 100%);
}
body.mobile #mhand.myturn{box-shadow:inset 0 2px 0 #ffd45455}
body.mobile #mhand .rack0{
  position:relative;
  left:auto;right:auto;top:auto;
  height:auto;
  padding:8px 10px 5px;
  flex-wrap:nowrap;
  justify-content:center;
  align-items:flex-end;
  gap:22px;
}
body.mobile #mhand #hand.hrow0{flex-wrap:nowrap;justify-content:center}
body.mobile #mhand .mrow0{gap:6px;padding-bottom:0}
body.mobile #mhand .mrow0 .flw{align-self:flex-end}
body.mobile .hrow0 .tile:hover:not(.sel){transform:none}
body.mobile .hrow0 .tile.sel{transform:translateY(-16px)}

/* Overlay layer: coach pill (bottom-left free corner), pill actions (bottom-right), corner icons */
body.mobile #bar{
  position:absolute;inset:0;z-index:9;
  display:block;min-height:0;padding:0;margin:0;
  background:none;border:0;border-radius:0;box-shadow:none;
  pointer-events:none;
}
body.mobile #bar > *{pointer-events:auto}
body.mobile #actions{
  position:absolute;
  right:calc(env(safe-area-inset-right,0px) + 30px);
  bottom:calc(env(safe-area-inset-bottom,0px) + var(--actb,90px));
  max-width:calc(100vw - 64px);
  min-height:0;
  display:flex;flex-direction:row;flex-wrap:wrap-reverse;justify-content:flex-end;align-items:center;
  gap:8px;
}
body.mobile #actions:empty{display:none}
body.mobile #bar.actwide #coach-slot{display:none}
body.mobile #actions > span.m-turninfo{display:none}
body.mobile #actions button{
  margin:0;min-height:46px;padding:4px 18px 4px 6px;
  font-size:16px;font-weight:800;
  border-radius:999px;border-width:2px;
  display:inline-flex;align-items:center;justify-content:center;gap:6px;flex-wrap:nowrap;white-space:nowrap;
  box-shadow:0 5px 16px #000c,inset 0 1px 0 #fff6;
}
body.mobile #actions button .kanji{width:34px;height:34px;font-size:19px}
body.mobile #actions button.act-emblem.pass{padding:4px 18px}
body.mobile #actions .act-emblem.discard{background:linear-gradient(180deg,#f5cf6b 0%,#c98a12 100%);border-color:#fff0b8;color:#1c1202}
body.mobile #actions button .tile.small{width:20px;height:27px;border-radius:3px;border-top-width:2px;box-shadow:0 1px 0 #c7b99b}
body.mobile #actions button .tile.small .tbadge{display:none}
body.mobile #actions button .tile.small::after{inset:1px}
body.mobile #actions.many{gap:6px}
body.mobile #actions.many button{min-height:42px;font-size:14px;padding:3px 12px 3px 4px}
body.mobile #actions.many button .kanji{width:28px;height:28px;font-size:16px}
body.mobile #actions.many button.act-emblem.pass{padding:3px 12px}
body.mobile #actions button .tile.small + .tile.small{margin-left:-3px}
body.mobile #actions > span.short{max-width:300px;font-size:12px;line-height:1.3;padding:5px 9px;border-radius:10px}
body.mobile.landscape .claim-call{display:none}
body.mobile .claim-call{
  display:flex;align-items:center;gap:6px;font-size:12px;line-height:1.2;color:#eef4ff;
  padding:3px 10px 3px 4px;border-radius:999px;
  background:linear-gradient(160deg,#172a4ae8,#0d182cf5);border:1.5px solid #38f2ff99;box-shadow:0 4px 12px #000a;
}
body.mobile .claim-call small{color:#cbd5e1}
body.mobile .claim-call b{color:#ffd86b}
.tile.claimcall{width:28px;height:37px;flex-shrink:0;border-radius:4px;border-top-width:2.5px;outline:2px solid #38f2ff;box-shadow:0 0 10px #38f2ff,0 2px 0 #c4b494}
.tile.claimcall .tbadge{font-size:8px;padding:0 2px;top:1px;left:1px}
body.mobile #coach-slot{
  position:absolute;
  left:calc(env(safe-area-inset-left,0px) + 28px);
  bottom:calc(env(safe-area-inset-bottom,0px) + var(--hb,80px) + 5px);
  margin:0;max-width:var(--coachw,220px);width:auto;
}
body.mobile .coach-bubble{
  border-radius:12px;padding:4px 6px;gap:5px;
  max-height:var(--coachh,60px);overflow:hidden;align-items:center;
}
body.mobile .coach-ava{width:22px;height:22px;font-size:12px}
body.mobile .coach-tag{font-size:9.5px;padding:1px 5px}
body.mobile .coach-body{white-space:normal;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;font-size:11.5px;line-height:1.25;min-width:0;flex:1 1 auto}
body.mobile .coach-body .tile.tmini{vertical-align:middle}
body.mobile .coach-btn{min-height:32px;padding:3px 11px;font-size:12px}
body.mobile .coach-min-btn{min-height:26px;min-width:26px;padding:0 6px}
body.mobile .coach-pill-restore{min-height:32px;padding:3px 11px;font-size:12px}
body.mobile #msg{position:absolute;left:50%;top:calc(env(safe-area-inset-top,0px) + 30px);transform:translateX(-50%);max-width:70vw;z-index:2;text-align:center;
  background:#2a0b0be6;border:1px solid #ff808066;border-radius:999px;padding:3px 12px;font-size:12px}
body.mobile #msg:empty{display:none}
body.mobile #mtools{
  position:absolute;
  top:calc(env(safe-area-inset-top,0px) + 4px);right:calc(env(safe-area-inset-right,0px) + 4px);
  display:flex;gap:6px;
}
body.mobile #mtools button{
  margin:0;width:36px;height:36px;min-height:36px;padding:0;border-radius:10px;
  font-size:17px;line-height:1;display:inline-flex;align-items:center;justify-content:center;
  background:linear-gradient(180deg,#1d2e4cee,#0f1a2ef5);border:1.5px solid #d9b25faa;color:#ffe9a8;
  box-shadow:0 3px 8px #000a;
}

/* Asisten sidebar becomes a slide-in drawer */
body.mobile #side,
body.mobile #game.side-collapsed #side{
  display:flex;
  position:fixed;
  top:0;right:0;bottom:0;
  width:min(360px,88vw);
  z-index:60;
  padding:max(6px,env(safe-area-inset-top)) max(6px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) 6px;
  background:linear-gradient(180deg,#0e1830f7,#070d19fa);
  border-left:1.5px solid #c8a45c88;
  box-shadow:-12px 0 32px #000c;
  transform:translateX(105%);
  transition:transform .25s cubic-bezier(.2,.8,.2,1);
}
body.mobile.drawer-open #side{transform:none}
body.mobile #topbar{display:flex;flex-wrap:wrap;gap:4px}
body.mobile #topbar button{flex:1 1 auto;margin:0}
body.mobile #btnCloseDrawer{display:inline-block}
body.mobile #helperPanel{overflow-y:auto;-webkit-overflow-scrolling:touch}
body.mobile #drawerBackdrop{display:block;position:fixed;inset:0;z-index:55;background:#0008;opacity:0;pointer-events:none;transition:opacity .2s}
body.mobile.drawer-open #drawerBackdrop{opacity:1;pointer-events:auto}
body.mobile .modal .card{max-width:calc(100vw - 16px);max-height:calc(100dvh - 16px);overflow:auto}

/* ---- Portrait: strong rotate-to-landscape overlay (with "continue anyway" fallback) ---- */
body.mobile.portrait #rotateHint{
  display:flex;position:fixed;inset:0;z-index:70;
  align-items:center;justify-content:center;padding:24px;
  background:radial-gradient(ellipse at 50% 40%,#123c31f2 0%,#06140ffa 70%);
  backdrop-filter:blur(3px);
}
body.mobile.portrait.rot-hidden #rotateHint{display:none}
body.mobile .rh-box{
  display:flex;flex-direction:column;align-items:center;gap:14px;text-align:center;
  max-width:340px;padding:22px 18px;border-radius:18px;
  background:linear-gradient(160deg,#15243ef5,#09101dfa);border:1.5px solid #d9b25f;box-shadow:0 12px 36px #000d;
  color:#f4efe6;font-size:14.5px;line-height:1.45;
}
body.mobile .rh-txt b{color:#ffd86b}
body.mobile .rh-ico{font-size:54px;line-height:1;display:inline-block;animation:rhSpin 2.2s ease-in-out infinite}
body.mobile .rh-box button{margin:0;width:100%;min-height:46px;font-size:15px}
body.mobile #btnRotateHide{background:none;border:1px solid #ffffff44;color:#dfe7f5;font-size:14px}
@keyframes rhSpin{0%,35%{transform:rotate(0)}55%,90%{transform:rotate(-90deg)}100%{transform:rotate(0)}}
/* portrait fallback: same table, hand wraps, coach becomes a strip above the hand */
body.mobile.portrait #mhand .rack0{flex-wrap:wrap;row-gap:6px;gap:8px}
body.mobile.portrait #mhand #hand.hrow0{flex-wrap:wrap}
body.mobile.portrait #coach-slot{left:calc(env(safe-area-inset-left,0px) + 6px);right:calc(env(safe-area-inset-right,0px) + 6px);max-width:none}
body.mobile.portrait #actions{right:calc(env(safe-area-inset-right,0px) + 8px);max-width:calc(100vw - 16px)}

/* ---- Online connection status & self-test ---- */
.conn-line{margin:4px 0;font-size:.85em;color:#cfe3ff}
.conn-line.relay{color:#ffe08a}
.conn-line.failed{color:#ff9b9b}
.net-test-row{margin:4px 0}
.net-test-btn{font-size:.82em;padding:.35em .8em;background:linear-gradient(180deg,#1d2a40,#141d2e);border-color:#6b7d9e;color:#d9e2f2}
.net-test-out{font-size:.82em;line-height:1.45;background:#0a111fcc;border:1px solid #c8a45c44;border-radius:8px;padding:6px 9px;margin:4px 0 8px;color:#e6eefc}
.conn-badge{flex:1 1 100%;font-size:.72em;color:#cfe3ff;background:#0a111f99;border:1px solid #ffffff1f;border-radius:6px;padding:2px 6px;line-height:1.35}
.conn-badge.relay{color:#ffe08a;border-color:#f5cf6b55}
.conn-badge.failed{color:#ff9b9b;border-color:#ff808055}

/* ================= DEDICATED MOBILE TABLE — Mahjong Soul style (body.mobile only; real px) ================= */
body.mobile #board.mb{perspective:none;transform:none}
.mb .mfelt{
  position:absolute;inset:0;
  background-color:#0e4739;
  background-image:radial-gradient(ellipse at 50% 46%,#2a9a7d55 0%,#13594822 42%,#06261ee8 88%,#03140ff5 100%),
    repeating-linear-gradient(45deg,#ffffff06 0px,#ffffff06 1px,transparent 1px,transparent 6px);
  box-shadow:inset 0 0 60px #000c;
}
/* thin inlaid square around the ponds (the "arena" lines of the Mahjong Soul table) */
.mb .marena{position:absolute;border:1.5px solid #f0cb7530;border-radius:10px;box-shadow:inset 0 0 0 4px #00000018,0 0 0 4px #0000000f;pointer-events:none}
/* center compass */
.mb .mcenter{
  position:absolute;z-index:3;
  border-radius:12px;
  background:radial-gradient(circle at 50% 50%,#1d2f4a 0%,#0d1524 72%,#060b14 100%);
  border:2px solid #d9b25f;
  box-shadow:0 8px 20px #000d,inset 0 0 14px #000c,0 0 0 3px #061c17;
}
.mb .mc-core{
  position:absolute;left:24px;right:24px;top:24px;bottom:24px;
  border-radius:9px;
  background:radial-gradient(circle at 50% 38%,#223a5e 0%,#0b1424 100%);
  border:1px solid #d9b25f99;box-shadow:inset 0 0 10px #000b;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;
  color:#e6eefc;text-align:center;line-height:1.15;overflow:hidden;
}
.mb .mc-round{display:flex;align-items:center;gap:3px;color:#f5cf6b;font-weight:800;font-size:11.5px;text-shadow:0 0 8px #f5cf6b55}
.mb .mc-round b{font-size:19px;line-height:1;color:#ffd86b}
.mb .mc-wall{font-size:15px;font-weight:800;color:#6bf2ff;text-shadow:0 0 8px #38d9ff66}
.mb .mc-wall small{font-size:9.5px;color:#a8bed9;font-weight:600}
.mb .mc-core .timer{position:static;font-size:12px;font-weight:800;color:#ffd454;min-height:14px;margin:0;padding:0;background:none;border:0;box-shadow:none;text-shadow:0 0 6px #ffa60088}
.mb .mcs{
  position:absolute;left:50%;top:50%;height:22px;
  width:calc(var(--cw) - 50px);
  display:flex;align-items:center;justify-content:center;gap:3px;
  font-size:11px;font-weight:700;color:#cbd7ea;white-space:nowrap;
}
.mb .mcs.s1,.mb .mcs.s3{width:calc(var(--ch) - 50px)}
.mb .mcs.s0{transform:translate(-50%,-50%) translateY(calc(var(--ch) / 2 - 12px))}
.mb .mcs.s2{transform:translate(-50%,-50%) rotate(180deg) translateY(calc(var(--ch) / 2 - 12px))}
.mb .mcs.s1{transform:translate(-50%,-50%) rotate(-90deg) translateY(calc(var(--cw) / 2 - 12px))}
.mb .mcs.s3{transform:translate(-50%,-50%) rotate(90deg) translateY(calc(var(--cw) / 2 - 12px))}
.mb .mcs .cw{
  flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;
  width:16px;height:16px;border-radius:4px;font-size:10.5px;font-weight:800;
  background:#1f304d;border:1px solid #758eb5;color:#dce8fa;
}
.mb .mcs .cw.dealer{border-color:#ff6b5b;box-shadow:0 0 0 1px #ff6b5b88}
.mb .mcs .cn{min-width:0;overflow:hidden;text-overflow:ellipsis;color:#e6eefc;font-size:10.5px}
.mb .mcs .cscore{flex:0 0 auto;font-family:monospace;font-size:11.5px;color:#f5ead2}
.mb .mcs .led{position:absolute;left:6px;right:6px;bottom:-1px;height:3px;border-radius:3px;background:#ffffff14}
.mb .mcs.active .cw{background:linear-gradient(180deg,#ffd86b 0%,#cf8e15 100%);border-color:#fff2b2;color:#1c1100;box-shadow:0 0 8px #ffd86baa}
.mb .mcs.active .cscore,.mb .mcs.active .cn{color:#ffd86b}
.mb .mcs.active .led{background:linear-gradient(90deg,#38f2ff,#ffd86b,#38f2ff);box-shadow:0 0 10px #4ef2ff,0 0 5px #ffd86b}
.mb .mcs.off{opacity:.55}
/* ponds */
.mb .mpond{position:absolute;z-index:2;border-radius:5px;background:#0000001f}
.mb .mpond.active{background:#ffd86b14;box-shadow:0 0 0 1.5px #f5cf6b66,0 0 12px #f5cf6b22}
.mb .mpond .tile{position:absolute;transform:rotate(var(--rot,0deg))}
.tile.tmp{
  width:var(--pw,24px);height:var(--ph,31px);
  border-radius:4px;border:1px solid #968565;border-top:2.5px solid #e5a52c;
  box-shadow:0 1.5px 0 #c4b494,0 2.5px 4px #000c;
}
.tile.tmp::after{inset:1.5px;border-radius:3px}
.tile.tmp .tface{width:90%;height:90%;margin-top:4%}
.tile.tmp .tbadge{font-size:max(7px,calc(var(--pw,24px) * .29));padding:0 1.5px;top:1px;left:1px;border-radius:2.5px}
body.mobile .mb .mpond .tile.tmp.last{outline:2.5px solid #38f2ff;transform:rotate(var(--rot,0deg)) scale(1.12);z-index:5;box-shadow:0 0 12px #38f2ff,0 0 4px #fff;animation:mDiscardLand .32s cubic-bezier(.2,.85,.3,1)}
body.mobile .tile.tmp.last::before{font-size:8px;top:-1px;right:1px}
body.mobile .mb .mpond .tile.tmp.claimhl{animation:mClaimPulse 1s ease-in-out infinite}
@keyframes mDiscardLand{0%{transform:rotate(var(--rot,0deg)) scale(1.35);filter:brightness(1.25)}100%{transform:rotate(var(--rot,0deg)) scale(1.12);filter:none}}
@keyframes mClaimPulse{0%,100%{box-shadow:0 0 8px #38f2ff,0 0 2px #fff;outline-color:#38f2ff}50%{box-shadow:0 0 22px #38f2ff,0 0 8px #fff;outline-color:#ffffff}}
/* opponent edge rows: hidden hand (backs) + melds + flowers, rotated to face each owner */
.mb .medge{
  position:absolute;z-index:4;height:20px;
  display:flex;align-items:center;gap:5px;white-space:nowrap;
  transform-origin:50% 50%;
}
.mb .mebacks{display:flex;gap:1px;align-items:center}
.tile.tbk{width:13px;height:18px;border-radius:2.5px;border-top-width:2px;box-shadow:0 1.5px 0 #825004,0 2px 3px #000a}
.tile.tbk::after{inset:1.5px;border-radius:1.5px}
.tile.tbk.drawn{margin-left:4px}
.mb .medge.active .tile.tbk{box-shadow:0 1.5px 0 #825004,0 0 6px #ffd86b}
.tile.tmo{
  width:15px;height:20px;border-radius:2.5px;border:1px solid #968565;border-top:2px solid #e5a52c;
  box-shadow:0 1px 0 #c4b494,0 1.5px 2px #000a;
}
.tile.tmo::after{inset:1px;border-radius:2px}
.tile.tmo .tbadge{display:none}
.tile.tmo .tface{width:94%;height:94%;margin-top:2%}
.tile.back.tmo{border-top:2px solid #fff0b3}
.tile.back.tmo::after{inset:1.5px}
.mb .medge .meld{gap:1px;padding:0;border:0;border-radius:3px;background:none;box-shadow:0 1px 3px #0008}
.mb .medge > *{flex-shrink:0}
.mb .mava{position:absolute;z-index:4;width:30px;height:30px;border-radius:50%;overflow:hidden;border:1.5px solid #d9b25f;box-shadow:0 2px 6px #000a;background:#0b1424}
.mb .mava svg{width:100%;height:100%;display:block}
.mb .mava.active{border-color:#ffd454;box-shadow:0 0 0 2px #ffd45488,0 0 10px #ffd454}
body.mobile #mhand .mfl{align-self:center;font-size:12px;font-weight:800;padding:2px 7px;border-radius:10px;background:#2a1636cc;border:1px solid #e8a8ff66;color:#ffd6ff;white-space:nowrap}
.mb .medge .mfl{font-size:10px;font-weight:800;line-height:16px;height:16px;padding:0 4px;border-radius:8px;background:#2a1636cc;border:1px solid #e8a8ff66;color:#ffd6ff}
.mb .medge .flw{flex-wrap:nowrap;gap:1px;padding:0;border:0;border-radius:3px;background:none;box-shadow:0 0 0 1px #e8c36a66}
body.mobile .vfx-banner{zoom:.6}

/* ---- minimum points setting ---- */
.minpts-box{margin:12px 0;padding:10px 12px;border:1px solid #c9a45c55;border-radius:10px;background:#00000033}
.minpts-head{display:flex;align-items:center;justify-content:space-between;gap:10px;font-weight:600;color:#e6d5b8}
.minpts-head select{min-width:7.5em;padding:5px 8px;border-radius:8px;background:#1d140c;color:#ffe9b8;border:1px solid #c9a45c88;font-size:15px}
.minpts-presets{display:flex;gap:6px;flex-wrap:wrap;margin-top:8px}
.minpts-presets button{padding:4px 10px;font-size:13px;border-radius:14px;min-height:0}
.minpts-presets button.on{background:#c9a45c;color:#2a1a0a;border-color:#ffe596}
.minpts-hint{margin:6px 0 0;font-size:12px}
.minpts-room{margin:8px 0;font-weight:600;color:#ffe596}
.minpts-room select{margin-left:6px;padding:4px 8px;border-radius:8px;background:#1d140c;color:#ffe9b8;border:1px solid #c9a45c88}
.minpts-tag{display:block;font-size:10px;color:#ffe596;opacity:.85;letter-spacing:.3px;margin-top:1px}
body.mobile .lobby-card .minpts-presets button{flex:1 1 0;min-height:38px;font-size:14px}

/* ---- Peluang Hu card ---- */
.huc-card{margin:8px 0;padding:9px 10px;border-radius:10px;background:linear-gradient(180deg,#14243a,#0f1a2b);border:1px solid #3d6a9a88;font-size:12.5px;color:#d9e6f5;line-height:1.35}
.huc-title{font-weight:800;color:#8fd3ff;font-size:13.5px;margin-bottom:3px}
.huc-title small{font-weight:600;color:#a8bed9}
.huc-overall{color:#cfe3ff;margin-bottom:5px}
.huc-best{background:#2d5a2a55;border:1px solid #6fd36f66;border-radius:7px;padding:4px 6px;margin:4px 0;color:#e8ffe0}
.huc-high{background:#5a3f1a55;border:1px solid #ffc46a66;border-radius:7px;padding:4px 6px;margin:4px 0;color:#fff0d6}
.huc-list{display:flex;flex-direction:column;gap:4px;margin-top:5px}
.huc-row{display:flex;gap:7px;align-items:flex-start;padding:4px 5px;border-radius:7px;background:#ffffff0a}
.huc-row.easiest{background:#6fd36f1f;outline:1px solid #6fd36f55}
.huc-pts{flex:0 0 auto;min-width:36px;text-align:center;font-weight:800;color:#ffe596;background:#00000044;border-radius:6px;padding:2px 3px}
.huc-main small{color:#a8bed9}
.huc-main .mini-tile,.huc-main img{vertical-align:middle}
.huc-tag{display:inline-block;font-size:10px;padding:0 5px;border-radius:8px;background:#ffffff22;margin-left:3px;color:#dfe9f7}
.huc-tag.e{background:#3c8f3c}.huc-tag.h{background:#a36a14}.huc-tag.t{background:#5b4a8a}
.huc-none{color:#ffd0a0;margin:4px 0}
.huc-note{color:#8ea3bd;font-size:11px;margin-top:4px}
.coach-huc{flex:0 0 auto;font-size:11px;font-weight:700;color:#8fd3ff;background:#0f1a2bcc;border:1px solid #3d6a9a88;border-radius:10px;padding:1px 7px;margin-left:6px;white-space:nowrap}

/* ---- 🎯 Rekomendasi Coach card (top of Asisten panel; collapsible) ---- */
.crec{margin:0 0 8px;padding:8px 10px;border-radius:11px;background:linear-gradient(180deg,#2b2410,#18140a);border:1.5px solid #f5cf6bbb;color:#f6efd9;font-size:12.5px;line-height:1.35;box-shadow:0 3px 12px #0007}
.crec summary{cursor:pointer;list-style:none;display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 8px;outline:none}
.crec summary::-webkit-details-marker{display:none}
.crec summary::after{content:'▾';margin-left:auto;color:#f5cf6b}
.crec:not([open]) summary::after{content:'▸'}
.crec-h{font-weight:900;color:#ffd86b;font-size:14px}
.crec summary small{color:#d8c79a}
.crec-sum{flex-basis:100%;font-size:11.5px;color:#fff3c4;display:none}
.crec:not([open]) .crec-sum{display:block}
.crec-target{display:flex;align-items:center;gap:8px;margin:6px 0 4px}
.crec-name{flex:1 1 auto;font-weight:800;color:#fff;font-size:13.5px;min-width:0}
.crec-pts{flex:0 0 auto;font-weight:900;color:#1c1202;background:linear-gradient(180deg,#f5cf6b,#d19a22);border-radius:8px;padding:2px 8px;white-space:nowrap}
.crec-fans{display:flex;flex-wrap:wrap;gap:3px;margin:2px 0 5px}
.crec-fans span{font-size:10.5px;background:#ffffff14;border:1px solid #ffffff22;border-radius:8px;padding:0 6px;color:#efe6cc}
.crec-grid{display:grid;grid-template-columns:auto 1fr;gap:3px 8px;align-items:center;margin:4px 0}
.crec-grid .k{color:#d8c79a;font-weight:700;font-size:11.5px}
.crec-grid .v{min-width:0;color:#f6efd9}
.crec-grid .v small{color:#bfae80}
.crec-tiles{display:flex;flex-wrap:wrap;gap:2px}
.crec-disc{cursor:pointer;display:inline-flex;align-items:center;gap:4px;padding:1px 6px 1px 2px;border-radius:7px;background:#ff6b6b22;border:1px solid #ff9b9b77}
.crec-disc b{color:#ffd0d0}
.crec-warn{color:#ffb4b4;font-weight:700}
.crec-why{margin:5px 0 3px;padding-left:16px;color:#efe6cc}
.crec-why li{margin:2px 0}
.crec-claim{margin:5px 0;padding:4px 7px;border-radius:8px;font-size:12px}
.crec-claim.take{background:#2d5a2a66;border:1px solid #6fd36f88}
.crec-claim.pass{background:#5a2a2a55;border:1px solid #ff9b9b66}
.crec-alt-h{margin-top:5px;font-weight:700;color:#d8c79a;font-size:11.5px}
.crec-alt{display:flex;gap:7px;align-items:flex-start;padding:3px 5px;margin-top:3px;border-radius:7px;background:#ffffff0c}
.crec-alt small{color:#bfae80}
.crec-alt-p{flex:0 0 auto;min-width:34px;text-align:center;font-weight:800;color:#ffe596;background:#00000044;border-radius:6px;padding:1px 3px}
.crec-below{margin-top:5px;font-size:11.5px;color:#ffb4b4}
.crec-none{margin:5px 0;color:#ffd0a0}
body.mobile .crec{font-size:11.5px;padding:6px 8px}
body.mobile .crec-h{font-size:13px}
body.mobile .crec-name{font-size:12.5px}
body.mobile .crec-why{padding-left:14px}
body.mobile .crec .tile.tmini{vertical-align:middle}
