/* gamegx.css — หน้าโต๊ะเล่นแนวนอน 4 ฝั่งทแยง (โหลดหลัง layout.css) · ใช้เฉพาะ #app.gxl */
@media (min-aspect-ratio: 5/4) {
  #app.gxl {
    display: block;
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    margin: 0;
    padding: 0;
    overflow: hidden;
    gap: 0;
    --u: min(1vh, 0.62vw);
    --cw: clamp(38px, calc(var(--u) * 11.5), 96px);
    --chr: calc(var(--u) * 30);
    background: transparent;
    font-family: Sarabun, sans-serif;
  }
  @supports (height: 1dvh) {
    #app.gxl {
      --u: min(1dvh, 0.62vw);
    }
  }
  .gxl .gx-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
  }

  /* ฝั่งทแยง 4 ชิ้น */
  .gxl .gx-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }
  .gxl .gx-q {
    stroke: #ffffff2e;
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
    fill: #2d2268;
    fill-opacity: 0.48;
  }
  .gxl .gx-q-top {
    fill: #3b2a86;
  }
  .gxl .gx-q-left {
    fill: #26548f;
  }
  .gxl .gx-q-right {
    fill: #6b2f78;
  }
  .gxl .gx-q-bottom {
    fill: #1e6a72;
  }
  .gxl .gx-q.on {
    stroke: #2ff3ff;
    stroke-width: 4;
    filter: drop-shadow(0 0 7px #2ff3ff);
    fill-opacity: 0.62;
  }

  /* ตัวละคร/อวตารของแต่ละฝั่ง */
  .gxl .gx-art {
    position: absolute;
    pointer-events: none;
    opacity: 0.42;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s;
  }
  .gxl .gx-art.on {
    opacity: 1;
  }
  .gxl .gx-art-top {
    left: 50%;
    top: 0;
    transform: translateX(-50%);
    width: 44%;
    height: 26%;
  }
  .gxl .gx-art-left {
    left: 0;
    top: 26%;
    width: 28%;
    height: 40%;
  }
  .gxl .gx-art-right {
    right: 0;
    top: 26%;
    width: 28%;
    height: 40%;
  }
  .gxl .gx-art-bottom {
    left: 0;
    bottom: 0;
    width: 17%;
    height: 34%;
  }
  .gxl .gx-chr {
    display: block;
    width: 100%;
    height: 100%;
  }
  .gxl .gx-chr .avatar-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    filter: drop-shadow(0 3px 4px #0009);
  }
  .gxl .gx-emo {
    font-size: calc(var(--u) * 20);
    line-height: 1;
    filter: drop-shadow(0 3px 4px #0008);
  }
  .gxl .gx-art-top .gx-emo {
    font-size: calc(var(--u) * 17);
  }

  /* แผงผู้เล่น: ชื่อ + แถวไพ่ซ้อนพร้อมจำนวนใบ */
  .gxl .gx-seat,
  .gxl .gx-me {
    position: absolute;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: calc(var(--u) * 0.5);
  }
  .gxl .gx-top {
    left: 50%;
    top: calc(var(--u) * 1);
    transform: translateX(-50%);
  }
  .gxl .gx-left {
    left: calc(var(--u) * 2.5);
    top: calc(var(--u) * 29.5);
  }
  .gxl .gx-top .gx-pts {
    position: absolute;
    left: 100%;
    bottom: 0;
    white-space: nowrap;
    margin-left: calc(var(--u) * 1);
  }
  .gxl .gx-right {
    right: calc(var(--u) * 2.5);
    top: calc(var(--u) * 29.5);
  }
  .gxl .gx-left,
  .gxl .gx-right {
    transform: none;
  }
  .gxl .gx-me {
    left: calc(var(--u) * 2);
    bottom: calc(var(--u) * 2.5);
  }
  .gxl .gx-name {
    max-width: calc(var(--u) * 30);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: calc(var(--u) * 0.5) calc(var(--u) * 3);
    border-radius: 99px;
    background: #120d2ee8;
    border: 2px solid #f2b84b;
    color: #fff;
    font-weight: 800;
    font-style: italic;
    font-size: max(10px, calc(var(--u) * 2.9));
    box-shadow: 0 2px 0 #0007;
  }
  .gxl .active .gx-name {
    border-color: #2ff3ff;
    box-shadow: 0 0 10px #2ff3ff;
  }
  .gxl .gx-stack {
    display: flex;
    align-items: flex-end;
    gap: calc(var(--u) * 0.35);
  }
  .gxl .gx-stack i,
  .gxl .gx-stack b {
    display: block;
    border-radius: calc(var(--u) * 0.7);
    border: 2px solid #cdbcff;
    background: linear-gradient(#a487f0, #5b3cb3);
    box-shadow: 0 2px 0 #0006;
  }
  .gxl .gx-stack i {
    width: calc(var(--u) * 2.4);
    height: calc(var(--u) * 5.6);
    opacity: 0.95;
  }
  .gxl .gx-stack b {
    width: calc(var(--u) * 5.4);
    height: calc(var(--u) * 7.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: max(11px, calc(var(--u) * 3.6));
  }
  .gxl .gx-pts {
    color: #ffe9b0;
    font-weight: 700;
    font-size: max(9px, calc(var(--u) * 2.3));
    text-shadow: 0 1px 2px #000;
  }
  .gxl .gx-turn {
    font-style: normal;
    font-weight: 800;
    font-size: max(9px, calc(var(--u) * 2.2));
    padding: 0 calc(var(--u) * 1.4);
    border-radius: 99px;
    background: #2ff3ff;
    color: #06222a;
    animation: gxp 1s ease-in-out infinite;
  }
  @keyframes gxp {
    50% {
      transform: scale(1.12);
    }
  }

  /* มุมบนซ้าย/ขวา */
  .gxl .gx-hud {
    position: absolute;
    z-index: 6;
    left: calc(var(--u) * 1.5);
    top: calc(var(--u) * 1.2);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(var(--u) * 0.6);
  }
  .gxl .gx-hud .pill {
    font-size: max(10px, calc(var(--u) * 2.5));
    padding: 0 calc(var(--u) * 1.6);
    background: #0009;
  }
  .gxl .gx-gear {
    position: absolute;
    z-index: 6;
    right: calc(var(--u) * 1.5);
    top: calc(var(--u) * 1.2);
    width: calc(var(--u) * 8);
    height: calc(var(--u) * 8);
    min-width: 32px;
    min-height: 32px;
    border-radius: 50%;
    border: 2px solid #5d6aa8;
    background: #1a2150;
    color: #fff;
    font-size: calc(var(--u) * 4.4);
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 0 0 3px #0006;
  }

  /* ศูนย์กลาง: กองจั่ว + กองทิ้ง */
  #app.gxl .gx-hub {
    position: absolute;
    z-index: 3;
    left: 28%;
    right: 28%;
    top: 28%;
    bottom: 40%;
    margin: 0;
    padding: calc(var(--u) * 1);
    border: 3px solid #ffe45c;
    border-radius: calc(var(--u) * 3);
    background-color: #0d0a22;
    background-image: linear-gradient(#0005, #0005), var(--table-image, linear-gradient(#171233, #0d0a22));
    background-size: cover;
    background-position: center;
    box-shadow:
      0 0 14px #ffe45c66,
      inset 0 0 18px #0009;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: calc(var(--u) * 0.8);
    min-height: 0;
    overflow: hidden;
  }
  #app.gxl .gx-hub .piles {
    grid-column: auto;
    grid-row: auto;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: calc(var(--u) * 1.6);
    padding: 0;
    width: 100%;
    min-width: 0;
    background: none;
    border: 0;
  }
  #app.gxl .gx-hub .piles > div {
    max-width: none;
    min-width: 0;
  }
  #app.gxl .gx-stock {
    flex: none;
    text-align: center;
  }
  #app.gxl .gx-disc {
    flex: 1 1 0;
    min-width: 0;
  }
  #app.gxl .gx-hub .back {
    width: calc(var(--u) * 11);
    height: calc(var(--u) * 15.5);
    font-size: max(12px, calc(var(--u) * 3.6));
    display: flex;
    align-items: center;
    justify-content: center;
  }
  #app.gxl .gx-hub .dp {
    display: flex;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    padding: calc(var(--u) * 1.2) calc(var(--u) * 0.8) calc(var(--u) * 0.4);
    scrollbar-width: thin;
    max-width: 100%;
  }
  #app.gxl .gx-hub .dp .c.d {
    width: calc(var(--u) * 10.4);
    height: calc(var(--u) * 14.6);
    margin-left: calc(var(--u) * -3.8);
    font-size: max(11px, calc(var(--u) * 3.2));
    flex: none;
  }
  #app.gxl .gx-hub .dp .c.d:first-child {
    margin-left: 0;
  }
  #app.gxl .gx-hub .lab {
    display: block;
    text-align: center;
    color: #cfd3ff;
    font-size: max(9px, calc(var(--u) * 2));
    margin-top: 1px;
  }
  .gxl .gx-hint {
    margin: 0 auto;
    max-width: 96%;
    padding: calc(var(--u) * 0.4) calc(var(--u) * 2.4);
    border-radius: 99px;
    background: #000a;
    border: 2px solid #ffffff2e;
    color: #ffd978;
    font-weight: 700;
    text-align: center;
    font-size: max(10px, calc(var(--u) * 2.5));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ไพ่ที่เกิด วางหน้าผู้เล่นแต่ละฝั่ง */
  #app.gxl .zone {
    position: absolute;
    z-index: 2;
    display: flex;
    gap: calc(var(--u) * 1);
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    pointer-events: none;
    min-height: 0;
  }
  #app.gxl .zone .m {
    display: flex;
    flex-direction: row;
    pointer-events: auto;
    cursor: pointer;
    padding: calc(var(--u) * 0.4);
    border-radius: calc(var(--u) * 1);
    background: #0000004d;
  }
  #app.gxl .zone .m .c {
    width: calc(var(--u) * 6.2);
    height: calc(var(--u) * 8.8);
    font-size: max(9px, calc(var(--u) * 2.5));
    margin: 0;
    transform: none;
  }
  #app.gxl .zone .m .c + .c {
    margin-left: calc(var(--u) * -3.4);
    margin-top: 0;
  }
  #app.gxl .zone-top {
    left: 30%;
    right: 30%;
    top: calc(var(--u) * 17);
  }
  #app.gxl .zone-left {
    left: calc(var(--u) * 1.5);
    width: 25%;
    top: calc(var(--u) * 49);
    align-content: flex-start;
    justify-content: flex-start;
    flex-wrap: wrap-reverse;
  } /* เรียงชุดไพ่จากขอบโต๊ะออกไป (เหมือนฝั่งขวา) ไม่ชิดขอบจอที่กล้องหน้าบัง */
  #app.gxl .zone-right {
    right: calc(var(--u) * 1.5);
    width: 25%;
    top: calc(var(--u) * 49);
    align-content: flex-start;
    justify-content: flex-end;
  }
  #app.gxl .zone-bottom {
    left: 30%;
    right: 30%;
    bottom: calc(var(--cw) * 1 + var(--u) * 4.5);
  }

  /* ไพ่ในมือ: เรียงกลางล่าง ล้นขอบจอเล็กน้อยแบบภาพตัวอย่าง */
  #app.gxl .gx-dock {
    position: absolute;
    z-index: 5;
    left: 17%;
    right: 17%;
    bottom: calc(var(--cw) * -0.3);
    margin: 0;
    padding: 0;
    background: none;
    border: 0;
  }
  #app.gxl .gx-dock .hand {
    display: flex;
    flex-wrap: nowrap;
    justify-content: safe center;
    overflow-x: auto;
    overflow-y: visible;
    padding: calc(var(--u) * 4) calc(var(--u) * 1) 0;
    min-height: 0;
    scrollbar-width: none;
  }
  #app.gxl .gx-dock .hand::-webkit-scrollbar {
    display: none;
  }
  #app.gxl .gx-dock .hand .c {
    flex: 0 0 var(--cw);
    width: var(--cw);
    height: calc(var(--cw) * 1.42);
    margin-left: calc(var(--cw) * -0.26);
    font-size: max(14px, calc(var(--cw) * 0.42));
    transform: none;
    border-radius: calc(var(--u) * 1.2);
    box-shadow: 0 2px 6px #0008;
  }
  #app.gxl .gx-dock .hand .c:first-child {
    margin-left: 0;
  }
  #app.gxl .gx-dock .hand .c.s {
    transform: translateY(calc(var(--u) * -3.5));
    box-shadow:
      0 0 0 3px #ffd34d,
      0 6px 10px #000a;
  }

  /* ปุ่มเรียงไพ่ (ซ้าย) · ปุ่มกระทำ (ขวา) */
  .gxl .gx-tools {
    position: absolute;
    z-index: 6;
    left: calc(var(--u) * 2);
    bottom: calc(var(--u) * 26);
    display: flex;
    gap: calc(var(--u) * 0.7);
  }
  .gxl .gx-tools button {
    padding: calc(var(--u) * 0.8) calc(var(--u) * 1.6);
    border-radius: 99px;
    border: 2px solid #ffffff55;
    background: #1b2b12dd;
    color: #c9ff6b;
    font-weight: 800;
    font-size: max(10px, calc(var(--u) * 2.5));
    cursor: pointer;
    box-shadow: 0 2px 0 #0007;
  }
  .gxl .gx-tools button:nth-child(2) {
    background: linear-gradient(#86e84a, #3fae1e);
    color: #0f2a06;
    border-color: #e6ffb8;
  }
  #app.gxl .gx-acts {
    position: absolute;
    z-index: 6;
    right: calc(var(--u) * 2);
    bottom: calc(var(--u) * 2.5);
    width: calc(var(--u) * 26);
    display: flex;
    flex-direction: column;
    gap: calc(var(--u) * 1);
    margin: 0;
    padding: 0;
  }
  #app.gxl .gx-acts button {
    flex: none;
    width: 100%;
    padding: calc(var(--u) * 1.3) 0;
    font-size: max(13px, calc(var(--u) * 3.4));
    border-radius: calc(var(--u) * 2);
  }

  #app.gxl .gx-lobbypile {
    flex-direction: column;
    gap: calc(var(--u) * 0.6);
  }
  #app.gxl .gx-lobbypile .lab {
    color: #fff;
    font-weight: 700;
  }
  .gxl .gx-pre {
    margin: 0 auto;
    max-width: 96%;
    text-align: center;
    color: #e6e9ff;
    font-size: max(9px, calc(var(--u) * 2.1));
    text-shadow: 0 1px 2px #000;
  }
  .gxl .gx-me .gx-pts,
  .gxl .gx-seat .gx-pts {
    background: #000a;
    border-radius: 99px;
    padding: 0 calc(var(--u) * 1.4);
  }
}
