/* Probability L3: The Counting Tent */

.counting-page {
  --count-ember: #b9452b;
  --count-ember-dark: #6f261b;
  --count-brass: #d0a84b;
  --count-peach: #e9a879;
  --count-canvas: #f7dec1;
  --count-teal: #2c8f88;
  --count-ink: #241b18;
  --count-plum: #442143;
  --count-wood: #7b4b2a;
  color: var(--count-ink);
}

.counting-topbar {
  border-color: rgba(208, 168, 75, 0.32);
}

.counting-progressbar {
  background: rgba(247, 222, 193, 0.74);
  border: 1px solid rgba(185, 69, 43, 0.2);
  border-radius: 999px;
  height: 8px;
  margin: 0 auto 10px;
  max-width: 1180px;
  overflow: hidden;
}

.counting-progressbar span {
  background: linear-gradient(90deg, var(--count-peach), var(--count-ember), var(--count-brass));
  display: block;
  height: 100%;
  transition: width 320ms ease;
}

.counting-progress {
  display: flex;
  gap: 7px;
  justify-content: center;
  margin: 0 auto 12px;
}

.counting-progress__dot {
  background: rgba(68, 33, 67, 0.42);
  border: 1px solid rgba(247, 222, 193, 0.7);
  border-radius: 50%;
  height: 10px;
  width: 10px;
}

.counting-progress__dot.is-current {
  background: var(--count-canvas);
  box-shadow: 0 0 0 3px rgba(208, 168, 75, 0.22);
}

.counting-progress__dot.is-filled {
  background: var(--count-brass);
  box-shadow: 0 0 12px rgba(208, 168, 75, 0.44);
}

.counting-room {
  margin: 0 auto;
  max-width: 1180px;
}

.counting-room__scene {
  background:
    radial-gradient(circle at 16% 78%, rgba(255, 118, 62, 0.3), transparent 18%),
    radial-gradient(circle at 82% 78%, rgba(255, 174, 76, 0.24), transparent 18%),
    linear-gradient(180deg, rgba(255, 238, 204, 0.12), rgba(67, 28, 45, 0.18)),
    linear-gradient(115deg, rgba(185, 69, 43, 0.42), transparent 43%),
    url("../img/arena-probability.jpg") center center / cover no-repeat;
  border: 1px solid rgba(247, 222, 193, 0.28);
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(44, 22, 24, 0.34);
  height: min(740px, calc(100vh - 130px));
  min-height: 680px;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

.counting-room__scene::before {
  background:
    repeating-linear-gradient(90deg, rgba(247, 222, 193, 0.09) 0 20px, rgba(185, 69, 43, 0.1) 20px 40px),
    linear-gradient(180deg, rgba(0, 0, 0, 0.1), transparent 46%);
  content: "";
  height: 150px;
  inset: 0 0 auto;
  opacity: 0.92;
  position: absolute;
  z-index: 1;
}

.counting-room__scene::after {
  background:
    repeating-linear-gradient(90deg, rgba(36, 24, 25, 0.13) 0 4px, transparent 4px 38px),
    linear-gradient(180deg, #986039, #58311f);
  border-top: 1px solid rgba(255, 239, 202, 0.2);
  bottom: -58px;
  box-shadow: 0 -20px 45px rgba(54, 30, 27, 0.34);
  content: "";
  height: 210px;
  left: -3%;
  position: absolute;
  right: -3%;
  transform: skewY(-2deg);
  z-index: -1;
}

.counting-room__braziers {
  inset: auto 4% 56px 4%;
  pointer-events: none;
  position: absolute;
  z-index: 2;
}

.counting-room__braziers span {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 206, 103, 0.95), transparent 32%),
    linear-gradient(180deg, var(--count-ember), var(--count-ember-dark));
  border: 2px solid rgba(247, 222, 193, 0.24);
  border-radius: 14px 14px 4px 4px;
  bottom: 0;
  box-shadow: 0 0 44px rgba(255, 119, 63, 0.48);
  height: 74px;
  position: absolute;
  width: 88px;
}

.counting-room__braziers span:first-child {
  left: 0;
}

.counting-room__braziers span:last-child {
  right: 0;
}

.counting-room__tent-poles {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.counting-room__tent-poles span {
  background: linear-gradient(180deg, rgba(247, 222, 193, 0.24), rgba(90, 48, 32, 0.5));
  bottom: 82px;
  position: absolute;
  top: 0;
  width: 8px;
}

.counting-room__tent-poles span:nth-child(1) { left: 13%; }
.counting-room__tent-poles span:nth-child(2) { left: 50%; }
.counting-room__tent-poles span:nth-child(3) { right: 13%; }

.counting-room__prompt {
  left: 50%;
  max-width: min(700px, 66%);
  position: absolute;
  text-align: center;
  text-shadow: 0 3px 10px rgba(44, 20, 40, 0.5);
  top: 3%;
  transform: translateX(-50%);
  z-index: 5;
}

.counting-room__prompt span,
.counting-shelf__title span,
.counting-problem-card > span,
.counting-token-group span,
.outcome-grid-panel__label span,
.choice-counter span,
.counting-total span,
.counting-why span {
  color: rgba(255, 248, 226, 0.84);
  display: block;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.counting-room__prompt h1 {
  color: #fff7df;
  font-family: var(--font-display);
  font-size: clamp(1.28rem, 2.35vw, 2rem);
  line-height: 1.04;
  margin: 3px 0 0;
}

.counting-shelf {
  background: linear-gradient(180deg, rgba(68, 33, 67, 0.9), rgba(48, 27, 48, 0.88));
  border: 2px solid rgba(247, 222, 193, 0.32);
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(48, 24, 48, 0.28);
  left: 4%;
  padding: 9px 12px;
  position: absolute;
  right: 4%;
  top: 11.5%;
  z-index: 4;
}

.counting-shelf__title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
}

.counting-shelf__title strong {
  color: #fff2c8;
  font-size: 0.82rem;
}

.counting-shelf__rail {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.counting-shelf__slot {
  background: rgba(247, 222, 193, 0.08);
  border: 1px dashed rgba(247, 222, 193, 0.28);
  border-radius: 6px;
  display: grid;
  min-height: 60px;
  padding: 5px;
  place-items: center;
}

.counting-shelf__slot.is-current {
  border-color: rgba(208, 168, 75, 0.62);
}

.counting-shelf__slot.is-filled {
  animation: countingGridArrive 420ms ease both;
  background: rgba(247, 222, 193, 0.16);
  border-style: solid;
}

.snapshot-grid {
  background:
    linear-gradient(90deg, rgba(36, 27, 24, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 27, 24, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, #fff1cf, #e8bd78);
  background-size: 18px 18px, 18px 18px, auto;
  border: 1px solid rgba(87, 51, 28, 0.28);
  border-radius: 6px;
  box-shadow: 0 8px 14px rgba(28, 16, 20, 0.22);
  color: var(--count-ink);
  display: grid;
  gap: 2px;
  min-height: 46px;
  min-width: 0;
  padding: 7px;
  text-align: center;
  width: 100%;
}

.counting-shelf__slot:not(.is-filled) .snapshot-grid {
  background: rgba(247, 222, 193, 0.08);
  box-shadow: none;
  color: rgba(255, 242, 212, 0.5);
}

.snapshot-grid span {
  font-size: 0.58rem;
  font-weight: 900;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.snapshot-grid strong {
  font-family: var(--font-display);
  font-size: 0.86rem;
  line-height: 1;
}

.snapshot-grid em {
  font-size: 0.62rem;
  font-style: normal;
}

.counting-steps {
  display: grid;
  gap: 8px;
  left: 8%;
  position: absolute;
  right: 8%;
  top: 24.5%;
  z-index: 5;
}

.counting-steps--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.counting-steps--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.counting-step {
  background: rgba(36, 24, 40, 0.72);
  border: 1px solid rgba(247, 222, 193, 0.2);
  border-radius: 999px;
  color: rgba(255, 247, 223, 0.74);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  padding: 7px 9px;
  text-align: center;
}

.counting-step--active {
  background: rgba(208, 168, 75, 0.22);
  border-color: rgba(208, 168, 75, 0.52);
  color: #fff7df;
}

.counting-step--complete {
  background: rgba(44, 143, 136, 0.24);
  border-color: rgba(44, 143, 136, 0.48);
  color: #ddfffb;
}

.counting-step--pending {
  opacity: 0.62;
}

.counting-workbench {
  align-items: stretch;
  display: grid;
  gap: 14px;
  grid-template-columns: 182px minmax(0, 1fr) 178px;
  left: 4%;
  position: absolute;
  right: 4%;
  top: 29%;
  z-index: 6;
}

.counting-problem-card,
.counting-grid-panel,
.counting-aldra {
  background: rgba(36, 24, 40, 0.84);
  border: 1px solid rgba(247, 222, 193, 0.28);
  border-radius: 8px;
  box-shadow: 0 16px 28px rgba(34, 18, 34, 0.25);
}

.counting-problem-card {
  color: #fff5d8;
  padding: 12px;
}

.counting-problem-card h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1.05;
  margin: 8px 0;
}

.counting-problem-card p {
  font-size: 0.88rem;
  line-height: 1.35;
  margin: 0;
}

.counting-grid-panel {
  display: grid;
  gap: 7px;
  padding: 9px;
}

.counting-token-rack {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.counting-token-group {
  background: rgba(255, 247, 223, 0.1);
  border: 1px solid rgba(255, 247, 223, 0.16);
  border-radius: 7px;
  color: #fff7df;
  padding: 8px;
}

.counting-token-group strong {
  display: block;
  font-size: 0.86rem;
  margin: 2px 0 6px;
}

.counting-tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.counting-tokens i {
  background: linear-gradient(180deg, #fff1cf, #e5a879);
  border: 1px solid rgba(87, 51, 28, 0.26);
  border-radius: 5px;
  color: var(--count-plum);
  display: grid;
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 900;
  height: 27px;
  min-width: 27px;
  padding: 0 5px;
  place-items: center;
}

.outcome-grid-panel {
  background: rgba(255, 247, 223, 0.94);
  border: 2px solid rgba(123, 75, 42, 0.38);
  border-radius: 8px;
  color: var(--count-ink);
  min-height: 184px;
  padding: 9px;
}

.outcome-grid-panel__label {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.outcome-grid-panel__label span {
  color: rgba(36, 27, 24, 0.58);
}

.outcome-grid-panel__label strong {
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.outcome-grid-empty {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(36, 27, 24, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 27, 24, 0.08) 1px, transparent 1px),
    rgba(255, 255, 255, 0.32);
  background-size: 34px 34px;
  border: 1px dashed rgba(36, 27, 24, 0.22);
  border-radius: 6px;
  color: rgba(36, 27, 24, 0.56);
  display: flex;
  font-weight: 900;
  justify-content: center;
  min-height: 128px;
  text-align: center;
}

.outcome-grid-layers {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.outcome-grid-layer {
  background: rgba(36, 27, 24, 0.05);
  border: 1px solid rgba(36, 27, 24, 0.12);
  border-radius: 6px;
  padding: 7px;
}

.outcome-grid-layer__title {
  color: var(--count-plum);
  font-size: 0.72rem;
  font-weight: 900;
  margin-bottom: 6px;
  text-align: center;
  text-transform: uppercase;
}

.outcome-grid-matrix {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
}

.outcome-cell {
  align-items: center;
  animation: countingCellIn 180ms ease both;
  background: linear-gradient(180deg, #fffdfa, #f3cf92);
  border: 1px solid rgba(123, 75, 42, 0.24);
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(36, 27, 24, 0.1);
  color: var(--count-ink);
  display: flex;
  font-size: 0.68rem;
  font-weight: 900;
  justify-content: center;
  min-height: 24px;
  overflow: hidden;
  padding: 3px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.choice-counter-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-counter {
  background: rgba(24, 18, 28, 0.82);
  border: 1px solid rgba(247, 222, 193, 0.18);
  border-radius: 7px;
  color: #fff7df;
  padding: 7px;
  text-align: center;
}

.choice-counter.is-correct {
  border-color: rgba(44, 143, 136, 0.72);
  box-shadow: inset 0 0 12px rgba(44, 143, 136, 0.14);
}

.choice-counter strong {
  display: block;
  font-size: 0.84rem;
}

.choice-counter__value {
  font-family: var(--font-display);
  font-size: 1.42rem;
  line-height: 1;
  margin: 3px 0 5px;
}

.choice-counter__buttons {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1fr;
}

.choice-counter__buttons button,
.counting-lock {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 900;
}

.choice-counter__buttons button {
  background: rgba(247, 222, 193, 0.95);
  color: var(--count-plum);
  font-size: 1.1rem;
  min-height: 32px;
}

.choice-counter__buttons button:disabled,
.counting-lock:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.counting-total {
  align-items: center;
  background: rgba(24, 18, 28, 0.86);
  border: 1px solid rgba(247, 222, 193, 0.2);
  border-radius: 8px;
  color: #fff7df;
  display: grid;
  gap: 8px;
  grid-template-columns: 120px minmax(0, 1fr) 136px;
  padding: 7px 9px;
}

.counting-total.is-ready {
  border-color: rgba(208, 168, 75, 0.6);
  box-shadow: 0 0 16px rgba(208, 168, 75, 0.14);
}

.counting-total strong {
  color: var(--count-brass);
  font-family: var(--font-display);
  font-size: 1.5rem;
  text-align: center;
}

.counting-lock {
  background: linear-gradient(180deg, var(--count-brass), #b98323);
  color: #25160f;
  min-height: 46px;
  padding: 8px 10px;
}

.counting-aldra {
  min-height: 300px;
  overflow: visible;
  position: relative;
}

.counting-aldra__hourglass {
  background: linear-gradient(180deg, #d0a84b, #7b4b2a);
  border-radius: 6px;
  bottom: 44px;
  height: 58px;
  left: 28px;
  position: absolute;
  width: 30px;
}

.counting-aldra__hourglass span {
  background: #fff1cf;
  border-radius: 50%;
  display: block;
  height: 30px;
  left: 5px;
  position: absolute;
  top: 13px;
  width: 20px;
}

.counting-aldra__head {
  background: #2b5e70;
  border-radius: 50% 50% 44% 44%;
  height: 54px;
  left: 61px;
  position: absolute;
  top: 70px;
  width: 54px;
}

.counting-aldra__head span {
  background: #f3dbc1;
  border-radius: 50%;
  display: block;
  height: 40px;
  left: 7px;
  position: absolute;
  top: 8px;
  width: 40px;
}

.counting-aldra__body {
  background: linear-gradient(180deg, #2d7f8e, #173746);
  border-radius: 34px 34px 12px 12px;
  height: 124px;
  left: 52px;
  position: absolute;
  top: 120px;
  width: 72px;
}

.counting-aldra__arm {
  background: #205a69;
  border-radius: 999px;
  height: 16px;
  position: absolute;
  top: 158px;
  width: 68px;
}

.counting-aldra__arm--left {
  left: 24px;
  transform: rotate(-18deg);
}

.counting-aldra__arm--right {
  right: 24px;
  transform: rotate(18deg);
}

.counting-aldra__bubble {
  background: rgba(255, 247, 223, 0.96);
  border: 1px solid rgba(68, 33, 67, 0.18);
  border-radius: 8px;
  color: var(--count-plum);
  font-size: 0.82rem;
  font-weight: 800;
  left: -22px;
  line-height: 1.25;
  padding: 9px 10px;
  position: absolute;
  right: -12px;
  top: 10px;
}

.counting-celebration {
  background: rgba(36, 24, 40, 0.94);
  border: 2px solid rgba(208, 168, 75, 0.72);
  border-radius: 8px;
  bottom: 20px;
  box-shadow: 0 18px 35px rgba(24, 18, 28, 0.38);
  color: #fff7df;
  left: 50%;
  max-width: 650px;
  padding: 14px;
  position: absolute;
  text-align: center;
  transform: translateX(-50%);
  width: min(650px, 86%);
  z-index: 10;
}

.counting-celebration strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.counting-celebration p {
  font-size: 0.9rem;
  margin: 6px 0 8px;
}

.counting-why > span {
  color: rgba(255, 248, 226, 0.72);
}

.counting-celebration > span {
  display: block;
  font-size: 0.78rem;
  font-weight: 900;
  margin-bottom: 8px;
}

.counting-reward {
  display: grid;
  inset: 0;
  overflow-y: auto;
  padding: 24px;
  place-items: center;
  position: absolute;
  z-index: 20;
}

.counting-reward__card {
  background: rgba(36, 24, 40, 0.94);
  border: 2px solid rgba(208, 168, 75, 0.72);
  border-radius: 8px;
  box-shadow: 0 24px 52px rgba(18, 12, 22, 0.46);
  color: #fff7df;
  display: grid;
  gap: 12px;
  max-width: 940px;
  padding: 20px;
  text-align: center;
  width: min(940px, 96%);
}

.counting-reward__copy span {
  color: rgba(255, 248, 226, 0.78);
  display: block;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.counting-reward__copy h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  line-height: 1;
  margin: 4px 0 6px;
}

.counting-reward__copy p {
  margin: 0 auto;
  max-width: 680px;
}

.counting-reward__snapshots {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.counting-reward__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.counting-reward__badges span {
  background: rgba(247, 222, 193, 0.1);
  border: 1px solid rgba(247, 222, 193, 0.2);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 7px 10px;
}

.counting-reward__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

@keyframes countingGridArrive {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes countingCellIn {
  from {
    opacity: 0;
    transform: scale(0.86);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 980px) {
  .counting-room__scene {
    height: auto;
    min-height: 0;
    overflow: visible;
    padding: 18px;
  }

  .counting-room__scene::before,
  .counting-room__scene::after,
  .counting-room__braziers,
  .counting-room__tent-poles {
    display: none;
  }

  .counting-room__prompt,
  .counting-shelf,
  .counting-steps,
  .counting-workbench,
  .counting-celebration {
    left: auto;
    position: relative;
    right: auto;
    top: auto;
    transform: none;
  }

  .counting-room__prompt,
  .counting-shelf,
  .counting-steps,
  .counting-workbench {
    margin-bottom: 12px;
  }

  .counting-room__prompt {
    max-width: none;
  }

  .counting-shelf__rail,
  .counting-reward__snapshots {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .counting-steps,
  .counting-workbench,
  .counting-token-rack,
  .choice-counter-row,
  .counting-total {
    grid-template-columns: 1fr;
  }

  .counting-aldra {
    min-height: 240px;
  }
}
