/* Shared minigame primitives. Individual games scope their own styles on top of
   these. Same rule as everything else: dark face, one lit keyline, hard slab. */

/* The shipped modules were written against the previous palette and name its
   colours directly. Rather than rewrite six games, the old names are bound here
   to the current ones, on the container every module builds inside — so a duel
   is lit like the rest of the set instead of falling back to brown. */
.mg-stage {
  --walnut-900: var(--ink);
  --walnut-700: rgba(10, 3, 24, 0.5);
  --walnut-500: var(--surface-raised);
  --parchment: var(--text);
  --parchment-dim: var(--text-dim);
  --brass: var(--prize);
  --claret: var(--danger);
  --patina: var(--ok);
}

.mg-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  width: 100%;
  min-height: 0;
  padding: var(--sp-5) var(--sp-4);
  text-align: center;
}

/* Sits beside the host's way out, so the foot reads as one sentence and a key. */
.mg-foot-note {
  flex: 1 1 14rem;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  color: var(--text-dim);
}

.mg-title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  line-height: var(--lh-tight);
  color: var(--accent-hi);
  text-wrap: balance;
}

.mg-sub {
  max-width: 40ch;
  font-family: var(--font-body);
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--text-dim);
  text-wrap: balance;
}

.mg-timer {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}

.mg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--sp-3);
  width: 100%;
}

.mg-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-3);
  min-width: 0;
  color: var(--text);
  background: rgba(10, 3, 24, 0.45);
  border: var(--bd-thin);
  border-top: 6px solid var(--pc, var(--accent));
  border-radius: var(--r-md);
  box-shadow: var(--shadow-stamp);
}

.mg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: var(--ctl-h);
  padding: var(--sp-2) var(--sp-4);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--on-ok);
  background-color: var(--ok);
  background-image: var(--fill-accent);
  border: 2px solid var(--ok);
  border-radius: var(--r-pill);
  box-shadow: 0 5px 0 var(--slab-deep), 0 0 26px -6px var(--ok);
  cursor: pointer;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast), filter var(--dur-fast);
}

.mg-btn:hover { filter: brightness(1.06); }

.mg-btn:active {
  transform: translateY(var(--press-travel));
  box-shadow: var(--shadow-press-down);
}

.mg-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-stamp);
}

.mg-btn.ghost {
  color: var(--text-dim);
  background-color: rgba(10, 3, 24, 0.5);
  background-image: none;
  border-color: var(--border-strong);
  box-shadow: var(--shadow-press);
}

.mg-btn.ghost:hover { color: var(--text); }

/* A plate you hit with your whole hand. */
.mg-big {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 28rem;
  min-height: 8rem;
  padding: var(--sp-4);
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  color: var(--ink);
  background-color: var(--prize);
  background-image: var(--fill-prize);
  border: 3px solid var(--sun-deep);
  border-radius: var(--r-lg);
  box-shadow: 0 10px 0 var(--slab-deep), 0 0 60px -12px var(--prize);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast);
}

.mg-big:active {
  transform: translateY(8px);
  box-shadow: 0 2px 0 var(--slab-deep);
}

.mg-big:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* The one light surface in a minigame: a drawing game needs paper under it. */
.mg-canvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  background: var(--surface-alt);
  border: 2px solid var(--violet);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-stamp);
  touch-action: none;
}

.mg-standings {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
  max-width: 34rem;
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  border: var(--bd-thin);
  border-radius: var(--r-md);
  overflow: hidden;
}

.mg-standing {
  display: grid;
  grid-template-columns: 2.5ch 1fr auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  border-left: 6px solid var(--pc, transparent);
  background: rgba(10, 3, 24, 0.45);
  transition: opacity var(--dur-fast), color var(--dur-fast);
}

.mg-standing + .mg-standing { border-top: 2px solid var(--border); }

.mg-standing.is-out {
  color: var(--text-faint);
  opacity: 0.55;
  text-decoration: line-through;
  text-decoration-color: var(--danger);
  text-decoration-thickness: 3px;
}

.mg-lane {
  position: relative;
  width: 100%;
  height: 2.6rem;
  border: 2px solid var(--border-strong);
  border-left: 8px solid var(--pc, var(--violet));
  border-radius: var(--r-pill);
  background-image: repeating-linear-gradient(90deg,
    transparent 0 calc(10% - 2px),
    var(--border) calc(10% - 2px) 10%);
  background-color: rgba(10, 3, 24, 0.5);
  overflow: hidden;
}

.mg-lane.is-live { box-shadow: var(--shadow-stamp); }

/* ---- the ready-up ----
   Nothing on this call starts live. Before any module mounts, the table reads
   what the game is and puts a finger on the button. The one loud thing here is
   the card: dead-dark name plates that light up in the player's own colour the
   moment they ready, so from across a video call you can see who is holding it
   up without reading a word. Everything else stays quiet under it. */

.mg-ready {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  max-width: 46rem;
  text-align: center;
}

.mg-ready__eyebrow {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--text-dim);
}

.mg-ready__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  line-height: var(--lh-tight);
  color: var(--accent-hi);
  text-wrap: balance;
}

.mg-ready__blurb {
  margin: 0;
  max-width: 40ch;
  font-size: var(--fs-xl);
  line-height: var(--lh-snug);
  color: var(--text);
  text-wrap: balance;
}

.mg-ready__how {
  margin: 0;
  max-width: 52ch;
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--text-dim);
  text-wrap: pretty;
}

.mg-ready__where {
  margin: 0;
  padding: var(--sp-1) var(--sp-3);
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  color: var(--info-hi);
  border-left: 4px solid var(--info);
}

/* The card. A duel is X, a struck VS, Y; everything else is a rank of plates. */
.mg-ready__card {
  display: grid;
  gap: var(--sp-3);
  align-items: stretch;
  width: 100%;
  margin: var(--sp-3) 0 var(--sp-2);
}

.mg-ready__card--duel { grid-template-columns: 1fr auto 1fr; }
.mg-ready__card--melee { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.mg-ready__card--melee .mg-plate__name { font-size: var(--fs-lg); }

.mg-ready__vs {
  align-self: center;
  padding: var(--sp-1) var(--sp-2);
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 900;
  letter-spacing: var(--track-caps);
  color: var(--text-faint);
  transition: color var(--dur-mid), text-shadow var(--dur-mid);
}

.mg-ready__card.is-lit .mg-ready__vs {
  color: var(--wire);
  text-shadow: 0 0 22px var(--halo);
}

/* Two fixed rows so a "You" tag on one seat cannot shove its name off the line
   the other seat's name sits on. */
.mg-plate {
  display: grid;
  grid-template-rows: 1fr auto;
  align-content: center;
  justify-items: center;
  gap: var(--sp-2);
  min-height: 6.5rem;
  padding: var(--sp-3) var(--sp-2);
  min-width: 0;
  border: 2px solid var(--border);
  border-bottom: 6px solid var(--border-strong);
  border-radius: var(--r-md);
  background: rgba(10, 3, 24, 0.55);
  box-shadow: var(--shadow-stamp);
  transition: border-color var(--dur-mid), background-color var(--dur-mid), box-shadow var(--dur-mid);
}

.mg-plate__name {
  align-self: center;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
  line-height: var(--lh-tight);
  color: var(--text-faint);
  overflow-wrap: break-word;
  transition: color var(--dur-mid);
}

.mg-plate__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.mg-plate__state {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--text-faint);
}

.mg-plate__you {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: var(--track-label);
  color: var(--ink);
  background: var(--wire);
  border-radius: var(--r-pill);
  padding: 0 var(--sp-2);
}

/* Lit in the player's own seat colour — the whole point of the card. */
.mg-plate.is-ready {
  border-color: var(--pc, var(--ok));
  border-bottom-color: var(--pc, var(--ok));
  background-color: color-mix(in srgb, var(--pc, var(--ok)) 16%, var(--ink));
  box-shadow: 0 3px 0 var(--slab), 0 0 34px -8px var(--pc, var(--ok));
}

.mg-plate.is-ready .mg-plate__name { color: var(--text); }
.mg-plate.is-ready .mg-plate__state { color: var(--pc, var(--ok)); }

/* Nobody is at this seat, so it is in by default rather than by choice. It
   counts toward the tally, but the dashed keyline says it never pressed. */
.mg-plate.is-auto { border-style: dashed; opacity: 0.72; }

.mg-plate.is-idle .mg-plate__state { animation: mg-ready-breathe var(--dur-breathe) var(--ease-in-out) var(--anim-iter) alternate; }

@keyframes mg-ready-breathe {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.mg-ready__act {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  margin-top: var(--sp-2);
}

.mg-ready__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
}

.mg-ready__btn { min-width: 16rem; }

.mg-ready__role {
  margin: 0;
  font-size: var(--fs-lg);
  color: var(--text);
}

.mg-ready__tally {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
}

/* Empty until the countdown owns it, so it takes no room while readying. */
.mg-ready__go:empty { display: none; }

.mg-ready__go {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3.5rem, 7vw, 5.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--prize);
  text-shadow: 0 0 40px var(--prize-deep);
}

.mg-ready__go.is-beat { animation: mg-ready-beat var(--dur-slow) var(--ease-pop) both; }

@keyframes mg-ready-beat {
  from { transform: scale(1.45); opacity: 0.2; }
  to { transform: scale(1); opacity: 1; }
}

/* The countdown is the buffer, so it still runs — it just stops moving. */
@media (prefers-reduced-motion: reduce) {
  .mg-ready__go.is-beat,
  .mg-plate.is-idle .mg-plate__state { animation: none; }
}

@media (max-width: 560px) {
  .mg-stage { padding: var(--sp-4) var(--sp-2); gap: var(--sp-3); }
  .mg-grid { grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); }
  .mg-big { min-height: 7rem; font-size: var(--fs-xl); }
  .mg-ready__card--duel { grid-template-columns: 1fr; }
  .mg-ready__card--melee { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-ready__vs { justify-self: center; }
  .mg-ready__btn { min-width: 0; width: 100%; }
}
