.mj-table {
  --mj-ink: #e7f6e8;
  --mj-gold: #f0c77a;
  --mj-muted: #b6d2c5;
  max-width: 570px;
  margin: auto;
  padding: clamp(10px, 2.6vw, 22px);
  border: 1px solid #477263;
  border-radius: 22px;
  color: var(--mj-ink);
  background: radial-gradient(ellipse at 85% 0, #2c6555 0, transparent 56%), linear-gradient(165deg, #173b37, #102622 70%);
  box-shadow: inset 0 1px #f4df9b32, 0 10px 24px #102f2729;
}

.mj-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.mj-head h2 {
  color: #fff3d4;
  font: 700 clamp(1.05rem, 3.5vw, 1.65rem)/1.15 Georgia, serif;
}

.mj-head p, .mj-help {
  color: var(--mj-muted);
  font-size: .85rem;
  line-height: 1.4;
  margin: 4px 0 0;
}

.mj-meter {
  flex: none;
  display: grid;
  justify-items: end;
  gap: 3px;
  font-variant-numeric: tabular-nums;
  font-size: .74rem;
  color: var(--mj-muted);
}

.mj-meter strong { color: var(--mj-gold); font-size: 1rem; }

.mj-stage {
  container-type: inline-size;
  padding: clamp(8px, 2vw, 15px);
  border: 1px solid #c8b68250;
  border-radius: 16px;
  background: radial-gradient(ellipse at 50% 35%, #276455a8, #102f2bad 78%), repeating-linear-gradient(45deg, #ffffff08 0 1px, transparent 1px 14px), #183c33;
  box-shadow: inset 0 2px 12px #041e18a4;
}

.mj-board {
  position: relative;
  width: min(100%, 445px);
  aspect-ratio: var(--mj-ratio);
  margin: auto;
}

.mj-board .mj-tile {
  position: absolute;
  top: calc(var(--ty) - var(--tz) * 2px);
  left: calc(var(--tx) + var(--tz) * 2px);
  z-index: calc(2 + var(--tz));
  width: calc(var(--tw) - 2px);
  height: calc(var(--th) - 3px);
  min-width: 0;
  min-height: 0;
  padding: 0;
  isolation: isolate;
  border-radius: 15%;
  border: 1px solid #d5ab60;
  color: #326355;
  background: #bd985e;
  box-shadow: 0 2px #5a6847, 0 4px 4px #0a241aca;
  font-size: 1rem;
  font-size: clamp(.58rem, 4cqw, 1.1rem);
  touch-action: manipulation;
}

.mj-board .mj-tile[hidden] { display: none; }
.mj-tile[data-open=false] { cursor: default; }
.mj-tile[data-open=false] .mj-tile-face { filter: brightness(.68) saturate(.72); }
.mj-tile[data-suit="circles"] { color: #245786; }
.mj-tile[data-suit="characters"], .mj-tile[data-suit="dragon-0"] { color: #9c3d37; }
.mj-tile[data-suit="wind"] { color: #473b6a; }
.mj-tile[data-suit="dragon-1"] { color: #176942; }
.mj-tile[data-suit="dragon-2"] { color: #385571; }

.mj-tile-face {
  position: absolute;
  inset: 0 0 2px;
  display: grid;
  place-items: center;
  border-radius: inherit;
  background: linear-gradient(155deg, #fffdfa, #fff4d9 62%, #ead2a3);
  box-shadow: inset 0 1px #fff, inset 0 -1px #e6c982;
}

.mj-rank {
  position: absolute;
  top: 6%;
  left: 9%;
  font: 800 .66em/1 system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

.mj-character { margin-top: 20%; font: 800 1.23em/1 Georgia, 'Songti SC', 'Noto Serif CJK SC', serif; }
.mj-pips { display: grid; width: 56%; height: 58%; grid-template: repeat(3, 1fr)/repeat(3, 1fr); gap: 5%; margin-top: 17%; }
.mj-pips i { display: block; place-self: center; width: 94%; max-width: 8px; aspect-ratio: 1; background: currentColor; border-radius: 50%; }
.mj-tile[data-suit="bamboo"] .mj-pips i { width: 53%; height: 95%; border-radius: 60% 15%; transform: rotate(12deg); }
.mj-tile[data-open=true]:hover .mj-tile-face { background: #fffef1; }
.mj-tile[aria-pressed=true] .mj-tile-face { background: #dcffe2; box-shadow: inset 0 0 0 2px #0d935f, inset 0 0 7px #49d89482; }
.mj-tile.mj-hinted .mj-tile-face { background: #fff0a8; box-shadow: inset 0 0 0 2px #9a5c14; }
.mj-board .mj-tile:focus-visible { outline: 2px solid #0e2230; outline-offset: -3px; }
.mj-board .mj-tile:focus-visible .mj-tile-face { box-shadow: inset 0 0 0 2px #ffe784; }
.mj-status { margin-top: 11px; min-height: 2.6em; color: var(--mj-ink); font-size: .89rem; line-height: 1.3; }

.mj-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.mj-actions button { min-height: 44px; padding: 5px 10px; flex: 1 1 auto; background: #285447; border: 1px solid #548275; border-radius: 9px; color: #f3fbef; font-size: .83rem; font-weight: 720; }
.mj-actions button:focus-visible { outline-color: #ffe28c; outline-offset: -3px; }
.mj-actions button:not(:disabled):hover { background: #3e7464; }
.mj-actions .mj-hint { color: #1d3129; background: #f0c77a; border-color: #f2d89d; }
.mj-actions .mj-hint:not(:disabled):hover { color: #182b25; background: #ffde9a; }
.mj-help { margin-top: 8px; }
