/* =====================================================================
   Bite - fixed "risograph field guide" theme.
   Cream specimen cards on a dark bench, printed in two inks: a soft black
   and a tomato spot. Every animal is a flat silhouette with knocked-out
   eyes, like a field guide plate. Shared base.css is loaded (back chip +
   reset) but glass.css deliberately is not: the c-* chrome is reprinted
   here in paper and ink.
   ===================================================================== */

:root {
  --bench-hi: #2b3730;
  --bench: #1c2621;
  --bench-lo: #111815;

  --paper-hi: #fcf7ea;
  --paper: #f3ecdb;
  --paper-lo: #e2d7c1;

  --ink: #20261f;
  --ink-soft: #5f6455;
  --rule: #b3a88f;

  --spot: #c2542c;
  --gold: #d8b258;

  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;

  /* One card wide. Grows with the window, but the vh term caps it so the
     two hands, the clash and the bar all fit one screen with no scroll. */
  --u: clamp(36px, min(12vw, calc((100dvh - 208px) / 4.6)), 106px);
}

/* ---------- The bench ---------- */
body.bt-page {
  margin: 0;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-color: var(--bench);
  background-image:
    /* specimen grid, printed on the bench */
    repeating-linear-gradient(90deg, rgba(243, 236, 220, .035) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(0deg, rgba(243, 236, 220, .035) 0 1px, transparent 1px 46px),
    radial-gradient(120% 80% at 50% -12%, rgba(243, 236, 220, .10), transparent 58%),
    radial-gradient(95% 72% at 50% 116%, rgba(0, 0, 0, .55), transparent 66%),
    linear-gradient(180deg, var(--bench-hi), var(--bench) 58%, var(--bench-lo));
  background-attachment: fixed;
}
body.bt-page *,
body.bt-page *::before,
body.bt-page *::after { box-sizing: border-box; }

.bt-app {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- Top bar: a pasted specimen label ---------- */
.c-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 9px clamp(10px, 2.6vw, 22px) 10px;
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgba(120, 108, 84, .05) 0 1px, transparent 1px 5px),
    linear-gradient(180deg, var(--paper-hi), var(--paper) 62%, var(--paper-lo));
  border-bottom: 2px solid rgba(12, 18, 14, .55);
  box-shadow: 0 8px 20px rgba(6, 10, 8, .5), inset 0 1px 0 rgba(255, 255, 255, .8);
  z-index: 5;
}
/* the printed rule under the label */
.c-bar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 3px;
  border-bottom: 1px solid rgba(32, 38, 31, .28);
  pointer-events: none;
}

.c-bar__brand { display: flex; align-items: center; gap: 8px; }
.c-bar__brand svg { display: block; }
.c-bar__title {
  margin: 0;
  font-size: clamp(19px, 2.8vw, 25px);
  font-weight: 800;
  letter-spacing: -.02em;
  color: #1b2119;
}
.c-bar__stats { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stat {
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.stat b {
  margin-left: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.c-bar__controls { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* Buttons read as small printed tabs with a hard bottom edge. */
.c-btn {
  appearance: none;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  letter-spacing: .02em;
  padding: 6px 11px;
  border-radius: 3px;
  color: #23291f;
  background: linear-gradient(180deg, #fffaee, #e9dfc9);
  border: 1px solid rgba(70, 76, 62, .45);
  box-shadow: 0 2px 0 rgba(60, 66, 52, .3), 0 4px 10px rgba(6, 10, 8, .2);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease, filter .12s ease;
}
.c-btn:hover { filter: brightness(1.04); }
.c-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(60, 66, 52, .3); }
.c-btn:focus-visible { outline: 2px solid var(--spot); outline-offset: 2px; }
.c-btn--primary {
  color: #fdf6e7;
  background: linear-gradient(180deg, #c2542c, #983d1f);
  border-color: #7d3116;
  box-shadow: 0 2px 0 #6c2a12, 0 4px 12px rgba(30, 8, 2, .4);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .28);
}

/* ---------- The table ---------- */
.bt-table {
  flex: 1 1 auto;
  min-height: 0;
  width: min(100%, calc(var(--u) * 13));
  margin: 0 auto;
  /* the bottom margin keeps the fixed Game Center chip clear of the last row
     of clickable cards at every width */
  padding: clamp(6px, 1.4vh, 14px) clamp(8px, 2vw, 20px) 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  overflow: hidden;
}

/* ---------- Seats ---------- */
.bt-seat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bt-seat__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: 16px;
  padding: 0 2px;
}
.bt-seat__tag {
  font-size: max(9px, calc(var(--u) * .075));
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(243, 236, 220, .52);
}
.bt-seat__score {
  font-family: var(--font-mono);
  font-size: max(13px, calc(var(--u) * .12));
  font-weight: 700;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}
.bt-seat__score small { font-size: .76em; font-weight: 600; opacity: .5; }
.bt-seat__score.is-lead { color: var(--gold); }
.bt-seat__foot {
  margin-left: 8px;
  font-size: max(10px, calc(var(--u) * .082));
  color: rgba(243, 236, 220, .42);
  white-space: nowrap;
}

.bt-tray {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: max(2px, calc(var(--u) * .045));
  min-height: calc(var(--u) * 1.42);
}
/* the rival's hand, face up but not playable */
.bt-open { display: block; cursor: default; }
.bt-tray__label { display: none; }

/* ---------- The card ---------- */
.bt-card {
  --w: var(--u);
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--w);
  height: calc(var(--w) * 1.42);
  padding: calc(var(--w) * .05);
  container-type: inline-size;
  border-radius: 3px;
  color: var(--ink);
  background:
    repeating-linear-gradient(45deg, rgba(160, 144, 110, .045) 0 2px, transparent 2px 4px),
    linear-gradient(170deg, var(--paper-hi), var(--paper) 62%, var(--paper-lo));
  box-shadow:
    inset 0 0 0 1px rgba(32, 38, 31, .22),
    0 0 0 1px rgba(8, 12, 10, .45),
    0 calc(var(--w) * .05) calc(var(--w) * .1) rgba(0, 0, 0, .38);
  overflow: hidden;
  text-align: left;
}
/* the plate rule, a hairline inside the card edge */
.bt-card::after {
  content: "";
  position: absolute;
  inset: calc(var(--w) * .018);
  border: 1px solid rgba(32, 38, 31, .14);
  border-radius: 2px;
  pointer-events: none;
}

.bt-card__num {
  font-family: var(--font-mono);
  font-size: calc(var(--w) * .28);
  font-weight: 700;
  line-height: .9;
  letter-spacing: -.04em;
  color: var(--sp, var(--ink));
}
.bt-card__art {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--w) * .02) 0;
}
.bt-card__art svg { display: block; width: 86%; height: 100%; max-height: calc(var(--w) * .74); }
.bt-card__name {
  font-size: calc(var(--w) * .115);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  line-height: 1.1;
  color: var(--ink);
}
/* the badge: the one animal this card beats. The caption gets its own line,
   because "beats" plus "Hedgehog" never fits across a card this narrow. */
.bt-card__beats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: calc(var(--w) * .03);
  margin-top: calc(var(--w) * .045);
  padding: calc(var(--w) * .03) calc(var(--w) * .04) calc(var(--w) * .035);
  border-radius: 2px;
  border: 1px solid color-mix(in srgb, var(--sp, #20261f) 55%, transparent);
  background: color-mix(in srgb, var(--sp, #20261f) 9%, transparent);
  font-size: calc(var(--w) * .105);
  font-weight: 650;
  letter-spacing: .01em;
  line-height: 1;
  text-align: center;
  color: var(--sp, var(--ink));
}
.bt-card__beats svg { flex: none; width: calc(var(--w) * .16); height: calc(var(--w) * .16); display: block; }
.bt-card__beats b { font-weight: 750; white-space: nowrap; }
.bt-card__beats em {
  /* the caption takes the first line, so the icon and the name share the
     second one and stay centred together */
  order: -1;
  flex: 0 0 100%;
  font-style: normal;
  font-size: calc(var(--w) * .072);
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .6;
}
/* knocked-out eyes and muzzles print in the paper colour */
.bt-card .knock { fill: var(--paper-hi); }

/* When the card itself is narrow the label no longer fits, so the badge keeps
   only its colour-coded silhouette. This is queried against the card, not the
   viewport, because --u follows the window's height as well as its width. */
@container (max-width: 72px) {
  .bt-card__beats em,
  .bt-card__beats b { display: none; }
  .bt-card__beats { padding: 0; border: 0; background: none; }
  .bt-card__beats svg { width: 42%; height: auto; }
}

/* ---------- Face-down card ---------- */
.bt-back {
  --w: calc(var(--u) * .58);
  position: relative;
  display: block;
  width: var(--w);
  height: calc(var(--w) * 1.42);
  border-radius: 2px;
  background:
    repeating-linear-gradient(45deg, rgba(32, 38, 31, .1) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(-45deg, rgba(32, 38, 31, .06) 0 1px, transparent 1px 6px),
    linear-gradient(170deg, var(--paper), var(--paper-lo));
  box-shadow:
    inset 0 0 0 1px rgba(32, 38, 31, .3),
    0 2px 5px rgba(0, 0, 0, .35);
}
.bt-back::after {
  content: "";
  position: absolute;
  inset: 28%;
  border: 1px solid rgba(32, 38, 31, .26);
  border-radius: 50%;
}

/* ---------- Hand cards are buttons ---------- */
.bt-pick {
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  border-radius: 3px;
  transition: transform .14s ease, filter .14s ease;
}
.bt-pick:hover:not(:disabled),
.bt-pick:focus-visible:not(:disabled) {
  transform: translateY(calc(var(--u) * -.09));
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .45));
}
.bt-pick:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.bt-pick:active:not(:disabled) { transform: translateY(calc(var(--u) * -.02)); }
.bt-pick:disabled { cursor: default; }
/* the card you have committed, and the rest of a spent hand */
.bt-pick.is-picked { transform: translateY(calc(var(--u) * -.1)); }
.bt-pick.is-picked .bt-card { opacity: .45; box-shadow: inset 0 0 0 1px rgba(32, 38, 31, .3), 0 0 0 2px var(--gold); }
.bt-pick.is-locked { opacity: .4; }

/* ---------- The clash ---------- */
.bt-clash {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: max(4px, calc(var(--u) * .05));
}
.bt-slots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 3vw, 28px);
}
.bt-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: calc(var(--u) * .94);
  height: calc(var(--u) * 1.34);
  border-radius: 3px;
  border: 1px dashed rgba(243, 236, 220, .18);
  background: rgba(0, 0, 0, .12);
}
.bt-slot.is-live { border-style: solid; border-color: rgba(243, 236, 220, .3); }
.bt-slot .bt-card,
.bt-slot .bt-back { --w: calc(var(--u) * .94); }
.bt-versus {
  font-size: max(14px, calc(var(--u) * .2));
  line-height: 1;
  color: rgba(243, 236, 220, .3);
}
/* the winning side gets a printed ring, the loser fades back */
.bt-slot.is-win { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(216, 178, 88, .35); }
.bt-slot.is-lose .bt-card { opacity: .45; filter: grayscale(.55); }
.bt-slot.is-tie .bt-card { opacity: .62; }

.bt-verdict {
  margin: 0;
  min-height: 2.5em;
  max-width: 46ch;
  text-align: center;
  font-size: max(11.5px, calc(var(--u) * .115));
  line-height: 1.35;
  color: rgba(243, 236, 220, .78);
}
.bt-verdict b { color: var(--paper); font-weight: 700; }
.bt-verdict .is-you { color: #f0c98a; }
.bt-verdict .is-them { color: #e8a08a; }
.bt-verdict.is-flash { animation: btFlash .4s ease; }

/* the floating score that lifts off a winning card */
.bt-pop {
  position: absolute;
  left: 50%;
  top: -6%;
  padding: 1px 6px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: var(--gold);
  color: #2b2110;
  font-family: var(--font-mono);
  font-size: max(10px, calc(var(--u) * .1));
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .45);
  animation: btPop .9s ease-out both;
  pointer-events: none;
}

/* ---------- Modals ---------- */
/* The overlay scrolls, never the card: no inner scrollbar gutter on Windows.
   Above .gc-back (400) so the back chip cannot sit over the backdrop. */
.c-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.c-modal[hidden] { display: none; }
.c-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 10, .68);
  cursor: pointer;
}
.c-modal__panel {
  position: relative;
  z-index: 1;
  margin: auto;
  width: min(94vw, 520px);
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgba(120, 108, 84, .05) 0 1px, transparent 1px 5px),
    linear-gradient(175deg, var(--paper-hi), var(--paper) 55%, var(--paper-lo));
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 1px rgba(32, 38, 31, .3),
    0 30px 70px rgba(0, 0, 0, .58);
  animation: btSheet .24s ease-out both;
}
.bt-rules { width: min(94vw, 600px); }
.c-modal__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(32, 38, 31, .2);
}
.c-modal__head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #1c2219;
}
.c-modal__x {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  border: 1px solid rgba(70, 76, 62, .45);
  background: linear-gradient(180deg, #fffaee, #e9dfc9);
  color: #3c4234;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.c-modal__x:hover { filter: brightness(1.03); }
.c-modal__x[hidden] { display: none; }
.c-modal__body { padding: 12px 20px 4px; font-size: 13px; line-height: 1.55; color: #3d4236; }
.c-modal__body h3 {
  margin: 14px 0 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(60, 66, 54, .62);
}
.c-modal__body ul { margin: 0 0 8px; padding-left: 16px; }
.c-modal__body li { margin-bottom: 4px; }
.c-modal__body li::marker { color: rgba(194, 84, 44, .7); }
.c-modal__body b { color: #1e2419; }
.c-modal__body kbd {
  padding: 0 4px;
  border-radius: 2px;
  border: 1px solid rgba(70, 76, 62, .4);
  background: rgba(255, 255, 255, .55);
  font-family: var(--font-mono);
  font-size: 11px;
}
.c-modal__lead { margin: 0 0 10px; font-size: 13px; }
.c-modal__note {
  margin: 12px 0 2px;
  font-size: 11px;
  color: rgba(60, 66, 54, .74);
}
.c-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 18px 14px;
}
/* the five-animal loop, printed as a chain */
.bt-loop {
  margin: 4px 0 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .01em;
  color: #2b3327;
}
.bt-loop span { color: var(--spot); opacity: .8; padding: 0 2px; }

/* ---------- Flow contents ---------- */
.bt-flow-lead { margin: 0 0 12px; font-size: 13px; }
.bt-end { text-align: center; padding: 4px 0 2px; }
.bt-end__big {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #1f251b;
}
.bt-end__sub { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-soft); }
.bt-end__stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.bt-end__stat {
  min-width: 88px;
  padding: 7px 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .45);
  border: 1px solid rgba(32, 38, 31, .18);
}
.bt-end__stat b { display: block; font-family: var(--font-mono); font-size: 17px; line-height: 1.2; }
.bt-end__stat span { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }

/* ---------- Toast ---------- */
.c-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 560;
  padding: 8px 16px;
  transform: translateX(-50%);
  border-radius: 3px;
  background: linear-gradient(180deg, var(--paper-hi), var(--paper-lo));
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: 0 0 0 1px rgba(32, 38, 31, .35), 0 12px 26px rgba(0, 0, 0, .45);
  animation: btToast .22s ease-out both;
}
.c-toast[hidden] { display: none; }

/* ---------- Motion ---------- */
@keyframes btSheet {
  from { opacity: 0; transform: translateY(10px); }
}
@keyframes btToast {
  from { opacity: 0; transform: translate(-50%, 10px); }
}
@keyframes btFlash {
  0% { transform: scale(1); }
  40% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes btPop {
  0% { opacity: 0; transform: translate(-50%, 6px) scale(.8); }
  22% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -22px) scale(1); }
}
@keyframes btFlip {
  from { opacity: .2; transform: rotateY(85deg) scale(.94); }
}

/* Cards flip in the clash as they are turned over. The hand itself does not
   animate on re-render: the table is rebuilt on every state change. */
.bt-slot.is-flip .bt-card { animation: btFlip .3s cubic-bezier(.2, .8, .3, 1.04) both; }

/* ---------- Responsive ---------- */
/* On a phone the card's name has no room left beside the shipped stats; the
   badge itself is already handled by the container query above. */
@media (max-width: 560px) {
  .stat:nth-child(2) { display: none; }
  .bt-card__name { display: none; }
}

@media (max-width: 470px) {
  .c-bar { gap: 8px; padding: 7px 9px 8px; }
  .c-bar__title { font-size: 18px; }
  .c-bar__stats { gap: 9px; }
  .stat { font-size: 9.5px; letter-spacing: .1em; }
  .c-bar__controls { gap: 4px; }
  .c-btn { padding: 5px 8px; font-size: 11px; }
  .c-modal__body { padding: 10px 14px 4px; }
  .c-modal__head { padding: 12px 14px 9px; }
  .c-modal__foot { padding: 8px 14px 12px; }
  .bt-seat__foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bt-pick,
  .bt-slot.is-flip .bt-card,
  .c-modal__panel,
  .c-toast { animation: none; transition: none; }
  .bt-verdict.is-flash { animation: none; }
  .bt-pick:hover:not(:disabled),
  .bt-pick:focus-visible:not(:disabled) { transform: none; }
}
