﻿:root {
  --cream: #fff2bf;
  --gold: #ffc75f;
  --gold-deep: #b87323;
  --green: #145237;
  --deep: #062719;
  --felt: #0e5c34;
  --peach: #ffb4a8;
  --mint: #bce86b;
  --wood: #6f3d1c;
  --shadow: rgba(20, 8, 1, .42);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #071c14; }
[hidden] { display: none !important; }
body {
  display: grid;
  place-items: center;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}
button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.game-shell {
  position: relative;
  width: min(100vw, 430px);
  height: 100svh;
  min-height: 620px;
  max-height: 932px;
  overflow: hidden;
  color: var(--cream);
  background:
    radial-gradient(circle at 50% 10%, rgba(133,234,223,.35), transparent 30%),
    linear-gradient(#103522, #05170f);
  isolation: isolate;
}
.game-shell:not(.is-started) .topbar,
.game-shell:not(.is-started) .side-controls,
.game-shell:not(.is-started) .dealer-area,
.game-shell:not(.is-started) .loan-strip,
.game-shell:not(.is-started) .table-area,
.game-shell:not(.is-started) .chips,
.game-shell:not(.is-started) .ambient-glow,
.game-shell:not(.is-started) .toast {
  opacity: 0;
  pointer-events: none;
}
.game-shell.is-started .topbar,
.game-shell.is-started .side-controls,
.game-shell.is-started .dealer-area,
.game-shell.is-started .table-area,
.game-shell.is-started .chips,
.game-shell.is-started .ambient-glow {
  animation-delay: .18s;
}
.bg, .particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bg { animation: bgIn 1s ease both; }
.particles {
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: .8;
  animation: drift 7s ease-in-out infinite alternate;
}

.topbar {
  position: absolute;
  z-index: 6;
  top: max(12px, env(safe-area-inset-top));
  left: 11px;
  right: 11px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.start-screen {
  position: absolute;
  z-index: 80;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255,226,142,.28), transparent 24%),
    linear-gradient(rgba(5,25,16,.18), rgba(3,17,11,.68));
  transition: opacity .45s ease, transform .45s cubic-bezier(.2,1,.25,1);
}
.start-screen.leaving {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}
.start-card {
  width: min(100%, 370px);
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 26px 22px;
  border: 3px solid rgba(255,207,103,.82);
  border-radius: 32px;
  background:
    radial-gradient(circle at 50% 0%, rgba(255,242,184,.35), transparent 34%),
    linear-gradient(180deg, rgba(34,77,45,.95), rgba(11,48,31,.97));
  box-shadow: 0 22px 38px rgba(0,0,0,.42), inset 0 2px 0 rgba(255,255,255,.22);
  text-align: center;
}
.start-panda {
  width: min(72vw, 246px);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 16px 16px rgba(0,0,0,.36));
  transform-origin: 50% 88%;
  animation: startPandaFloat 2.4s ease-in-out infinite alternate;
}
.start-badge {
  padding: 5px 13px;
  border: 1px solid rgba(255,223,142,.85);
  border-radius: 999px;
  background: rgba(255,241,196,.16);
  color: #ffe9a6;
  font-size: 13px;
  font-weight: 1000;
}
.start-card h1 {
  margin: 0;
  color: #ffd979;
  font-size: clamp(34px, 9vw, 44px);
}
.start-card p {
  max-width: 270px;
  margin: 0 0 4px;
  color: #fff3c6;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.55;
}
.start-btn {
  width: min(100%, 250px);
  min-height: 58px;
  border: 3px solid #fff2b5;
  border-radius: 31px;
  background: linear-gradient(#ffe37f, #f4a734 58%, #bd681d);
  color: #fff7d6;
  font-size: 22px;
  font-weight: 1000;
  text-shadow: 0 2px 0 rgba(88,43,10,.35);
  box-shadow: 0 8px 0 rgba(75,43,20,.62), 0 13px 18px rgba(0,0,0,.26), inset 0 3px 0 rgba(255,255,255,.38);
}
.start-btn:disabled {
  filter: brightness(.9);
}
.loading-row {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #ffe9a6;
  font-size: 13px;
  font-weight: 1000;
}
.loading-row span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffd979;
  animation: loadingDot .7s ease-in-out infinite alternate;
}
.loading-row span:nth-child(2) { animation-delay: .12s; }
.loading-row span:nth-child(3) { animation-delay: .24s; }
.player-panel, .coin-panel {
  min-height: 59px;
  display: flex;
  align-items: center;
  border: 2px solid rgba(255,207,103,.9);
  background:
    linear-gradient(90deg, rgba(255,218,113,.12), transparent 22%),
    linear-gradient(180deg, rgba(58,54,26,.92), rgba(30,50,27,.96));
  box-shadow: 0 8px 18px var(--shadow), inset 0 1px 0 rgba(255,255,255,.28), inset 0 -4px 0 rgba(0,0,0,.16);
}
.player-panel {
  gap: 8px;
  width: 46%;
  padding: 5px 10px 5px 5px;
  border-radius: 34px 20px 20px 34px;
}
.avatar {
  width: 47px;
  height: 47px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff6db url("./panda.webp") center 37% / 128% auto no-repeat;
  border: 2px solid #c78b34;
  font-size: 0;
  box-shadow: inset 0 2px 5px rgba(255,255,255,.55), 0 3px 7px rgba(0,0,0,.28);
}
.player-panel strong, .coin-panel strong { display: block; font-size: clamp(15px, 4vw, 18px); }
.player-panel small { display: block; color: #ffdca2; font-weight: 800; font-size: 12px; }
.coin-panel {
  width: 45%;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 7px 6px 9px;
  border-radius: 22px 34px 34px 22px;
}
.coin-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 26%, #fff4a8, #ffbd39 55%, #a76215);
  color: #68400e;
  font-size: 12px;
  font-weight: 1000;
}
.plus-btn {
  width: 38px;
  height: 38px;
  border: 2px solid #e5f7a8;
  border-radius: 50%;
  background: linear-gradient(#d9fb80, #53b83c 58%, #247729);
  color: #11391d;
  font-size: 24px;
  font-weight: 1000;
  box-shadow: 0 5px 0 rgba(5,65,24,.55);
}

.side-controls {
  position: absolute;
  z-index: 7;
  top: 100px;
  right: 13px;
  display: grid;
  gap: 10px;
}
.side-controls button {
  width: 52px;
  height: 52px;
  padding: 5px;
  border: 2px solid rgba(255,209,113,.9);
  border-radius: 50%;
  background: radial-gradient(circle at 32% 22%, #8b5b2b, #3f2515 68%);
  box-shadow: 0 8px 14px rgba(0,0,0,.32), inset 0 2px 0 rgba(255,255,255,.2);
}
.side-controls img { width: 100%; filter: drop-shadow(0 2px 1px rgba(0,0,0,.25)); }
.rules-fab {
  color: #ffe9ae;
  font-size: 28px;
  font-weight: 1000;
  line-height: 1;
}
.side-controls button.muted { filter: grayscale(1) brightness(.65); opacity: .78; }

.all-in-btn {
  position: absolute;
  z-index: 7;
  top: 168px;
  left: 22px;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0;
  border: 3px solid rgba(255,211,111,.9);
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 24%, rgba(255,239,169,.24), transparent 32%),
    linear-gradient(#7b5026, #3e2415 70%);
  color: #fff1ba;
  box-shadow: 0 10px 17px rgba(0,0,0,.34), inset 0 2px 0 rgba(255,255,255,.22);
  text-shadow: 0 2px 0 rgba(62,28,9,.5);
  transform: rotate(-8deg);
  transition: transform .12s ease, filter .15s ease;
}
.all-in-btn span,
.all-in-btn strong {
  display: block;
  line-height: .95;
  font-weight: 1000;
}
.all-in-btn span { font-size: 20px; }
.all-in-btn strong { font-size: 25px; }
.all-in-btn:active { transform: rotate(-8deg) translateY(3px) scale(.97); }
.all-in-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(.7) brightness(.65);
}

.dealer-area {
  position: absolute;
  z-index: 3;
  top: 80px;
  left: 0;
  width: 100%;
  height: 330px;
}
.panda {
  position: absolute;
  z-index: 3;
  left: 50%;
  top: 10px;
  width: min(84%, 360px);
  transform: translateX(-50%);
  filter: drop-shadow(0 18px 18px rgba(11,5,1,.45)) drop-shadow(0 0 18px rgba(255,224,142,.2));
  animation: pandaEnter .9s cubic-bezier(.2,1.25,.3,1) both, pandaIdle 2.8s ease-in-out 1.1s infinite alternate;
}
.panda.win { animation: pandaClap .55s ease 2; }
.panda.bust { animation: pandaJump .5s ease 2; }
.bubble-text {
  position: relative;
  z-index: 3;
  width: fit-content;
  max-width: 74%;
  margin: 7px auto 0;
  padding: 5px 13px;
  border: 2px solid rgba(255,220,142,.72);
  border-radius: 999px;
  background: rgba(255,241,196,.94);
  color: #533217;
  font-size: clamp(12px, 3.4vw, 15px);
  line-height: 1.15;
  font-weight: 1000;
  text-align: center;
  box-shadow: 0 5px 10px rgba(43,21,5,.22);
}
.deck {
  position: absolute;
  z-index: 4;
  left: 96px;
  top: 236px;
  width: 61px;
  transform: rotate(-3deg);
  filter: drop-shadow(0 8px 8px rgba(0,0,0,.25));
}
.dealer-score-card {
  position: absolute;
  z-index: 5;
  right: 14px;
  top: 204px;
  width: 130px;
  min-height: 84px;
  display: grid;
  place-items: center;
  padding: 10px;
  border: 3px solid #b96f2b;
  border-radius: 12px;
  background:
    linear-gradient(90deg, rgba(255,218,119,.12), transparent),
    linear-gradient(#6b3e1d, #3c2415);
  color: #ffe39d;
  box-shadow: 0 9px 15px var(--shadow), inset 0 2px 0 rgba(255,255,255,.16);
  text-align: center;
  font-weight: 1000;
}
.dealer-score-card strong { font-size: 30px; line-height: .9; }
.lantern {
  position: absolute;
  right: 3px;
  top: 244px;
  width: 72px;
  animation: lantern 2.4s ease-in-out infinite alternate;
}

.loan-strip {
  position: absolute;
  z-index: 6;
  top: 365px;
  left: 18px;
  right: 18px;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  border: 1px solid rgba(244,201,113,.85);
  border-radius: 18px;
  background: rgba(20,54,37,.82);
  box-shadow: 0 7px 14px rgba(0,0,0,.2);
  font-size: 13px;
  font-weight: 900;
}
.loan-strip button {
  min-width: 74px;
  min-height: 28px;
  border: 0;
  border-radius: 15px;
  background: #ffe19a;
  color: #593416;
  font-weight: 1000;
}

.table-area {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 104px;
  height: 438px;
  animation: tableEnter .9s cubic-bezier(.2,1,.25,1) both;
}
.table {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  filter: saturate(1.1) contrast(1.04) drop-shadow(0 -5px 12px rgba(255,206,92,.16));
}
h1 {
  position: relative;
  margin: 38px 0 0;
  text-align: center;
  font-size: clamp(31px, 8.8vw, 43px);
  line-height: 1;
  letter-spacing: 0;
  color: #ffd979;
  text-shadow: 0 3px 0 #705118, 0 7px 14px var(--shadow), 0 0 16px rgba(255,219,118,.24);
}
.bet-line {
  position: relative;
  width: fit-content;
  margin: 7px auto 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(8,35,22,.56);
  color: #fff5c9;
  font-size: 13px;
  font-weight: 1000;
}

.dealer-hand-wrap {
  position: relative;
  z-index: 2;
  width: min(52vw, 220px);
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 7px auto 0;
  padding: 4px 10px;
  border-radius: 17px;
  background: rgba(8,35,22,.34);
  color: #ffe8a3;
  font-size: 12px;
  font-weight: 1000;
}

.dealer-cards {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 38px;
}

.mini-card {
  width: 30px;
  height: 40px;
  display: grid;
  place-items: center;
  margin-left: -5px;
  border: 1px solid #f2d07d;
  border-radius: 6px;
  background: linear-gradient(145deg, #fff8e8, #f3d89d);
  color: #213024;
  font-size: 15px;
  font-weight: 1000;
  box-shadow: 0 4px 6px rgba(0,0,0,.24);
}
.mini-card:first-child { margin-left: 0; }
.mini-card.red { color: #b73b43; }
.mini-card.back {
  background: linear-gradient(145deg, #6d4c9d, #2f265d);
  color: #ffe29a;
}

.cards {
  position: relative;
  z-index: 2;
  width: min(63vw, 266px);
  height: 124px;
  margin: 6px auto 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.playing-card {
  width: clamp(66px, 18vw, 82px);
  height: clamp(96px, 27vw, 118px);
  margin-left: -13px;
  display: grid;
  place-items: center;
  border: 2px solid #f6d58a;
  border-radius: 13px;
  background:
    radial-gradient(circle at 22% 18%, rgba(255,255,255,.85), transparent 22%),
    linear-gradient(145deg, #fff8e8, #f5dca5);
  color: #253224;
  box-shadow: 0 12px 14px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.55);
  transform: rotate(var(--tilt));
  animation: dealCard .42s cubic-bezier(.18,1.2,.3,1) both;
}
.playing-card.red { color: #b73b43; }
.playing-card:first-child { margin-left: 0; }
.card-inner { display: grid; gap: 4px; text-align: center; font-weight: 1000; }
.card-rank { font-size: 30px; line-height: 1; }
.card-suit { font-size: 28px; line-height: 1; }
.score-pill {
  position: relative;
  z-index: 2;
  width: 92px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: -11px auto 0;
  border: 2px solid rgba(255,234,164,.9);
  border-radius: 18px;
  background: linear-gradient(#ffe398, #b9772e);
  color: #4f2f15;
  font-weight: 1000;
  box-shadow: 0 6px 10px rgba(0,0,0,.25);
}
.score-pill strong { font-size: 22px; }
.double-lock {
  position: absolute;
  z-index: 2;
  right: 21px;
  top: 162px;
  width: 110px;
  min-height: 91px;
  display: grid;
  place-items: center;
  padding: 9px 8px;
  border: 3px dashed rgba(255,226,141,.58);
  border-radius: 22px;
  background: rgba(11,62,38,.5);
  color: rgba(255,244,201,.82);
  font-weight: 1000;
  text-align: center;
  box-shadow: inset 0 0 18px rgba(0,0,0,.28);
}
.double-lock small { font-size: 12px; line-height: 1.15; }
.double-lock.unlocked {
  border-style: solid;
  background: linear-gradient(#ffde8b, #e7974b);
  color: #4c2a13;
  box-shadow: 0 0 16px rgba(255,223,126,.8), 0 8px 14px rgba(0,0,0,.25);
}
.double-lock.unlocked .lock-icon { content: "🔓"; }

.actions {
  position: absolute;
  z-index: 3;
  left: 24px;
  right: 24px;
  bottom: 36px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.action {
  position: relative;
  min-height: 64px;
  border: 3px solid rgba(255,238,179,.95);
  border-radius: 34px;
  overflow: hidden;
  color: #fff7cf;
  font-size: 25px;
  font-weight: 1000;
  text-shadow: 0 2px 0 rgba(70,28,9,.38);
  box-shadow: 0 9px 0 rgba(75,43,20,.62), 0 13px 18px rgba(0,0,0,.28), inset 0 3px 0 rgba(255,255,255,.38);
  transition: transform .12s ease, filter .15s ease;
}
.action span { margin-right: 5px; }
.hit { background: linear-gradient(#ffe37f, #f4a734 58%, #bd681d); }
.stand { background: linear-gradient(#d8ef75, #77b82f 58%, #3d7f25); }
.action:after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-120%) skewX(-20deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
}
.action.flash:after { animation: sheen .45s ease; }
.action:active, .plus-btn:active, .claim-btn:active, .chip:active { transform: translateY(3px) scale(.98); }
.action:disabled, .chip:disabled, .double-lock:disabled {
  cursor: not-allowed;
  filter: grayscale(.6) brightness(.72);
}

.chips {
  position: absolute;
  z-index: 8;
  left: 18px;
  right: 18px;
  bottom: max(14px, env(safe-area-inset-bottom));
  height: 96px;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  align-items: center;
  padding: 8px 7px 11px;
  border: 2px solid rgba(255,203,99,.48);
  border-radius: 19px;
  background: linear-gradient(#8f572c, #4b2b14);
  box-shadow: 0 10px 18px rgba(0,0,0,.32), inset 0 2px 0 rgba(255,255,255,.18);
}
.chip {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  animation: chipEnter .65s cubic-bezier(.18,1.35,.34,1) both;
}
.chip:nth-child(2) { animation-delay: .08s; }
.chip:nth-child(3) { animation-delay: .16s; }
.chip:nth-child(4) { animation-delay: .24s; }
.chip:nth-child(5) { animation-delay: .32s; }
.chip img { width: 100%; display: block; filter: drop-shadow(0 8px 8px rgba(0,0,0,.28)); }
.chip.selected img { filter: drop-shadow(0 0 9px rgba(255,224,113,.95)) drop-shadow(0 8px 8px rgba(0,0,0,.28)); }
.flying-chip {
  position: absolute;
  z-index: 20;
  width: 58px;
  pointer-events: none;
  animation: flyChip .55s cubic-bezier(.2,.85,.15,1) forwards;
}

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: 214px;
  max-width: 86%;
  transform: translate(-50%, 18px);
  opacity: 0;
  padding: 9px 15px;
  border: 1px solid rgba(244,201,113,.75);
  border-radius: 999px;
  background: rgba(10,37,24,.88);
  color: #fff5c9;
  font-size: 14px;
  font-weight: 1000;
  text-align: center;
  box-shadow: 0 8px 18px rgba(0,0,0,.25);
  transition: opacity .22s ease, transform .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.ambient-glow {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff1a8;
  box-shadow: 0 0 14px 5px rgba(255,231,141,.55);
  pointer-events: none;
  animation: sparkle 2.2s ease-in-out infinite alternate;
}
.glow-a { left: 34px; bottom: 180px; }
.glow-b { right: 38px; top: 78px; animation-delay: .8s; }

.modal {
  position: absolute;
  z-index: 40;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 20px 18px max(24px, env(safe-area-inset-bottom));
  background: rgba(4,18,12,.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.modal.show { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%;
  max-width: 390px;
  position: relative;
  padding: 28px 20px 20px;
  border: 2px solid #f3c873;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% -10%, rgba(255,229,159,.7), transparent 34%),
    linear-gradient(#fff3cb, #ffc889);
  color: #543115;
  text-align: center;
  box-shadow: 0 20px 34px rgba(0,0,0,.4);
  transform: translateY(24px) scale(.96);
  transition: transform .26s cubic-bezier(.2,1.2,.3,1);
}
.modal.show .modal-card { transform: translateY(0) scale(1); }
.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #6c4020;
  color: #fff3c7;
  font-size: 24px;
  font-weight: 900;
}
.modal-panda { font-size: 42px; }
.modal-card h2 { margin: 4px 0 8px; font-size: 27px; }
.modal-card p { margin: 0 0 16px; font-weight: 800; line-height: 1.55; }
.loan-slider {
  display: grid;
  gap: 10px;
  margin: 4px 0 16px;
  padding: 12px;
  border: 2px solid rgba(166,98,31,.28);
  border-radius: 18px;
  background: rgba(255,244,199,.46);
  font-weight: 1000;
}
.loan-slider span {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.loan-slider strong { color: #1d6d33; font-size: 20px; }
.loan-slider input {
  width: 100%;
  accent-color: #56b83f;
}
.claim-btn {
  width: 100%;
  min-height: 56px;
  border: 2px solid #fff2b5;
  border-radius: 28px;
  background: linear-gradient(#9aee84, #24994e);
  color: #11391d;
  font-size: 19px;
  font-weight: 1000;
  box-shadow: 0 8px 0 rgba(28,91,37,.55);
}
.claim-btn:disabled {
  filter: grayscale(.65);
  opacity: .72;
}
.modal-card small { display: block; margin-top: 13px; font-weight: 800; color: #70451f; }
.rules-card {
  max-height: min(82svh, 720px);
  display: flex;
  flex-direction: column;
}
.rules-copy {
  overflow: auto;
  padding: 2px 4px 4px;
  text-align: left;
}
.rules-copy p {
  margin: 0 0 10px;
  font-size: 14px;
}
.reset-btn {
  width: 100%;
  min-height: 52px;
  margin-top: 8px;
  border: 2px solid #fff2b5;
  border-radius: 27px;
  background: linear-gradient(#ffbd75, #d65b3f);
  color: #fff7d6;
  font-size: 18px;
  font-weight: 1000;
  box-shadow: 0 7px 0 rgba(103,44,26,.48), inset 0 2px 0 rgba(255,255,255,.35);
}

.shake { animation: shake .34s ease; }
.coin-up { animation: coinUp .45s ease; }
.coin-down { animation: coinDown .45s ease; }
.table-area.quake { animation: tableQuake .4s ease; }

@media (max-height: 790px) {
  .dealer-area { top: 68px; transform: scale(.9); transform-origin: top center; }
  .loan-strip { top: 326px; }
  .table-area { bottom: 91px; transform: scale(.94); transform-origin: bottom center; }
  .chips { height: 82px; }
  .toast { bottom: 190px; }
}
@media (max-height: 730px) {
  .dealer-area { top: 58px; transform: scale(.82); }
  .side-controls { top: 82px; }
  .loan-strip { top: 288px; }
  .table-area { bottom: 78px; transform: scale(.9); }
  .chips { height: 74px; padding-bottom: 8px; }
  h1 { margin-top: 30px; }
}

@media (max-width: 430px) and (max-height: 760px) {
  .topbar {
    top: max(9px, env(safe-area-inset-top));
    left: 9px;
    right: 9px;
  }
  .player-panel, .coin-panel { min-height: 48px; }
  .player-panel { width: 43%; }
  .coin-panel { width: 47%; }
  .avatar { width: 38px; height: 38px; }
  .coin-icon, .plus-btn { width: 32px; height: 32px; }
  .side-controls {
    top: 78px;
    right: 10px;
    gap: 7px;
  }
  .side-controls button {
    width: 43px;
    height: 43px;
  }
  .all-in-btn {
    top: 142px;
    left: 18px;
    width: 62px;
    height: 62px;
  }
  .all-in-btn span { font-size: 16px; }
  .all-in-btn strong { font-size: 21px; }
  .dealer-area {
    top: 58px;
    height: 258px;
    transform: none;
  }
  .panda {
    top: 16px;
    width: min(76%, 306px);
  }
  .bubble-text {
    max-width: 68%;
    margin-top: 5px;
    padding: 4px 10px;
    font-size: 12px;
  }
  .deck {
    left: 70px;
    top: 205px;
    width: 50px;
  }
  .dealer-score-card {
    right: 14px;
    top: 204px;
    width: 112px;
    min-height: 70px;
    font-size: 12px;
  }
  .dealer-score-card strong { font-size: 24px; }
  .lantern { display: none; }
  .loan-strip { top: 292px; }
  .table-area {
    bottom: 83px;
    height: 386px;
    transform: none;
  }
  h1 {
    margin-top: 28px;
    font-size: clamp(29px, 8.2vw, 36px);
  }
  .bet-line { margin-top: 8px; }
  .cards {
    height: 105px;
    margin-top: 5px;
  }
  .playing-card {
    width: clamp(61px, 17vw, 72px);
    height: clamp(88px, 24vw, 104px);
  }
  .score-pill {
    width: 86px;
    height: 31px;
  }
  .double-lock {
    right: 18px;
    top: 140px;
    width: 100px;
    min-height: 78px;
    font-size: 13px;
  }
  .actions {
    left: 22px;
    right: 22px;
    bottom: 25px;
  }
  .action {
    min-height: 56px;
    font-size: 22px;
  }
  .chips {
    left: 14px;
    right: 14px;
    bottom: max(8px, env(safe-area-inset-bottom));
    height: 76px;
    padding: 6px;
  }
}

@keyframes bgIn { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: scale(1); } }
@keyframes drift { from { transform: translateY(-5px); } to { transform: translateY(10px); } }
@keyframes pandaEnter { from { opacity: 0; transform: translate(-50%, -32px) scale(.95); } to { opacity: 1; transform: translateX(-50%) scale(1); } }
@keyframes pandaIdle { to { transform: translate(-50%, 5px) rotate(.6deg); } }
@keyframes startPandaFloat {
  from { transform: translateY(0) scale(1); }
  to { transform: translateY(6px) scale(1.015) rotate(.4deg); }
}
@keyframes pandaClap { 50% { transform: translateX(-50%) scale(1.05) rotate(-2deg); } }
@keyframes pandaJump { 50% { transform: translate(-50%, -10px) scale(1.04); } }
@keyframes lantern { to { transform: rotate(3deg); filter: drop-shadow(0 0 10px rgba(255,197,87,.65)); } }
@keyframes tableEnter { from { opacity: 0; transform: translateY(42px); } to { opacity: 1; transform: translateY(0); } }
@keyframes dealCard { from { opacity: 0; transform: translate(88px, -80px) rotate(28deg) scale(.75); } to { opacity: 1; transform: rotate(var(--tilt)) scale(1); } }
@keyframes chipEnter { from { opacity: 0; transform: translateY(22px) scale(.72); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes flyChip { to { transform: translate(var(--fly-x), var(--fly-y)) scale(.45) rotate(240deg); opacity: 0; } }
@keyframes sheen { to { transform: translateX(120%) skewX(-20deg); } }
@keyframes shake {
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}
@keyframes coinUp { 40% { color: #ffe782; text-shadow: 0 0 10px #ffe782; } }
@keyframes coinDown { 40% { color: #ff9c91; text-shadow: 0 0 10px #ff8174; } }
@keyframes tableQuake {
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}
@keyframes sparkle {
  from { opacity: .35; transform: translateY(0) scale(.8); }
  to { opacity: 1; transform: translateY(-8px) scale(1.2); }
}
@keyframes loadingDot {
  to { transform: translateY(-5px); opacity: .55; }
}

