/* Efron's Dice — "The Wager" theme. Everything scoped under .ek-stage so the
   dark felt never leaks into the site shell. Dice colours are game pieces —
   documented exemption from the no-purple theme rule. */

.ek-stage {
  --ek-felt: #0f3d2e;
  --ek-felt-dark: #0a2b20;
  --ek-chalk: #f4efe3;
  --ek-dim: #9fb3a8;
  --ek-gold: #d9a441;
  --ek-win: #7fd1a8;
  --ek-lose: #e08585;
  --ek-display: "Fraunces", Georgia, serif;
  --ek-mono: "IBM Plex Mono", ui-monospace, monospace;

  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.05), transparent 60%),
    radial-gradient(ellipse at 50% 120%, var(--ek-felt-dark), transparent 70%),
    var(--ek-felt);
  color: var(--ek-chalk);
  border-radius: 1rem;
  padding: 1.5rem 1.25rem 2rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 1rem 3rem rgba(0, 0, 0, 0.35);
  min-height: 70vh;
}
.ek-stage h1,
.ek-stage h2,
.ek-stage .ek-display {
  font-family: var(--ek-display);
  font-weight: 600;
  letter-spacing: 0.01em;
}
.ek-stage .ek-mono {
  font-family: var(--ek-mono);
}
.ek-dim { color: var(--ek-dim); }
.ek-gold { color: var(--ek-gold); }

.ek-rule {
  border: 0;
  border-top: 1px solid var(--ek-gold);
  box-shadow: 0 3px 0 -1px var(--ek-gold);
  opacity: 0.65;
  margin: 1rem 0;
}

/* Story beat: framed italic intro lines */
.ek-story {
  font-family: var(--ek-display);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ek-dim);
  border-left: 2px solid var(--ek-gold);
  padding-left: 0.75rem;
}

/* Inputs on felt */
.ek-stage .form-control {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--ek-chalk);
  font-family: var(--ek-mono);
}
.ek-stage .form-control::placeholder { color: var(--ek-dim); }
.ek-stage .form-control:focus {
  border-color: var(--ek-gold);
  box-shadow: 0 0 0 0.2rem rgba(217, 164, 65, 0.25);
  background: rgba(0, 0, 0, 0.3);
  color: var(--ek-chalk);
}

/* Gold CTA */
.ek-btn {
  background: var(--ek-gold);
  border: 0;
  color: #1d1407;
  font-family: var(--ek-display);
  font-weight: 700;
  border-radius: 0.6rem;
  padding: 0.8rem 1.25rem;
  width: 100%;
  font-size: 1.2rem;
  box-shadow: 0 0.4rem 1rem rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease, filter 0.15s ease;
}
.ek-btn:not(:disabled):active { transform: translateY(2px); box-shadow: 0 0.15rem 0.4rem rgba(0, 0, 0, 0.35); }
.ek-btn:not(:disabled):hover { filter: brightness(1.06); }
.ek-btn:disabled { filter: saturate(0.3) brightness(0.7); }
.ek-btn--quiet {
  background: transparent;
  color: var(--ek-chalk);
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 500;
}

/* Dice cards */
.ek-die {
  border-radius: 0.75rem;
  padding: 0.75rem 0.5rem;
  color: #fff;
  text-align: center;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 0.5rem 1rem rgba(0, 0, 0, 0.35);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.ek-die:not(.ek-die--locked):hover { transform: translateY(-3px); }
.ek-die.ek-die--selected { border-color: var(--ek-gold); box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.45), 0 0.5rem 1rem rgba(0, 0, 0, 0.35); }
.ek-die.ek-die--locked { opacity: 0.35; cursor: not-allowed; }
.ek-die.ek-die--selected.ek-die--locked { opacity: 1; }
.ek-die--green { background: #2e8b57; }
.ek-die--yellow { background: #e0a800; }
.ek-die--red { background: #c0392b; }
.ek-die--purple { background: #6f42c1; } /* die piece colour, not a theme colour */
.ek-die__name {
  font-family: var(--ek-display);
  font-weight: 700;
  font-size: 1.05rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}
.ek-faces { display: flex; gap: 0.25rem; justify-content: center; flex-wrap: wrap; margin-top: 0.5rem; }
.ek-face {
  background: rgba(255, 255, 255, 0.94);
  color: #1d1407;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ek-mono);
  font-weight: 700;
}
.ek-face--big { width: 3.25rem; height: 3.25rem; font-size: 1.75rem; border-radius: 0.5rem; }

/* Roll tumble */
@keyframes ek-tumble {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(8deg) scale(1.08); }
  50% { transform: rotate(-6deg) scale(0.95); }
  75% { transform: rotate(4deg) scale(1.05); }
  100% { transform: rotate(0deg) scale(1); }
}
.ek-tumbling { animation: ek-tumble 0.6s ease-in-out; }

/* Round-winner stamp */
@keyframes ek-stamp {
  0% { transform: scale(1.6); opacity: 0; }
  60% { transform: scale(0.95); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.ek-stamp {
  animation: ek-stamp 0.35s ease-out both;
  font-family: var(--ek-display);
  font-weight: 700;
  font-size: 1.3rem;
}
.ek-stamp--win { color: var(--ek-win); }
.ek-stamp--lose { color: var(--ek-lose); }

/* Score strip */
.ek-score {
  font-family: var(--ek-mono);
  font-size: 1.6rem;
  letter-spacing: 0.1em;
}
.ek-pips { display: flex; gap: 0.2rem; flex-wrap: wrap; }
.ek-pip {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
}
.ek-pip--you { background: var(--ek-win); }
.ek-pip--them { background: var(--ek-lose); }

/* Prediction picker */
.ek-predict { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: center; }
.ek-predict button {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ek-chalk);
  font-family: var(--ek-mono);
  font-weight: 700;
}
.ek-predict button.ek-on { background: var(--ek-gold); color: #1d1407; border-color: var(--ek-gold); }

/* Sample space / tally grids */
.ek-grid { border-collapse: collapse; margin: 0 auto; }
.ek-grid th, .ek-grid td {
  border: 1px solid rgba(255, 255, 255, 0.18);
  width: 2.1rem;
  height: 2.1rem;
  text-align: center;
  font-family: var(--ek-mono);
  font-size: 0.85rem;
}
.ek-grid th { color: var(--ek-dim); font-weight: 500; }
.ek-grid th.ek-corner { font-size: 0.65rem; }
.ek-grid td.ek-cell-win { background: rgba(127, 209, 168, 0.28); }
.ek-grid td.ek-cell-lose { background: rgba(224, 133, 133, 0.22); }

/* Stagger-build: each cell fades in by its --i index. The build IS the lesson. */
@keyframes ek-cell-in { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
.ek-grid--build td {
  opacity: 0;
  animation: ek-cell-in 0.25s ease-out forwards;
  animation-delay: calc(var(--i) * 20ms);
}

/* Analysis act cards */
.ek-act {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.75rem;
  padding: 1rem;
  margin-top: 1rem;
}
.ek-act__label {
  font-family: var(--ek-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--ek-gold);
}

/* Conjecture options */
.ek-conj { display: grid; gap: 0.5rem; }
.ek-conj button {
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.6rem;
  color: var(--ek-chalk);
  padding: 0.7rem 0.9rem;
}
.ek-conj button.ek-on { border-color: var(--ek-gold); box-shadow: 0 0 0 2px rgba(217, 164, 65, 0.35); }

/* Dashboard (projector) */
.ek-board { min-height: 80vh; }
.ek-board__code {
  font-family: var(--ek-display);
  font-size: clamp(4rem, 14vw, 9rem);
  letter-spacing: 0.18em;
  color: var(--ek-gold);
  line-height: 1;
  text-shadow: 0 0.5rem 2rem rgba(0, 0, 0, 0.5);
}
.ek-hero {
  font-family: var(--ek-mono);
  font-size: clamp(2.5rem, 7vw, 5rem);
  color: var(--ek-gold);
  line-height: 1.05;
}
.ek-board table { color: var(--ek-chalk); }
.ek-board .table { --bs-table-bg: transparent; --bs-table-color: var(--ek-chalk); --bs-table-border-color: rgba(255, 255, 255, 0.15); }
.ek-board .table thead th {
  background: transparent;
  color: var(--ek-dim);
  border-color: rgba(255, 255, 255, 0.25);
}
.ek-board .table tbody td {
  background: transparent;
}
.ek-poll-bar {
  height: 1.4rem;
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}
.ek-poll-bar > div {
  height: 100%;
  background: var(--ek-gold);
  transition: width 0.6s ease;
}

/* Page narrow wrapper */
.ek-page-narrow {
  max-width: 560px;
  margin: 0 auto;
}

/* Inline-style replacement utilities */
.ek-small { font-size: 0.8rem; }
.ek-vs { font-size: 1.5rem; }
.ek-note { font-size: 0.9rem; }

/* Convergence chart (solo + dashboard) */
.ek-chart {
  margin-bottom: 0.75rem;
}
.ek-chart__svg {
  display: block;
  width: 100%;
  height: 6.5rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
}
.ek-chart__line {
  fill: none;
  stroke-width: 2.5;
  vector-effect: non-scaling-stroke;
}
.ek-stroke--green { stroke: #5fd49a; }
.ek-stroke--yellow { stroke: #f0c24b; }
.ek-stroke--red { stroke: #ef8a7c; }
.ek-stroke--purple { stroke: #b89be0; } /* die piece tint */
.ek-chart__guide {
  stroke: rgba(255, 255, 255, 0.25);
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}
.ek-chart__theory {
  stroke: #d9a441;
  stroke-width: 2;
  stroke-dasharray: 6 3;
  vector-effect: non-scaling-stroke;
}
.ek-chart__labels { font-size: 0.7rem; font-family: var(--ek-mono); }
.ek-row--clickable { cursor: pointer; }
.ek-row--active td { background: rgba(217, 164, 65, 0.12) !important; }

/* Dashboard utilities */
.ek-w-auto { width: auto; }
.ek-lead { font-size: 1.4rem; }
.ek-roster { max-width: 720px; margin: 0 auto; }
.ek-rule--centered { max-width: 480px; margin: 1.5rem auto; }
.ek-duel-row { border-bottom: 1px solid rgba(255, 255, 255, 0.08); }

/* ── Solo free play ── */
.ek-stage--fit { min-height: auto; }
.ek-page-narrow { padding-bottom: 5rem; } /* clear the mobile bottom tab bar */

/* Visible focus for keyboard users on the felt */
.ek-btn:focus-visible,
.ek-die:focus-visible,
.ek-conj button:focus-visible {
  outline: 3px solid var(--ek-gold);
  outline-offset: 2px;
}
.ek-btn:disabled { cursor: not-allowed; }

.ek-text--green { color: #5fd49a; }
.ek-text--yellow { color: #f0c24b; }
.ek-text--red { color: #ef8a7c; }
.ek-text--purple { color: #b89be0; } /* die piece tint, not a theme colour */

/* Picking cards (solo): roomier, die-like 3x2 face grid, hover lift */
.ek-die--pickable {
  position: relative;
  padding: 1.1rem 0.75rem 1.25rem;
}
.ek-die--pickable .ek-die__name {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}
.ek-die__tag {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  font-family: var(--ek-mono);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--ek-gold);
  color: #1d1407;
  border-radius: 0.3rem;
  padding: 0.1rem 0.4rem;
}
.ek-faces--grid {
  display: grid;
  grid-template-columns: repeat(3, 2.2rem);
  justify-content: center;
  gap: 0.35rem;
}
.ek-faces--grid .ek-face {
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.05rem;
  border-radius: 0.4rem;
}

/* The arena: two real 3D cubes that tumble and settle on the rolled face */
.ek-arena {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.75rem;
  min-height: 8rem;
}
@media (max-width: 576px) {
  .ek-arena { min-height: 6.5rem; margin-top: 0.5rem; margin-bottom: 0.5rem; }
}
.ek-scene {
  width: 6rem;
  height: 6rem;
  perspective: 700px;
}
.ek-cube3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.2, 0.75, 0.3, 1);
}
.ek-cube3d__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--ek-mono);
  font-size: 2.6rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 0.9rem;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.3),
    inset 0 -0.5rem 0.9rem rgba(0, 0, 0, 0.25);
  backface-visibility: hidden;
}
.ek-cube3d--green .ek-cube3d__face { background: #2e8b57; }
.ek-cube3d--yellow .ek-cube3d__face { background: #e0a800; }
.ek-cube3d--red .ek-cube3d__face { background: #c0392b; }
.ek-cube3d--purple .ek-cube3d__face { background: #6f42c1; } /* piece colour */
/* Face order: front, right, back, left, top, bottom (3rem = half cube) */
.ek-cube3d__face--0 { transform: translateZ(3rem); }
.ek-cube3d__face--1 { transform: rotateY(90deg) translateZ(3rem); }
.ek-cube3d__face--2 { transform: rotateY(180deg) translateZ(3rem); }
.ek-cube3d__face--3 { transform: rotateY(-90deg) translateZ(3rem); }
.ek-cube3d__face--4 { transform: rotateX(90deg) translateZ(3rem); }
.ek-cube3d__face--5 { transform: rotateX(-90deg) translateZ(3rem); }

.ek-stamp-slot { min-height: 2.2rem; }

.ek-totals .ek-score { font-size: 2.2rem; }
.ek-log {
  max-height: 16rem;
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 0.5rem;
}
.ek-log__table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--ek-mono);
  font-size: 0.9rem;
}
.ek-log__table th,
.ek-log__table td {
  padding: 0.3rem 0.6rem;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.ek-log__table thead th {
  position: sticky;
  top: 0;
  background: #11342a;
  color: var(--ek-dim);
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

@media (prefers-reduced-motion: reduce) {
  .ek-tumbling, .ek-stamp, .ek-grid--build td { animation: none; opacity: 1; }
  .ek-cube3d { transition-duration: 0s; }
  .ek-poll-bar > div { transition: none; }
}
