/* Phone Blackjack — table, cards, dock. Portrait 390x844 and landscape 844x390. */

:root {
  --gold: #ffd36a;
  --green: #7ee08a;
  --red: #ff8080;
  --ink: #f6f1e6;
  --card-w: 62px;
  --card-h: 88px;
}

html, body {
  touch-action: none;
  overscroll-behavior: none;
  background: #140626;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(ellipse 120% 80% at 50% 26%, #7a35b4 0%, #3d1166 46%, #1b0730 78%, #12041f 100%);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Display", system-ui, -apple-system, sans-serif;
  padding:
    env(safe-area-inset-top, 0px)
    env(safe-area-inset-right, 0px)
    env(safe-area-inset-bottom, 0px)
    env(safe-area-inset-left, 0px);
  -webkit-user-select: none;
  user-select: none;
}

/* ---------------------------------------------------------------- HUD */
.hud {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  /* the arcade pill owns the top-left 120x52 */
  padding: 56px 12px 4px;
}
.bank-label { font-size: 10px; letter-spacing: 0.16em; opacity: 0.6; }
.bank { font-size: 27px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.best { font-size: 11px; opacity: 0.55; font-variant-numeric: tabular-nums; margin-top: 2px; }
.hud-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.wl { font-size: 12px; font-variant-numeric: tabular-nums; opacity: 0.85; }
.streak { font-size: 11px; opacity: 0.6; }
.hud-btns { display: flex; gap: 6px; margin-top: 2px; }
.icon {
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  font-size: 16px;
  line-height: 1;
}
.icon.off { opacity: 0.45; }
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 13px;
}

/* ---------------------------------------------------------------- felt */
.felt {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 12px 6px;
  overflow: hidden;
}
.seat { flex: 0 0 auto; }
.seat-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.seat-name { font-size: 10px; letter-spacing: 0.16em; opacity: 0.55; }
.total {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.28);
  border-radius: 8px;
  padding: 1px 7px;
}
.total.hot { color: #ffffff; background: rgba(196, 31, 58, 0.75); }
.seat.you .seat-head { justify-content: flex-start; }

/* centre: wager chip, verdict banner, coach line */
.mid {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 0;
}
.pot { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.pot-chip {
  min-width: 58px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(160deg, #ffe9a8, #d9a127 62%, #8f6412);
  color: #2a1a02;
  font-weight: 800;
  font-size: 16px;
  text-align: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 0 0 2px rgba(255, 255, 255, 0.35);
}
.pot-label { font-size: 9px; letter-spacing: 0.2em; opacity: 0.5; }
.banner {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-align: center;
  line-height: 1.1;
}
.banner.win { color: var(--green); }
.banner.lose { color: var(--red); }
.banner.push { color: #d7d2c8; }
.banner.bj { color: var(--gold); }
.banner.pop { animation: bannerPop 380ms cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes bannerPop {
  from { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.12); opacity: 1; }
  to { transform: scale(1); opacity: 1; }
}
.msg {
  text-align: center;
  font-size: 12.5px;
  line-height: 1.35;
  opacity: 0.78;
  margin: 0;
  max-width: 30ch;
}

/* ---------------------------------------------------------------- cards */
.hand { margin-bottom: 6px; }
.hand.active .fan { filter: drop-shadow(0 0 7px rgba(255, 211, 106, 0.55)); }
.hand-label { font-size: 11px; opacity: 0.75; margin-bottom: 3px; }
.idle {
  opacity: 0.5;
  font-size: 12px;
  padding: 10px 0;
}
.fan {
  --n: 1;
  --w: var(--card-w);
  --h: var(--card-h);
  position: relative;
  height: var(--h);
  --step: min(46px, calc((100% - var(--w)) / max(1, calc(var(--n) - 1))));
}
.card {
  position: absolute;
  top: 0;
  left: calc(var(--i, 0) * var(--step));
  width: var(--w);
  height: var(--h);
  border-radius: 8px;
  background: linear-gradient(170deg, #ffffff, #f3ecdd);
  color: #16181d;
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.42);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px 7px;
  font-weight: 800;
  backface-visibility: hidden;
}
.card.enter { animation: dealIn 300ms cubic-bezier(.2, .9, .3, 1) both; }
@keyframes dealIn {
  from { transform: translate(46px, -72px) rotate(16deg) scale(0.72); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.card.flip { animation: cardFlip 320ms ease-out both; }
@keyframes cardFlip {
  from { transform: rotateY(88deg); }
  to { transform: rotateY(0deg); }
}
.card.red { color: #c4142f; }
.card.back {
  background:
    repeating-linear-gradient(45deg, #24388f, #24388f 7px, #16204d 7px, #16204d 14px);
  color: #a8c0ff;
  align-items: center;
  justify-content: center;
}
.card.back .pip { font-size: 22px; opacity: 0.8; }
.rank { font-size: 17px; line-height: 1; }
.suit { font-size: 20px; align-self: flex-end; line-height: 1; }
.fan .card:nth-child(1) { --i: 0; }
.fan .card:nth-child(2) { --i: 1; }
.fan .card:nth-child(3) { --i: 2; }
.fan .card:nth-child(4) { --i: 3; }
.fan .card:nth-child(5) { --i: 4; }
.fan .card:nth-child(6) { --i: 5; }
.fan .card:nth-child(7) { --i: 6; }
.fan .card:nth-child(8) { --i: 7; }

/* ---------------------------------------------------------------- dock */
.dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 12px max(8px, env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(10, 4, 20, 0.0), rgba(10, 4, 20, 0.55) 40%, rgba(8, 3, 16, 0.9));
  /* beat the base sheet's fixed thumb dock: this dock is a real row, so cards can never sit on it */
  position: static !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  pointer-events: auto !important;
}
.dock > * { pointer-events: auto; }
.bets, .verbs, .insure-row {
  display: grid;
  gap: 6px;
  align-items: center;
}
.bets { grid-template-columns: 1fr 1fr 1fr auto; }
.verbs { grid-template-columns: repeat(5, 1fr); }
.insure-row { grid-template-columns: 1fr 1fr; }
.chip {
  background: transparent;
  border: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip-face {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #2a1a02;
  background: linear-gradient(160deg, #ffe9a8, #d9a127 62%, #8f6412);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.4), 0 3px 8px rgba(0, 0, 0, 0.45);
  border: 2px dashed rgba(42, 26, 2, 0.45);
}
.chip.sel .chip-face {
  box-shadow: inset 0 0 0 3px #fff, 0 0 0 3px var(--gold), 0 3px 10px rgba(0, 0, 0, 0.5);
}
.bet-read {
  font-size: 10px;
  letter-spacing: 0.14em;
  opacity: 0.7;
  white-space: nowrap;
}
.bet-read b { color: var(--gold); font-size: 14px; }
.verbs button, .insure-row button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0 4px;
  height: 50px;
}
.verbs button.primary {
  background: linear-gradient(170deg, #ffe9a8, #ffc247);
  color: #241703;
  border: 0;
  box-shadow: 0 4px 14px rgba(255, 194, 71, 0.35);
}
.verbs button.primary.ready { animation: ready 1.4s ease-in-out infinite; }
@keyframes ready {
  0%, 100% { box-shadow: 0 4px 14px rgba(255, 194, 71, 0.28); }
  50% { box-shadow: 0 4px 22px rgba(255, 194, 71, 0.75); }
}
.insure-row .insure {
  background: linear-gradient(170deg, #a9d8ff, #4f9de0);
  color: #071c33;
  border: 0;
}
button:disabled { opacity: 0.28; }
button { font-family: inherit; }
[hidden] { display: none !important; }
/* during the insurance prompt only the two insurance buttons are live */
.dock.insuring .bets,
.dock.insuring .verbs { display: none; }
.hint {
  text-align: center;
  font-size: 11px;
  opacity: 0.55;
  min-height: 14px;
}

/* ---------------------------------------------------------------- desktop: a centred table, not a stretched one */
@media (min-width: 700px) {
  :root { --card-w: 78px; --card-h: 112px; }
  .hud, .felt, .dock { width: 100%; max-width: 560px; margin-left: auto; margin-right: auto; }
  .hud { padding: 18px 16px 4px; }
  .felt { padding: 8px 16px; }
  .dock { padding: 8px 16px 18px; gap: 8px; }
  .banner { font-size: 24px; }
  .msg { font-size: 14px; }
  .bank { font-size: 30px; }
  .chip-face { width: 52px; height: 52px; font-size: 15px; }
  .verbs button { height: 54px; }
  .hint { font-size: 12px; }
}

/* ---------------------------------------------------------------- landscape 844x390 */
@media (max-height: 500px) {
  :root { --card-w: 46px; --card-h: 64px; }
  .hud, .felt, .dock { max-width: none; }
  .hud { padding: 6px 10px 2px 128px; align-items: center; }
  .bank { font-size: 19px; }
  .bank-label { display: none; }
  .best { font-size: 10px; margin-top: 0; }
  .hud-right { flex-direction: row; align-items: center; gap: 10px; }
  .hud-btns { margin-top: 0; }
  .felt { padding: 2px 10px; gap: 2px; }
  .seat-head { margin-bottom: 2px; }
  .mid { gap: 2px; padding: 0; }
  .banner { font-size: 16px; }
  .msg { font-size: 11px; max-width: 34ch; }
  .rank { font-size: 14px; }
  .suit { font-size: 16px; }
  .hand { margin-bottom: 2px; }
  .hand-label { font-size: 10px; margin-bottom: 1px; }
  .idle { padding: 4px 0; }
  .dock { flex-direction: row; align-items: center; gap: 8px; padding: 4px 10px 6px; }
  .insure-row { flex: 1 1 100%; }
  .verbs { flex: 1 1 auto; }
  .verbs button { height: 44px; font-size: 11px; }
  .bets { grid-template-columns: repeat(3, auto) auto; }
  .chip-face { width: 40px; height: 40px; font-size: 12px; }
  .hint { display: none; }
  .pot-chip { min-width: 46px; font-size: 13px; padding: 3px 8px; }
}

/* portrait 390x844: the player fan must never reach the dock */
@media (orientation: portrait) and (max-width: 480px) {
  .dock { position: static !important; left: auto !important; right: auto !important; bottom: auto !important; }
  .verbs button { height: 52px; }
}
