/* Star TPJP: "Aurora Ice Palace". Sizes follow --u (game width / 390) and --w (one pillar's width), both set by main.js. */
:root {
  color-scheme: dark;
  --ink: #eef8ff;
  --ice: #bfe6ff;
  --gold: #ffd978;
  --gold-deep: #b98a2c;
  --navy: #0b2a66;
  --deep: #07183d;
  --u: 1;
  --game-h: 100dvh;
  --w: 110px;
  --colh: 380px;
  --hud-h: max(34px, calc(44px * var(--u)));
  --pool-h: calc(80px * var(--u));
  --meta-h: calc(56px * var(--u));
  --timer: calc(42px * var(--u));
  --chip: max(30px, calc(34px * var(--u)));
  --money-h: calc(48px * var(--u));
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: transparent;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  color: inherit;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #fff4be;
  outline-offset: 2px;
}
button:disabled {
  cursor: default;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
b,
strong {
  font-variant-numeric: tabular-nums;
}

#game {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 500px);
  height: var(--game-h);
  min-height: 0;
  padding: max(5px, env(safe-area-inset-top)) calc(8px * var(--u))
    max(6px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: calc(4px * var(--u));
  background:
    linear-gradient(#0a1f4a22, #0a1f4a66), url(assets/art/bg.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/cover;
  overflow: hidden;
}
.is-half #game {
  padding-top: 5px;
  border-top: 2px solid var(--gold);
  border-radius: 14px 14px 0 0;
}

/* ---- header ---- */
.hud {
  display: flex;
  align-items: center;
  gap: calc(5px * var(--u));
  flex: none;
  height: var(--hud-h);
}
.rbtn {
  position: relative;
  flex: none;
  width: calc(var(--hud-h) - 4px);
  height: calc(var(--hud-h) - 4px);
  padding: 0;
  border: 0;
  background: url(assets/art/rbtn.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
  color: #fff;
  font-size: calc(26px * var(--u));
  font-weight: 800;
  display: grid;
  place-items: center;
}
.rbtn:active {
  transform: scale(0.94);
}
.rbtn svg {
  width: 52%;
  height: 52%;
  fill: none;
  stroke: #f4fbff;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 1px 1px #04204a);
}
.hud .rbtn > span {
  line-height: 1;
  text-shadow: 0 1px 2px #04204a;
}
.view-toggle .to-half {
  display: none;
}
.view-toggle[aria-pressed="true"] .to-full {
  display: none;
}
.view-toggle[aria-pressed="true"] .to-half {
  display: inline;
}
.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.1;
  direction: ltr;
  padding-inline: 2px;
}
.brand b {
  font-size: calc(21px * var(--u));
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #eaf7ff;
  text-shadow:
    0 2px 0 #1b4f9a,
    0 0 8px #3a8ee6;
}
.brand small {
  font-size: calc(11px * var(--u));
  color: #a9d4f5;
  white-space: nowrap;
}
.demo {
  position: absolute;
  z-index: 3;
  top: 2px;
  inset-inline-start: 4px;
  padding: 0 7px;
  border-radius: 999px;
  background: #0b2f6acc;
  border: 1px solid #e3c06a88;
  color: var(--gold);
  font-size: calc(10px * var(--u));
  font-style: normal;
  line-height: 1.5;
}

/* ---- STAR POOL banner ---- */
.pool {
  position: relative;
  flex: none;
  height: var(--pool-h);
  display: flex;
  align-items: center;
  direction: ltr;
}
.crown {
  position: relative;
  z-index: 2;
  flex: none;
  width: calc(var(--pool-h) * 0.7);
  height: calc(var(--pool-h) * 0.7);
  background: url(assets/art/crown.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
}
.banner {
  --cap: calc(var(--pool-h) * 0.5);
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100%;
  margin-inline: calc(var(--pool-h) * -0.16);
  border-style: solid;
  border-color: transparent;
  border-width: 0 var(--cap);
  border-image: url(assets/art/banner.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) 0 150 fill / 0 var(--cap) / 0 stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: calc(var(--pool-h) * 0.04);
  gap: 1px;
  line-height: 1;
}
.pool-label {
  font-size: calc(9px * var(--u));
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--gold);
  text-shadow: 0 1px 2px #04204a;
}
.banner #pool {
  font-size: calc(25px * var(--u));
  font-weight: 900;
  color: #ffd45c;
  text-shadow:
    0 2px 0 #7a5410,
    0 0 10px #ffb43088;
  white-space: nowrap;
}
.pool-cue {
  position: absolute;
  z-index: 3;
  bottom: calc(var(--pool-h) * -0.1);
  left: 50%;
  transform: translateX(-50%);
  padding: 1px 10px;
  border-radius: 999px;
  background: linear-gradient(#fff2a8, #f0a82a);
  border: 1px solid #fff8cf;
  color: #4a2a00;
  font-size: calc(10px * var(--u));
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
  animation: cue 0.7s ease-in-out infinite alternate;
}
.pool.cueing .banner {
  filter: drop-shadow(0 0 calc(10px * var(--u)) #ffd45c);
}
.burst {
  position: absolute;
  z-index: 1;
  left: 50%;
  top: 50%;
  width: calc(var(--pool-h) * 3);
  height: calc(var(--pool-h) * 3);
  margin: calc(var(--pool-h) * -1.5) 0 0 calc(var(--pool-h) * -1.5);
  pointer-events: none;
  opacity: 0;
}
.burst.on {
  animation: burst 1.6s ease-out both;
}

/* ---- rank, countdown, recent results ---- */
.meta {
  flex: none;
  display: flex;
  align-items: center;
  gap: calc(6px * var(--u));
  height: var(--meta-h);
  direction: ltr;
}
.rank-badge {
  position: relative;
  flex: none;
  width: calc(var(--meta-h) * 1.02);
  height: var(--meta-h);
  padding: 0;
  border: 0;
  background: url(assets/art/badge.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}
.rank-badge b {
  margin-bottom: calc(var(--meta-h) * 0.2);
  font-size: calc(var(--meta-h) * 0.25);
  font-weight: 900;
  color: #fff8e0;
  text-shadow: 0 1px 2px #04204a;
  line-height: 1;
}
.rank-badge small {
  position: absolute;
  bottom: calc(var(--meta-h) * -0.04);
  padding: 0 calc(var(--meta-h) * 0.1);
  border: 1px solid #e3c06a;
  border-radius: 999px;
  background: #0b2f6af2;
  font-size: calc(var(--meta-h) * 0.19);
  font-weight: 800;
  color: #eaf7ff;
  line-height: 1.25;
}
.timer {
  flex: none;
}
.timer b {
  display: grid;
  place-items: center;
  width: var(--timer);
  height: var(--timer);
  background: url(assets/art/timer.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
  font-size: calc(var(--timer) * 0.44);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px #04204a;
}
.timer.urgent b {
  color: #ffd45c;
  animation: pulse 0.5s ease-in-out infinite alternate;
}
.new-tag {
  flex: none;
  display: grid;
  place-items: center;
  width: calc(var(--timer) * 1.5);
  height: calc(var(--timer) * 0.75);
  background: url(assets/art/newtag.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
  font-size: calc(11px * var(--u));
  font-weight: 900;
  color: #12408a;
}
.history {
  --cap: calc(var(--timer) * 0.4);
  flex: 1;
  min-width: 0;
  height: var(--timer);
  padding: 0;
  border-style: solid;
  border-color: transparent;
  border-width: 0 var(--cap);
  border-image: url(assets/art/pill.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) 0 55 fill / 0 var(--cap) / 0 stretch;
  background: none;
  display: flex;
  align-items: center;
  direction: ltr;
}
.recent {
  display: flex;
  gap: calc(5px * var(--u));
  align-items: center;
  min-width: 0;
  overflow: hidden;
}
.recent .item {
  flex: 0 0 auto;
  width: calc(var(--timer) * 0.72);
  height: calc(var(--timer) * 0.72);
}
.recent .item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.recent .item .unknown,
.record-icons .unknown {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ffffff1f;
  color: #f6e8b8;
  font-size: 15px;
}

/* ---- stage: three arched pillars ---- */
.stage {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  direction: ltr;
}
.cols {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: var(--gap, 4px);
  direction: ltr;
}
.col {
  position: relative;
  flex: none;
  width: var(--w);
  height: var(--colh);
  padding: 0;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: calc(var(--w) * 0.1);
  transition: filter 0.3s;
}
.col:disabled {
  color: inherit;
}
.col:active:not(:disabled) .arch {
  transform: scale(0.985);
}
.mult {
  flex: none;
  height: calc(var(--w) * 0.22);
  width: 100%;
  display: grid;
  place-items: center;
  font-size: max(12px, calc(var(--w) * 0.19));
  font-weight: 900;
  font-style: italic;
  color: #ffd45c;
  text-shadow:
    0 2px 0 #7a5410,
    0 0 8px #ffb43066;
  position: relative;
}
.arch {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--w) * 0.22);
  bottom: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  transition:
    transform 0.2s,
    filter 0.3s;
}
.arch i {
  display: block;
  width: 100%;
}
.a-top {
  flex: none;
  height: calc(var(--w) * 1.728);
  background: url(assets/art/arch-top.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
}
.a-mid {
  flex: 1;
  min-height: 0;
  background: url(assets/art/arch-mid.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% repeat-y;
}
.a-bot {
  flex: none;
  height: calc(var(--w) * 0.166);
  background: url(assets/art/arch-bot.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
}
.col > :not(.arch):not(.mult) {
  position: relative;
}
.emblem {
  flex: none;
  width: calc(var(--w) * 0.46);
  height: calc(var(--w) * 0.46);
  margin-top: calc(var(--w) * 0.21);
}
.emblem img,
.well .ghost {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.name {
  flex: none;
  width: calc(var(--w) * 0.56);
  height: calc(var(--w) * 0.175);
  margin-top: calc(var(--w) * 0.04);
  display: grid;
  place-items: center;
  background: url(assets/art/label.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
  font-size: max(8px, calc(var(--w) * 0.09));
  font-weight: 900;
  letter-spacing: 0.4px;
  color: #0b2a66;
  text-transform: uppercase;
  white-space: nowrap;
}
.fan {
  flex: none;
  position: relative;
  width: calc(var(--w) * 0.76);
  height: calc(var(--w) * 0.52);
  margin-top: calc(var(--w) * 0.05);
  perspective: 600px;
}
.card {
  position: absolute;
  top: calc(var(--w) * 0.03);
  width: calc(var(--w) * 0.3);
  height: calc(var(--w) * 0.454);
  left: calc(50% - var(--w) * 0.15);
  transform-origin: 50% 110%;
  transform: translateX(calc(var(--k, 0) * var(--w) * 0.18))
    rotate(calc(var(--k, 0) * 9deg));
}
.card[data-i="0"] {
  --k: -1;
}
.card[data-i="2"] {
  --k: 1;
}
.card-in {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.42s ease-in-out;
}
.card.flipped .card-in {
  transform: rotateY(180deg);
}
.card .back,
.card .front {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  filter: drop-shadow(0 2px 2px #0007);
}
.card .back {
  background-image: url(assets/art/card-back.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d);
}
.card .front {
  transform: rotateY(180deg);
  background-image: url(assets/art/card-face.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d);
  color: #12306a;
}
.card.red .front {
  color: #c2273a;
}
.front .rank {
  position: absolute;
  top: 11%;
  left: 15%;
  font-size: calc(var(--w) * 0.088);
  line-height: 1;
  font-weight: 900;
}
.front > svg {
  position: absolute;
  fill: currentColor;
  left: 14%;
  top: 28%;
  width: 24%;
  height: 16%;
}
.front > svg.pip {
  left: 28%;
  top: 44%;
  width: 46%;
  height: 34%;
}
.card.unknown .front {
  color: #7a5a1a;
  outline: 2px dashed #c26a1a;
  outline-offset: -4px;
}
.card.unknown .front .rank {
  font-size: calc(var(--w) * 0.18);
  left: 30%;
  top: 30%;
}
.hand {
  flex: none;
  min-height: calc(var(--w) * 0.13);
  max-width: 94%;
  margin-top: calc(var(--w) * 0.02);
  font-size: calc(var(--w) * 0.095);
  font-weight: 900;
  line-height: 1.2;
  color: var(--gold);
  text-shadow: 0 1px 2px #04204a;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lit-tag {
  position: absolute !important;
  left: 50%;
  bottom: calc(var(--w) * 0.42);
  transform: translateX(-50%);
  display: none;
  padding: 1px calc(var(--w) * 0.12);
  border-radius: 999px;
  background: linear-gradient(#fff2a8, #f0a82a);
  border: 1px solid #fff8cf;
  color: #4a2a00;
  font-size: calc(var(--w) * 0.1);
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 0 2px 8px #000a;
  z-index: 3;
}
.col.win .lit-tag {
  display: block;
  animation: pop 0.45s ease-out;
}
.well {
  flex: 1;
  min-height: 0;
  width: calc(var(--w) * 0.5);
  display: grid;
  place-items: center;
}
.well .ghost {
  grid-area: 1 / 1;
  width: 70%;
  height: auto;
  max-height: 100%;
  opacity: 0.14;
}
.stake {
  grid-area: 1 / 1;
  min-width: calc(var(--w) * 0.44);
  height: calc(var(--w) * 0.44);
  padding: 0 calc(var(--w) * 0.06);
  display: grid;
  place-items: center;
  background: url(assets/art/timer.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
  font-size: max(12px, calc(var(--w) * 0.13));
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px #04204a;
}
.stake:empty {
  display: none;
}
.plate {
  flex: none;
  width: calc(var(--w) * 0.8);
  height: calc(var(--w) * 0.34);
  margin-bottom: calc(var(--w) * 0.2);
  padding: calc(var(--w) * 0.085) calc(var(--w) * 0.09) calc(var(--w) * 0.05);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: url(assets/art/pot.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/100% 100% no-repeat;
  font-size: max(8px, calc(var(--w) * 0.078));
  line-height: 1.2;
  font-weight: 700;
  text-shadow: 0 1px 2px #04204a;
  direction: ltr;
}
.plate > span {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  white-space: nowrap;
}
.plate .k {
  color: #b9dcf7;
}
.plate b {
  color: #fff;
}
.plate .mine b {
  color: var(--gold);
}
.col.selected .arch {
  filter: drop-shadow(0 0 calc(var(--w) * 0.05) #ffd978cc);
}
.col.pending .arch {
  filter: drop-shadow(0 0 calc(var(--w) * 0.05) #fff4be);
}
.col.win .arch {
  filter: drop-shadow(0 0 calc(var(--w) * 0.09) #ffd45c)
    drop-shadow(0 0 calc(var(--w) * 0.04) #fff);
}
.col.win {
  z-index: 2;
}
.col.dim {
  filter: saturate(0.5) brightness(0.62);
}
.dealing .col .card {
  animation: deal 0.5s ease-out both;
}
.dealing .col:nth-child(2) .card {
  animation-delay: 0.1s;
}
.dealing .col:nth-child(3) .card {
  animation-delay: 0.2s;
}
.stage.snap .card-in,
.stage.snap .col,
.stage.snap .arch {
  transition: none !important;
}
.players-button {
  position: absolute;
  z-index: 4;
  inset-inline-end: 2px;
  bottom: calc(var(--w) * 0.02);
  width: calc(46px * var(--u));
  height: calc(46px * var(--u));
}
[dir="rtl"] .players-button {
  inset-inline-end: auto;
  right: 2px;
}
.online-count {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  min-width: 1.6em;
  padding: 0 4px;
  border: 1px solid #e3c06a;
  border-radius: 999px;
  background: #0b2f6af2;
  font-size: calc(10px * var(--u));
  line-height: 1.3;
  color: #eaf7ff;
  text-align: center;
}

/* ---- feedback ---- */
.feedback {
  position: absolute;
  z-index: 8;
  top: 2px;
  left: 6px;
  right: 6px;
  display: grid;
  gap: 4px;
  pointer-events: none;
}
.feedback > * {
  pointer-events: auto;
}
.notice,
.connection {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 2px 8px;
  border: 2px solid var(--gold);
  border-radius: 14px;
  background: #0a2a62f2;
  box-shadow: 0 4px 14px #000a;
  font-size: 12px;
}
.connection {
  justify-content: center;
  text-align: center;
}
.notice p {
  flex: 1;
  margin: 0;
  line-height: 1.3;
}
.notice button,
.result-card button,
.loading button,
.panel-retry {
  min-height: 44px;
  padding: 6px 14px;
  border: 2px solid #fff1c0;
  border-radius: 12px;
  background: linear-gradient(#ffe39a, #d79b2e);
  color: #3a2400;
  font-weight: 800;
}

/* ---- dock: balance, chips, Again ---- */
.dock {
  flex: none;
  display: flex;
  align-items: center;
  gap: calc(4px * var(--u));
  height: calc(var(--chip) + 10px * var(--u));
  direction: ltr;
}
.wallet,
.again {
  position: relative;
  height: var(--money-h);
  min-width: 0;
  padding: 0;
  border-style: solid;
  border-color: transparent;
  background: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wallet {
  --capL: calc(var(--money-h) * 112 / 126);
  --capR: calc(var(--money-h) * 34 / 126);
  flex: 1.7 1 0;
  border-width: 0 var(--capR) 0 var(--capL);
  border-image: url(assets/art/wallet.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) 0 34 0 112 fill / 0 var(--capR) 0 var(--capL) / 0 stretch;
}
.wallet::before {
  content: "";
  position: absolute;
  left: calc(var(--money-h) * 0.13 - var(--capL));
  top: 50%;
  width: calc(var(--money-h) * 0.62);
  height: calc(var(--money-h) * 0.62);
  transform: translateY(-50%);
  background: url(assets/art/coin.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/contain no-repeat;
}
.wallet b {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: max(12px, calc(14px * var(--u)));
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px #04204a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wallet.long b {
  font-size: max(12px, calc(12px * var(--u)));
}
.wallet .plus {
  display: none;
}
.again {
  --cap: calc(var(--money-h) * 60 / 171);
  flex: 1 1 0;
  border-width: 0 var(--cap);
  border-image: url(assets/art/again.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) 0 60 fill / 0 var(--cap) / 0 stretch;
  font-size: calc(16px * var(--u));
  font-weight: 900;
  font-style: italic;
  color: #12408a;
  text-shadow: 0 1px 0 #ffffffaa;
}
.again span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.again:active:not(:disabled) {
  transform: scale(0.97);
}
.again:disabled {
  filter: grayscale(0.7) brightness(0.85);
  opacity: 0.6;
}
.chips {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: calc(3px * var(--u));
  height: 100%;
  padding-bottom: calc(4px * var(--u));
  direction: ltr;
}
.chips button {
  position: relative;
  width: var(--chip);
  height: var(--chip);
  padding: 0;
  border: 0;
  background-color: transparent;
  background-position: center;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  font-size: calc(var(--chip) * 0.28);
  font-weight: 900;
  color: #fff;
  text-shadow:
    0 1px 2px #012,
    0 0 3px #012;
  transition: transform 0.14s;
}
.chips button[data-art="chip-green"] {
  background-image: url(assets/art/chip-green.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d);
}
.chips button[data-art="chip-blue"] {
  background-image: url(assets/art/chip-blue.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d);
}
.chips button[data-art="chip-purple"] {
  background-image: url(assets/art/chip-purple.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d);
}
.chips button[data-art="chip-orange"] {
  background-image: url(assets/art/chip-orange.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d);
}
.chips button[aria-pressed="true"] {
  transform: translateY(-6px) scale(1.12);
  filter: drop-shadow(0 0 7px var(--gold)) drop-shadow(0 0 2px #fff);
}

/* ---- result card ---- */
.result-card {
  position: absolute;
  z-index: 10;
  left: 8px;
  right: 8px;
  bottom: 6px;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "hands hands" "main values" "foot foot";
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px 8px;
  border: 2px solid var(--gold);
  border-radius: 18px;
  background: linear-gradient(#17509f, #0a2a62);
  box-shadow:
    0 6px 22px #000b,
    inset 0 0 14px #bfe6ff44;
  animation: rise 0.28s ease-out;
}
.result-hands {
  grid-area: hands;
  display: flex;
  justify-content: center;
  gap: 10px;
}
.hand-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 2px 6px;
  border-radius: 10px;
  opacity: 0.7;
}
.hand-chip.lit {
  opacity: 1;
  background: #ffd97833;
  box-shadow: 0 0 10px #ffd97899;
}
.hand-chip img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}
.hand-chip small {
  font-size: 11px;
  color: var(--gold);
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-main {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.result-main strong {
  font-size: 12px;
  color: #bfe6ff;
}
.result-main #result-reward {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 2px 0 #7a5410;
}
.result-main small {
  font-size: 11px;
  color: #fff3a0;
}
.result-pool {
  color: #8fe9ff !important;
}
.result-values {
  grid-area: values;
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 10px;
  font-size: 12px;
  color: #bfe6ff;
}
.result-values b {
  text-align: end;
  color: #fff;
}
.result-card footer {
  grid-area: foot;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.result-card footer p {
  margin: 0;
  font-size: 11px;
  color: #a9d4f5;
}
.result-card .result-close {
  position: absolute;
  top: 2px;
  inset-inline-end: 4px;
  min-height: 36px;
  width: 36px;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font-size: 24px;
}

/* ---- loading ---- */
.loading {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px;
  text-align: center;
  background:
    linear-gradient(#071a4290, #071a42d8), url(assets/art/bg.webp?v=2ab444fbdec84a690c3daeb20e73c36114c6eded8af2c0b8081769dde5729c9d) center/cover;
}
.loading-logo {
  width: 120px;
  height: 120px;
  object-fit: contain;
}
.loading-title {
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  color: #eaf7ff;
  text-shadow:
    0 2px 0 #1b4f9a,
    0 0 10px #3a8ee6;
}
.loading-emblems {
  display: flex;
  gap: 8px;
  direction: ltr;
}
.loading-emblems img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.loading p {
  margin: 0;
  font-size: 15px;
}
.loading progress {
  width: 70%;
  height: 12px;
  accent-color: var(--gold);
}
.loading small {
  margin-top: 10px;
  color: #a9d4f5;
  font-size: 12px;
}
.loading.failed .loading-emblems,
.loading.failed progress {
  display: none;
}
.is-half .loading-logo,
.tier-tiny .loading-logo,
.tier-short .loading-logo {
  width: 70px;
  height: 70px;
}

/* ---- panels ---- */
#panel-mask {
  position: absolute;
  inset: 0;
  z-index: 40;
}
dialog {
  position: absolute;
  inset: 10px;
  margin: auto;
  width: calc(100% - 20px);
  max-width: 450px;
  max-height: calc(100% - 20px);
  height: fit-content;
  padding: 0;
  display: flex;
  flex-direction: column;
  border: 2px solid var(--gold);
  border-radius: 16px;
  background: linear-gradient(#14478f, #0a2a62);
  color: var(--ink);
  box-shadow: 0 6px 24px #000c;
  overflow: hidden;
  z-index: 41;
}
dialog:not([open]) {
  display: none;
}
dialog::backdrop {
  background: transparent;
}
dialog header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 16px;
  border-bottom: 1px solid #b98a2c88;
  background: #0a2a62;
}
dialog h2 {
  margin: 0;
  font-size: 18px;
}
dialog header button {
  border: 0;
  background: none;
  font-size: 28px;
  min-width: 44px;
  min-height: 44px;
}
#panel-body {
  padding: 14px;
  overflow: auto;
  min-height: 0;
  overscroll-behavior: contain;
}
#panel-body p {
  font-size: 14px;
  line-height: 1.6;
  margin: 6px 0;
}
#panel-body label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  margin: 14px 0;
}
#panel-body input[type="range"] {
  width: 55%;
  accent-color: var(--gold);
}
#panel-body input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--gold);
}
#panel-body select {
  max-width: 58%;
  min-height: 44px;
  background: #0b2f6a;
  color: var(--ink);
  border: 1px solid var(--gold-deep);
  border-radius: 8px;
}
#panel-body ol {
  padding-inline-start: 22px;
  font-size: 14px;
  line-height: 1.65;
}
#panel-body .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #3a6fb8;
  padding: 8px 0;
  font-size: 14px;
}
#panel-body .row > span:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
#panel-body .record {
  padding: 8px 0;
  border-bottom: 1px solid #3a6fb8;
}
#panel-body img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.record-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 12px;
  color: var(--gold);
  direction: ltr;
}
.record-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  font-size: 12px;
  color: #bfe6ff;
}
.record-values div {
  display: flex;
  flex-direction: column;
}
.record-values b {
  font-size: 14px;
  color: #fff;
}
.list-caption {
  color: #a9d4f5;
  font-size: 12px !important;
}
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.tabs button {
  flex: 1;
  min-height: 40px;
  border: 1px solid var(--gold-deep);
  border-radius: 10px;
  background: #0b2f6a;
  font-size: 13px;
  font-weight: 700;
}
.tabs button[aria-pressed="true"] {
  background: linear-gradient(#ffe39a, #d79b2e);
  border-color: #fff1c0;
  color: #3a2400;
}
.today-line {
  margin: 0 0 6px;
  font-size: 13px !important;
  color: #bfe6ff;
}

/* ---- compact tiers: by the height the game really has ---- */
.tier-short {
  --hud-h: max(34px, calc(40px * var(--u)));
  --pool-h: calc(68px * var(--u));
  --meta-h: calc(48px * var(--u));
  --timer: calc(36px * var(--u));
  --chip: max(30px, calc(32px * var(--u)));
  --money-h: calc(42px * var(--u));
}
.tier-tiny {
  --hud-h: max(34px, calc(36px * var(--u)));
  --pool-h: calc(58px * var(--u));
  --meta-h: calc(42px * var(--u));
  --timer: calc(32px * var(--u));
  --chip: max(28px, calc(30px * var(--u)));
  --money-h: calc(38px * var(--u));
}
.tier-short .demo,
.tier-tiny .demo {
  display: none;
}
.tier-short #game,
.tier-tiny #game {
  gap: 2px;
}
.tier-short .banner #pool {
  font-size: calc(21px * var(--u));
}
.tier-tiny .banner #pool {
  font-size: calc(18px * var(--u));
}
.tier-tiny .pool-label,
.tier-tiny .brand small {
  display: none;
}
.tier-tiny .brand b {
  font-size: 17px;
}
.tier-tiny .result-card footer p,
.tier-tiny .result-main small {
  display: none;
}
.tier-tiny .result-main #result-reward {
  font-size: 22px;
}
.tier-tiny .hand-chip img {
  width: 26px;
  height: 26px;
}
@media (max-width: 350px) {
  #game {
    padding-left: 5px;
    padding-right: 5px;
  }
  .hud {
    gap: 3px;
  }
  .brand b {
    font-size: 16px;
  }
  .brand small {
    font-size: 10px;
  }
}

/* ---- RTL: the interface mirrors, the stage and numbers do not ---- */
[dir="rtl"] .hud {
  direction: rtl;
}
[dir="rtl"] .brand {
  direction: ltr;
}
[dir="rtl"] #exit span {
  display: inline-block;
  transform: scaleX(-1);
}
[dir="rtl"] .notice,
[dir="rtl"] .connection,
[dir="rtl"] .result-card,
[dir="rtl"] dialog {
  direction: rtl;
}
[dir="rtl"] .name,
[dir="rtl"] .hand,
[dir="rtl"] .lit-tag {
  direction: rtl;
}

/* ---- motion ---- */
@keyframes pop {
  0% {
    transform: translateX(-50%) scale(0.9);
  }
  55% {
    transform: translateX(-50%) scale(1.14);
  }
  100% {
    transform: translateX(-50%) scale(1);
  }
}
@keyframes pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.14);
  }
}
@keyframes rise {
  from {
    transform: translateY(14px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@keyframes deal {
  from {
    transform: translate(0, calc(var(--w) * -0.9)) scale(0.5);
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes cue {
  from {
    transform: translateX(-50%) scale(1);
  }
  to {
    transform: translateX(-50%) scale(1.08);
  }
}
@keyframes burst {
  0% {
    opacity: 0;
    transform: scale(0.3) rotate(0deg);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.1) rotate(40deg);
  }
}
.low-motion *,
.low-motion *::before,
.low-motion *::after {
  animation: none !important;
  transition: none !important;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* The server-stage wait hint never intercepts gameplay or panel actions. */
#next-open {
  pointer-events: none;
}

/* Reserve disjoint touch targets even when the artwork scales down. */
.hud {
  min-height: 44px;
}
.hud button {
  min-width: 44px;
  min-height: 44px;
}

.hud .brand {
  min-width: 0;
  overflow: hidden;
}

/* Keep labels and values on separate lines inside each betting column. */
.plate {
  width: 100%;
  height: auto;
  min-height: 64px;
  padding: 3px 2px;
  margin-bottom: 2px;
  font-size: 12px;
  line-height: 1.15;
}
.plate > span {
  flex-direction: column;
  gap: 0;
  white-space: normal;
  text-align: center;
}
.plate b,
.stake {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.plate > span,
.plate b {
  width: 100%;
  min-width: 0;
}
.tier-tiny .emblem {
  width: calc(var(--w) * 0.35);
  height: calc(var(--w) * 0.35);
  margin-top: calc(var(--w) * 0.1);
}

.banner #pool {
  max-width: 100%;
  font-size: max(12px, calc(18px * var(--u)));
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: center;
}

/* The plate already shows the personal stake; compact layouts omit its duplicate badge. */
.tier-short .well,
.tier-tiny .well {
  display: none;
}

/* Long wallet values retain their complete formatter output. */
.wallet b {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.05;
}
