/* Card Games — deep felt table, jeepney-sign accents.
   No webfonts: the game must work with no internet at all. */

:root {
  --felt-dark: #0b2e1f;
  --felt: #14432e;
  --felt-line: #1e5a3e;
  --bone: #f6f1e3;
  --bone-dim: #cfc8b4;
  --ink: #1f2421;
  --santan: #d64533;
  --mango: #f2b63c;
  --palm: #7fbf9e;
  --display: "Didot", "Bodoni 72", "Playfair Display", Georgia, "Times New Roman", serif;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--ui);
  color: var(--bone);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--felt) 0%, var(--felt-dark) 78%);
  background-attachment: fixed;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overflow: hidden;
}
button, input, select { font: inherit; }

.screen { height: 100dvh; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- join */

#screen-join { align-items: center; justify-content: center; padding: 24px; }
.join-wrap { width: min(340px, 100%); text-align: center; }
.brand { margin-bottom: 36px; }
.brand-suits { font-size: 18px; letter-spacing: 14px; text-indent: 14px; color: var(--bone-dim); }
.brand-suits .red { color: var(--santan); }
.brand-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: 56px;
  line-height: 1.05;
  margin-top: 6px;
  letter-spacing: 1px;
}
.brand-accent { color: var(--mango); font-style: italic; }
#join-form { display: grid; gap: 14px; text-align: left; }
.field span {
  display: block;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--bone-dim);
  margin-bottom: 6px;
}
.field input,
.field select {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--felt-line);
  background: rgba(0, 0, 0, 0.25);
  color: var(--bone);
  font-size: 17px;
  outline: none;
}
.field input:focus,
.field select:focus { border-color: var(--mango); }
.field select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' fill='none' stroke='%23f2b63c' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
.field select option { color: #111; background: #fff; }
.join-error { margin-top: 14px; color: var(--santan); font-size: 14px; }
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--bone-dim);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin: 4px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--felt-line);
}

/* ---------------------------------------------------------------- buttons */

.btn {
  min-height: 52px;
  padding: 12px 20px;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  color: var(--bone);
  background: var(--felt-line);
  transition: transform 80ms ease, opacity 120ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; pointer-events: none; }
.btn:focus-visible { outline: 3px solid var(--mango); outline-offset: 2px; }
.btn-primary { background: var(--mango); color: var(--ink); }
.btn-danger { background: var(--santan); }
.btn-ghost { background: transparent; border: 1px solid var(--felt-line); }

/* ---------------------------------------------------------------- lobby */

#screen-lobby { align-items: center; justify-content: center; padding: 24px; overflow-y: auto; }
.lobby-wrap { width: min(360px, 100%); text-align: center; }
.lobby-eyebrow { font-size: 11px; letter-spacing: 3px; text-transform: uppercase; color: var(--bone-dim); }
.lobby-code {
  font-family: var(--display);
  font-weight: 400;
  font-size: 72px;
  letter-spacing: 10px;
  text-indent: 10px;
  color: var(--mango);
  line-height: 1.1;
}
.lobby-hint { font-size: 13px; color: var(--bone-dim); margin: 6px 0 20px; word-break: break-all; }
.lobby-players { list-style: none; display: grid; gap: 8px; margin-bottom: 20px; }
.lobby-players li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--felt-line);
  font-size: 15px;
  text-align: left;
}
.lobby-players .seat-no {
  font-family: var(--display);
  color: var(--bone-dim);
  width: 18px;
}
.lobby-players .who { flex: 1; }
.lobby-players li.offline { opacity: 0.45; }
.badge {
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 700;
}
.badge-banker { background: var(--santan); color: var(--bone); }
.badge-host { background: var(--felt-line); color: var(--bone); }
.badge-dealer { background: var(--mango); color: var(--ink); }

.lobby-config { display: grid; gap: 10px; margin-bottom: 20px; text-align: left; }
.cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  color: var(--bone-dim);
}
.cfg-row .cfg-label { letter-spacing: 1px; text-transform: uppercase; font-size: 11px; }
.seg { display: flex; border: 1px solid var(--felt-line); border-radius: 9px; overflow: hidden; }
.seg button {
  border: none;
  background: transparent;
  color: var(--bone-dim);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  min-height: 40px;
}
.seg button.on { background: var(--mango); color: var(--ink); }
.stepper { display: flex; align-items: center; gap: 2px; }
.stepper button {
  width: 40px; min-height: 40px;
  border: 1px solid var(--felt-line); border-radius: 9px;
  background: transparent; color: var(--bone); font-size: 18px; cursor: pointer;
}
.stepper .stepper-val { min-width: 34px; text-align: center; color: var(--bone); font-size: 15px; }
.cfg-summary { font-size: 13px; color: var(--bone-dim); line-height: 1.7; }
.lobby-actions { display: grid; gap: 10px; }
.lobby-wait { font-size: 13px; color: var(--bone-dim); letter-spacing: 1px; }

/* banker voting */
.vote-btn {
  min-height: 40px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--felt-line);
  background: transparent;
  color: var(--bone-dim);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.vote-btn.on {
  background: var(--mango);
  border-color: var(--mango);
  color: var(--ink);
}
.vote-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.vote-label {
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--bone-dim);
}
.btn-reset { min-height: 44px; font-size: 14px; max-width: 240px; }
.btn-leave { min-height: 44px; font-size: 14px; max-width: 240px; color: var(--bone-dim); }

/* ---------------------------------------------------------------- table frame */

.table-screen { padding-bottom: env(safe-area-inset-bottom); }

.top-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0.14));
  border-bottom: 1px solid rgba(214, 69, 51, 0.5); /* Lucky 9: the banker's red */
}
.top-strip.inbetween { border-bottom-color: rgba(242, 182, 60, 0.55); } /* In-Between: the pot's gold */
.banker-id .banker-tag {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--santan);
  font-weight: 700;
}
.banker-id .banker-name { font-size: 16px; font-weight: 700; }
.banker-id .banker-chips { font-size: 12px; color: var(--bone-dim); }
.banker-cards { display: flex; gap: 4px; margin-left: auto; }
.banker-count {
  font-family: var(--display);
  font-size: 34px;
  min-width: 30px;
  text-align: center;
  color: var(--bone);
}
.banker-count.is-nine { color: var(--mango); }
.shoe-pill {
  font-size: 10px;
  color: var(--bone-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
  text-align: right;
  line-height: 1.5;
}

/* your own stack, top right of the table in every game */
.you-chips { text-align: right; flex-shrink: 0; }
.you-chips .you-tag {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--bone-dim);
  font-weight: 700;
}
.you-chips .you-num {
  font-family: var(--display);
  font-size: 26px;
  line-height: 1;
  color: var(--bone);
  font-variant-numeric: tabular-nums;
}
.you-chips .you-num.pop { animation: count-pop 380ms cubic-bezier(0.2, 0.8, 0.3, 1); }

/* ---------------------------------------------------------------- opponents */

.opponents {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.opponents::-webkit-scrollbar { display: none; }
.opp {
  flex: 1 0 72px;
  max-width: 96px;
  border: 1px solid var(--felt-line);
  border-radius: 12px;
  padding: 7px 6px;
  text-align: center;
  background: rgba(0, 0, 0, 0.18);
  position: relative;
}
.opp.active { border-color: var(--mango); box-shadow: 0 0 0 1px var(--mango), 0 0 14px rgba(242, 182, 60, 0.35); }
.opp.offline { opacity: 0.45; }
.opp .opp-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.opp .opp-cards { display: flex; justify-content: center; gap: 3px; min-height: 30px; margin: 5px 0 3px; align-items: center; }
.opp .opp-meta { font-size: 10px; color: var(--bone-dim); }
.opp .opp-flag {
  position: absolute;
  top: -7px;
  right: -4px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 2px 7px;
  border-radius: 12px;
  background: var(--felt-line);
  color: var(--bone);
}
.opp .opp-flag.win { background: var(--palm); color: var(--ink); }
.opp .opp-flag.lose { background: var(--santan); }
.opp .opp-flag.push { background: var(--bone-dim); color: var(--ink); }
.opp .opp-count { font-family: var(--display); font-size: 17px; color: var(--bone); }

/* ---------------------------------------------------------------- cards */

.card {
  width: var(--card-w, 84px);
  aspect-ratio: 5 / 7;
  border-radius: calc(var(--card-w, 84px) * 0.11);
  background: var(--bone);
  color: var(--ink);
  position: relative;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}
.card.red { color: var(--santan); }
.card .corner {
  position: absolute;
  top: 6%;
  left: 9%;
  font-family: var(--display);
  font-size: calc(var(--card-w, 84px) * 0.26);
  line-height: 1;
}
.card .corner small { display: block; font-size: 70%; font-family: var(--ui); }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--card-w, 84px) * 0.42);
  padding-top: 12%;
}
.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(246, 241, 227, 0.16) 0 2px, transparent 2px 7px),
    repeating-linear-gradient(-45deg, rgba(246, 241, 227, 0.16) 0 2px, transparent 2px 7px),
    linear-gradient(160deg, #b23a2b, #8f2d21);
  border: 2px solid rgba(246, 241, 227, 0.75);
}
.card.mini { --card-w: 22px; border-radius: 3px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.card.mini.back { border-width: 1px; }
.card.mini .corner { display: none; }
.card.mini .pip { font-size: 11px; padding-top: 0; }
.card.mini .mini-rank {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 12px; font-weight: 700;
}

/* deal + reveal motion */
@keyframes deal-in {
  from { transform: translateY(-46px) rotate(-7deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes flip-in {
  from { transform: rotateY(88deg); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
.card.deal-in { animation: deal-in 320ms cubic-bezier(0.2, 0.8, 0.3, 1) both; animation-delay: var(--d, 0ms); }
.card.flip-in { animation: flip-in 300ms ease-out both; animation-delay: var(--d, 0ms); }

/* ---------------------------------------------------------------- stage */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
}
.my-hand { display: flex; gap: 10px; min-height: calc(var(--card-w, 84px) * 1.4); align-items: center; }
.my-hand:empty::before {
  content: "no cards yet";
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--felt-line);
}

/* The signature: the live count, huge. */
.my-count {
  font-family: var(--display);
  font-size: clamp(64px, 22vh, 118px);
  line-height: 1;
  color: var(--bone);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
.my-count.is-nine {
  color: var(--mango);
  text-shadow: 0 0 18px rgba(242, 182, 60, 0.55), 0 0 60px rgba(242, 182, 60, 0.30);
}
@keyframes count-pop {
  0% { transform: scale(0.8); }
  55% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.my-count.pop { animation: count-pop 380ms cubic-bezier(0.2, 0.8, 0.3, 1); }

.stage-status {
  font-size: 13px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--bone-dim);
  min-height: 18px;
  text-align: center;
}
.stage-status.urgent { color: var(--mango); }

.my-result {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 2px;
  padding: 4px 18px;
  border-radius: 12px;
}
.my-result.win { color: var(--ink); background: var(--palm); }
.my-result.lose { color: var(--bone); background: var(--santan); }
.my-result.push { color: var(--ink); background: var(--bone-dim); }

/* ---------------------------------------------------------------- ticker + dock */

.ticker {
  text-align: center;
  font-size: 13px;
  color: var(--bone-dim);
  padding: 2px 16px 6px;
  min-height: 22px;
  font-style: italic;
}

.dock {
  padding: 6px 16px 14px;
  display: grid;
  gap: 10px;
}
.dock .dock-row { display: flex; gap: 10px; justify-content: center; }
.dock .dock-row .btn { flex: 1; max-width: 200px; min-height: 58px; font-size: 19px; }
.btn-hit { background: var(--mango); color: var(--ink); }
.btn-stand { background: transparent; border: 2px solid var(--bone); }
.dock-note {
  text-align: center;
  font-size: 13px;
  color: var(--bone-dim);
  letter-spacing: 1px;
}
.dock-timer { color: var(--mango); font-weight: 700; font-variant-numeric: tabular-nums; }

/* betting chips */
.chip-row { display: flex; gap: 10px; justify-content: center; }
.chip {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px dashed rgba(31, 36, 33, 0.35);
  background: var(--bone);
  color: var(--ink);
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
}
.chip:active { transform: translateY(2px); }
.chip:disabled { opacity: 0.35; pointer-events: none; }
.chip.chip-5 { background: var(--santan); color: var(--bone); }
.chip.chip-10 { background: var(--ink); color: var(--bone); border-color: rgba(246, 241, 227, 0.4); }
.bet-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  font-size: 14px;
  color: var(--bone-dim);
}
.bet-amount { font-family: var(--display); font-size: 40px; color: var(--mango); line-height: 1; }
.bet-clear { background: none; border: none; color: var(--bone-dim); text-decoration: underline; font-size: 13px; cursor: pointer; padding: 6px; }

/* ---------------------------------------------------------------- coins */

/* Chips in flight between the house's money (the pot, the banker) and a
   player's cards. Whatever they land on pops. */
.coin-layer { position: fixed; inset: 0; pointer-events: none; z-index: 20; overflow: hidden; }
.coin {
  position: absolute;
  top: -8px;
  left: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffd979, var(--mango) 55%, #b7801c);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(255, 255, 255, 0.28);
  will-change: transform;
}
.my-hand.pop, .opp.pop, .banker-chips.pop { animation: count-pop 380ms cubic-bezier(0.2, 0.8, 0.3, 1); }

/* ---------------------------------------------------------------- in-between */

/* The pot takes the banker's place at the top of the table — centred, with
   the round readout on the left and your chips on the right. */
.top-strip.inbetween {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}
.top-strip.inbetween .shoe-pill { text-align: left; }
.top-strip.inbetween .you-chips { justify-self: end; }
.pot { display: flex; align-items: baseline; gap: 10px; justify-self: center; }
.pot .pot-tag {
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--mango);
  font-weight: 700;
}
.pot .pot-num {
  font-family: var(--display);
  font-size: 40px;
  line-height: 1;
  color: var(--mango);
  text-shadow: 0 0 16px rgba(242, 182, 60, 0.35);
  font-variant-numeric: tabular-nums;
}
.pot .pot-num.empty { color: var(--bone-dim); text-shadow: none; }
.pot .pot-num.pop { animation: count-pop 380ms cubic-bezier(0.2, 0.8, 0.3, 1); }

/* The spread: two cards with the gap the drawn card has to land in. */
.my-hand.spread { gap: 14px; }
.card.gap {
  background: transparent;
  border: 2px dashed rgba(246, 241, 227, 0.4);
  box-shadow: none;
}
.card.gap::after {
  content: "?";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: calc(var(--card-w, 84px) * 0.4);
  color: rgba(246, 241, 227, 0.35);
}
.card.mini.gap { border-width: 1px; }
.card.mini.gap::after { font-size: 11px; }
.card.drawn { box-shadow: 0 0 0 2px var(--mango), 0 0 18px rgba(242, 182, 60, 0.45); }
.card.mini.drawn { box-shadow: 0 0 0 1px var(--mango), 0 0 8px rgba(242, 182, 60, 0.45); }

/* Where Lucky 9 shows its count, In-Between says what wins, in words. */
.my-count.is-window {
  font-size: clamp(26px, 5vh, 36px);
  letter-spacing: 1px;
  font-style: italic;
}

/* wagering */
.chip.chip-allin {
  background: var(--mango);
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0.5px;
}
.call-row { display: flex; justify-content: center; }
.dock .seg button { padding: 10px 26px; min-height: 46px; font-size: 15px; }
.btn-hit.all-in { box-shadow: 0 0 0 2px var(--mango), 0 0 22px rgba(242, 182, 60, 0.55); }

/* timebar */
.timebar { height: 4px; background: rgba(0, 0, 0, 0.4); }
.timebar-fill {
  height: 100%;
  width: 0%;
  background: var(--mango);
  transition: width 200ms linear;
}
.timebar-fill.low { background: var(--santan); }

/* ---------------------------------------------------------------- overlays */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bone);
  border: 1px solid var(--santan);
  padding: 10px 18px;
  border-radius: 24px;
  font-size: 14px;
  max-width: 86vw;
  text-align: center;
  z-index: 30;
}
.reconnect-banner {
  position: fixed;
  inset: 0;
  background: rgba(11, 46, 31, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  letter-spacing: 1px;
  z-index: 40;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
