body {
  background: radial-gradient(ellipse at 50% -14%, #375040, #172c24 42%, #0c1916 76%);
}
.top {
  border-bottom-color: #bba17239;
}
.top .seal, #lobby .gold, .modal-actions .gold {
  background: linear-gradient(145deg, #ffebc0, #d4ad69 82%);
}
.hero { border-color: #c7a66d78; }
.mode {
  background: linear-gradient(132deg, #314b3c, #182f27 72%);
  border-color: #b4ad7c48;
  box-shadow: inset 0 1px #eddbab20, 0 5px 12px #05191255;
}
.mode:hover { background: linear-gradient(130deg, #415c49, #233d30 80%); }

#game {
  max-width: 1140px;
  --ivory: #f8ecd1;
  --brass: #d2ae6f;
  --felt-ink: #9eb59c;
  --wall-fill: 1;
}
.gamebar {
  grid-template-columns: minmax(74px,1fr) minmax(0,3fr) minmax(74px,1fr);
  min-height: 62px;
  padding: 4px 0 9px;
}
.gamebar #history { justify-self: end; }
.gamebar button {
  min-height: 38px; padding-inline: 13px;
  color: #e2d5b4; background: #13291f;
  border-color: #ad94665c; border-radius: 7px;
}
.gamebar strong {
  display: block;
  color: #f7dfaa;
  font: 700 clamp(18px,2.4vw,25px)/1.25 "Songti SC","Noto Serif CJK SC",serif;
}
.gamebar small { font-size: 12px; color: #ccddc6; }

.table, .duel .table {
  --seat-side: 14%;
  --rail: clamp(6px, 1.1vw, 12px);
  --radius: clamp(16px, 3.6vw, 46px);
  box-sizing: border-box;
  display: block;
  padding: 0;
  height: clamp(340px, 56dvh, 595px);
  min-height: 0;
  border: var(--rail) solid #91734a;
  border-top-color: #b49464;
  border-bottom-color: #63492e;
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(38deg,#e4e3b309 0 1px,transparent 1px 4px),
    repeating-linear-gradient(128deg,#0b201b14 0 1px,transparent 1px 4px),
    radial-gradient(ellipse at 49% 41%,#315f47,#214936 66%,#112f25);
  box-shadow: 0 4px 0 #443021, 0 14px 30px #071610aa,
    inset 0 0 0 2px #dabc846d, inset 0 0 0 5px #102d2390, inset 0 0 36px #091e18a6;
}
.table::before {
  inset: clamp(7px, 1.3vw, 15px);
  border-radius: calc(var(--radius) - 7px);
  border-color: #c8c78f46;
}
.wallstack {
  position: absolute;
  z-index: -1;
  width: calc(29% * var(--wall-fill));
  height: clamp(10px, 1.7vw, 19px);
  background:
    repeating-linear-gradient(90deg,transparent 0 9px,#111f18 9px 10px),
    linear-gradient(#b9bb99 0 13%,#64836d 13% 67%,#c5b794 68% 79%,#53644b 80%);
  border-radius: 2px;
  box-shadow: 0 3px 5px #071f18ad;
  opacity: .82;
}
.wallstack-top, .wallstack-bottom { left: 50%; transform: translateX(-50%); }
.wallstack-top { top: 16%; }
.wallstack-bottom { bottom: 5%; }
.wallstack-left, .wallstack-right { top: 50%; width: calc(24% * var(--wall-fill)); }
.wallstack-left { left: 8%; transform: translate(-50%,-50%) rotate(90deg); }
.wallstack-right { right: 8%; transform: translate(50%,-50%) rotate(90deg); }
.duel .wallstack-left,.duel .wallstack-right { display: none; }
#rivers, .duel #rivers {
  position: absolute;
  inset: 24% 15% 12%;
  width: auto;
  max-width: none;
  display: grid;
  grid-template: "west north east" 1fr "west center east" .74fr "west south east" 1fr / 1fr 1.65fr 1fr;
  gap: 7px;
}
.river {
  align-self: start;
  min-height: 0;
  max-height: 100%;
  padding: 3px 5px;
  overflow: auto;
  border: 1px solid #d1dcb529;
  border-radius: 6px;
  background: #153c2c35;
  scrollbar-width: thin;
}
.river-0 { grid-area: south; align-self: end; }
.river-1 { grid-area: east; align-self: center; }
.river-2 { grid-area: north; }
.river-3 { grid-area: west; align-self: center; }
.duel .river-1 { grid-area: north; }
.riverhead {
  min-height: 17px; display: flex; flex-wrap: wrap; gap: 2px; align-items: center;
  margin-bottom: 3px; color: #d3dfbc; font-size: 10px;
}
.riverhead > span:first-child { margin-right: 3px; color: #dfc18a; }
.river .tiles { gap: 3px; }
.river .tile {
  width: clamp(12px, 1.7vw, 23px);
  height: clamp(16px, 2.2vw, 30px);
  font-size: clamp(8px, 1.1vw, 13px);
  border-bottom-width: 2px;
}
.river .exposed { margin-left: 0; }
.river .exposed .tile { width: 13px; height: 17px; font-size: 8px; }
#compass {
  position: absolute;
  left: 50%; top: 52%;
  transform: translate(-50%,-50%);
  width: clamp(58px,8vw,88px); aspect-ratio: 1;
  display: grid; place-content: center; text-align: center; gap: 1px;
  border-radius: 50%; border: 1px solid #bda46782;
  box-shadow: 0 0 0 4px #bdab692b, inset 0 0 0 3px #152e25;
  background: radial-gradient(#244335,#132d24);
  color: #e9c888; pointer-events: none;
}
#compass.mine { border-color: #f2cd84; box-shadow: 0 0 0 4px #e9c17b45,0 0 15px #deb77438; }
#activeWind { font: 700 clamp(22px,4vw,37px)/1 "Songti SC","Noto Serif CJK SC",serif; }
#wall { color: #d4dfc9; font-size: 10px; white-space: nowrap; }
.opponent, #me {
  display: flex; align-items: center; text-align: left; gap: 7px;
  min-width: 0; white-space: nowrap;
}
.opponent {
  z-index: 2;
  border: 1px solid #ae986460; padding: 5px 8px;
  box-shadow: 0 4px 10px #0a1d1666;
  background: linear-gradient(155deg,#233c31,#11251d);
  writing-mode: horizontal-tb;
}
.north { top: 5px; }
.west { top: 47%; left: 5px; }
.east { top: 47%; right: 5px; }
.seat-wind {
  width: 27px; height: 27px; display: grid; place-items: center;
  flex: none; border: 1px solid #bda4767a; border-radius: 50%;
  background: #344638; color: #efcf94; font: 700 14px/1 serif;
}
.turn .seat-wind { color: #192822; background: #ebc686; }
.seat-details strong, .seat-details small { display: block; }
.seat-details strong { color: #f1e7cc; font-size: 13px; }
.seat-details small { color: #b8cab5; font-size: 10px; }
.rack {
  margin-top: 10px; padding: 2px 10px 11px;
  border-radius: 11px;
  border-color: #bba1756c;
  background: linear-gradient(110deg,#232d25,#122920 53%,#22352b);
  box-shadow: 0 5px 14px #05110d80,inset 0 1px #dcc49726;
}
.racktop { padding: 2px 2px 4px; min-height: 48px; }
.racktop #actions { margin-left: auto; }
.racktop button { min-width: 48px; border-color: #b5a47570; background: #284538; padding: 6px 12px; }
.racktop .gold { color: #2b2b20; background: linear-gradient(#ffe7ab,#c9a265); border-color: #f3d297; }
.racktop .gold:disabled { background: #294237; border-color: #9eb09370; color: #d5dbc6; opacity: .88; }
#hand {
  padding: 11px 2px 6px;
  border-block: 1px solid #e4c68a32;
  border-radius: 6px;
  background: linear-gradient(#0c211b8c,#30372b45);
  gap: clamp(1px,.42vw,5px);
}
#hand .tile {
  width: clamp(16px,calc((100vw - 52px)/14),49px);
  height: clamp(35px,11vw,66px);
  font-size: clamp(12px,4.5vw,26px);
  border-radius: 5px;
  border-width: 1px 2px clamp(3px,.65vw,7px);
  border-color: #f5e9cf #e1cdab #477253;
  background: linear-gradient(147deg,#fffbed,#e8dabc);
  box-shadow: inset 0 0 0 1px #fff4d8af, 0 3px 2px #091813ba;
}
#hand .tile:disabled { opacity: .92; filter: saturate(.78); }
#hand .tile.selected {
  transform: translateY(-7px);
  outline: 2px solid #f6cb79;
  box-shadow: 0 4px 7px #08130c,0 0 11px #eac27783;
}
#hand .tile.drawn { margin-left: clamp(1px,.6vw,8px); }
dialog {
  border: 1px solid #d0b077;
  background: linear-gradient(155deg,#284336,#132a23 77%);
  box-shadow: 0 0 0 3px #b49c7450,0 15px 54px #0515108c;
  width: min(92vw,520px);
}
dialog h2 { font-family: "Songti SC","Noto Serif CJK SC",serif; color: #f1d39b; }
.scores tr:first-child td { color: #f4d59b; }
.winning-hand { padding: 6px 0 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.winning-hand>span { display:flex; flex-wrap:wrap; gap:2px; }
.winning-hand .tile { width: clamp(15px,4vw,22px); height:31px; font-size:13px; }
.winning-hand .last { outline: 2px solid #f9d389; }

@media(max-width:640px) {
  .gamebar { min-height: 52px; }
  .gamebar button { min-height: 35px; padding-inline: 5px; }
  .table,.duel .table { height: clamp(285px,50dvh,470px); }
  #rivers,.duel #rivers { inset: 23% 11% 12%; gap:5px; grid-template-rows: 1fr 1.2fr 1fr; grid-template-columns: 1fr 1.55fr 1fr; }
  .opponent { gap: 3px; padding: 3px; }
  .opponent .seat-wind { width: 19px; height: 19px; font-size: 11px; }
  .opponent .seat-details strong { font-size: 10px; }
  .opponent .seat-details small { font-size: 8px; }
  .west,.east { top: 28%; }
  .wallstack-left { left: 7%; }
  .wallstack-right { right: 7%; }
  #compass { top: 54%; }
 .river { padding-inline: 3px; }
  .river .tiles { gap: 2px; }
  .rack { padding-inline: 3px; }
  .racktop button { min-width: 44px; padding-inline:7px; }
}
@media(max-height:570px) and (orientation:landscape) {
  body:has(#lobby:not([hidden])) .top { display:flex; }
  .table,.duel .table { height: clamp(148px,calc(100dvh - 128px),54dvh); }
  .gamebar { min-height: 40px; padding: 1px 0 4px; }
  .gamebar strong { font-size: 16px; }
  .gamebar small { font-size: 10px; }
  .gamebar button,.racktop button { min-height: 32px; padding-block: 3px; }
  .rack { margin-top: 6px; padding-bottom: 3px; }
  .racktop { min-height: 34px; }
  #hand { min-height: 0; padding-top: 8px; }
  #hand .tile { width: 29px; height: 40px; font-size: 16px; }
  .wallstack-top { top: 23%; }
  .opponent { padding-block: 3px; }
  .river .tile { width: 13px; height: 18px; font-size: 8px; }
  #compass { width: 42px; box-shadow: 0 0 0 2px #bdab6948; }
  #activeWind { font-size: 19px; }
  #wall { font-size: 8px; }
}
