/* Hi-Lo card table. Every class starts with bq-hl-. */

.bq-hl-wrap {
  container-type: inline-size;
  width: min(960px, 100%);
}

.bq-hl {
  --hl-felt: #0c3a44;
  --hl-felt-2: #061d24;
  --hl-brass: linear-gradient(135deg, #f8dc8c 0%, #b07a2c 32%, #ffe8a6 52%, #8c5a1c 78%, #e2b75e 100%);
  --hl-card-w: clamp(104px, 21cqi, 168px);
  --hl-mini-w: clamp(34px, 6.4cqi, 46px);
  position: relative;
  width: 100%;
  padding: clamp(14px, 3cqi, 28px);
  border: clamp(6px, 1.2cqi, 10px) solid transparent;
  border-radius: clamp(22px, 4cqi, 36px);
  background:
    radial-gradient(70% 55% at 50% 0%, rgba(255, 196, 120, 0.22), transparent 70%) padding-box,
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0, 0, 0, 0.45)) padding-box,
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E") padding-box,
    radial-gradient(110% 100% at 50% 30%, var(--hl-felt), var(--hl-felt-2)) padding-box,
    var(--hl-brass) border-box;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(0, 0, 0, 0.5), inset 0 0 60px rgba(0, 0, 0, 0.4);
  color: var(--bq-ink);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---- header: name + running value */
.bq-hl-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--bq-s4);
  margin-bottom: clamp(10px, 2.4cqi, 22px);
}

.bq-hl-title { display: grid; gap: 2px; }

.bq-hl-title__name {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(18px, 3cqi, 26px);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--hl-brass);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.bq-hl-title__sub {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bq-faint);
}

.bq-hl-meter {
  display: grid;
  justify-items: end;
  gap: 0;
  padding: var(--bq-s2) var(--bq-s4);
  border-radius: var(--bq-r);
  background: rgba(3, 14, 18, 0.55);
  border: 1px solid rgba(255, 207, 90, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  min-width: 150px;
}

.bq-hl-meter__cap {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bq-faint);
}

.bq-hl-meter__mult {
  display: block;
  font-family: var(--bq-font-display);
  font-size: clamp(26px, 4.6cqi, 40px);
  font-weight: 900;
  line-height: 1.05;
  color: var(--bq-gold);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(255, 207, 90, 0.35);
  transform-origin: right center;
}

.bq-hl-meter__worth {
  font-size: 13px;
  font-weight: 700;
  color: var(--bq-muted);
  font-variant-numeric: tabular-nums;
}

.bq-hl.is-bust .bq-hl-meter__mult { color: var(--bq-coral); text-shadow: none; }
.bq-hl.is-done .bq-hl-meter__mult { color: var(--bq-mint); text-shadow: 0 0 18px rgba(95, 227, 181, 0.35); }

/* ---- play area: pile | card | calls */
.bq-hl-play {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(14px, 4cqi, 44px);
}

.bq-hl-pile {
  position: relative;
  justify-self: end;
  width: calc(var(--hl-card-w) * 0.62);
  aspect-ratio: 5 / 7;
}

.bq-hl-pile .bq-hl-card { position: absolute; inset: 0; width: 100%; }
.bq-hl-pile .bq-hl-card:nth-child(1) { transform: translate(-6px, 6px) rotate(-4deg); }
.bq-hl-pile .bq-hl-card:nth-child(2) { transform: translate(-3px, 3px) rotate(-2deg); }
.bq-hl-pile .bq-hl-card:nth-child(3) { transform: translate(-1px, 1px) rotate(-1deg); }

.bq-hl-pile__count {
  position: absolute;
  left: 50%;
  top: calc(100% + 12px);
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--bq-muted);
  font-variant-numeric: tabular-nums;
}

.bq-hl-slot {
  position: relative;
  width: var(--hl-card-w);
  aspect-ratio: 5 / 7;
}

.bq-hl-slot::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 18px;
  border: 1.5px dashed rgba(255, 207, 90, 0.28);
}

.bq-hl-slot::after {
  content: "";
  position: absolute;
  inset: -40px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 196, 120, 0.22), transparent);
}

/* ---- cards */
.bq-hl-card {
  position: relative;
  width: var(--hl-card-w);
  aspect-ratio: 5 / 7;
  perspective: 900px;
}

.bq-hl-card__in {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 420ms var(--bq-ease-out);
}

.bq-hl-card[data-up="0"] .bq-hl-card__in { transform: rotateY(180deg); }

.bq-hl-card__face,
.bq-hl-card__back {
  position: absolute;
  inset: 0;
  border-radius: 9% / 6.4%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.5) inset, 0 10px 24px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.35);
}

.bq-hl-card__face {
  background: linear-gradient(160deg, #fffdf7 0%, #f6efe0 60%, #ede2cb 100%);
}

.bq-hl-card__face::after {
  content: "";
  position: absolute;
  inset: 3.5%;
  border-radius: 7% / 5%;
  border: 1px solid rgba(185, 138, 51, 0.35);
  pointer-events: none;
}

.bq-hl-art { width: 100%; height: 100%; }

.bq-hl-card__back {
  transform: rotateY(180deg);
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 207, 90, 0.9) 0 7%, transparent 7.5%),
    radial-gradient(circle at 50% 50%, transparent 0 13%, rgba(255, 207, 90, 0.55) 13.5% 15%, transparent 15.5%),
    repeating-linear-gradient(45deg, rgba(255, 123, 92, 0.32) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(-45deg, rgba(255, 207, 90, 0.22) 0 2px, transparent 2px 12px),
    linear-gradient(160deg, #135561, #0a2f38);
  border: 4px solid #f3ead6;
  outline: 1px solid rgba(185, 138, 51, 0.6);
  outline-offset: -9px;
}

.bq-hl-card.is-hit .bq-hl-card__face {
  box-shadow: 0 0 0 3px var(--bq-gold), 0 0 34px rgba(255, 207, 90, 0.55), 0 10px 24px rgba(0, 0, 0, 0.45);
}

.bq-hl-card.is-miss .bq-hl-card__face {
  box-shadow: 0 0 0 3px var(--bq-coral), 0 0 30px rgba(255, 123, 92, 0.5), 0 10px 24px rgba(0, 0, 0, 0.45);
}

.bq-hl-card.is-miss { animation: bq-hl-nudge 360ms var(--bq-ease-out) 380ms; }

@keyframes bq-hl-nudge {
  0%, 100% { transform: none; }
  25% { transform: translateX(-7px) rotate(-1.5deg); }
  60% { transform: translateX(5px) rotate(1deg); }
}

/* ---- calls */
.bq-hl-calls {
  display: grid;
  gap: var(--bq-s2);
  justify-self: start;
  width: min(250px, 100%);
}

.bq-hl-call {
  --c-tone: var(--bq-mint);
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: var(--bq-s3);
  min-height: 64px;
  padding: var(--bq-s2) var(--bq-s4) var(--bq-s2) var(--bq-s2);
  border: 1px solid color-mix(in srgb, var(--c-tone) 45%, transparent);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(0, 0, 0, 0.18)), rgba(3, 16, 20, 0.6);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 6px 16px rgba(0, 0, 0, 0.3);
  text-align: left;
  transition: transform var(--bq-fast) var(--bq-ease-out), background-color var(--bq-fast) var(--bq-ease-out),
    box-shadow var(--bq-med) var(--bq-ease-out), opacity var(--bq-fast) var(--bq-ease-out);
}

.bq-hl-call--same { --c-tone: var(--bq-gold); min-height: 52px; }
.bq-hl-call--lower { --c-tone: var(--bq-coral); }

.bq-hl-call:not(:disabled):hover {
  background-color: color-mix(in srgb, var(--c-tone) 14%, transparent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 0 22px color-mix(in srgb, var(--c-tone) 35%, transparent);
}

.bq-hl-call:not(:disabled):active { transform: scale(0.97); }
.bq-hl-call:disabled { opacity: 0.38; cursor: not-allowed; }

.bq-hl-call__mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c-tone) 70%, white), var(--c-tone) 60%, color-mix(in srgb, var(--c-tone) 60%, black));
  color: #08201c;
  font-size: 22px;
  font-weight: 900;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.2), 0 3px 8px rgba(0, 0, 0, 0.35);
}

.bq-hl-call--same .bq-hl-call__mark { width: 36px; height: 36px; font-size: 19px; justify-self: center; }

.bq-hl-call__txt {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: var(--bq-s2);
}

.bq-hl-call__name {
  font-family: var(--bq-font-display);
  font-size: 16px;
  font-weight: 800;
}

.bq-hl-call__odds {
  font-family: var(--bq-font-display);
  font-size: 19px;
  font-weight: 900;
  color: var(--c-tone);
  font-variant-numeric: tabular-nums;
}

.bq-hl-call__hint {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--bq-faint);
  font-variant-numeric: tabular-nums;
}

/* ---- printed felt legend */
.bq-hl-felt {
  margin: clamp(26px, 4cqi, 40px) 0 0;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(11px, 1.5cqi, 13px);
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 214, 140, 0.55);
}

.bq-hl-felt::before,
.bq-hl-felt::after {
  content: "";
  display: inline-block;
  width: clamp(18px, 5cqi, 56px);
  height: 1px;
  margin: 0 12px;
  vertical-align: middle;
  background: linear-gradient(90deg, transparent, rgba(255, 214, 140, 0.5), transparent);
}

/* ---- trail of the round */
.bq-hl-trailwrap {
  margin-top: var(--bq-s3);
  padding: var(--bq-s3) var(--bq-s4);
  border-radius: var(--bq-r);
  background: rgba(2, 12, 15, 0.42);
  border: 1px solid rgba(173, 232, 220, 0.1);
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: var(--bq-s4);
  min-height: calc(var(--hl-mini-w) * 1.4 + 26px);
}

.bq-hl-trail__cap {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--bq-faint);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.bq-hl-trail {
  display: flex;
  gap: var(--bq-s2);
  margin: 0;
  padding: 4px 2px 6px;
  list-style: none;
  overflow-x: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

.bq-hl-trail:empty::before {
  content: attr(data-empty);
  align-self: center;
  font-size: 13px;
  color: var(--bq-faint);
}

.bq-hl-step { position: relative; flex: none; }
.bq-hl-card--mini { width: var(--hl-mini-w); }
.bq-hl-card--mini .bq-hl-card__face { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); }
.bq-hl-step--skip .bq-hl-card--mini { opacity: 0.5; }

.bq-hl-step__tag {
  position: absolute;
  right: -6px;
  bottom: -6px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  color: #082019;
  background: var(--bq-mint);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.bq-hl-step--bad .bq-hl-step__tag { background: var(--bq-coral); color: var(--bq-on-coral); }
.bq-hl-step--skip .bq-hl-step__tag { background: var(--bq-raise); color: var(--bq-muted); }
.bq-hl-step--end .bq-hl-step__tag { background: var(--bq-gold); color: var(--bq-on-gold); }

/* ---- narrow tables (phones) */
@container (max-width: 600px) {
  .bq-hl { --hl-card-w: clamp(104px, 34cqi, 150px); }
  .bq-hl-play {
    grid-template-columns: auto auto;
    grid-template-areas: "pile slot" "calls calls";
    justify-content: center;
    row-gap: 26px;
  }
  .bq-hl-pile { grid-area: pile; width: calc(var(--hl-card-w) * 0.5); align-self: center; }
  .bq-hl-slot { grid-area: slot; }
  .bq-hl-calls {
    grid-area: calls;
    grid-template-columns: 1fr 0.8fr 1fr;
    width: 100%;
    justify-self: stretch;
  }
  .bq-hl-call {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
    gap: 4px;
    min-height: 0;
    padding: var(--bq-s2) var(--bq-s1);
  }
  .bq-hl-call--same .bq-hl-call__mark,
  .bq-hl-call__mark { width: 34px; height: 34px; font-size: 18px; }
  .bq-hl-call__txt { grid-template-columns: 1fr; justify-items: center; }
  .bq-hl-call__name { font-size: 14px; }
  .bq-hl-call__odds { font-size: 17px; }
  .bq-hl-call__hint { font-size: 11px; }
  .bq-hl-head { align-items: center; gap: var(--bq-s2); }
  .bq-hl-title__name { font-size: 17px; white-space: nowrap; }
  .bq-hl-meter { min-width: 0; padding: 6px var(--bq-s3); }
  .bq-hl-meter__cap { font-size: 10px; }
  .bq-hl-meter__worth { font-size: 12px; white-space: nowrap; }
  .bq-hl-title__sub { display: none; }
  .bq-hl-felt { letter-spacing: 0.08em; }
  .bq-hl-felt::before,
  .bq-hl-felt::after { display: none; }
}

@container (max-width: 400px) {
  .bq-hl-head { flex-direction: column; align-items: stretch; }
  .bq-hl-title { justify-items: center; }
  .bq-hl-meter {
    grid-template-columns: auto 1fr;
    align-items: baseline;
    justify-items: start;
    column-gap: var(--bq-s2);
  }
  .bq-hl-meter__cap { display: none; }
  .bq-hl-meter__mult { font-size: 24px; }
  .bq-hl-meter__worth { justify-self: end; }
}

@media (prefers-reduced-motion: reduce) {
  .bq-hl-card__in { transition-duration: 1ms; }
  .bq-hl-card.is-miss { animation: none; }
  .bq-hl-trail { scroll-behavior: auto; }
}
