/* ---------------------------------------------------------------------------
 * Barn Run — the playable hero.
 *
 * Two palettes meet here on purpose. The chrome around the screen (HUD, buttons,
 * overlays) is drawn from the studio's own tokens so the game sits *in* the page
 * rather than on top of it. Everything inside the canvas is CropCorp's own
 * palette, painted in JS from CCBlocks.h — because that is the game's world, and
 * it should look like it.
 *
 * Everything is scoped under .brun so it cannot collide with the theme.
 * ------------------------------------------------------------------------- */

.brun {
  --brun-coin: var(--amb);            /* the site's own "CropCorp warmth" token */
  max-width: 760px;
  margin: 38px auto 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brun-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-family: var(--fm);
  font-size: .7rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--dim);
}
.brun-label b { color: var(--g); font-weight: 700; }

.brun-cab {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* --- HUD ---------------------------------------------------------------- */
.brun-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  font-family: var(--fm);
  font-variant-numeric: tabular-nums;
}
.brun-stat {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 6px 9px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.brun-stat .k {
  font-size: .55rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--dim);
}
.brun-stat .v { font-size: clamp(.95rem, 3.2vw, 1.16rem); font-weight: 700; color: var(--tx); }
.brun-stat .v.coin { color: var(--brun-coin); }
.brun-stat .v.crop { color: #e07a3a; }
.brun-stat .v.low  { color: #ff6b6b; }
.brun-stat.flash { animation: brun-pop .4s ease; }
@keyframes brun-pop { 0%,100% { transform: none; } 30% { transform: translateY(-3px) scale(1.04); } }

/* --- screen ------------------------------------------------------------- */
.brun-screen { position: relative; border-radius: 10px; overflow: hidden; background: #0d1a24; }
.brun-screen canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  touch-action: none;
}

.brun-over {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; gap: 13px;
  text-align: center; padding: 20px;
  background: rgba(10, 12, 16, .9);
  backdrop-filter: blur(3px);
}
.brun-over[hidden] { display: none; }
.brun-over h3 {
  margin: 0;
  font-size: clamp(1.3rem, 4.4vw, 1.9rem);
  color: var(--tx);
  letter-spacing: -.01em;
}
.brun-over p { margin: 0; color: var(--mut); font-size: .95rem; line-height: 1.55; max-width: 34ch; }
.brun-over p b { color: var(--tx); }
.brun-over .warn { color: #ff8b8b; }
.brun-keys { font-family: var(--fm); font-size: .68rem; color: var(--dim); }
.brun-keys kbd {
  background: var(--bg3); border: 1px solid var(--line2); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; color: var(--tx); font: inherit; font-size: .64rem;
}

.brun-tally { font-family: var(--fm); font-variant-numeric: tabular-nums; display: grid; gap: 3px; }
.brun-tally .big { font-size: clamp(2rem, 8vw, 2.9rem); font-weight: 800; color: var(--brun-coin); line-height: 1; }
.brun-tally .sub { font-size: .78rem; color: var(--mut); }
.brun-tally .best { font-size: .7rem; color: var(--dim); }
.brun-tally .best.new { color: var(--g); }

.brun-row { display: flex; gap: 9px; justify-content: center; flex-wrap: wrap; }

/* Buttons borrow the theme's shape but stay local, so a theme change to .btn
   never silently reflows the game's controls. */
.brun-btn {
  font-family: var(--fm);
  font-weight: 700; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase;
  color: #04140a; background: var(--g);
  border: 0; border-radius: 9px; padding: 11px 18px;
  cursor: pointer; text-decoration: none; display: inline-block;
  transition: filter .15s ease, transform .08s ease;
}
.brun-btn:hover { filter: brightness(1.08); }
.brun-btn:active { transform: translateY(1px); }
.brun-btn--ghost { background: transparent; color: var(--tx); border: 1px solid var(--line2); }
.brun-btn--ghost:hover { background: var(--bg3); }
.brun-btn:focus-visible { outline: 2px solid var(--g); outline-offset: 3px; }

.brun-hint {
  font-family: var(--fm);
  font-size: .68rem; line-height: 1.6; color: var(--dim); text-align: center; margin: 0;
}
.brun-hint b { color: var(--mut); font-weight: 700; }

.brun-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .brun-btn { transition: none; }
  .brun-stat.flash { animation: none; }
}
