* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #05080e;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

canvas {
  position: fixed;
  display: block;
  cursor: default;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

/* ── Score bug — compact broadcast cluster pinned top-center ───────────── */
/* #sb is the positioning context. The scoreboard (.sb-front) sits underneath a single ad
   overlay (#sb-ad) that gently FADES in over it for short, evenly-spread stretches, then
   fades out. Opacity only, and #sb stays position:fixed → never changes VW/VH → PCI untouched. */
#sb {
  position: fixed;
  top: clamp(8px, 1.4vh, 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  /* Display-only HUD: let mouse events pass through to the canvas underneath, so the hidden aim
     cursor drifting up here never gets captured (which froze the PCI and re-showed the OS cursor). */
  pointer-events: none;
}

/* FRONT — dark slate panel, matching the flat in-game UI kit */
.sb-front {
  display: inline-flex;
  align-items: stretch;
  background: #1c2635;
  border: 3px solid #12151c;
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.30);
  padding: clamp(6px, 1vh, 10px) 0;
}

/* Ad overlay — same footprint as the scoreboard, fades in/out over it (opacity only, no motion) */
#sb-ad {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #12151c;
  border: 3px solid #12151c;
  border-radius: 16px;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
#sb-ad.sb-ad-show { opacity: 1; }
#sb-ad img,
#sb-ad video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Clickable ONLY while the ad is live and the pointer isn't locked (toggled by ads.js),
   so the HUD can never capture the aim cursor during a pitch. */
#sb-ad.sb-ad-live { pointer-events: auto; cursor: pointer; }

/* Small honest "Ad" label */
.sb-ad-tag {
  position: absolute; top: 4px; right: 6px;
  font-size: 8px; font-weight: 800; letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.65); text-transform: uppercase;
  pointer-events: none;
}

.sbc {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 clamp(10px, 1.4vw, 18px);
  border-right: 1px solid rgba(244, 247, 251, 0.10);
}
.sbc:last-child { border-right: none; }

.sbl {
  font-size: clamp(7px, 0.8vw, 9px);
  font-weight: 800;
  color: rgba(244, 247, 251, 0.5);
  letter-spacing: 1.6px;
  text-transform: uppercase;
  white-space: nowrap;
}

.score-row { display: flex; align-items: baseline; gap: 7px; }

.sbv {
  font-family: 'Arial Black', 'Arial Rounded MT Bold', Impact, 'Inter', sans-serif;
  font-size: clamp(14px, 2vw, 22px);
  font-weight: 900;
  color: #f4f7fb;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.you { color: #ffd23f; }
.cpu { color: #f4f7fb; }

/* Scoreboard flip: old digit drops out the bottom, new one drops in from the top */
.sbv.you, .sbv.cpu { position: relative; overflow: hidden; }
.fv { display: inline-block; }
.fv.out { position: absolute; left: 0; top: 0; animation: fvOut 0.42s ease-in forwards; }
.fv.in  { animation: fvIn 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.12); }
@keyframes fvOut { to   { transform: translateY(115%); opacity: 0; } }
@keyframes fvIn  { from { transform: translateY(-115%); } to { transform: translateY(0); } }
.score-sep { color: rgba(244, 247, 251, 0.35); font-weight: 400; font-size: clamp(11px, 1.4vw, 15px); }
.inn { color: #f4f7fb; }

/* Bases diamond */
#bdd {
  display: grid;
  grid-template-areas: 'a b' 'c d';
  grid-template-rows: clamp(9px, 1.2vw, 13px) clamp(9px, 1.2vw, 13px);
  grid-template-columns: clamp(9px, 1.2vw, 13px) clamp(9px, 1.2vw, 13px);
  gap: 3px;
  /* -45°: 2B on top, 3B left, 1B right, home-gap at the bottom */
  transform: rotate(-45deg);
}

.bd {
  background: rgba(244, 247, 251, 0.10);
  border: 2px solid rgba(244, 247, 251, 0.55);
  border-radius: 3px;
  transition: background 0.12s, transform 0.12s;
}
.bd.on {
  background: #ffd23f;
  transform: scale(1.15);
}

/* Balls / strikes / outs pips */
#pips { display: flex; gap: 5px; align-items: center; }

.pip {
  width: clamp(8px, 1vw, 11px);
  height: clamp(8px, 1vw, 11px);
  border-radius: 50%;
  border: 2px solid rgba(244, 247, 251, 0.55);
  background: rgba(244, 247, 251, 0.10);
  transition: background 0.1s, transform 0.1s;
}

.pb.on { background: #58b8ff; transform: scale(1.15); }
.ps.on { background: #ff5c5c; transform: scale(1.15); }
.po.on { background: #ffd23f; transform: scale(1.15); }

.pl {
  font-size: clamp(7px, 0.8vw, 9px);
  font-weight: 800;
  color: rgba(244, 247, 251, 0.5);
  letter-spacing: 0.5px;
  margin: 0 1px 0 6px;
}
.pl:first-child { margin-left: 0; }

/* ── Leaderboard name field ──────────────────────────────────────────────────
   Sits over the canvas menu; main.js positions it (canvas logical px == CSS px)
   and toggles display, so it only ever shows on the title screen. Styled to
   match the arcade card kit: cream paper, thick ink border, chunky type. */
#pname {
  position: fixed;
  display: none;
  left: 0; top: 0;
  border: 3px solid #12151c;
  border-radius: 999px;
  background: #2a3648;
  color: #f4f7fb;
  font-family: 'Arial Black', 'Arial Rounded MT Bold', Impact, 'Inter', sans-serif;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  outline: none;
  box-shadow: 0 4px 0 rgba(0,0,0,0.30);
}
#pname::placeholder {
  color: rgba(244,247,251,0.35);
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
}
#pname:focus { border-color: #ffd23f; }
