:root {
  color-scheme: dark;
  --page: #15110d;
  --ink: #f0dfbd;
  --muted: #bda985;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
}

.yard-shell {
  width: min(100%, 1700px);
  margin: 0 auto;
  padding: 20px clamp(10px, 2vw, 28px) 28px;
}

.yard-header { text-align: center; margin-bottom: 16px; }

.eyebrow,
.grid-readout {
  margin: 0;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.eyebrow { color: var(--muted); font-size: .78rem; }

h1 {
  margin: 3px 0;
  font-size: clamp(1.7rem, 4vw, 3rem);
  line-height: 1;
}

.tabletop {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

/*
  The source artwork is 1600 × 950. Keeping the wrapper at that aspect ratio
  means every invisible interaction zone scales with the artwork itself.
*/
.tabletop-board {
  position: relative;
  width: min(100%, calc((100vh - 155px) * 1.6842105263));
  line-height: 0;
}

#pitch {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

/*
  Playing pitch in the master artwork:
  left  = 9.6875%  (155 / 1600)
  top   = 11.0526% (105 / 950)
  width = 80.1875% (1283 / 1600)
  height= 77.2632% (734 / 950)

  The overlay itself is invisible. Only the selected square is shown for QA.
*/
.pitch-grid {
  position: absolute;
  left: 9.6875%;
  top: 11.0526316%;
  width: 80.1875%;
  height: 77.2631579%;
  display: grid;
  grid-template-columns: repeat(26, 1fr);
  grid-template-rows: repeat(15, 1fr);
  line-height: normal;
}

.pitch-cell {
  min-width: 0;
  min-height: 0;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  cursor: crosshair;
}

.pitch-cell:hover {
  outline: 1px dashed rgba(255, 244, 181, .55);
  outline-offset: -1px;
}

.pitch-cell.is-selected {
  background: rgba(255, 230, 70, .28);
  outline: 2px solid rgba(255, 239, 128, .95);
  outline-offset: -2px;
}

.grid-readout {
  margin-top: 9px;
  min-height: 1.1em;
  color: var(--ink);
  text-align: center;
  font-size: .72rem;
}

@media (max-width: 700px) {
  .yard-shell { padding-top: 12px; }
  .tabletop-board { width: 100%; }
}

.coordinate-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  line-height: normal;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: 700;
  color: rgba(245, 232, 181, .92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .95);
}

.coords { position: absolute; display: grid; }
.coords span { display: flex; align-items: center; justify-content: center; }

.coords-columns {
  left: 9.6875%;
  width: 80.1875%;
  grid-template-columns: repeat(26, 1fr);
  font-size: clamp(5px, .62vw, 11px);
}
.coords-top { top: 9.35%; }
.coords-bottom { top: 88.35%; }

.coords-rows {
  top: 11.0526316%;
  height: 77.2631579%;
  grid-template-rows: repeat(15, 1fr);
  font-size: clamp(5px, .62vw, 11px);
}
.coords-left { left: 8.72%; width: .9%; }
.coords-right { left: 89.93%; width: .9%; }

.pitch-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-token {
  display: block;
  width: 88%;
  max-height: 78%;
  object-fit: contain;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: element;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.55));
  z-index: 4;
}

.player-token:active { cursor: grabbing; }
.player-token.is-picked {
  outline: 2px solid rgba(255, 239, 128, .95);
  outline-offset: 2px;
}

.pitch-cell.is-drop-target {
  background: rgba(255, 230, 70, .18);
  outline: 2px dashed rgba(255, 239, 128, .9);
  outline-offset: -2px;
}

.pitch-cell.is-blocked {
  background: rgba(255, 80, 60, .32);
  outline: 2px solid rgba(255, 220, 180, .95);
  outline-offset: -2px;
}

.dugout-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  line-height: normal;
}

.dugout-zone {
  position: absolute;
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: center;
  gap: 2px;
  padding: 15px 2px 3px;
  cursor: pointer;
}

.dugout-zone.left  { left: 3.55%; width: 4.55%; }
.dugout-zone.right { left: 92.05%; width: 4.55%; }
.dugout-zone.sinbin   { top: 9.35%; height: 17.15%; }
.dugout-zone.reserve  { top: 26.55%; height: 19.55%; padding-top: 32px; }
.dugout-zone.ko       { top: 46.15%; height: 20.35%; padding-top: 32px; }
.dugout-zone.injured  { top: 66.55%; height: 23.15%; padding-top: 32px; }

.dugout-zone.is-drop-target {
  background: rgba(255, 230, 70, .18);
  outline: 2px dashed rgba(255, 239, 128, .9);
  outline-offset: -2px;
}

.dugout-zone .player-token {
  width: 44%;
  height: auto;
  max-height: 28%;
  margin-top: 3px;
}

.bench {
  width: min(100%, 1120px);
  margin: 12px auto 0;
  padding: 10px 12px 12px;
  border: 1px solid rgba(189, 169, 133, .42);
  background: rgba(35, 27, 20, .72);
}

.bench-title {
  margin: 0 0 8px;
  color: var(--muted);
  text-align: center;
  font-size: .68rem;
  letter-spacing: .09em;
  text-transform: uppercase;
}

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

.bench-piece {
  min-width: 0;
  padding: 7px 6px 6px;
  border: 1px solid rgba(240, 223, 189, .24);
  background: rgba(12, 10, 8, .5);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.bench-piece:hover,
.bench-piece:focus-visible {
  border-color: rgba(255, 239, 128, .9);
  background: rgba(255, 239, 128, .08);
  outline: none;
}

.bench-piece img {
  display: block;
  width: min(100%, 96px);
  height: 42px;
  margin: 0 auto 5px;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.45));
}

.bench-piece span {
  display: block;
  font-size: clamp(.55rem, .8vw, .7rem);
  letter-spacing: .05em;
  text-align: center;
}

@media (max-width: 760px) {
  .bench-pieces { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.yard-shell { width: min(100%, 1920px); }
.game-table {
  width: 100%;
  display: grid;
  grid-template-columns: clamp(112px, 9vw, 160px) minmax(0, 1fr) clamp(112px, 9vw, 160px);
  gap: clamp(6px, .8vw, 12px);
  align-items: center;
}
.game-table .tabletop { min-width: 0; }
.game-table .tabletop-board { width: 100%; }
.side-bench {
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid rgba(189, 169, 133, .42);
  background: rgba(35, 27, 20, .72);
}
.side-bench-title {
  margin: 0 0 7px;
  color: var(--ink);
  text-align: center;
  font-size: clamp(.62rem, .8vw, .78rem);
  letter-spacing: .09em;
  text-transform: uppercase;
}
.team-pink .team-shape { color: #ff00d9; }
.team-blue .team-shape { color: #1717df; }
.side-bench-pieces { display: grid; grid-template-columns: 1fr; gap: 6px; }
.side-bench .bench-piece { padding: 5px 3px 4px; }
.side-bench .bench-piece img { width: min(100%, 110px); height: clamp(30px, 4.1vw, 58px); margin-bottom: 3px; }
.side-bench .bench-piece span { font-size: clamp(.48rem, .58vw, .62rem); }
.team-pink { border-color: rgba(255, 0, 217, .55); }
.team-blue { border-color: rgba(23, 23, 223, .75); }
@media (max-width: 900px) {
  .game-table { grid-template-columns: 92px minmax(0, 1fr) 92px; gap: 4px; }
  .side-bench { padding: 5px 3px; }
  .side-bench .bench-piece span { font-size: .45rem; }
}

.player-token {
  position: relative;
  width: 88%;
  max-height: 78%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.player-token img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.55));
  transition: transform 120ms ease;
}

.player-token.state-prone img,
.player-token.state-stunned img {
  transform: rotate(90deg) scale(.72);
}

.state-badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: none;
  min-width: 1.15em;
  padding: .04em .18em;
  border: 1px solid rgba(255,255,255,.92);
  border-radius: 3px;
  background: rgba(24,18,13,.9);
  color: #fff4c8;
  font: 900 clamp(8px, .8vw, 15px)/1 Georgia, serif;
  text-align: center;
  pointer-events: none;
  z-index: 7;
}

.player-token.state-prone .state-badge,
.player-token.state-stunned .state-badge { display: block; }

.dugout-zone .player-token {
  width: 44%;
  height: auto;
  max-height: 28%;
  margin-top: 3px;
}

.status-row {
  width: min(100%, 1540px);
  margin: 10px auto 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 36px;
}

.status-row .grid-readout { margin: 0; }

.state-chooser {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 5px);
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid rgba(232,214,171,.55);
  border-radius: 5px;
  background: rgba(20,15,11,.94);
  box-shadow: 0 2px 7px rgba(0,0,0,.5);
  z-index: 30;
  white-space: nowrap;
}
.state-chooser[hidden] { display: none; }
.state-chooser button {
  width: 28px;
  height: 26px;
  border: 1px solid rgba(232,214,171,.65);
  border-radius: 5px;
  background: rgba(49,38,28,.96);
  color: #f2dfaa;
  font: 900 .9rem Georgia, serif;
  cursor: pointer;
}
.state-chooser button:hover,
.state-chooser button:focus-visible {
  background: rgba(91,72,49,.98);
  outline: 2px solid rgba(255,239,128,.85);
  outline-offset: 1px;
}


.ball-token {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(18px, 58%, 38px);
  aspect-ratio: 168 / 88;
  transform: translate(-50%, -50%) rotate(-8deg);
  cursor: grab;
  z-index: 9;
}
.ball-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.7));
}
.pitch-cell:has(.player-token) .ball-token {
  left: auto;
  top: auto;
  right: -5%;
  bottom: -1%;
  transform: rotate(-8deg) scale(.72);
}
.ball-token:active { cursor: grabbing; }
.ball-token.is-picked {
  outline: 2px solid rgba(255, 239, 128, .98);
  outline-offset: 2px;
}



.counter-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  line-height: normal;
  z-index: 12;
}
.counter-hit {
  position: absolute;
  pointer-events: auto;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
.counter-hit:hover {
  outline: 2px dashed rgba(255,255,225,.82);
  outline-offset: -3px;
}
.counter-hit.is-active {
  outline: 4px solid var(--counter-colour);
  outline-offset: -5px;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.88);
}
.counter-hit:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -4px;
}


.tagline {
  margin: -.25rem 0 .35rem;
  font-style: italic;
  color: rgba(242,223,170,.9);
}
.table-controls {
  display: flex;
  justify-content: center;
  margin: .8rem 0 .15rem;
}
.new-game-button {
  border: 2px solid rgba(242,223,170,.55);
  border-radius: 7px;
  background: rgba(49,38,28,.96);
  color: #f2dfaa;
  padding: .58rem 1.05rem;
  font: 900 .82rem Georgia, serif;
  letter-spacing: .08em;
  cursor: pointer;
}
.new-game-button:hover, .new-game-button:focus-visible {
  border-color: #fff1b6;
  outline: none;
  box-shadow: 0 0 0 2px rgba(255,241,182,.18);
}
.new-game-dialog {
  max-width: 380px;
  border: 3px solid #4a3022;
  border-radius: 10px;
  background: #e6d3a8;
  color: #2e2017;
  padding: 1.2rem 1.3rem;
  box-shadow: 0 18px 60px rgba(0,0,0,.5);
  font-family: Georgia, serif;
}
.new-game-dialog::backdrop { background: rgba(0,0,0,.62); }
.new-game-dialog h2 { margin: 0 0 .45rem; font-size: 1.2rem; }
.new-game-dialog p { margin: 0 0 1rem; }
.new-game-dialog-actions { display: flex; justify-content: flex-end; gap: .55rem; }
.new-game-dialog-actions button {
  border: 2px solid #4a3022; border-radius: 6px; padding: .48rem .7rem;
  font: 900 .78rem Georgia, serif; cursor: pointer; background: #f2e3c1; color: #2e2017;
}
.new-game-dialog-actions .danger { background: #4a3022; color: #f2dfaa; }

/* QA FIX 01 — NEW GAME lives above the pink bench and does not consume bench height. */
.side-bench.team-pink { position: relative; }
.side-bench.team-pink .bench-control {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 28px);
  margin: 0;
  justify-content: center;
  z-index: 30;
}
.side-bench.team-pink .new-game-button {
  padding: .38rem .58rem;
  font-size: .68rem;
  white-space: nowrap;
}


.side-bench.team-blue { position: relative; }
.side-bench.team-blue .table-file-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 28px);
  margin: 0;
  display: flex;
  justify-content: center;
  gap: .22rem;
  z-index: 30;
}
.file-control-button {
  border: 2px solid rgba(242,223,170,.55);
  border-radius: 7px;
  background: rgba(49,38,28,.96);
  color: #f2dfaa;
  padding: .34rem .34rem;
  font: 900 .58rem Georgia, serif;
  letter-spacing: .035em;
  cursor: pointer;
  white-space: nowrap;
}
.file-control-button:hover, .file-control-button:focus-visible {
  border-color: #fff1b6;
  outline: none;
  box-shadow: 0 0 0 2px rgba(255,241,182,.18);
}

.dice-tray-dialog{width:min(980px,92vw);height:min(650px,86vh);padding:0;border:2px solid rgba(242,223,170,.68);border-radius:14px;background:#120c08;color:#f2dfaa;box-shadow:0 24px 90px rgba(0,0,0,.78);overflow:hidden}.dice-tray-dialog::backdrop{background:rgba(0,0,0,.68)}.dice-tray-shell{display:flex;flex-direction:column;height:100%}.dice-tray-topbar{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:1rem;padding:.55rem .7rem .55rem .9rem;border-bottom:1px solid rgba(242,223,170,.28);background:#1b120c;font:900 .72rem Georgia,serif;letter-spacing:.11em}.dice-tray-topbar button{border:1px solid rgba(242,223,170,.55);border-radius:7px;background:#31261c;color:#f2dfaa;padding:.38rem .55rem;font:900 .64rem Georgia,serif;letter-spacing:.055em;cursor:pointer}.dice-tray-topbar button:hover,.dice-tray-topbar button:focus-visible{border-color:#fff1b6;outline:none}#dice-tray-frame{flex:1 1 auto;width:100%;min-height:0;border:0;background:#120c08}@media(max-width:900px){.dice-tray-dialog{width:96vw;height:88vh}.side-bench.team-blue .table-file-controls{gap:.2rem}.file-control-button{padding-left:.34rem;padding-right:.34rem;font-size:.58rem}}

.global-school-nav{position:relative;z-index:1000;width:100%;background:#0d110e;border-bottom:1px solid #6f5130;font-family:Arial,sans-serif}
.global-nav-inner{width:min(1500px,100%);margin:0 auto;padding:12px clamp(14px,3vw,42px);display:flex;align-items:center;gap:24px}
.global-school-nav .global-brand{font-weight:900;letter-spacing:.09em;color:#f4d078;text-decoration:none;font-size:1rem;white-space:nowrap}
.global-school-nav .global-links{margin-left:auto;display:flex;align-items:center;justify-content:flex-end;gap:24px;flex-wrap:nowrap;font:700 .78rem Arial,sans-serif;letter-spacing:.08em}
.global-school-nav .global-links a{text-decoration:none;color:#ddd4bd}
.global-school-nav .global-links a:hover,.global-school-nav .global-links .active{color:#f4d078}
/* Preserve the one-screen tabletop composition after adding the site header. */
.tabletop-board{width:min(100%,calc((100vh - 200px) * 1.6842105263))}
@media(max-width:900px){.global-nav-inner{align-items:flex-start;flex-direction:column;gap:8px;padding:10px 14px}.global-school-nav .global-links{margin-left:0;gap:12px;font-size:.64rem;flex-wrap:wrap;justify-content:flex-start}}
