/* Base geometry and components. Later theme and responsive sections intentionally
   preserve the released cascade; do not reorder overrides without visual checks. */
:root {
  font-family: Inter, 'Microsoft YaHei', sans-serif;
  color: #edf4ef;
  background: #102b25;
  font-synthesis: none;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header {
  padding: 24px 5%;
  display: flex;
  align-items: center;
  gap: 22px;
  border-bottom: 1px solid #ffffff18;
}
header a {
  font-size: 22px;
  color: inherit;
  text-decoration: none;
  font-weight: bold;
}
header span {
  color: #9bb3aa;
}
header b {
  margin-left: auto;
  font-size: 13px;
  color: #bddcaa;
}
main {
  max-width: 1400px;
  margin: auto;
  padding: 48px 5%;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid #ffffff30;
  background: #234c40;
  color: #fff;
  border-radius: 9px;
  padding: 12px 18px;
  margin: 4px;
}
button:hover {
  background: #326b59;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
}
.primary {
  background: #e8c478;
  color: #23352d;
  font-weight: bold;
}
.primary:hover {
  background: #f5d99e;
}
.welcome {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 90px;
  align-items: center;
  min-height: 65vh;
}
.eyebrow {
  font-size: 13px;
  letter-spacing: 3px;
  color: #dfc588;
}
h1 {
  font-size: clamp(44px, 6vw, 80px);
  margin: 24px 0;
}
p {
  line-height: 1.8;
}
.intro > p {
  font-size: 20px;
  color: #b0c7bc;
}
.rule {
  border-left: 3px solid #dfc588;
  padding: 4px 22px;
  max-width: 480px;
  margin-top: 35px;
}
.rule p {
  color: #a8c0b4;
  font-size: 14px;
}
.entry {
  background: #193b31;
  border: 1px solid #ffffff1a;
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 20px 80px #0003;
}
.entry h2 {
  font-size: 23px;
  margin: 0 0 25px;
}
label {
  display: block;
  color: #bdd1c6;
  font-size: 14px;
}
input {
  display: block;
  background: #112c25;
  border: 1px solid #547061;
  border-radius: 8px;
  padding: 14px;
  color: white;
  width: 100%;
  margin: 10px 0 18px;
}
.entry button {
  width: 100%;
  margin: 0;
}
.divider {
  text-align: center;
  font-size: 13px;
  color: #92a99c;
  margin: 26px 0;
}
small {
  display: block;
  color: #9bb0a4;
  margin-top: 18px;
  font-size: 12px;
  line-height: 1.7;
}
.roombar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.roombar h2 {
  margin: 6px 0;
  letter-spacing: 5px;
}
.layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 20px;
}
.table {
  border: 8px solid #335145;
  border-radius: 30px;
  background: radial-gradient(ellipse at center, #28694f, #174734);
  padding: 24px;
  min-height: 560px;
}
.players {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.player {
  border: 1px solid #ffffff20;
  border-radius: 10px;
  padding: 12px;
  background: #123d30;
}
.player.active {
  border-color: #e8c478;
  box-shadow: 0 0 0 2px #e8c47833;
}
.player b {
  font-size: 14px;
}
.player p {
  font-size: 12px;
  color: #b0c6b8;
  margin: 7px 0;
}
.player .tile {
  font-size: 12px;
  padding: 4px 3px;
  min-width: 20px;
  height: auto;
  margin: 1px;
}
.center {
  text-align: center;
  min-height: 250px;
  padding: 20px 0;
}
.center p {
  font-size: 13px;
  color: #c0d5c5;
}
.river {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: center;
  max-width: 580px;
  margin: auto;
}
.tile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 54px;
  background: #fff6de;
  color: #214b35;
  border: 1px solid #b4baa4;
  border-radius: 5px;
  font-size: 20px;
  padding: 8px 4px;
  box-shadow: 0 3px 0 #a2aa94;
  margin: 3px;
}
.tile:hover {
  background: #fff6de;
}
.wild {
  background: #f7d37b !important;
  color: #805c16;
}
.special {
  background: #f1ad7a !important;
  color: #732f16;
}
.selected {
  transform: translateY(-10px);
  outline: 3px solid #edd597;
}
.hand {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  padding: 20px 0 6px;
}
.handarea {
  text-align: center;
  border-top: 1px solid #ffffff20;
  padding-top: 18px;
}
aside {
  background: #183c30;
  border-radius: 14px;
  padding: 22px;
}
aside h3 {
  margin: 0 0 20px;
}
#log {
  max-height: 400px;
  overflow: auto;
}
#log p {
  font-size: 13px;
  border-bottom: 1px solid #ffffff12;
  padding-bottom: 9px;
}
.hint {
  font-size: 12px;
  color: #8eaa99;
}
#message {
  color: #ffcf93;
  text-align: center;
}
footer {
  text-align: center;
  color: #789a87;
  font-size: 12px;
  margin-top: 40px;
}
[hidden] {
  display: none !important;
}
@media (max-width: 850px) {
  main {
    padding: 24px 4%;
  }
  .welcome {
    grid-template-columns: 1fr;
    gap: 30px;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .players {
    grid-template-columns: repeat(2, 1fr);
  }
  .table {
    padding: 12px;
    border-width: 5px;
  }
  .roombar {
    align-items: start;
    gap: 10px;
  }
  .roombar button {
    font-size: 12px;
    padding: 8px;
  }
  .tile {
    min-width: 30px;
    font-size: 16px;
    height: 46px;
  }
  .center {
    min-height: 200px;
  }
  header {
    padding: 18px 4%;
  }
  header span {
    display: none;
  }
}
:root {
  --ivory: #fff7e3;
  --wood: #493728;
  --felt: #245e48;
}
header {
  padding: 16px 4%;
}
main {
  max-width: 1600px;
  padding: 22px 3%;
}
.roombar {
  margin-bottom: 14px;
}
.roombar h2 {
  font-size: 22px;
}
.layout {
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 18px;
}
.table {
  position: relative;
  isolation: isolate;
  height: 720px;
  min-height: 720px;
  padding: 0;
  border: 14px solid #594434;
  border-radius: 42px;
  background: radial-gradient(
    ellipse at 50% 38%,
    #31735a 0,
    #245b46 55%,
    #184534 100%
  );
  box-shadow:
    inset 0 0 0 3px #b99a68,
    inset 0 0 60px #09271999,
    0 15px 35px #0005;
  overflow: hidden;
}
.table-grain {
  position: absolute;
  inset: 8px;
  border: 1px solid #a4be9860;
  border-radius: 23px;
  pointer-events: none;
  z-index: -1;
  background: repeating-linear-gradient(
    33deg,
    transparent 0 3px,
    #ffffff03 3px 4px
  );
}
.players {
  display: contents;
}
.player {
  position: absolute;
  border: 0;
  background: none;
  padding: 0;
  border-radius: 0;
  width: auto;
  max-width: 100%;
  z-index: 3;
}
.player.active {
  border: 0;
  box-shadow: none;
}
.player-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: #0c2e26d9;
  border: 1px solid #6c8c7460;
  border-radius: 12px;
  width: max-content;
  max-width: 100%;
  box-shadow: 0 4px 14px #0002;
}
.player.active .player-badge {
  border-color: #e7c575;
  box-shadow: 0 0 18px #eccb6b33;
}
.avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(140deg, #778b6e, #385a45);
  color: #f5e6b9;
  font-size: 14px;
  border: 1px solid #b7b290;
}
.player b {
  font-size: 12px;
  white-space: nowrap;
}
.player small {
  margin: 4px 0 0;
  font-size: 10px;
  color: #c3cdbd;
}
.seat-top {
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 8px;
}
.seat-bottom {
  bottom: 180px;
  left: 50%;
  transform: translateX(-50%);
}
.seat-left {
  top: 170px;
  bottom: 230px;
  left: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}
.seat-right {
  top: 170px;
  bottom: 230px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.concealed {
  display: flex;
  gap: 2px;
  justify-content: center;
}
.tile {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 0;
  width: 48px;
  height: 68px;
  padding: 3px;
  margin: 0;
  border: 1px solid #d6cbaa;
  border-radius: 5px;
  background: linear-gradient(
    100deg,
    #e8e0c8 0,
    #fff9e8 12%,
    #fff7df 90%,
    #dacdaf 100%
  );
  box-shadow:
    0 4px 0 #b7b39c,
    0 6px 0 #195d49,
    0 8px 6px #0005;
  color: #16452f;
  vertical-align: middle;
  transition:
    transform 0.15s,
    box-shadow 0.15s;
}
.tile svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}
.tile:hover {
  background: linear-gradient(100deg, #eee5ce, #fffbed 15%, #fff7df);
}
button.tile {
  padding: 3px;
  margin: 0;
  cursor: pointer;
}
.tile-back {
  background: #ecdfbb !important;
}
.wild,
.special {
  background: linear-gradient(100deg, #eee5ce, #fffbed 15%, #fff7df) !important;
}
.wild {
  outline: 2px solid #dfbb55;
  outline-offset: -2px;
}
.special {
  outline: 2px solid #c98048;
  outline-offset: -2px;
}
.tile[data-badge]::after {
  content: attr(data-badge);
  position: absolute;
  top: -7px;
  right: -3px;
  font-size: 10px;
  border-radius: 4px;
  padding: 1px 3px;
  background: #d8af44;
  color: #352c16;
  box-shadow: 0 1px 3px #0004;
}
.special[data-badge]::after {
  background: #bf7440;
  color: white;
}
.selected {
  transform: translateY(-15px);
  outline: 2px solid #ffe197;
  box-shadow:
    0 4px 0 #b7b39c,
    0 6px 0 #195d49,
    0 8px 14px #0006;
}
.hand .tile:hover {
  transform: translateY(-8px);
}
.hand .tile.selected:hover {
  transform: translateY(-15px);
}
.player .tile {
  width: 27px;
  height: 38px;
  min-width: 0;
  padding: 2px;
  margin: 0;
  font-size: 12px;
  box-shadow:
    0 2px 0 #b7b39c,
    0 3px 0 #174d3d,
    0 4px 3px #0004;
}
.seat-left .concealed,
.seat-right .concealed {
  flex-direction: column;
  gap: 2px;
}
.seat-left .concealed {
  margin-left: 65px;
}
.seat-right .concealed {
  margin-right: 65px;
}
.seat-left .concealed .tile,
.seat-right .concealed .tile {
  width: 38px;
  height: 19px;
  box-shadow:
    2px 0 0 #b7b39c,
    4px 0 0 #174d3d;
}
.seat-left .concealed .tile svg,
.seat-right .concealed .tile svg {
  transform: rotate(90deg);
  width: 19px;
  height: 33px;
}
.melds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 300px;
  justify-content: center;
}
.meld {
  display: flex;
  gap: 2px;
}
.seat-left .melds,
.seat-right .melds {
  max-width: 110px;
  gap: 5px;
}
.seat-bottom .melds {
  position: absolute;
  bottom: 0;
  left: calc(100% + 16px);
  width: 200px;
}
.seat-top .melds {
  position: absolute;
  top: 104px;
}
.center {
  position: absolute;
  left: 24%;
  right: 24%;
  top: 155px;
  bottom: 255px;
  min-height: 0;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}
.center p {
  font-size: 12px;
  margin: 8px 0;
  color: #c5d9c9;
}
.center h2 {
  font-size: 19px;
  letter-spacing: 1px;
  margin: 13px 0 1px;
}
.rule-tiles {
  display: flex;
  gap: 16px;
  justify-content: center;
}
.legend-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}
.legend-tile small {
  font-size: 10px;
  margin: 0;
  white-space: nowrap;
  color: #d1d9bb;
}
.rule-tiles .tile {
  width: 34px;
  height: 47px;
}
.river {
  display: flex;
  gap: 4px;
  max-width: 370px;
  max-height: 140px;
  overflow: auto;
  margin-top: 13px;
  padding: 2px 4px 8px;
  align-content: flex-start;
}
.river .tile {
  width: 27px;
  height: 37px;
  box-shadow:
    0 2px 0 #b7b39c,
    0 3px 0 #195d49;
}
.river .tile[data-badge]::after {
  display: none;
}
.walls {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.wall {
  position: absolute;
  background: repeating-linear-gradient(
    90deg,
    #15776c 0 17px,
    #83b99d 17px 19px
  );
  height: 20px;
  border: 2px solid #b7b895;
  border-radius: 3px;
  box-shadow:
    0 4px 0 #0e4e42,
    0 7px 0 #bcc2a3,
    0 10px 0 #125b4c,
    0 12px 8px #0005;
  opacity: 0.9;
}
.wall-top {
  top: -10px;
  left: 8%;
  right: 8%;
}
.wall-bottom {
  bottom: -14px;
  left: 8%;
  right: 8%;
}
.wall-left {
  top: 30px;
  left: -25px;
  width: 150px;
  transform-origin: 0 0;
  transform: rotate(90deg);
}
.wall-right {
  top: 180px;
  right: -175px;
  width: 150px;
  transform-origin: 0 0;
  transform: rotate(-90deg);
}
.handarea {
  position: absolute;
  bottom: 16px;
  left: 4%;
  right: 4%;
  border: 0;
  padding: 0;
  z-index: 5;
}
.handarea #myinfo {
  font-size: 11px;
  color: #adc7b5;
}
.hand {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 5px;
  padding: 23px 0 13px;
  overflow: visible;
}
.handarea small {
  margin-top: 8px;
  font-size: 10px;
}
.handarea button:not(.tile) {
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 13px;
  background: #103e30;
}
.handarea button:not(.tile):hover {
  background: #305f49;
}
aside {
  padding: 18px;
  border: 1px solid #50715a30;
  background: #15362b;
}
aside h3 {
  font-size: 15px;
}
#log {
  max-height: 500px;
}
#log p {
  font-size: 12px;
}
.hint {
  font-size: 11px;
}
footer {
  margin-top: 20px;
}
.opening {
  position: absolute;
  left: 23%;
  right: 23%;
  top: 190px;
  z-index: 10;
  border-radius: 20px;
  padding: 24px 20px;
  background: #133e30f5;
  border: 1px solid #c4ab7250;
  box-shadow: 0 15px 60px #06281ea0;
  text-align: center;
  animation: panel-in 0.25s ease;
}
.opening h2 {
  font-size: 21px;
  color: #ffe2a0;
  margin: 0 0 10px;
}
.opening p {
  font-size: 13px;
  line-height: 1.8;
  margin: 0;
  color: #d6e1ce;
}
.flip-area {
  display: flex;
  gap: 22px;
  justify-content: center;
  margin-top: 20px;
  min-height: 105px;
  perspective: 700px;
}
.flip-area .tile {
  width: 58px;
  height: 82px;
}
.flip-area small {
  font-size: 10px;
}
.flip-card {
  position: relative;
  width: 65px;
  height: 91px;
  transform-style: preserve-3d;
  animation: turn-card 1s 0.08s ease forwards;
}
.flip-card .tile {
  position: absolute;
  inset: 0;
  width: 65px;
  height: 91px;
  backface-visibility: hidden;
}
.flip-front {
  transform: rotateY(180deg);
}
.flip-back {
  transform: rotateY(0);
}
.flying-card {
  position: absolute !important;
  left: calc(50% - 18px);
  top: calc(43% - 24px);
  z-index: 20 !important;
  width: 36px !important;
  height: 50px !important;
  pointer-events: none;
  animation-duration: 0.18s;
  animation-timing-function: ease-out;
  animation-fill-mode: forwards;
}
.to-bottom {
  animation-name: deal-bottom;
}
.to-top {
  animation-name: deal-top;
}
.to-left {
  animation-name: deal-left;
}
.to-right {
  animation-name: deal-right;
}
@keyframes deal-bottom {
  to {
    transform: translateY(240px) rotate(-8deg);
    opacity: 0;
  }
}
@keyframes deal-top {
  to {
    transform: translateY(-230px) rotate(8deg);
    opacity: 0;
  }
}
@keyframes deal-left {
  to {
    transform: translateX(-320px) rotate(-90deg);
    opacity: 0;
  }
}
@keyframes deal-right {
  to {
    transform: translateX(320px) rotate(90deg);
    opacity: 0;
  }
}
@keyframes turn-card {
  from {
    transform: rotateY(0);
  }
  to {
    transform: rotateY(180deg);
  }
}
@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  aside {
    display: none;
  }
  .table {
    height: 700px;
    min-height: 700px;
  }
  .seat-left {
    left: 16px;
  }
  .seat-right {
    right: 16px;
  }
  .hand {
    gap: 4px;
  }
  .hand > .tile {
    width: clamp(28px, 4.8vw, 48px);
    height: clamp(42px, 6.8vw, 68px);
  }
}
@media (max-width: 650px) {
  main {
    padding: 14px 8px;
  }
  header {
    padding: 12px 16px;
  }
  header a {
    font-size: 19px;
  }
  .table {
    height: 650px;
    min-height: 650px;
    border-width: 8px;
    border-radius: 26px;
  }
  .table-grain {
    border-radius: 16px;
  }
  .roombar h2 {
    font-size: 17px;
  }
  .roombar .eyebrow {
    font-size: 10px;
    letter-spacing: 1px;
  }
  .roombar button {
    font-size: 10px;
    padding: 8px;
    margin: 2px;
  }
  .player-badge {
    padding: 5px 6px;
    gap: 5px;
  }
  .avatar {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }
  .player b {
    font-size: 9px;
  }
  .player small {
    font-size: 8px;
  }
  .seat-top {
    top: 12px;
  }
  .seat-bottom {
    bottom: 152px;
  }
  .seat-left,
  .seat-right {
    top: 147px;
    bottom: 215px;
  }
  .seat-left {
    left: 8px;
  }
  .seat-right {
    right: 8px;
  }
  .player .tile {
    width: 19px;
    height: 27px;
    padding: 1px;
  }
  .seat-left .concealed {
    margin-left: 12px;
  }
  .seat-right .concealed {
    margin-right: 12px;
  }
  .seat-left .concealed .tile,
  .seat-right .concealed .tile {
    width: 27px;
    height: 15px;
  }
  .seat-left .concealed .tile svg,
  .seat-right .concealed .tile svg {
    width: 15px;
    height: 25px;
  }
  .seat-left .melds,
  .seat-right .melds {
    max-width: 80px;
  }
  .seat-bottom .melds {
    width: 70px;
    left: calc(100% + 4px);
  }
  .seat-top .melds {
    top: 78px;
  }
  .center {
    left: 23%;
    right: 23%;
    top: 140px;
    bottom: 230px;
    padding-top: 24px;
  }
  .center p {
    font-size: 9px;
  }
  .center h2 {
    font-size: 13px;
    letter-spacing: 0;
  }
  .rule-tiles {
    gap: 8px;
  }
  .rule-tiles .tile {
    width: 25px;
    height: 36px;
  }
  .legend-tile small {
    font-size: 8px;
  }
  .river {
    gap: 3px;
    max-height: 140px;
    padding: 2px;
  }
  .river .tile {
    width: 21px;
    height: 30px;
  }
  .wall-left {
    width: 100px;
    left: -14px;
  }
  .wall-right {
    width: 100px;
    right: -114px;
    top: 130px;
  }
  .wall {
    height: 13px;
    background: repeating-linear-gradient(
      90deg,
      #15776c 0 11px,
      #83b99d 11px 13px
    );
  }
  .handarea {
    left: 2%;
    right: 2%;
    bottom: 18px;
  }
  .hand {
    gap: 2px;
    padding-top: 22px;
  }
  .hand > .tile {
    width: clamp(19px, 5.7vw, 34px);
    height: clamp(30px, 8vw, 48px);
    padding: 1px;
  }
  .handarea button:not(.tile) {
    font-size: 11px;
    padding: 8px 12px;
  }
  .handarea small {
    font-size: 8px;
  }
  .tile[data-badge]::after {
    font-size: 8px;
    top: -5px;
  }
  .opening {
    left: 15%;
    right: 15%;
    top: 180px;
    padding: 18px 12px;
  }
  .opening h2 {
    font-size: 17px;
  }
  .opening p {
    font-size: 11px;
  }
  .flip-area {
    gap: 12px;
  }
  .flip-area .tile {
    width: 44px;
    height: 63px;
  }
  .flip-area small {
    font-size: 8px;
  }
  .flip-card,
  .flip-card .tile {
    width: 56px;
    height: 80px;
  }
  .welcome {
    padding: 20px 12px;
  }
  .entry {
    padding: 24px;
  }
  .intro > p {
    font-size: 17px;
  }
  .divider {
    margin: 18px 0;
  }
}
.handarea #myinfo {
  display: none;
}
.hand .drawn-tile {
  margin-left: 18px;
  box-shadow:
    0 4px 0 #b7b39c,
    0 6px 0 #195d49,
    0 8px 12px #0005,
    0 0 14px #e9d18e55;
  animation: draw-arrive 0.3s ease-out;
}
.drawn-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  transform: translateX(-50%);
  font-size: 10px;
  white-space: nowrap;
  color: #ffe0a0;
  line-height: 1.2;
  pointer-events: none;
}
@keyframes draw-arrive {
  from {
    opacity: 0;
    translate: 12px -5px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}
@media (max-width: 650px) {
  .hand .drawn-tile {
    margin-left: 8px;
  }
  .drawn-label {
    font-size: 8px;
  }
}
.center.has-discard {
  top: 140px;
  bottom: 220px;
  padding: 4px 0;
}
.discard-show {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  order: 2;
  flex-shrink: 0;
}
.discard-show > b {
  font-size: 14px;
  color: #ffdfa0;
  letter-spacing: 1px;
}
.discard-show .tile {
  width: 76px;
  height: 108px;
  animation: panel-in 0.25s ease-out;
  box-shadow:
    0 5px 0 #b7b39c,
    0 8px 0 #195d49,
    0 12px 20px #0005;
}
.discard-show small {
  margin: 3px 0;
  color: #d8e9d3;
  font-size: 11px;
}
.has-discard #rule {
  margin: 0 0 7px;
}
.has-discard #status {
  order: 3;
  font-size: 15px;
  margin-top: 9px;
}
.has-discard #remaining {
  order: 4;
  font-size: 10px;
  margin: 4px;
}
.has-discard .river {
  order: 5;
  max-height: 73px;
  margin-top: 6px;
}
@media (max-width: 650px) {
  .center.has-discard {
    top: 142px;
    bottom: 222px;
  }
  .discard-show > b {
    font-size: 10px;
    letter-spacing: 0;
  }
  .discard-show .tile {
    width: 56px;
    height: 80px;
  }
  .discard-show small {
    font-size: 8px;
    line-height: 1.5;
  }
  .has-discard #status {
    font-size: 11px;
  }
  .has-discard .river {
    max-height: 95px;
  }
}
.hand {
  box-sizing: border-box;
  max-width: 100%;
  padding-left: 6px;
  padding-right: 6px;
}
.hand > .tile {
  flex-shrink: 0;
}
.flying-card {
  max-width: calc(100% - 24px);
}
#resume {
  margin-bottom: 12px;
  border-color: #d2b977;
}
#sound-toggle {
  padding: 7px 10px;
  font-size: 12px;
  margin-left: auto;
}
header b {
  margin-left: 0;
}
.gang-zone {
  position: absolute;
  z-index: 4;
  padding: 7px;
  border: 1px solid #d5bc7955;
  border-radius: 9px;
  background: #0e3325c9;
  max-width: 26%;
  box-shadow: 0 4px 12px #0002;
}
.gang-zone > small {
  margin: 0 0 6px;
  color: #e8ce8e;
  font-size: 10px;
}
.gang-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.gang-zone .tile {
  width: 25px;
  height: 36px;
  box-shadow:
    0 2px 0 #b7b39c,
    0 4px 0 #195d49;
}
.gang-bottom {
  left: 4%;
  bottom: 172px;
}
.gang-right {
  right: 4%;
  bottom: 172px;
}
.gang-top {
  right: 4%;
  top: 74px;
}
.gang-left {
  left: 4%;
  top: 74px;
}
#discard-card {
  display: flex;
  gap: 5px;
  justify-content: center;
}
#discard-card .tile:not(:only-child) {
  width: 43px;
  height: 62px;
}
@media (max-width: 650px) {
  .gang-zone {
    max-width: 25%;
    padding: 5px;
  }
  .gang-zone .tile {
    width: 18px;
    height: 26px;
  }
  .gang-zone > small {
    font-size: 8px;
  }
  .gang-cards {
    gap: 3px;
  }
  .gang-cards .meld {
    flex-wrap: wrap;
    max-width: 100%;
  }
  .gang-bottom,
  .gang-right {
    bottom: 146px;
  }
  .gang-top,
  .gang-left {
    top: 78px;
  }
  #discard-card .tile:not(:only-child) {
    width: 31px;
    height: 44px;
  }
}
.gang-cards > .meld {
  flex-wrap: wrap;
  max-width: 100%;
}
#result-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #061b16dc;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  backdrop-filter: blur(5px);
}
#result-layer[hidden] {
  display: none;
}
.result-panel {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #153f31;
  border: 2px solid #e8c478;
  border-radius: 22px;
  padding: 28px;
  box-shadow: 0 20px 100px #0009;
  animation: panel-in 0.35s ease;
}
.result-panel h2 {
  color: #ffdc8e;
  font-size: 34px;
  text-align: center;
  margin: 0;
}
.result-winner {
  font-size: 26px;
  font-weight: bold;
  text-align: center;
  margin: 12px 0;
  color: #fff1ce;
}
.result-panel > p {
  text-align: center;
  font-size: 14px;
}
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 20px 0;
}
.result-table caption {
  text-align: left;
  font-weight: bold;
  padding-bottom: 10px;
}
.result-table th,
.result-table td {
  padding: 10px 6px;
  border-bottom: 1px solid #ffffff25;
  text-align: center;
}
.result-table th {
  color: #e8c478;
}
.result-payments {
  border-radius: 12px;
  background: #0b2d23;
  padding: 12px 16px;
}
.result-payments p {
  font-size: 14px;
  margin: 8px 0;
}
.result-mine {
  display: block;
  text-align: center;
  color: #ffdc8e;
  font-size: 21px;
  margin-top: 20px;
}
.result-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.rematch-status {
  flex-basis: 100%;
  width: 100%;
  padding: 10px;
  border: 1px solid #9fb8d044;
  border-radius: 10px;
  text-align: center;
}
.rematch-status p {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}
.result-actions button {
  min-width: 130px;
}
@media (max-width: 650px) {
  .result-panel {
    padding: 20px 12px;
  }
  .result-table {
    font-size: 10px;
  }
  .result-table td,
  .result-table th {
    padding: 8px 2px;
  }
  .result-payments {
    padding: 8px;
  }
  .result-payments p {
    font-size: 12px;
  }
  .result-winner {
    font-size: 22px;
  }
  .result-mine {
    font-size: 18px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .result-panel {
    animation: none;
  }
}
#win-requirement {
  font-size: 10px;
  line-height: 1.5;
  color: #f2ceaa;
  margin: 4px 0;
  overflow-wrap: anywhere;
}
#win-requirement.ready {
  color: #d9ebac;
}
@media (max-width: 650px) {
  #win-requirement {
    font-size: 8px;
  }
}
#round-banner {
  padding: 10px 16px;
  margin: -8px 0 18px;
  border-radius: 10px;
  border: 1px solid #6d8e7744;
  color: #bdd3be;
  background: #193e31;
  font-size: 13px;
}
#round-banner.double-round {
  border-color: #e8c478;
  background: #544628;
  color: #ffe3a2;
  font-weight: bold;
  box-shadow: 0 0 15px #e8c47822;
}
@media (max-width: 650px) {
  #round-banner {
    font-size: 11px;
    padding: 9px 12px;
    margin-top: 0;
  }
}
.round-reference {
  position: sticky;
  top: 8px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  padding: 12px 20px;
  margin: 0 0 18px;
  background: #123b2ff5;
  border: 1px solid #b6a47188;
  border-radius: 14px;
  box-shadow: 0 6px 18px #0004;
  backdrop-filter: blur(8px);
}
.reference-heading b {
  font-size: 15px;
  color: #ffe3a2;
}
.reference-heading small {
  font-size: 11px;
  margin: 5px 0 0;
  color: #b5cbbd;
}
.round-reference .rule-tiles {
  gap: 22px;
}
.round-reference .legend-tile {
  gap: 5px;
}
.round-reference .tile {
  width: 38px;
  height: 54px;
}
.round-reference .reference-gang .tile {
  outline: 1px solid #eeae7966;
}
.round-reference .reference-flipped .tile {
  outline: 2px solid #e8c478;
}
.round-reference .reference-wild .tile {
  background: #f7d37b;
  outline: 1px solid #e8c478;
}
.round-reference .reference-wild small {
  color: #ffdf8b;
}
.round-reference .reference-gang small {
  color: #f4c1a0;
}
@media (max-width: 650px) {
  .round-reference {
    top: 4px;
    gap: 12px;
    padding: 8px;
    margin-bottom: 12px;
  }
  .reference-heading b {
    font-size: 12px;
  }
  .reference-heading small {
    font-size: 8px;
  }
  .round-reference .rule-tiles {
    gap: 9px;
  }
  .round-reference .tile {
    width: 30px;
    height: 43px;
  }
  .round-reference .legend-tile small {
    font-size: 8px;
  }
}
.round-reference .legend-tile small,
.flip-area .legend-tile small {
  white-space: normal;
  text-align: center;
  max-width: 95px;
  line-height: 1.5;
}
.round-reference .rule-tiles {
  align-items: flex-start;
}
.flip-area .legend-tile {
  min-width: 0;
}
.flip-area .reference-wild .tile {
  background: #f7d37b;
}
@media (max-width: 650px) {
  .round-reference {
    gap: 8px;
    padding: 8px 6px;
  }
  .round-reference .rule-tiles {
    gap: 6px;
    min-width: 0;
  }
  .round-reference .legend-tile {
    width: 43px;
    flex-shrink: 0;
  }
  .round-reference .reference-heading {
    max-width: 76px;
  }
  .round-reference .reference-heading small {
    max-width: 76px;
  }
  .flip-area {
    gap: 7px;
  }
  .flip-area .tile {
    width: 38px;
    height: 54px;
  }
  .flip-area .legend-tile small {
    max-width: 58px;
  }
}
.round-showdown {
  margin-top: 20px;
  padding: 20px;
  border: 1px solid #cfb77577;
  background: #143b2d;
  border-radius: 16px;
}
.revealed-hands h3 {
  font-size: 16px;
  color: #ffe1a0;
  margin: 16px 0 12px;
}
.revealed-player {
  padding: 12px;
  margin: 9px 0;
  border: 1px solid #ffffff20;
  border-radius: 10px;
  background: #0e3026;
}
.revealed-player > b {
  display: block;
  font-size: 12px;
  color: #cde0d0;
  margin-bottom: 12px;
}
.revealed-winner {
  border-color: #dfbb55;
  background: #264d33;
}
.revealed-winner > b {
  color: #ffe1a0;
}
.revealed-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 3px 0 6px;
}
.revealed-cards .tile {
  width: 30px;
  height: 43px;
  pointer-events: none;
}
.revealed-cards .tile[data-badge]::after {
  font-size: 8px;
  top: -5px;
}
.result-panel .revealed-hands {
  margin-top: 18px;
}
@media (max-width: 650px) {
  .round-showdown {
    padding: 12px;
  }
  .revealed-player {
    padding: 10px 7px;
  }
  .revealed-cards {
    gap: 4px;
  }
  .revealed-cards .tile {
    width: 23px;
    height: 33px;
  }
  .revealed-player > b {
    font-size: 11px;
  }
  .revealed-hands h3 {
    font-size: 14px;
  }
}
.table {
  --table-base: 720px;
  height: calc(var(--table-base) + var(--exposed-space, 0px));
  min-height: calc(var(--table-base) + var(--exposed-space, 0px));
}
.handarea {
  bottom: calc(16px + var(--exposed-space, 0px));
}
.seat-bottom {
  bottom: calc(180px + var(--exposed-space, 0px));
}
.seat-left,
.seat-right {
  bottom: calc(230px + var(--exposed-space, 0px));
}
.center {
  bottom: calc(255px + var(--exposed-space, 0px));
}
.center.has-discard {
  bottom: calc(220px + var(--exposed-space, 0px));
}
.gang-right {
  bottom: calc(172px + var(--exposed-space, 0px));
}
.gang-bottom {
  left: 4%;
  right: 4%;
  bottom: 14px;
  max-width: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
}
.gang-bottom > small {
  margin: 0;
  flex-shrink: 0;
}
.gang-bottom .gang-cards {
  flex: 1;
  min-width: 0;
  gap: 8px;
  justify-content: flex-start;
}
.gang-cards > .meld {
  padding: 2px;
  border-radius: 4px;
  background: #ffffff08;
}
.gang-zone:not(.gang-bottom) {
  max-width: 26%;
}
@media (max-width: 1100px) {
  .table {
    --table-base: 700px;
  }
}
@media (max-width: 650px) {
  .table {
    --table-base: 650px;
  }
  .handarea {
    bottom: calc(18px + var(--exposed-space, 0px));
  }
  .seat-bottom {
    bottom: calc(152px + var(--exposed-space, 0px));
  }
  .seat-left,
  .seat-right {
    bottom: calc(215px + var(--exposed-space, 0px));
  }
  .center {
    bottom: calc(230px + var(--exposed-space, 0px));
  }
  .center.has-discard {
    bottom: calc(222px + var(--exposed-space, 0px));
  }
  .gang-right {
    bottom: calc(146px + var(--exposed-space, 0px));
  }
  .gang-bottom {
    bottom: 12px;
    left: 3%;
    right: 3%;
    padding: 7px;
    gap: 7px;
  }
  .gang-bottom .gang-cards {
    gap: 6px;
  }
  .gang-zone:not(.gang-bottom) {
    max-width: 25%;
  }
}
.seat-bottom {
  bottom: var(--self-seat-bottom, calc(180px + var(--exposed-space, 0px)));
}
.gang-right {
  right: calc(4% + 100px);
  bottom: calc(250px + var(--exposed-space, 0px));
}
@media (max-width: 650px) {
  .seat-bottom {
    bottom: var(--self-seat-bottom, calc(152px + var(--exposed-space, 0px)));
  }
  .gang-right {
    right: calc(3% + 52px);
    bottom: calc(225px + var(--exposed-space, 0px));
  }
}
.seat-manager {
  padding: 18px;
  margin: 0 0 18px;
  border: 1px solid #a4be9855;
  border-radius: 14px;
  background: #153b30;
}
.seat-manager h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #ffe1a0;
}
.seat-manager p {
  font-size: 12px;
  margin: 0 0 12px;
  color: #b8cfbd;
}
.setup-seats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.setup-seat {
  padding: 12px;
  border-radius: 9px;
  border: 1px solid #71947c55;
  background: #0e3026;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.setup-seat b {
  font-size: 12px;
  overflow-wrap: anywhere;
}
.setup-seat.empty {
  border-style: dashed;
  color: #9cb7a5;
  background: transparent;
}
.setup-seat button {
  padding: 6px 9px;
  font-size: 11px;
  margin: 0;
}
.seat-manager > button {
  margin: 14px 0 0;
}
@media (max-width: 650px) {
  .seat-manager {
    padding: 12px;
  }
  .setup-seats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .setup-seat {
    padding: 10px;
  }
}
.meld.wild-gang {
  align-items: center;
}
.meld.wild-gang > small {
  margin: 0 2px 0 4px;
  font-size: 9px;
  color: #ffe1a0;
  white-space: nowrap;
}
@media (max-width: 650px) {
  .meld.wild-gang > small {
    font-size: 8px;
  }
}

/* Mist blue, warm ivory and a slate playing surface. Keep game geometry intact. */
:root {
  color-scheme: light;
  --ink: #26334c;
  --muted: #748198;
  --line: #dce3ed;
  --blue: #526ad1;
  --ivory: #fffaf0;
  --wood: #b9c7dc;
  --felt: #34476a;
  color: var(--ink);
  background: #f1f4f9;
  font-family: Inter, 'Microsoft YaHei', sans-serif;
}
body {
  background:
    radial-gradient(ellipse at 5% 0, #e4eaff, transparent 48%), #f1f4f9;
  min-height: 100vh;
}
header {
  background: #ffffffc9;
  border-bottom: 1px solid var(--line);
  padding: 18px 4%;
  backdrop-filter: blur(16px);
}
header a {
  letter-spacing: 1px;
  color: #293956;
}
header span {
  color: var(--muted);
}
header b {
  color: #566ac2;
}
button {
  color: #435576;
  background: #fff;
  border: 1px solid #d5ddeb;
  border-radius: 12px;
  box-shadow: 0 2px 4px #25385606;
  transition:
    background 0.15s,
    box-shadow 0.15s,
    transform 0.15s;
}
button:hover {
  background: #edf1ff;
  border-color: #b0bfe5;
  box-shadow: 0 4px 12px #354e8d12;
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid #9bafe7;
  outline-offset: 3px;
}
.primary {
  background: #566bd3;
  color: #fff;
  border-color: #566bd3;
  box-shadow: 0 5px 14px #526ad12b;
}
.primary:hover {
  background: #455bc1;
  border-color: #455bc1;
}
input {
  background: #f7f9fd;
  border: 1px solid #d6dfed;
  color: #26334c;
  border-radius: 12px;
}
input::placeholder {
  color: #98a3b5;
}
label {
  color: #56647b;
}
small,
.hint,
footer {
  color: var(--muted);
}
#message {
  color: #a45d32;
}
.eyebrow {
  color: #697ac0;
  letter-spacing: 2px;
}
.intro h1 {
  font-weight: 750;
  letter-spacing: -2px;
  color: #293956;
}
.intro > p {
  color: #78859b;
}
.welcome {
  gap: 65px;
}
.entry {
  background: #ffffffeb;
  border: 1px solid #fff;
  border-radius: 26px;
  box-shadow: 0 18px 60px #344a7710;
  padding: 34px;
}
.entry h2 {
  color: #344561;
}
.rule {
  border-color: #a9b8e8;
  background: #ffffff70;
  border-radius: 0 16px 16px 0;
  padding: 16px 22px;
}
.rule b {
  color: #5265a3;
}
.rule p {
  color: #7a879c;
}
.divider {
  color: #8b96a8;
}
#resume {
  border-color: #c6d1ef;
  color: #596db8;
  background: #f3f5ff;
}
.roombar h2 {
  color: #314666;
  font-variant-numeric: tabular-nums;
}
.roombar .eyebrow {
  font-size: 11px;
  letter-spacing: 2px;
}
#round-banner {
  background: #e9eef8;
  color: #61728f;
  border-color: #d8e1f0;
  border-radius: 12px;
}
#round-banner.double-round {
  background: #fff2dc;
  color: #966a2d;
  border-color: #ebd5ac;
  box-shadow: none;
}
.round-reference {
  background: #ffffffed;
  border: 1px solid #dfe5ef;
  box-shadow: 0 5px 20px #40547c08;
  border-radius: 18px;
}
.reference-heading b {
  color: #3d5076;
}
.reference-heading small {
  color: #8b97ab;
}
.round-reference .reference-gang small {
  color: #947255;
}
.round-reference .reference-wild small {
  color: #8b713a;
}
.round-reference .reference-flipped .tile {
  outline-color: #b4a17e;
}
.round-reference .reference-wild .tile {
  background: #ffebbb;
}
.table {
  border-color: #b5c3d9;
  background: radial-gradient(
    ellipse at 50% 35%,
    #4a6088 0,
    #384d72 55%,
    #2c3e5e 100%
  );
  box-shadow:
    inset 0 0 0 2px #e2e8f3,
    inset 0 0 65px #15284166,
    0 14px 35px #32476d1c;
}
.table-grain {
  border-color: #c9d8f02b;
  background: repeating-linear-gradient(
    33deg,
    transparent 0 3px,
    #ffffff02 3px 4px
  );
}
.table {
  color: #edf2fc;
}
.player-badge {
  background: #263955ed;
  border-color: #97acd04a;
  box-shadow: 0 4px 14px #17243c20;
  border-radius: 14px;
}
.player.active .player-badge {
  border-color: #eacb87;
  box-shadow: 0 0 0 3px #eacb8714;
}
.player small {
  color: #b5c4dc;
}
.avatar {
  background: linear-gradient(140deg, #7f95c6, #536d9b);
  border-color: #a6badb;
  color: #f6f8ff;
}
.center p {
  color: #b7c7e1;
}
.center h2 {
  color: #f3f6ff;
}
.legend-tile small {
  color: #c3cee0;
}
.wall {
  background: repeating-linear-gradient(
    90deg,
    #516f9f 0 17px,
    #9eb4d4 17px 19px
  );
  border-color: #bdc9dd;
  box-shadow:
    0 4px 0 #2d466d,
    0 7px 0 #b9c6da,
    0 10px 0 #354d75,
    0 12px 8px #17243b55;
}
.tile {
  box-shadow:
    0 4px 0 #b7b9c5,
    0 6px 0 #2a4269,
    0 8px 6px #17243b55;
}
.tile-back {
  background: #edf0f8 !important;
}
.selected {
  box-shadow:
    0 4px 0 #b7b9c5,
    0 6px 0 #2a4269,
    0 8px 14px #17243b66;
}
.player .tile,
.river .tile {
  box-shadow:
    0 2px 0 #bdc2cf,
    0 3px 0 #2a4269,
    0 4px 3px #17243b44;
}
.seat-left .concealed .tile,
.seat-right .concealed .tile {
  box-shadow:
    2px 0 0 #bdc2cf,
    4px 0 0 #2a4269;
}
.hand .drawn-tile {
  box-shadow:
    0 4px 0 #b7b9c5,
    0 6px 0 #2a4269,
    0 8px 12px #17243b55,
    0 0 14px #e9d18e44;
}
.handarea small {
  color: #aebed8;
}
.handarea button:not(.tile) {
  color: #f4f6ff;
  background: #627cb0;
  border-color: #91a6cc55;
  border-radius: 10px;
  box-shadow: 0 3px 10px #19294225;
}
.handarea button:not(.tile):hover {
  background: #718abe;
}
#win-requirement {
  color: #e4c9a3;
}
#win-requirement.ready {
  color: #c7d6ff;
}
.discard-show > b {
  color: #ffe3ac;
}
.discard-show small {
  color: #c7d4e9;
}
.discard-show .tile {
  box-shadow:
    0 5px 0 #b7b9c5,
    0 8px 0 #2a4269,
    0 12px 20px #17243b55;
}
.gang-zone {
  background: #253957e6;
  border-color: #9ab0d345;
  box-shadow: 0 4px 12px #15253d22;
  border-radius: 12px;
}
.gang-zone > small {
  color: #c9d5ee;
}
.gang-zone .tile {
  box-shadow:
    0 2px 0 #bdc2cf,
    0 4px 0 #2a4269;
}
aside {
  background: #ffffffbf;
  border: 1px solid #e0e6f0;
  border-radius: 20px;
  padding: 22px;
}
aside h3 {
  color: #526382;
  font-weight: 600;
}
#log p {
  color: #7e8ba1;
  border-bottom-color: #e6ebf3;
}
aside .hint {
  color: #9aa5b7;
}
.opening {
  background: #293d60f5;
  border-color: #91a8d15c;
  box-shadow: 0 15px 60px #10213c66;
}
.opening p {
  color: #c6d3e8;
}
.opening h2 {
  color: #ffe2a0;
}
.seat-manager {
  background: #fff;
  border-color: #dce4f1;
  border-radius: 18px;
}
.seat-manager h3 {
  color: #455d89;
}
.seat-manager p {
  color: #8794a9;
}
.setup-seat {
  background: #f2f5fc;
  border-color: #d8e1f0;
}
.setup-seat.empty {
  color: #9aa6ba;
}
#result-layer {
  background: #19263cba;
}
.result-panel {
  background: #f8faff;
  border: 1px solid #d7e0f1;
  box-shadow: 0 20px 100px #13213d55;
  color: #344561;
  border-radius: 26px;
}
.result-panel h2 {
  color: #5a6ec2;
}
.result-winner {
  color: #34496f;
}
.result-table th {
  color: #6477b3;
}
.result-table td,
.result-table th {
  border-bottom-color: #e1e7f2;
}
.result-payments {
  background: #eaf0fa;
}
.result-mine {
  color: #8b6837;
}
.round-showdown {
  background: #fff;
  border-color: #dce4ef;
}
.revealed-hands h3 {
  color: #6476a5;
}
.revealed-player {
  background: #edf2fa;
  border-color: #dce4f0;
}
.revealed-player > b {
  color: #60718d;
}
.revealed-winner {
  background: #fff4dc;
  border-color: #e5c98c;
}
.revealed-winner > b {
  color: #997435;
}
@media (max-width: 650px) {
  .welcome {
    gap: 26px;
  }
  .entry {
    padding: 24px;
  }
  .wall {
    background: repeating-linear-gradient(
      90deg,
      #516f9f 0 11px,
      #9eb4d4 11px 13px
    );
  }
  header {
    padding: 14px 16px;
  }
  .round-reference {
    border-radius: 14px;
  }
  .table {
    border-color: #afbed7;
  }
}
/* Public tiles keep enough face area to read ranks without opening details. */
#gang-zones .gang-zone {
  width: 144px;
  max-width: 144px;
  padding: 7px;
  border-radius: 10px;
}
#gang-zones .gang-zone > small {
  font-size: 9px;
  margin: 0 0 6px;
}
#gang-zones .gang-cards {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 7px;
}
#gang-zones .gang-cards > .meld {
  flex-wrap: nowrap;
  gap: 2px;
  padding: 2px;
  max-width: 100%;
  background: #ffffff08;
}
#gang-zones .gang-cards > .meld:nth-child(n + 3) {
  display: none;
}
#gang-zones .tile {
  width: 28px;
  height: 40px;
  padding: 1px;
}
#gang-zones .gang-top {
  top: 18px;
  right: 18px;
  bottom: auto;
  left: auto;
}
#gang-zones .gang-left {
  top: 18px;
  left: 18px;
  bottom: auto;
  right: auto;
}
#gang-zones .gang-right {
  right: calc(3% + 110px);
  bottom: calc(235px + var(--exposed-space, 0px));
  top: auto;
  left: auto;
}
#gang-zones .gang-bottom {
  width: auto;
  max-width: none;
  left: 4%;
  right: auto;
  bottom: 14px;
  gap: 10px;
  padding: 8px 10px;
}
#gang-zones .gang-bottom > small {
  margin: 0;
}
#gang-zones .gang-bottom .gang-cards {
  flex-direction: row;
  flex: none;
  gap: 8px;
}
#gang-zones .exposed-expand {
  padding: 5px 7px;
  margin: 7px 0 0;
  width: 100%;
  font-size: 10px;
  background: #526d9b;
  border: 1px solid #9eb5da55;
  color: #edf3ff;
  border-radius: 7px;
  white-space: nowrap;
}
#gang-zones .gang-bottom .exposed-expand {
  margin: 0;
  width: auto;
}
@media (max-width: 650px) {
  #gang-zones .gang-zone {
    width: 112px;
    max-width: 112px;
    padding: 5px;
  }
  #gang-zones .gang-zone > small {
    font-size: 8px;
    margin-bottom: 5px;
  }
  #gang-zones .tile {
    width: 22px;
    height: 32px;
  }
  #gang-zones .gang-cards {
    gap: 6px;
  }
  #gang-zones .gang-top {
    top: 12px;
    right: 8px;
  }
  #gang-zones .gang-left {
    top: 12px;
    left: 8px;
  }
  #gang-zones .gang-right {
    right: calc(3% + 65px);
    bottom: calc(235px + var(--exposed-space, 0px));
  }
  #gang-zones .gang-bottom {
    width: auto;
    max-width: none;
    left: 3%;
    right: auto;
    bottom: 12px;
    gap: 6px;
    padding: 7px;
  }
  #gang-zones .gang-bottom .gang-cards {
    gap: 6px;
  }
  #gang-zones .gang-bottom > small {
    margin: 0;
  }
  #gang-zones .exposed-expand {
    font-size: 8px;
    padding: 5px;
    margin-top: 6px;
  }
  .exposed-panel {
    padding: 20px;
  }
  .exposed-panel .tile {
    width: 29px;
    height: 41px;
  }
  .exposed-panel .gang-cards {
    gap: 12px;
  }
}
#gang-zones .gang-right {
  bottom: calc(
    var(--self-seat-bottom, 300px) + var(--self-badge-height, 60px) + 12px
  );
}
.seat-top {
  max-width: calc(100% - 240px);
}
.seat-top .concealed {
  max-width: 100%;
}
.seat-top .concealed .tile {
  flex: 0 1 27px;
  min-width: 0;
}
@media (max-width: 650px) {
  #gang-zones .gang-right {
    right: calc(3% + 45px);
    bottom: calc(
      var(--self-seat-bottom, 260px) + var(--self-badge-height, 50px) + 12px
    );
  }
  .seat-top {
    max-width: calc(100% - 248px);
  }
  .seat-top .concealed .tile {
    flex-basis: 19px;
  }
}
.river {
  max-width: 220px;
}
@media (max-width: 650px) {
  .river {
    max-width: 90px;
    align-self: flex-start;
    margin-left: 0;
    margin-right: 0;
  }
}
.table {
  height: calc(
    var(--table-base) + var(--exposed-space, 0px) + var(--right-clearance, 0px)
  );
  min-height: calc(
    var(--table-base) + var(--exposed-space, 0px) + var(--right-clearance, 0px)
  );
}
#gang-zones .gang-right {
  right: 18px;
  top: var(--right-exposed-top, 470px);
  bottom: auto;
}
@media (max-width: 650px) {
  #gang-zones .gang-right {
    right: 8px;
    top: var(--right-exposed-top, 430px);
    bottom: auto;
  }
}
/* Expand locally down the seat's existing preview, keeping the table visible. */
#gang-zones .gang-zone.is-expanded:not(.gang-bottom) {
  width: 180px;
  max-width: 180px;
}
#gang-zones .gang-zone.is-expanded .tile {
  width: 36px;
  height: 50px;
}
#gang-zones .gang-zone.is-expanded .gang-cards {
  max-height: 178px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0 5px;
  scrollbar-width: thin;
  scrollbar-color: #8fa7cf #263b59;
  overscroll-behavior: contain;
}
#gang-zones .gang-zone.is-expanded .gang-cards > .meld:nth-child(n + 3) {
  display: flex;
}
#gang-zones .gang-zone.is-expanded .meld {
  flex-shrink: 0;
}
#gang-zones .gang-bottom.is-expanded {
  align-items: flex-start;
}
#gang-zones .gang-bottom.is-expanded .gang-cards {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  max-width: 332px;
  max-height: 178px;
  gap: 8px;
}
#gang-zones .gang-zone.is-expanded .exposed-expand {
  background: #7892bf;
}
.table.top-exposed-expanded .seat-top {
  top: var(--top-player-offset);
}
.table.top-exposed-expanded .center {
  top: calc(var(--top-row-bottom) + 60px);
}
.seat-left {
  top: max(170px, var(--left-seat-top, 0px), var(--top-row-bottom, 0px));
}
.seat-right {
  top: max(170px, var(--right-seat-top, 0px), var(--top-row-bottom, 0px));
}
@media (max-width: 650px) {
  #gang-zones .gang-zone.is-expanded:not(.gang-bottom) {
    width: 154px;
    max-width: 154px;
  }
  #gang-zones .gang-zone.is-expanded .tile {
    width: 32px;
    height: 46px;
  }
  #gang-zones .gang-zone.is-expanded .gang-cards {
    max-height: 166px;
  }
  #gang-zones .gang-bottom.is-expanded .gang-cards {
    grid-template-columns: max-content;
    max-width: none;
    gap: 6px;
  }
  .seat-left {
    top: max(147px, var(--left-seat-top, 0px), var(--top-row-bottom, 0px));
  }
  .seat-right {
    top: max(147px, var(--right-seat-top, 0px), var(--top-row-bottom, 0px));
  }
}
/* Selected hand tiles reveal matching public tiles without moving them. */
#river .tile.matching-tile,
#discard-card .tile.matching-tile,
#gang-zones .tile.matching-tile {
  background: #ffefb3 !important;
  outline: 2px solid #65d9ff !important;
  outline-offset: -1px;
  box-shadow:
    0 2px 0 #b7b9c5,
    0 0 10px #65d9ffb3;
  filter: brightness(1.07);
}
#gang-zones .exposed-expand.matching-hidden {
  border-color: #65d9ff;
  background: #486c99;
  color: #fff4bf;
}
#gang-zones .exposed-expand.matching-hidden::after {
  content: attr(data-matches);
  display: block;
  margin-top: 2px;
  font-size: 9px;
  line-height: 1.4;
  color: #a7edff;
  white-space: normal;
}
@media (max-width: 650px) {
  #gang-zones .exposed-expand.matching-hidden::after {
    font-size: 8px;
  }
}
#win-waits {
  font-size: 11px;
  line-height: 1.6;
  margin: 5px 0;
  color: #cde3ff;
  overflow-wrap: anywhere;
}
.handarea button.win-action {
  background: #f6d184;
  color: #3c4157;
  border-color: #ffe4b1;
  font-weight: 700;
  box-shadow: 0 0 0 2px #f6d18422;
}
.handarea button.win-action:hover {
  background: #ffe0a0;
}
@media (max-width: 650px) {
  #win-waits {
    font-size: 9px;
  }
}
.result-cap {
  padding: 12px 15px;
  border: 1px solid #e7c56d;
  border-radius: 12px;
  background: #fff5db;
  color: #735321;
  font-weight: 600;
  line-height: 1.7;
}
.tutorial-entry {
  background: #e9cf92;
  color: #303b54;
  border: 1px solid #cfb070;
  font-weight: 700;
}
.tutorial-panel {
  margin: 14px 0 20px;
  border: 1px solid #d6be83;
  border-radius: 18px;
  background: #fff9ec;
  color: #33435c;
  box-shadow: 0 8px 24px #243a5710;
  overflow: hidden;
}
.tutorial-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: #f6ebcf;
}
.tutorial-heading button {
  margin: 0;
  padding: 7px 12px;
  background: #fff9ed;
  color: #45516a;
  border: 1px solid #d5c6a1;
}
.tutorial-content {
  padding: 16px 20px;
}
.tutorial-content select {
  width: 100%;
  max-width: 320px;
  border: 1px solid #d5c6a1;
  border-radius: 9px;
  background: white;
  color: #33435c;
  padding: 9px 12px;
  font: inherit;
  margin: 0 14px 8px 0;
}
.tutorial-content small {
  display: inline-block;
  color: #6a624e;
}
.tutorial-content h3 {
  margin: 10px 0 8px;
  font-size: 19px;
}
.tutorial-content p {
  line-height: 1.8;
  margin: 7px 0;
  max-width: 950px;
}
.tutorial-content .tutorial-note {
  font-size: 12px;
  color: #74674c;
}
.tutorial-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.tutorial-content .tutorial-coach {
  font-size: 12px;
  color: #3c6650;
  border-left: 3px solid #8fae97;
  padding-left: 10px;
}
.tutorial-controls button {
  margin: 0;
  padding: 9px 14px;
  background: #435b7f;
  color: white;
  border: 1px solid #435b7f;
}
.tutorial-controls button:disabled {
  opacity: 0.4;
  cursor: default;
}
#actions button.tutorial-target,
#hand .tile.tutorial-target {
  outline: 3px solid #e7bd62;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px #e7bd6229;
}
@media (max-width: 650px) {
  .tutorial-heading {
    padding: 12px;
    align-items: flex-start;
  }
  .tutorial-heading b {
    font-size: 14px;
  }
  .tutorial-heading button {
    font-size: 11px;
    white-space: nowrap;
  }
  .tutorial-content {
    padding: 12px;
  }
  .tutorial-content h3 {
    font-size: 17px;
  }
  .tutorial-content p {
    font-size: 13px;
  }
  .tutorial-controls button {
    font-size: 12px;
    padding: 9px 11px;
  }
}
.result-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
.result-table-wrap .result-table {
  min-width: 640px;
}
.dice-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin: 22px 0 12px;
  min-height: 92px;
  perspective: 500px;
}
.die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 5px;
  width: 70px;
  height: 70px;
  padding: 10px;
  border: 1px solid #d7d1bd;
  border-radius: 13px;
  background: linear-gradient(135deg, #fffef5, #e4dfcc);
  box-shadow:
    inset 2px 2px 5px #fff,
    0 6px 0 #aeb3b5,
    0 14px 18px #101e3c66;
  transform: rotate(-7deg);
}
.die:nth-child(2) {
  transform: rotate(8deg);
}
.dice-pip {
  border-radius: 50%;
  background: transparent;
}
.dice-pip.filled {
  background: #315184;
  box-shadow: inset 0 2px 2px #122a4b66;
}
.die-red .dice-pip.filled {
  background: #b63236;
}
.dice-area.rolling .die {
  animation: dice-tumble 1.15s cubic-bezier(0.2, 0.6, 0.3, 1) both;
}
.dice-area.rolling .die:nth-child(2) {
  animation-delay: 0.08s;
  animation-direction: reverse;
}
.dice-area.leopard .die {
  outline: 2px solid #e9c16c;
  box-shadow:
    0 6px 0 #b29b64,
    0 0 24px #f6ce7a77;
}
.wall.draw-start {
  outline: 3px solid #f4d184;
  box-shadow: 0 0 20px #ffdb8c;
  opacity: 1;
}
@keyframes dice-tumble {
  0% {
    transform: translate(-25px, -30px) rotateX(0deg) rotateZ(-30deg);
  }
  25% {
    transform: translate(16px, -44px) rotateX(160deg) rotateZ(100deg);
  }
  55% {
    transform: translate(-12px, 4px) rotateX(300deg) rotateZ(230deg);
  }
  80% {
    transform: translate(4px, -8px) rotateX(360deg) rotateZ(350deg);
  }
  100% {
    transform: translate(0, 0) rotateX(360deg) rotateZ(353deg);
  }
}
@media (max-width: 650px) {
  .dice-area {
    min-height: 82px;
    gap: 20px;
  }
  .die {
    width: 60px;
    height: 60px;
    padding: 8px;
    gap: 4px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .dice-area.rolling .die {
    animation: none;
  }
}

/* A dedicated footer keeps the reference entry clear of hands and exposed tiles. */
#score-reference-button {
  position: absolute;
  right: 14px;
  bottom: 10px;
  z-index: 12;
  margin: 0;
  padding: 8px 14px;
  min-height: 36px;
  border-color: #d5c396;
  background: #fff8e8;
  color: #53442c;
  font-size: 13px;
  font-weight: 700;
}
#gang-zones .gang-bottom { bottom: 58px; }
.score-reference-open { overflow: hidden; }
#score-reference-dialog {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #f3f5fa;
  color: #26334c;
  overscroll-behavior: contain;
}
#score-reference-dialog[open] { display: flex; flex-direction: column; }
#score-reference-dialog::backdrop { background: #1c2e47bb; }
.score-reference-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) max(5%, env(safe-area-inset-right)) 14px;
  border-bottom: 1px solid #dce3ed;
  background: #fff;
}
.score-reference-header h1 { margin: 0; font-size: 22px; letter-spacing: 2px; }
.score-reference-header button { margin: 0; min-height: 44px; }
.score-reference-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px max(5%, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom));
}
.score-reference-content > * { max-width: 1000px; margin-left: auto; margin-right: auto; }
.score-reference-content h2 { font-size: 22px; margin: 12px 0; }
.score-reference-lead { text-align: center; margin-bottom: 24px; }
.score-reference-lead p { color: #66748b; margin: 8px 0; }
.score-reference-chip {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 30px;
  color: #5266b6;
  background: #e6ebfc;
  font-size: 13px;
  font-weight: 700;
}
.score-reference-double { display: block; margin-top: 12px; color: #91601d; }
.score-reference-table-wrap { overflow-x: auto; border: 1px solid #dce3ed; border-radius: 16px; background: #fff; }
.score-reference-table-wrap table { width: 100%; border-collapse: collapse; text-align: center; }
.score-reference-table-wrap caption { padding: 16px; text-align: left; font-weight: 700; }
.score-reference-table-wrap th, .score-reference-table-wrap td { padding: 15px 12px; border-top: 1px solid #e7ebf2; }
.score-reference-table-wrap thead th { color: #62738b; background: #f8faff; font-size: 14px; }
.score-reference-table-wrap tbody th { font-weight: 500; }
.score-reference-table-wrap td { font-size: 23px; font-weight: 750; color: #344765; font-variant-numeric: tabular-nums; }
.score-reference-table-wrap .score-reference-current { background: #fff8e7; color: #946621; }
.score-reference-table-wrap tbody tr:last-child { border-top: 2px solid #dce3ed; }
.score-reference-items { margin-top: 32px; }
.score-reference-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.score-reference-grid > div { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 16px; border: 1px solid #e0e5ef; border-radius: 12px; background: #fff; }
.score-reference-grid strong { color: #5266b6; }
.score-reference-grid small { grid-column: 1 / -1; color: #748198; line-height: 1.6; }
.score-reference-notes { margin-top: 28px; padding: 20px; border: 1px solid #e5d9be; border-radius: 14px; background: #fffbf3; }
.score-reference-notes p { font-size: 14px; line-height: 1.9; margin: 10px 0 0; }
@media (max-width: 650px) {
  #score-reference-button { right: 10px; font-size: 12px; }
  .score-reference-content { padding: 20px 14px max(28px, env(safe-area-inset-bottom)); }
  .score-reference-content h2 { font-size: 20px; }
  .score-reference-header { padding-left: 16px; padding-right: 16px; }
  .score-reference-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .score-reference-grid > div { padding: 12px; font-size: 13px; }
  .score-reference-table-wrap th, .score-reference-table-wrap td { padding: 13px 8px; }
  .score-reference-table-wrap td { font-size: 21px; }
  .score-reference-notes { padding: 16px; }
}

#create-room-dialog {
  width: min(620px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  border: 1px solid #dce3ed;
  border-radius: 20px;
  padding: 28px;
  color: #26334c;
  background: #f8faff;
  box-shadow: 0 24px 80px #12213a44;
}
#create-room-dialog::backdrop { background: #1c2e47bb; }
#create-room-dialog h2 { margin: 0 0 10px; font-size: 24px; }
#create-room-dialog p { font-size: 14px; color: #66748b; }
.create-score-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 22px 0; }
#create-room-dialog label { display: grid; gap: 8px; color: #344765; font-size: 14px; }
#create-room-dialog input { width: 100%; margin: 0; padding: 12px; font-size: 20px; font-weight: 700; }
#create-room-dialog label small { margin: 0; color: #78869b; font-size: 12px; }
#create-room-dialog details { padding: 14px; border: 1px solid #dce3ed; border-radius: 12px; background: #fff; }
#create-room-dialog summary { cursor: pointer; font-size: 14px; }
#create-room-dialog details label { max-width: 200px; }
#create-room-dialog .create-score-error { min-height: 20px; color: #aa463e; }
.create-score-actions { display: flex; gap: 10px; justify-content: flex-end; }
.create-score-actions button { margin: 0; min-height: 44px; }
.room-score-summary { padding: 14px 18px; border: 1px solid #dce3ed; border-radius: 12px; background: #fffaf0; color: #5c5543; font-size: 14px; }
@media (max-width: 650px) {
  #create-room-dialog { padding: 20px; }
  .create-score-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
