/* 7s, 8s & 9s — basement poker night. Felt, mahogany, brass. */

:root {
  --felt: #1e5c40;
  --felt-dark: #0e3a26;
  --wood: #5c3a20;
  --wood-dark: #33200f;
  --wood-light: #7b5230;
  --gilt: #d4af5e;
  --gilt-dim: #a8843d;
  --cream: #f7f2e2;
  --oxblood: #6e222b;
  --ink: #201b15;
  --plaque: rgba(18, 14, 9, 0.82);
  --serif: "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  background: radial-gradient(120% 100% at 50% 0%, #241a10 0%, #0d0906 70%, #060403 100%);
  font-family: var(--sans);
  color: var(--cream);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; color: inherit; }

/* Pin the app to the dynamic viewport on mobile browsers (URL bar collapse). */
body {
  position: fixed;
  inset: 0;
}
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

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

/* Game surfaces reject every gesture except plain taps — no pinch, no
 * double-tap zoom. Overlay panels keep vertical panning so they scroll. */
#table, #card-layer, #player-zone, #seats { touch-action: none; }
.panel { touch-action: pan-y; }

#table {
  position: absolute;
  inset: clamp(6px, 1.5vmin, 16px);
  border-radius: clamp(60px, 14vmin, 160px);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='420'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.007 0.11' numOctaves='4'/%3E%3CfeColorMatrix values='0 0 0 0 0.16 0 0 0 0 0.09 0 0 0 0 0.04 0 0 0 0.5 0'/%3E%3C/filter%3E%3Crect width='420' height='420' filter='url(%23g)'/%3E%3C/svg%3E"),
    linear-gradient(135deg, var(--wood-light) 0%, var(--wood) 30%, var(--wood-dark) 70%, var(--wood) 100%);
  box-shadow:
    0 20px 60px rgba(0,0,0,0.8),
    inset 0 2px 3px rgba(255,220,160,0.25),
    inset 0 -3px 8px rgba(0,0,0,0.6);
  padding: clamp(12px, 2.6vmin, 30px);
}

#felt {
  position: absolute;
  inset: clamp(12px, 2.6vmin, 30px);
  border-radius: clamp(48px, 12vmin, 140px);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='320' height='320'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.55' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.045 0'/%3E%3C/filter%3E%3Crect width='320' height='320' filter='url(%23n)'/%3E%3C/svg%3E"),
    radial-gradient(90% 80% at 50% 42%, #257a54 0%, var(--felt) 35%, var(--felt-dark) 100%);
  background-color: var(--felt);
  box-shadow:
    inset 0 0 60px rgba(0,0,0,0.55),
    inset 0 0 8px rgba(0,0,0,0.7),
    inset 0 1px 0 rgba(255,255,255,0.08);
  border: 2px solid rgba(212, 175, 94, 0.35);
}

/* Gilt pinstripe inside the felt */
#felt::after {
  content: "";
  position: absolute;
  inset: clamp(10px, 2vmin, 24px);
  border-radius: inherit;
  border: 1.5px solid rgba(212, 175, 94, 0.22);
  pointer-events: none;
}

/* ------------------------------------------------------------- center --- */

#center {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  text-align: center;
  z-index: 3;
  pointer-events: none;
}

#phase-title {
  font-family: var(--serif);
  font-size: clamp(18px, 3.4vmin, 30px);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gilt);
  text-shadow: 0 2px 6px rgba(0,0,0,0.7);
}

#phase-sub {
  font-size: clamp(11px, 1.7vmin, 14px);
  opacity: 0.75;
  margin-top: 2px;
}

#pot {
  margin: clamp(6px, 1.4vmin, 14px) auto 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--plaque);
  border: 1px solid var(--gilt-dim);
  border-radius: 999px;
  padding: clamp(5px, 1vmin, 10px) clamp(14px, 2.4vmin, 24px);
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

#pot .chip { flex: none; }

#pot-amount {
  font-family: var(--serif);
  font-size: clamp(18px, 3vmin, 28px);
  font-variant-numeric: tabular-nums;
  color: var(--cream);
}

#pot-label {
  font-size: clamp(9px, 1.3vmin, 11px);
  letter-spacing: 0.2em;
  color: var(--gilt);
}

.chip {
  width: clamp(20px, 3vmin, 28px);
  height: clamp(20px, 3vmin, 28px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, #b8394a, #8c1f30 60%, #6e1624);
  border: 3px dashed rgba(255, 245, 225, 0.85);
  box-shadow: 0 2px 4px rgba(0,0,0,0.6), inset 0 0 0 2px #8c1f30;
}

.fly-chip {
  position: fixed;
  z-index: 60;
  transform: translate(-50%, -50%);
  transition: left 0.65s cubic-bezier(.5,0,.4,1), top 0.65s cubic-bezier(.5,0,.4,1);
  pointer-events: none;
}

/* -------------------------------------------------- physical chip racks --- */

.chips-rack {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  min-height: 12px;
  margin-top: 3px;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.45));
}

.chipgroup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.piles {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.chipn {
  font-size: 8.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--cream);
  opacity: 0.7;
  line-height: 1;
  letter-spacing: 0.04em;
}

.chipcol {
  display: flex;
  flex-direction: column-reverse;
}
.chipcol:nth-child(even) { transform: translateY(-0.5px) rotate(0.6deg); }

/* One chip seen from the side: clay body with cream edge stripes. */
.pchip {
  display: block;
  width: clamp(15px, 2.4vmin, 21px);
  height: clamp(4px, 0.72vmin, 6px);
  border-radius: 38% / 50%;
  margin-top: -1px;
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.32) 0%, rgba(255,255,255,0) 45%, rgba(0,0,0,0.3) 100%),
    repeating-linear-gradient(90deg,
      transparent 0 2.6px, var(--edge, #f5eed9) 2.6px 4.6px, transparent 4.6px 7.2px);
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.35);
}
.chipcol .pchip:last-child {
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.35), inset 0 1.5px 0 rgba(255, 255, 255, 0.35);
}

.pchip.d25 { background-color: #1e6e46; }
.pchip.d10 { background-color: #2b4d9c; }
.pchip.d5  { background-color: #8c1f30; }

.chips-rack.big .pchip {
  width: clamp(20px, 3vmin, 26px);
  height: clamp(5px, 0.9vmin, 7px);
}

@media (max-width: 640px) {
  .chips-rack { gap: 5px; margin-top: 2px; }
  .pchip { width: 13px; height: 3.5px; }
  .chips-rack.big .pchip { width: 17px; height: 4.5px; }
  .chipn { font-size: 7px; }
}

/* -------------------------------------------------------------- seats --- */

#seats { position: absolute; inset: 0; z-index: 4; pointer-events: none; }

.seat {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  transition: opacity 0.4s, filter 0.4s;
}

.seat.folded { opacity: 0.42; filter: saturate(0.4); }

.plate {
  display: flex;
  align-items: center;
  gap: 8px;
  height: clamp(40px, 6.2vmin, 52px);
  background: var(--plaque);
  border: 1px solid rgba(212,175,94,0.5);
  border-radius: 999px;
  padding: 0 14px 0 5px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.55);
  transition: box-shadow 0.3s, border-color 0.3s;
  white-space: nowrap;
}

.seat.acting .plate,
#player-zone.acting #player-plate {
  border-color: var(--gilt);
  box-shadow: 0 0 0 2px rgba(212,175,94,0.55), 0 0 22px rgba(212,175,94,0.5);
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% { box-shadow: 0 0 0 2px rgba(212,175,94,0.85), 0 0 30px rgba(212,175,94,0.75); }
}

.seat.winner .plate,
#player-zone.winner #player-plate {
  border-color: var(--gilt);
  box-shadow: 0 0 0 3px var(--gilt), 0 0 34px rgba(212,175,94,0.9);
}

.plate .avatar {
  width: clamp(28px, 4.4vmin, 40px);
  height: clamp(28px, 4.4vmin, 40px);
  flex: none;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #46586b, #232f3d);
  border: 1.5px solid var(--gilt-dim);
  display: grid;
  place-items: center;
  font-size: clamp(14px, 2.4vmin, 21px);
}

.plate .who { display: flex; flex-direction: column; line-height: 1.12; min-width: 0; }
.plate .name { font-family: var(--serif); font-size: clamp(13px, 2vmin, 16px); white-space: nowrap; }
.plate .tag {
  font-size: clamp(7.5px, 1.1vmin, 9px);
  letter-spacing: 0.16em;
  opacity: 0.55;
  text-transform: uppercase;
  white-space: nowrap;
}

.plate .stack {
  font-variant-numeric: tabular-nums;
  font-size: clamp(12px, 1.8vmin, 15px);
  font-weight: 600;
  color: var(--gilt);
  margin-left: 2px;
  min-width: 3ch;
  text-align: right;
}

.seat-cards {
  display: flex;
  height: clamp(24px, 4vmin, 40px);
}
.seat-cards .card { margin-left: calc(clamp(14px, 2.4vmin, 26px) * -0.55); }
.seat-cards .card:first-child { margin-left: 0; }
.seat-cards.folded-cards { opacity: 0.35; }
.seat-cards {
  transition: opacity 0.4s, transform 0.4s;
}
.seat-cards.sweep {
  opacity: 0;
  transform: translateY(16px) scale(0.75);
}

.bubble {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translate(-50%, -100%) scale(0.8);
  background: var(--cream);
  color: var(--ink);
  font-weight: 600;
  font-size: clamp(11px, 1.7vmin, 14px);
  border-radius: 10px;
  padding: 4px 12px;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  z-index: 20;
}
.bubble::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -5px;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--cream);
  border-bottom: none;
}
.bubble.show { opacity: 1; transform: translate(-50%, -100%) scale(1); }

/* Seats along the top edge speak downward so bubbles never leave the screen. */
.seat.top .bubble {
  top: auto;
  bottom: -14px;
  transform: translate(-50%, 100%) scale(0.8);
}
.seat.top .bubble.show { transform: translate(-50%, 100%) scale(1); }
.seat.top .bubble::after {
  bottom: auto;
  top: -5px;
  border-top: none;
  border-bottom: 6px solid var(--cream);
}

.declare-chips { min-height: 20px; }

/* Declare theater: fists out → three-count → simultaneous pop. */
.fist-wait {
  display: inline-block;
  font-size: clamp(17px, 2.8vmin, 24px);
  animation: fist-in 0.32s cubic-bezier(.34,1.56,.64,1) backwards;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
}
@keyframes fist-in {
  from { transform: translateY(10px) scale(0.3); opacity: 0; }
}
.fist-wait.bump { animation: fist-bump 0.42s ease-out; }
@keyframes fist-bump {
  30% { transform: scale(1.3) rotate(-10deg); }
}

.declare-badge.pop {
  animation: badge-pop 0.55s cubic-bezier(.34,1.56,.64,1) backwards;
}
@keyframes badge-pop {
  0% { transform: scale(0.15) rotate(-14deg); opacity: 0; }
  60% { transform: scale(1.22) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

#phase-title.count { animation: count-pop 0.42s ease-out; }
@keyframes count-pop {
  0% { transform: scale(1.9); opacity: 0.2; }
  100% { transform: scale(1); opacity: 1; }
}

.declare-card.chosen {
  transform: scale(1.09) !important;
  box-shadow: 0 0 0 3px var(--gilt), 0 0 44px rgba(212, 175, 94, 0.55);
  transition: transform 0.18s, box-shadow 0.18s;
}
.declare-card.dim {
  opacity: 0.22;
  transform: scale(0.94) !important;
  transition: opacity 0.25s, transform 0.25s;
}

.declare-badge {
  display: inline-block;
  font-weight: 700;
  font-size: clamp(10px, 1.6vmin, 13px);
  letter-spacing: 0.1em;
  border-radius: 999px;
  padding: 3px 11px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}
.declare-badge.sm { font-size: 10px; padding: 1px 8px; }
.declare-badge.low { background: #274a7a; color: #dfeaff; }
.declare-badge.high { background: #8c1f30; color: #ffe9e9; }
.declare-badge.piggy { background: var(--gilt); color: #3a2a08; }

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

.card {
  position: relative;
  border-radius: 8%;
  flex: none;
  isolation: isolate; /* ribbon z-index stays inside its own card */
}

.card.face {
  background: linear-gradient(160deg, #fffdf4 0%, var(--cream) 55%, #eee5cc 100%);
  border: 1px solid #c9bd9c;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
  color: var(--ink);
  overflow: hidden;
}
.card.face.red { color: #a32332; }

.card.back {
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.45);
}
.card.back svg { display: block; width: 100%; height: 100%; }

.card.big {
  width: clamp(58px, 11.5vmin, 104px);
  height: calc(clamp(58px, 11.5vmin, 104px) * 1.36);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.card.mini {
  width: clamp(14px, 2.4vmin, 26px);
  height: calc(clamp(14px, 2.4vmin, 26px) * 1.36);
  border-radius: 12%;
}
.card.mini .corner, .card.mini .wild-ribbon { display: none; }

.card.fly {
  position: fixed;
  width: clamp(30px, 5vmin, 48px);
  height: calc(clamp(30px, 5vmin, 48px) * 1.36);
  z-index: 50;
  transform: translate(-50%, -50%);
  transition-property: left, top, transform;
  transition-timing-function: cubic-bezier(0.45, 0, 0.35, 1);
  pointer-events: none;
}

.corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.95;
  font-family: var(--serif);
  z-index: 2;
}
.corner b { font-size: clamp(13px, 2.5vmin, 24px); }
.corner i { font-style: normal; font-size: clamp(11px, 2vmin, 19px); }
.corner.tl { top: 5%; left: 7%; }
.corner.br { bottom: 5%; right: 7%; transform: rotate(180deg); }

.face-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

/* Lower-left diagonal: the left strip is the part of a fanned card that
 * stays visible under the neighbor to its right. */
.wild-ribbon {
  position: absolute;
  top: 62%;
  left: -32%;
  width: 100%;
  transform: rotate(-38deg);
  background: linear-gradient(90deg, var(--gilt-dim), var(--gilt), var(--gilt-dim));
  color: #3a2a08;
  font-size: clamp(7px, 1.25vmin, 11px);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-align: center;
  padding: 2px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  z-index: 3;
}
.card.face:has(.wild-ribbon) { border-color: var(--gilt-dim); box-shadow: 0 2px 6px rgba(0,0,0,0.45), inset 0 0 0 1.5px rgba(212,175,94,0.55); }

/* -------------------------------------------------------- player zone --- */

#player-zone {
  position: absolute;
  left: 50%;
  bottom: clamp(6px, 1.6vmin, 18px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1vmin, 10px);
  z-index: 6;
  width: min(96vw, 900px);
}

/* The hand itself lives in #card-layer as physics bodies; this anchor just
 * reserves the space in the layout (its height is set from JS). */
#hand-anchor { width: 100%; }

/* ------------------------------------------------------- 3D card layer --- */

#card-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

.c3d {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  perspective: 900px;
  will-change: transform;
}
.c3d:active { cursor: grabbing; }

.c3d-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.c3d-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.c3d-face.backf { transform: rotateY(180deg); }
.c3d .card {
  width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  transition: none;
}
.c3d-face.just-got {
  box-shadow: inset 0 0 0 2px var(--gilt), 0 0 18px rgba(212, 175, 94, 0.65);
}

.c3d-sh {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -7%;
  height: 16%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.55), transparent 70%);
  filter: blur(3px);
  pointer-events: none;
}

/* Arcing chips (driven from JS, page coordinates). */
.chip-air {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 65;
  pointer-events: none;
  will-change: transform;
}

/* Opponent mini cards flip in at showdown. */
.card.mini.reveal { animation: flip-in 0.45s backwards; }
@keyframes flip-in {
  from { transform: rotateY(88deg); }
  to { transform: rotateY(0deg); }
}

#player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

#player-plate { position: relative; height: 48px; }

#player-bubble { top: auto; bottom: 105%; }

#strength {
  display: flex;
  align-items: stretch;
  gap: 0;
  max-width: 94vw;
  background: rgba(10, 26, 18, 0.78);
  border: 1px solid rgba(212,175,94,0.35);
  border-radius: 999px;
  padding: 7px clamp(10px, 2.4vmin, 22px);
  font-size: clamp(11px, 1.7vmin, 13px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
}
#strength > span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 clamp(8px, 2vmin, 18px);
  text-align: center;
  line-height: 1.3;
  min-width: 0;           /* let long hand names shrink and wrap */
  flex: 0 1 auto;
}
#strength #str-high, #strength #str-low, #strength #str-wilds {
  white-space: normal;
  overflow-wrap: break-word;
}
#strength > span + span { border-left: 1px solid rgba(212,175,94,0.22); }
#strength .lbl {
  color: var(--gilt);
  letter-spacing: 0.2em;
  font-size: 8.5px;
  font-weight: 600;
  display: block;
  opacity: 0.8;
}

#prompt {
  display: flex;
  align-items: center;
  height: 48px;
  background: var(--plaque);
  border: 1px solid rgba(212,175,94,0.5);
  border-radius: 999px;
  padding: 0 20px;
  font-size: 14px;
  letter-spacing: 0.01em;
  box-shadow: 0 3px 10px rgba(0,0,0,0.55);
  white-space: nowrap;
}
#prompt b { color: var(--gilt); font-weight: 700; }

#actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn {
  min-height: 48px;
  min-width: 104px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1.5px solid var(--gilt-dim);
  background: linear-gradient(180deg, #234f3a, #16382a);
  color: var(--cream);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.12);
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.2s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 2px 6px rgba(0,0,0,0.5); }
.btn.primary { background: linear-gradient(180deg, var(--gilt), #b58f3f); color: #2c1f06; border-color: #e8cf8d; }
.btn.danger { background: linear-gradient(180deg, #7a2a33, #571c23); }
.btn:disabled { opacity: 0.45; cursor: default; }

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 6, 0.78);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  transition: opacity 0.3s;
}

.hidden { display: none !important; }

.panel {
  position: relative;
  background: linear-gradient(170deg, #1d1712, #120d09);
  border: 1.5px solid var(--gilt-dim);
  border-radius: 20px;
  padding: clamp(22px, 4vmin, 36px) clamp(20px, 4vmin, 40px);
  max-width: min(92vw, 620px);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.8);
  text-align: center;
}

.panel h1, .panel h2 {
  font-family: var(--serif);
  color: var(--gilt);
  letter-spacing: 0.06em;
}
.panel h2 { font-size: clamp(20px, 3.2vmin, 25px); }

.panel-sub {
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gilt);
  opacity: 0.7;
  text-align: center;
  margin: 5px 0 16px;
}

.panel h3 {
  font-family: var(--serif);
  color: var(--gilt);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin: 18px 0 8px;
  text-align: left;
}

/* Visual example rows — real cards instead of prose */
.ex-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 6px 0;
}
.ex-card {
  width: 46px;
  height: 63px;
  position: relative;
  flex: none;
  border-radius: 5px;
}
.ex-card .wild-ribbon { font-size: 5.5px; padding: 1px 0; top: 58%; }
.ex-op {
  font-family: var(--serif);
  color: var(--gilt);
  font-size: 20px;
  padding: 0 2px;
}
.wild-chip {
  background: linear-gradient(90deg, var(--gilt-dim), var(--gilt));
  color: #3a2a08;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  border-radius: 999px;
  padding: 6px 14px;
}
.ex-cap {
  font-size: 11px;
  opacity: 0.6;
  padding-left: 4px;
}
.ex-note {
  font-size: 12px;
  line-height: 1.55;
  opacity: 0.7;
  text-align: left;
  margin: 4px 0;
}

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.tag-chip {
  border: 1px solid rgba(212,175,94,0.45);
  color: var(--cream);
  opacity: 0.85;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 11px;
  letter-spacing: 0.06em;
}

#title-screen .medallion {
  width: clamp(90px, 18vmin, 150px);
  margin: 0 auto 14px;
  filter: drop-shadow(0 10px 24px rgba(0,0,0,0.7));
}
#title-screen .medallion svg { width: 100%; height: auto; border-radius: 10px; }

#title-screen h1 {
  font-size: clamp(30px, 6.5vmin, 54px);
  line-height: 1.05;
}
#title-screen .subtitle {
  font-family: var(--serif);
  font-style: italic;
  opacity: 0.8;
  margin: 8px 0 18px;
  font-size: clamp(13px, 2.2vmin, 17px);
}
#title-screen .lineup {
  font-size: clamp(11px, 1.8vmin, 14px);
  opacity: 0.7;
  margin-bottom: 22px;
}

/* Declare overlay — keep it light so the table stays readable behind it */
#declare-overlay {
  background: rgba(5, 8, 6, 0.5);
  backdrop-filter: none;
  align-items: start;
  padding-top: clamp(20px, 8vh, 90px);
}

#declare-strength {
  font-size: clamp(12px, 1.9vmin, 15px);
  opacity: 0.9;
  margin-top: 6px;
}
#declare-strength b { color: var(--gilt); font-weight: 600; }

#declare-overlay .choices {
  display: flex;
  gap: clamp(10px, 2.4vmin, 22px);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 18px;
}
.declare-card {
  width: clamp(120px, 22vmin, 170px);
  border-radius: 14px;
  border: 1.5px solid var(--gilt-dim);
  padding: 18px 10px 16px;
  cursor: pointer;
  background: linear-gradient(180deg, #20342a, #14231c);
  transition: transform 0.12s, box-shadow 0.12s;
}
.declare-card:active { transform: scale(0.96); }
.declare-card .fist { font-size: clamp(30px, 6vmin, 46px); display: block; }
.declare-card h3 { font-family: var(--serif); font-size: clamp(18px, 3vmin, 24px); margin: 8px 0 4px; color: var(--cream); }
.declare-card p { font-size: clamp(10px, 1.6vmin, 12px); opacity: 0.7; line-height: 1.4; }
.declare-card.low { border-color: #4a76b8; }
.declare-card.high { border-color: #b8394a; }
.declare-card.piggy { border-color: var(--gilt); background: linear-gradient(180deg, #3a2f16, #241c0c); }

/* Showdown */
#showdown .panel { min-width: min(92vw, 560px); text-align: left; position: relative; }
#showdown h2 {
  text-align: center;
  font-size: clamp(20px, 3.6vmin, 30px);
  margin-bottom: 14px;
  padding: 0 34px;
}
table.results { width: 100%; border-collapse: collapse; font-size: clamp(11px, 1.8vmin, 14px); }
table.results td { padding: 7px 8px; border-bottom: 1px solid rgba(212,175,94,0.15); }
table.results tr.dim { opacity: 0.45; }
table.results tr.won td { background: rgba(212,175,94,0.1); }
table.results td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--gilt); }
.win-badge {
  background: var(--gilt);
  color: #2c1f06;
  font-size: 9px;
  font-weight: 800;
  border-radius: 4px;
  padding: 2px 6px;
  letter-spacing: 0.1em;
}
.carry-note { margin-top: 10px; font-size: 12px; opacity: 0.7; text-align: center; }
#showdown-close, .panel-x {
  position: absolute;
  top: 10px; right: 14px;
  background: none; border: none;
  color: var(--gilt);
  font-size: 22px;
  cursor: pointer;
  min-width: 44px; min-height: 44px;
}

/* Title links + resume note */
.title-links { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; }
.text-link.danger { color: #d98a94; }
.resume-note {
  font-size: 12px;
  color: var(--gilt);
  opacity: 0.85;
  margin: 10px 0 4px;
}

/* Customize the table */
#customize-overlay { z-index: 125; }
.cz-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(212, 175, 94, 0.15);
}
.cz-avatar {
  width: 46px;
  height: 46px;
  flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--gilt-dim);
  background: radial-gradient(circle at 35% 30%, #46586b, #232f3d);
  font-size: 22px;
  cursor: pointer;
}
.cz-avatar:active { transform: scale(0.92); }
.cz-name {
  flex: 1;
  min-width: 0;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(212, 175, 94, 0.4);
  background: rgba(10, 26, 18, 0.6);
  color: var(--cream);
  font-family: var(--serif);
  font-size: 16px;      /* ≥16px so iOS doesn't zoom the form */
  padding: 0 12px;
}
.cz-name:focus { outline: none; border-color: var(--gilt); }
.cz-persona {
  flex: none;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 94, 0.45);
  background: rgba(212, 175, 94, 0.08);
  color: var(--gilt);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
.cz-persona:active { transform: scale(0.94); }
.cz-persona.static { cursor: default; }
.cz-persona.static:active { transform: none; }

.persona-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  text-align: left;
}
.persona-row .cz-persona { min-width: 108px; text-align: center; height: 28px; padding: 0 8px; }
.persona-desc { font-size: 12px; line-height: 1.4; opacity: 0.8; }

/* About & credits */
#about-overlay { z-index: 130; }
.text-link {
  display: block;
  margin: 14px auto 0;
  background: none;
  border: none;
  color: var(--gilt);
  opacity: 0.7;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-decoration: underline;
  cursor: pointer;
  min-height: 44px;
}
.about-p { font-size: 13px; line-height: 1.6; opacity: 0.9; text-align: left; }
.attribution {
  margin: 10px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--gilt-dim);
  background: rgba(212, 175, 94, 0.07);
  font-size: 12px;
  line-height: 1.7;
}
.attribution a { color: var(--gilt); }

/* Scoreboard — sits above the title screen so the book is browsable anytime */
#score-overlay { z-index: 120; }
#score-overlay .panel { min-width: min(92vw, 520px); position: relative; }
.score-sub { font-size: 12px; opacity: 0.7; margin: 4px 0 12px; }
table.score { text-align: left; }
table.score tr.hdr td {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gilt);
  border-bottom: 1px solid var(--gilt-dim);
}


/* Flex topbar: hiding any button (e.g. no fullscreen API on iPhone)
 * collapses the row instead of leaving a gap. */
#topbar {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: 14px;
  display: flex;
  gap: 8px;
  z-index: 90;
}
#topbar button {
  width: 46px; height: 46px;
  border-radius: 50%;
  border: 1.5px solid var(--gilt-dim);
  background: var(--plaque);
  color: var(--gilt);
  font-family: var(--serif);
  font-size: 19px;
  cursor: pointer;
}
#help-btn { font-size: 22px; }

/* ---------------------------------------------------------- responsive --- */

@media (max-aspect-ratio: 5/6) {
  #center { top: 38%; }
  .plate .tag { display: none; }
}

/* Phones — compress plates, pull side seats in from the edges, tighten fan. */
@media (max-width: 640px) {
  .plate { gap: 5px; padding: 0 10px 0 4px; height: 34px; }
  .plate .tag { display: none; }
  .plate .avatar { width: 24px; height: 24px; font-size: 13px; }
  .plate .name { font-size: 11px; }
  .plate .stack { font-size: 10px; }
  #player-plate { height: 44px; }
  #prompt { height: 44px; padding: 0 14px; font-size: 12px; }
  .seat-cards { height: 20px; }
  .seat-cards .card { margin-left: -8px; }

  #seat-1 { left: 84% !important; top: 62% !important; }
  #seat-2 { left: 81% !important; top: 24% !important; }
  #seat-3 { left: 63% !important; top: 10.5% !important; }
  #seat-4 { left: 37% !important; top: 10.5% !important; }
  #seat-5 { left: 19% !important; top: 24% !important; }
  #seat-6 { left: 16% !important; top: 62% !important; }

  #table { inset: 4px; border-radius: 40px; padding: 9px; }
  #felt { inset: 9px; border-radius: 32px; }
  #felt::after { inset: 8px; }
  #center { top: 39%; }

  #player-zone { bottom: max(6px, env(safe-area-inset-bottom)); gap: 4px; }
  #player-row { gap: 6px; }
  #player-plate { padding: 4px 12px; }
  #strength { padding: 4px 10px; gap: 10px; flex-wrap: wrap; justify-content: center; }
  .btn { min-height: 44px; min-width: 88px; padding: 0 16px; font-size: 14px; }
  #topbar { gap: 5px; }
  #topbar button { width: 34px; height: 34px; font-size: 14px; }
  #help-btn { font-size: 16px; }
}

/* Short landscape phones — reclaim vertical space. */
@media (max-height: 480px) {
  #center { top: 40%; }
  #pot { margin-top: 4px; padding: 3px 14px; }
  #player-zone { bottom: 4px; gap: 3px; }
  .plate .tag { display: none; }
  .plate { height: 32px; }
  #player-plate { height: 42px; }
  #prompt { height: 42px; }
  .seat-cards { height: 18px; }
  .btn { min-height: 42px; }
}

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