/* KNUCKLEBONES — room styles. Every rule scoped under #screen-bones. */

#screen-bones .kb-room {
  max-width: 30rem;
  margin: 0 auto;
  padding: 0.4rem 0.4rem 2rem;
  position: relative;
}

/* ---------- head / the Fingerless Man ---------- */
#screen-bones .kb-head { margin-bottom: 0.3rem; }
#screen-bones .kb-head .label { font-size: 0.8rem; letter-spacing: 0.34em; }
#screen-bones .kb-man {
  min-height: 2.1rem;
  margin: 0.25rem auto 0;
  max-width: 24rem;
  font-size: 0.86rem;
  color: var(--bone);
  transition: opacity 0.3s ease;
}

/* ---------- HUD ---------- */
#screen-bones .kb-hud {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.3rem 0 0.5rem;
  border-bottom: 1px dashed rgba(216, 180, 90, 0.18);
  margin-bottom: 0.6rem;
}
#screen-bones .kb-felt-coins { font-size: 1.15rem; }
#screen-bones .kb-bank-coins { font-size: 1.15rem; color: var(--bone); }
#screen-bones .kb-flag { color: var(--gold-dim); width: 100%; }

/* the rack — twenty notches, burnt as they go */
#screen-bones .kb-rack { display: flex; gap: 2px; align-items: center; }
#screen-bones .kb-notch {
  width: 4px;
  height: 13px;
  background: linear-gradient(#bfa05a, #6e552f);
  border-radius: 1px;
  opacity: 0.85;
  transition: opacity 0.4s, background 0.4s;
}
#screen-bones .kb-notch.spent { background: #1d1812; opacity: 0.55; }

/* the wall tally — strokes in dried blood */
#screen-bones .kb-tally { display: flex; gap: 5px; align-items: center; }
#screen-bones .kb-stroke {
  width: 5px;
  height: 18px;
  border-radius: 2px;
  background: rgba(122, 24, 18, 0.16);
  box-shadow: inset 0 0 0 1px rgba(122, 24, 18, 0.18);
  transform: rotate(8deg);
  transition: background 0.5s, box-shadow 0.5s;
}
#screen-bones .kb-stroke.drawn {
  background: linear-gradient(#8c241c, #5d130e 70%, #470d09);
  box-shadow:
    0 0 8px rgba(140, 36, 28, 0.55),
    inset 0 -3px 4px rgba(20, 2, 1, 0.8);
  animation: kb-stroke-drag 0.7s ease-out;
}
@keyframes kb-stroke-drag {
  0% { height: 2px; filter: brightness(1.7); }
  100% { height: 18px; filter: none; }
}

/* the table dims as the count climbs — the room knows */
#screen-bones .kb-feltwrap { transition: filter 1.2s ease; }
#screen-bones .kb-room[data-skulls='1'] .kb-feltwrap { filter: brightness(0.9); }
#screen-bones .kb-room[data-skulls='2'] .kb-feltwrap {
  filter: brightness(0.78) saturate(1.15) sepia(0.12) hue-rotate(-12deg);
}
#screen-bones .kb-room[data-skulls='3'] .kb-feltwrap {
  filter: brightness(0.6) saturate(1.3) sepia(0.2) hue-rotate(-18deg);
}

/* ---------- coach ---------- */
#screen-bones .kb-coach {
  margin: 0 auto 0.5rem;
  max-width: 24rem;
  font-style: italic;
  font-size: 0.82rem;
  color: var(--gold-dim);
}

/* ---------- the felt ---------- */
#screen-bones .kb-feltwrap {
  position: relative;
  width: min(100%, 560px);
  margin: 0 auto;
}
#screen-bones .kb-canvas {
  display: block;
  margin: 0 auto;
  border: 1px solid #2a2118;
  border-radius: 4px;
  box-shadow:
    inset 0 0 0 2px rgba(0, 0, 0, 0.7),
    0 14px 44px rgba(0, 0, 0, 0.8),
    0 0 0 4px #120d08,
    0 0 0 5px #2c2010;
  touch-action: none; /* the felt IS the throw surface — a straight-up drag must never become a page scroll (scroll lives outside the felt) */
  cursor: grab;
}
#screen-bones .kb-canvas:active { cursor: grabbing; }

/* the wobble — words under the dark; twins of the sound */
#screen-bones .kb-wobble {
  position: absolute;
  top: 22px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  font-style: italic;
  font-size: 0.78rem;
  color: rgba(207, 201, 184, 0.62);
  text-shadow: 0 1px 3px #000;
}
#screen-bones .kb-keen-words {
  display: block;
  color: #c0564c;
  animation: kb-keen-flicker 1.7s ease-in-out infinite;
}
@keyframes kb-keen-flicker {
  0%, 100% { opacity: 0.55; }
  18% { opacity: 1; }
  22% { opacity: 0.4; }
  60% { opacity: 0.9; }
}
#screen-bones .kb-wobble.keening .kb-wobble-words { color: rgba(207, 201, 184, 0.45); }

/* ---------- toast ---------- */
#screen-bones .kb-toast {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, 0) scale(0.94);
  background: rgba(8, 7, 4, 0.92);
  border: 1px solid #4a3d22;
  border-radius: 3px;
  color: var(--bone);
  padding: 0.5rem 0.85rem;
  font-size: 0.86rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 5;
}
#screen-bones .kb-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
#screen-bones .kb-toast[data-kind='win'] { color: var(--gold); border-color: var(--gold-dim); }
#screen-bones .kb-toast[data-kind='bank'] { color: var(--gold); border-color: var(--gold-dim); }
#screen-bones .kb-toast[data-kind='lose'] { color: #c98e86; border-color: #5e3a35; }
#screen-bones .kb-toast[data-kind='skull'] {
  color: #d4837d;
  border-color: var(--red);
  box-shadow: 0 0 22px rgba(168, 54, 46, 0.45);
  letter-spacing: 0.06em;
}

/* the hold — a stack standing on the felt's edge */
#screen-bones .kb-holdstack {
  position: absolute;
  right: 10px;
  bottom: 14px;
  width: 26px;
  height: 76px;
  pointer-events: none;
}
#screen-bones .kb-holdchip {
  position: absolute;
  left: 2px;
  width: 22px;
  height: 8px;
  border-radius: 50% / 42%;
  background: radial-gradient(circle at 35% 30%, #d8b45a, #6e552f 75%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 240, 200, 0.5);
  animation: kb-chip-land 0.3s ease-out;
}
@keyframes kb-chip-land {
  0% { transform: translateY(-14px); opacity: 0; }
  100% { transform: none; opacity: 1; }
}
#screen-bones .kb-holdmult {
  position: absolute;
  top: -14px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.74rem;
  color: var(--gold);
  text-shadow: 0 0 8px rgba(216, 180, 90, 0.6);
}

/* ---------- the lines ---------- */
#screen-bones .kb-lines {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin: 0.7rem auto 0;
  width: min(100%, 380px);
}
#screen-bones .kb-linebtn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.12rem;
  min-height: 64px;
  padding: 0.45rem 0.2rem 0.4rem;
  font-family: inherit;
  cursor: pointer;
  background: #0b0f12;
  color: var(--bone);
  border: 1px solid #3a3322;
  border-radius: 3px;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}
#screen-bones .kb-linebtn .kb-line-name { font-size: 0.66rem; letter-spacing: 0.18em; color: var(--bone); }
#screen-bones .kb-linebtn .kb-line-terms { font-size: 0.92rem; color: var(--gold); letter-spacing: 0.08em; }
#screen-bones .kb-linebtn .kb-line-band { font-size: 0.62rem; }
#screen-bones .kb-linebtn.picked {
  border-color: var(--gold);
  background: #10151a;
  box-shadow: 0 0 14px rgba(216, 180, 90, 0.25), inset 0 0 10px rgba(216, 180, 90, 0.08);
}
#screen-bones .kb-linebtn[data-line='deep'] .kb-line-terms { color: #c0564c; }
#screen-bones .kb-linebtn[data-line='deep'].picked {
  border-color: var(--red);
  box-shadow: 0 0 14px rgba(168, 54, 46, 0.3), inset 0 0 10px rgba(168, 54, 46, 0.08);
}
#screen-bones .kb-linebtn:disabled { opacity: 0.55; cursor: default; }

/* ---------- the stakes + the pocket ---------- */
#screen-bones .kb-stakes {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 0.5rem;
  margin: 0.55rem auto 0;
  width: min(100%, 380px);
}
#screen-bones .kb-chipbtns { display: flex; gap: 0.45rem; }
#screen-bones .kb-chipbtn {
  min-width: 52px;
  min-height: 48px;
  font-family: inherit;
  font-size: 1rem;
  cursor: pointer;
  background: #0d1014;
  color: var(--bone);
  border: 1px solid #4a3d22;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}
#screen-bones .kb-chipbtn .kb-chipface { color: var(--gold-dim); font-size: 0.85rem; }
#screen-bones .kb-chipbtn.picked {
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 12px rgba(216, 180, 90, 0.25);
}
#screen-bones .kb-chipbtn.picked .kb-chipface { color: var(--gold); }
#screen-bones .kb-chipbtn:disabled { color: #5a5346; cursor: default; box-shadow: none; }
#screen-bones .kb-bankbtn {
  flex: 1 1 auto;
  min-height: 48px;
  font-family: inherit;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  cursor: pointer;
  background: #0f130d;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  border-radius: 3px;
  transition: box-shadow 0.25s, border-color 0.25s, opacity 0.25s;
}
#screen-bones .kb-bankbtn:not(:disabled):hover { box-shadow: 0 0 14px rgba(216, 180, 90, 0.3); }
#screen-bones .kb-bankbtn:disabled { opacity: 0.45; cursor: default; }
#screen-bones .kb-bankbtn.urge {
  border-color: var(--red);
  color: #d4837d;
  animation: kb-urge 1.1s ease-in-out infinite;
}
@keyframes kb-urge {
  0%, 100% { box-shadow: 0 0 4px rgba(168, 54, 46, 0.2); }
  50% { box-shadow: 0 0 18px rgba(168, 54, 46, 0.55); }
}

/* ---------- footer ---------- */
#screen-bones .kb-footer {
  display: flex;
  justify-content: center;
  gap: 1.2rem;
  margin-top: 0.6rem;
}

/* ---------- explainer (the vestibule) ---------- */
#screen-bones .kb-explainer {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 5, 6, 0.94);
  overflow-y: auto;
  padding: 1.6rem 0.8rem 2.4rem;
  text-align: center;
}
#screen-bones .kb-explainer-house {
  font-style: italic;
  color: var(--bone);
  max-width: 26rem;
  margin: 1.2rem auto 1rem;
}
#screen-bones .kb-dismiss { min-height: 48px; letter-spacing: 0.2em; }
#screen-bones .kb-howto {
  text-align: left;
  margin: 0.2rem 0 0;
  padding-left: 1.1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--bone);
}
#screen-bones .kb-howto li { margin-bottom: 0.45rem; }
#screen-bones .kb-howto b { color: var(--gold); font-weight: 600; }

/* placard demos */
#screen-bones .kb-demo {
  position: relative;
  height: 74px;
  margin: 0 auto 0.7rem;
  width: 150px;
}
/* II — the lines: three chalk arcs, a die that hops between them */
#screen-bones .kb-demo-lines .kb-demo-arc {
  position: absolute;
  left: 8px;
  right: 8px;
  border-top: 1px dashed rgba(207, 201, 184, 0.5);
  border-radius: 50% 50% 0 0 / 18px 18px 0 0;
  height: 16px;
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  color: rgba(207, 201, 184, 0.6);
  padding-top: 1px;
}
#screen-bones .kb-demo-lines .kb-demo-arc.deep { top: 2px; color: #c0564c; border-top-color: rgba(168, 54, 46, 0.6); }
#screen-bones .kb-demo-lines .kb-demo-arc.mid { top: 24px; }
#screen-bones .kb-demo-lines .kb-demo-arc.low { top: 46px; }
#screen-bones .kb-demo-lines .kb-demo-die {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border-radius: 3px;
  background: linear-gradient(135deg, #d9d3c2, #a89f8a);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.7);
  animation: kb-demo-throw 3.2s ease-in-out infinite;
}
@keyframes kb-demo-throw {
  0%, 14% { transform: translateY(0) rotate(0); }
  34% { transform: translateY(-46px) rotate(200deg); }
  48% { transform: translateY(-22px) rotate(335deg); }
  58%, 100% { transform: translateY(-26px) rotate(360deg); }
}
/* III — the hold: chips land, the mult swells */
#screen-bones .kb-demo-hold .kb-demo-chip {
  position: absolute;
  left: 50%;
  width: 26px;
  height: 9px;
  margin-left: -13px;
  border-radius: 50% / 42%;
  background: radial-gradient(circle at 35% 30%, #d8b45a, #6e552f 75%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.7);
  opacity: 0;
  animation: kb-demo-stack 3.6s ease-out infinite;
}
#screen-bones .kb-demo-hold .kb-demo-chip.c1 { bottom: 8px; animation-delay: 0.2s; }
#screen-bones .kb-demo-hold .kb-demo-chip.c2 { bottom: 16px; animation-delay: 0.9s; }
#screen-bones .kb-demo-hold .kb-demo-chip.c3 { bottom: 24px; animation-delay: 1.6s; }
@keyframes kb-demo-stack {
  0% { opacity: 0; transform: translateY(-16px); }
  12%, 82% { opacity: 1; transform: none; }
  92%, 100% { opacity: 0; }
}
#screen-bones .kb-demo-hold .kb-demo-mult {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  color: var(--gold);
  font-size: 0.85rem;
  opacity: 0;
  animation: kb-demo-mult 3.6s ease-out infinite;
}
@keyframes kb-demo-mult {
  0%, 44% { opacity: 0; }
  58%, 82% { opacity: 1; text-shadow: 0 0 10px rgba(216, 180, 90, 0.7); }
  92%, 100% { opacity: 0; }
}
/* IV — the skull: the face surfaces, a stroke is dragged */
#screen-bones .kb-demo-skull .kb-demo-skullface {
  position: absolute;
  left: 26px;
  top: 8px;
  width: 40px;
  height: 40px;
  line-height: 40px;
  font-size: 1.5rem;
  color: var(--bone);
  background: #0c0a08;
  border: 1px solid rgba(207, 201, 184, 0.3);
  border-radius: 6px;
  animation: kb-demo-skullpulse 2.8s ease-in-out infinite;
}
@keyframes kb-demo-skullpulse {
  0%, 100% { filter: brightness(0.7); transform: rotate(-4deg); }
  50% { filter: brightness(1.25) drop-shadow(0 0 8px rgba(168, 54, 46, 0.8)); transform: rotate(3deg); }
}
#screen-bones .kb-demo-skull .kb-demo-tallies {
  position: absolute;
  right: 22px;
  top: 14px;
  display: flex;
  gap: 6px;
}
#screen-bones .kb-demo-skull .kb-demo-tallies i {
  width: 5px;
  height: 26px;
  border-radius: 2px;
  background: rgba(122, 24, 18, 0.2);
  transform: rotate(8deg);
  animation: kb-demo-tally 4.2s ease-out infinite;
}
#screen-bones .kb-demo-skull .kb-demo-tallies i:nth-child(2) { animation-delay: 1.2s; }
#screen-bones .kb-demo-skull .kb-demo-tallies i:nth-child(3) { animation-delay: 2.4s; }
@keyframes kb-demo-tally {
  0%, 18% { background: rgba(122, 24, 18, 0.2); box-shadow: none; }
  30%, 88% { background: #8c241c; box-shadow: 0 0 8px rgba(140, 36, 28, 0.6); }
  100% { background: rgba(122, 24, 18, 0.2); }
}

/* ---------- end panel: the ledger and the verdict ---------- */
#screen-bones .kb-end {
  position: fixed;
  inset: 0;
  z-index: 38;
  background: rgba(4, 5, 6, 0.94);
  padding: 0;
  text-align: center;
}
#screen-bones .kb-end-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 2.2rem 1rem 2.4rem;
}
#screen-bones .kb-end h3 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: 0.26em;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(216, 180, 90, 0.35);
}
#screen-bones .kb-end h3.kb-down { color: var(--red); text-shadow: 0 0 18px rgba(168, 54, 46, 0.45); }
#screen-bones .kb-end-detail { margin: 0.4rem 0; color: var(--bone); letter-spacing: 0.04em; }
#screen-bones .kb-ledger {
  max-width: 22rem;
  margin: 1rem auto;
  border: 1px solid #2c2418;
  border-radius: 3px;
  background: rgba(10, 9, 6, 0.8);
  padding: 0.6rem 0.5rem 0.7rem;
}
#screen-bones .kb-ledger-label {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.3em;
  color: var(--gold-dim);
  margin-bottom: 0.45rem;
}
#screen-bones .kb-ledger-row {
  display: grid;
  grid-template-columns: 1.4rem 1fr 2.6rem 4.2rem 3.6rem;
  gap: 0.3rem;
  align-items: baseline;
  font-size: 0.74rem;
  padding: 0.14rem 0.2rem;
  color: var(--bone);
}
#screen-bones .kb-ledger-row:nth-child(odd) { background: rgba(255, 250, 235, 0.025); }
#screen-bones .kb-ledger-row .kb-lg-line { text-align: left; }
#screen-bones .kb-ledger-row .kb-lg-dice { letter-spacing: 0.05em; }
#screen-bones .kb-ledger-row .kb-lg-res { text-align: right; }
#screen-bones .kb-ledger-row[data-kind='win'] .kb-lg-res { color: var(--gold); }
#screen-bones .kb-ledger-row[data-kind='lose'] .kb-lg-res { color: #c98e86; }
#screen-bones .kb-ledger-row[data-kind='skull'] .kb-lg-res,
#screen-bones .kb-ledger-row[data-kind='skull'] .kb-lg-dice { color: var(--red); }
#screen-bones .kb-end-house {
  font-style: italic;
  color: #9a937e;
  max-width: 24rem;
  margin: 0.6rem auto 1rem;
}
#screen-bones .kb-end-leave { min-height: 48px; letter-spacing: 0.18em; }

/* ---------- mobile: thumb-fair at ≤600px, no horizontal scroll ---------- */
@media (max-width: 600px) {
  #screen-bones .kb-room { padding: 0.2rem 0.2rem 1.4rem; }
  #screen-bones .kb-feltwrap { width: min(100%, 94vw); }
  #screen-bones .kb-hud { gap: 0.55rem; }
  #screen-bones .kb-felt-coins,
  #screen-bones .kb-bank-coins { font-size: 1rem; }
  #screen-bones .kb-notch { width: 3px; height: 11px; }
  #screen-bones .kb-lines { width: min(100%, 94vw); gap: 0.3rem; }
  #screen-bones .kb-linebtn { min-height: 64px; padding: 0.4rem 0.1rem; }
  #screen-bones .kb-linebtn .kb-line-band { font-size: 0.55rem; }
  #screen-bones .kb-stakes { width: min(100%, 94vw); flex-wrap: wrap; }
  #screen-bones .kb-chipbtn { min-width: 56px; min-height: 50px; }
  #screen-bones .kb-bankbtn { flex: 1 1 100%; min-height: 50px; }
  #screen-bones .kb-man { font-size: 0.8rem; min-height: 1.9rem; }
  #screen-bones .kb-toast { white-space: normal; width: 86%; text-align: center; }
  #screen-bones .kb-wobble { font-size: 0.72rem; }
  #screen-bones .kb-ledger-row { font-size: 0.7rem; grid-template-columns: 1.2rem 1fr 2.2rem 3.8rem 3.4rem; }
}
