.tally-frame {
  --tally-ink: #30241d;
  --tally-gold: #edb957;
  position: relative;
  isolation: isolate;
  container-type: inline-size;
  overflow: hidden;
  box-sizing: border-box;
  width: 100%;
  padding: 12px clamp(10px, 3vw, 20px) 13px;
  color: #f9eed7;
  border: 1px solid #ac8b59;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at 49% 0%, #5e4933aa, transparent 67%),
    repeating-linear-gradient(132deg, transparent 0 11px, #d8b26807 11px 12px),
    #2a2624;
  box-shadow: inset 0 0 0 3px #332a23, inset 0 0 0 4px #ac8b5945;
}
.run-score {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
  padding: 1px 6px 1px 3px;
  border: 1px solid #92764f;
  border-radius: 5px;
  background: #26392c;
  color: #ffe6a5;
  white-space: nowrap;
}
.run-score-eye { display: block; width: clamp(17px, 4vmin, 25px); aspect-ratio: 1; object-fit: contain; }
.run-score-value { min-width: 2ch; text-align: center; font: 700 16px/1 Georgia, serif; font-variant-numeric: tabular-nums; }
.run-score-label { color: #ecd9b5; font: 600 10px/1 system-ui, sans-serif; }
.tally-transfer {
  position: fixed;
  z-index: 119;
  pointer-events: none;
  background: url(assets/eye-token.webp) center/contain no-repeat;
  filter: drop-shadow(0 2px 5px #2f1a0b99);
}
@media(max-width:455px) {
  .run-score-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
@media(max-width:385px) {
  .game-shell .mast-tools .guide-button { padding-inline: 7px; gap: 0; font-size: 0; }
}
@media(prefers-reduced-motion:reduce) {
  .tally-transfer { display: none; }
}
.tally-frame *, .tally-frame *::before, .tally-frame *::after { box-sizing: border-box; }
.tally-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tally-kicker, .tally-label {
  font: 700 10px/1.2 system-ui,sans-serif;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.tally-kicker { color: #e5cb9f; }
.tally-frame .tally-control {
  min-height: 30px;
  padding: 4px 9px;
  color: #fcf2dc;
  border: 1px solid #9d8768;
  border-radius: 4px;
  background: #252220;
  font: 600 12px/1 system-ui,sans-serif;
  cursor: pointer;
}
.tally-control:focus-visible { outline: 2px solid #ffeead; outline-offset: 2px; }
.tally-readout { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 45px; }
.tally-frame .tally-number {
  color: #fce6a9;
  font: 700 clamp(32px, 13cqw, 49px)/1 Georgia,serif;
  font-variant-numeric: lining-nums tabular-nums;
  text-shadow: 0 2px #190f08;
}
.tally-unit { align-self:center; padding-top:.6em; font: italic 16px/1 Georgia,serif; color: #e9d8b9; }
.tally-eye {
  flex: 0 0 clamp(37px, 7vmin, 70px);
  aspect-ratio: 1;
  transform: rotate(-9deg);
  background: url(assets/eye-token.webp) center/contain no-repeat;
}
.tally-caption { min-height: 1.55em; margin: 3px 0 7px; text-align: center; color: #fcf2df; font: 500 13px/1.3 system-ui,sans-serif; }
.tally-ledger { display: flex; list-style: none; margin: 0; padding: 0; }
.tally-cell {
  --sigil: #e8be65;
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  justify-items: center;
  align-content: start;
  row-gap: 2px;
  position: relative;
  opacity: .55;
  color: #eee5d5;
}
.tally-cell::before {
  content: ''; height: 1px; position:absolute; left:-50%; width:100%; top:12px;
  background:#776651; z-index:-1;
}
.tally-cell:first-child::before { content: none; }
.tally-cell[data-kind=skills] { --sigil: #98c8b4; }
.tally-cell[data-kind=risk] { --sigil: #e69c81; }
.tally-cell[data-kind=move] { --sigil: #c6aae6; }
.tally-cell[data-kind=viral] { --sigil: #a6cdec; }
.tally-stamp {
  display:grid; place-items:center; width:26px; height:26px;
  background:#302a25; color:var(--sigil); border:1px solid var(--sigil);
  border-radius:50%; font:bold 17px/1 Georgia,serif;
}
.tally-label { font-size: 9px; letter-spacing:.06em; }
.tally-value { font: bold 14px/1 Georgia,serif; color:var(--sigil); font-variant-numeric:tabular-nums; }
.tally-cell.is-seen { opacity:1; }
.tally-cell.is-seen .tally-stamp { background:var(--sigil); color:#30231b; box-shadow:inset 0 0 0 2px #30231b, inset 0 0 0 3px var(--sigil); }
.tally-cell.is-now .tally-stamp { animation:tally-stamp .42s cubic-bezier(.2,.8,.4,1) both; }
.tally-frame[data-kind=skills] .tally-eye { animation:tally-sketch .45s ease; }
.tally-frame[data-kind=risk] .tally-eye { animation:tally-rattle .48s ease; }
.tally-frame[data-kind=move] .tally-eye { animation:tally-flip .55s ease; }
.tally-frame[data-kind=viral][data-viral=true] .tally-eye { animation:tally-flare .68s ease-out; }
.tally-frame[data-kind=done][data-viral=true] .tally-caption { color:#ffe08c; }
.tally-sr { clip-path:inset(50%); position:absolute; overflow:hidden; white-space:nowrap; width:1px; height:1px; }
@keyframes tally-stamp { from { transform:scale(1.55) rotate(-17deg); } 72% {transform:scale(.92) rotate(3deg);} }
@keyframes tally-sketch { 45% {transform:rotate(6deg) translateY(-3px);} }
@keyframes tally-rattle { 25%,65% {transform:translateX(-3px) rotate(-14deg);} 45% {transform:translateX(3px) rotate(-3deg);} }
@keyframes tally-flip { 45% {transform:translateY(-4px) rotateY(68deg) rotate(-8deg);} }
@keyframes tally-flare { 45% {transform:scale(1.2) rotate(4deg);box-shadow:0 0 22px #ffc93a;} }
@media(max-height:680px) {
  .tally-frame {padding-top:6px;padding-bottom:7px;}
  .tally-readout {min-height:34px;}
  .tally-frame .tally-number {font-size:34px;}
  .tally-stamp {width:22px;height:22px;font-size:15px;}
}
@media(prefers-reduced-motion:reduce) {
  .tally-frame * { animation:none!important; }
}


.tally-chamber {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(90px, 1fr);
  gap: clamp(5px, 1.4vmin, 15px);
  align-items: center;
}
.tally-commission { min-width: 0; }
.audience-draw {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: clamp(76px, 20vmin, 178px);
}
.audience-card {
  position: relative;
  width: 100%;
  height: 100%;
}
.audience-back,.audience-front {
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 3px double #c8a76d;
  border-radius: 6px;
  font: 700 clamp(9px,1.7vmin,14px)/1.15 Inter,Arial,sans-serif;
}
.audience-back {
  gap: 3px;
  padding: 5px;
  color: #f0d69e;
  background: radial-gradient(ellipse,#425442,#21372d 72%);
}
.audience-seal { font: 600 clamp(20px,6vmin,50px)/1 Crimson,Georgia,serif; }
.audience-front {
  align-content: end;
  visibility: hidden;
  padding: 4px;
  background: #38271d;
  color: #fff2d1;
}
.audience-draw[data-revealed="true"] .audience-back { visibility: hidden; }
.audience-draw[data-revealed="true"] .audience-front { visibility: visible; }
.audience-draw[data-flipping="true"] .audience-back { animation: audience-turn-away .22s ease-in both; }
.audience-draw[data-flipping="true"] .audience-front { animation: audience-turn-toward .30s ease-out .22s both; }
@keyframes audience-turn-away {
  from { visibility: visible; transform: scaleX(1); }
  to { visibility: hidden; transform: scaleX(0); }
}
@keyframes audience-turn-toward {
  from { visibility: hidden; transform: scaleX(0); }
  to { visibility: visible; transform: scaleX(1); }
}
.audience-art { position:absolute; inset:0; width:100%;height:100%;object-fit:cover;object-position:center 55%; }
.audience-front strong {
  position: relative;
  background: #201912da;
  padding: 2px 4px;
  border-radius: 3px;
  box-shadow: 0 0 9px #21140b96;
}
.audience-draw[data-variant="burst"] .audience-front { border-color: #ffe4a0; }
.audience-coins { position:absolute; inset:0; pointer-events:none; }
.audience-coin {
  display: none;
  position:absolute;
  left: calc(50% - 11px);
  bottom: 12%;
  width: 22px;
  height: 22px;
  background: url(assets/eye-token.webp) center/contain no-repeat;
}
.audience-draw[data-coins="true"] .audience-coin {
  display: block;
  animation: eye-rain .74s cubic-bezier(.14,.58,.61,1) both;
  animation-delay: calc(var(--coin-index) * 24ms);
}
.tally-frame[data-kind=skills][data-delta=even] .tally-eye { animation: tally-stamp .38s ease; }
.tally-frame[data-kind=risk]:not([data-delta=loss]) .tally-eye,
.tally-frame[data-kind=move][data-delta=even] .tally-eye { animation: none; }
@keyframes eye-rain {
  0% { opacity: 0; transform: translate(0,0) scale(.45) rotateY(0); }
  20% { opacity: 1; }
  70% { opacity: .9; transform: translate(var(--coin-x),-63px) scale(1) rotateY(300deg); }
  100% { opacity: 0; transform: translate(var(--coin-x),-51px) scale(.75) rotateY(420deg); }
}
@media(max-width:370px) and (orientation: portrait) {
  .tally-chamber { grid-template-columns: 1fr; }
  .audience-draw { height: clamp(60px, 23vmin, 100px); }
}
@media(max-height:399px) {
  .audience-draw { height: clamp(70px, 24dvh, 97px); }
  .tally-caption { font-size: 11px; }
}
@media(prefers-reduced-motion:reduce) {
  .audience-coin { display:none!important; }
}
.tally-stamp:has(.tally-stamp-art) { border:0; background:none; box-shadow:none; }
.tally-stamp-art { display:block;width:100%;height:100%;object-fit:contain; }
.tally-chamber:not(:has(.audience-draw)) { grid-template-columns: 1fr; }
