:root {
  --away: #2f6fed;
  --home: #e03131;
  --bat: var(--away);
  --amber: #ffc53d;
  --panel: rgba(17, 25, 40, 0.88);
  --line: #27344d;
  --ink: #e7ecf5;
  --dim: #8fa0bd;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", sans-serif;
  --led: "Courier New", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(1100px 520px at 50% -8%, #20345c 0%, #0a0f1a 62%) fixed #0a0f1a;
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.good { color: #69db7c; }
.bad { color: #ff7b7b; }
.warn { color: #ffd43b; }
.gold { color: #ffd700; }
.away-t { color: #8db8ff; }
.home-t { color: #ff9a9a; }

#app {
  height: 100vh;
  height: 100dvh;
  max-width: 1500px;
  margin: 0 auto;
  padding: 8px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
}

/* ---------------------------------------------------------------- jumbotron */

.jt {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 14px 10px;
  border-radius: 14px;
  border: 3px solid #2c3444;
  background:
    radial-gradient(circle at 6px 5px, #ffe9a8 0 2px, transparent 3px) 0 0 / 18px 10px repeat-x,
    linear-gradient(#10151f, #05070b);
  box-shadow: inset 0 0 0 2px #000, 0 8px 26px rgba(0, 0, 0, 0.55);
}
.jt-label {
  font: 700 10px/1 var(--led);
  letter-spacing: 2px;
  color: var(--dim);
}

.jt-atbat { display: grid; gap: 6px; justify-items: center; }
.atbat-row { display: flex; align-items: center; gap: 6px; }
.vs { font: 700 11px var(--led); color: var(--dim); }
.chip {
  position: relative;
  display: grid;
  justify-items: center;
  min-width: 62px;
  padding: 5px 8px 4px;
  border-radius: 8px;
  border: 2px solid #2a3345;
  background: #0b0f17;
  opacity: 0.5;
  transition: opacity 0.2s, box-shadow 0.2s;
}
.chip b { font: 400 17px/1 var(--display); letter-spacing: 1px; }
.chip small { font: 700 10px/1.3 var(--led); color: var(--dim); }
.chip .arrow {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%) rotate(90deg);
  font-size: 12px;
  visibility: hidden;
}
.chip.away b, .chip.away .arrow { color: #8db8ff; }
.chip.home b, .chip.home .arrow { color: #ff9a9a; }
.chip.batting { opacity: 1; }
.chip.batting .arrow { visibility: visible; animation: bob 0.8s ease-in-out infinite; }
.chip.away.batting { border-color: var(--away); box-shadow: 0 0 14px rgba(47, 111, 237, 0.7); }
.chip.home.batting { border-color: var(--home); box-shadow: 0 0 14px rgba(224, 49, 49, 0.7); }
.half { font: 700 14px/1 var(--led); color: var(--amber); text-shadow: 0 0 8px rgba(255, 197, 61, 0.6); letter-spacing: 2px; white-space: nowrap; }
.half small { margin-left: 7px; font-size: 11px; color: #cbd5e1; text-shadow: none; letter-spacing: 1.5px; }
@keyframes bob { 50% { transform: translateX(-50%) translateY(3px) rotate(90deg); } }

#linescore {
  width: 100%;
  border-collapse: separate;
  border-spacing: 2px;
  font: 700 15px/1 var(--led);
  table-layout: fixed;
  margin: 0 auto;
}
#linescore th, #linescore td {
  height: 26px;
  text-align: center;
  background: #0a0e15;
  border: 1px solid #1c2534;
  border-radius: 3px;
  color: #cbd5e1;
  position: relative;
}
#linescore thead th { height: 30px; font-size: 12px; color: var(--dim); vertical-align: bottom; padding-bottom: 3px; }
#linescore td { color: var(--amber); text-shadow: 0 0 7px rgba(255, 197, 61, 0.55); }
#linescore th.team {
  width: 104px;
  text-align: left;
  padding: 0 6px 0 4px;
  white-space: nowrap;
  font: 400 15px/1 var(--display);
  letter-spacing: 1px;
}
#linescore th.team small { font: 700 10px var(--led); color: var(--dim); margin-left: 5px; }
#linescore tr.away th.team { color: #8db8ff; }
#linescore tr.home th.team { color: #ff9a9a; }
#linescore .arrow { display: inline-block; width: 14px; font-size: 10px; visibility: hidden; }
#linescore tr.batting .arrow { visibility: visible; }
#linescore tr.batting th.team { background: #121a29; }
#linescore thead th.length { font: 700 10px/1 var(--led); letter-spacing: 1.5px; color: var(--amber); vertical-align: middle; padding: 0 4px; text-align: center; }
#linescore thead th.extra { color: #ff9a9a; }
#linescore thead th.cur { background: #3b2f08; color: #fff; border-color: var(--amber); }
#linescore td.cur { background: #241d06; border-color: var(--amber); }
#linescore .half-tag { display: block; font-size: 8px; letter-spacing: 1px; color: var(--amber); line-height: 1.1; }
#linescore .total { width: 38px; color: #fff; text-shadow: 0 0 8px rgba(255, 255, 255, 0.5); font-size: 17px; }
#linescore thead .total { color: var(--dim); text-shadow: none; font-size: 12px; }

.jt-count { display: flex; align-items: center; gap: 14px; }
.count-lights { display: grid; gap: 8px; }
.lights { display: flex; align-items: center; gap: 6px; }
.lights .jt-label { width: 58px; }
.light {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #262c38;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}
.light.out.on { background: #ff3b30; box-shadow: 0 0 12px #ff3b30, inset 0 1px 2px rgba(255, 255, 255, 0.6); }
.light.strike.on { background: #ffd60a; box-shadow: 0 0 12px #ffd60a, inset 0 1px 2px rgba(255, 255, 255, 0.6); }

.mini-diamond { position: relative; width: 62px; height: 58px; }
.mini-diamond .bag, .mini-diamond .plate {
  position: absolute;
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  background: #262c38;
  border: 1px solid #3d475a;
  border-radius: 2px;
}
#b2 { left: 23px; top: 3px; }
#b3 { left: 3px; top: 23px; }
#b1 { left: 43px; top: 23px; }
.mini-diamond .plate { left: 26px; top: 43px; width: 10px; height: 10px; background: #5b6474; }
.mini-diamond .bag.on { background: var(--bat); border-color: #fff; box-shadow: 0 0 12px var(--bat); }

/* ---------------------------------------------------------------- stage */

#stage {
  display: grid;
  grid-template-columns: minmax(170px, 250px) minmax(0, 1fr) minmax(170px, 250px);
  gap: 10px;
  min-height: 0;
}
#center { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-width: 0; min-height: 0; }
#lane-wrap { display: flex; justify-content: center; align-items: center; min-width: 0; min-height: 0; }
#lane {
  display: block;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.65), 0 0 0 2px #1d120a;
  touch-action: none;
  cursor: grab;
}
#lane:active { cursor: grabbing; }

.panel { display: flex; flex-direction: column; gap: 10px; min-width: 0; min-height: 0; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}
.card.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.card h3 { margin: 0 0 8px; font: 400 14px/1 var(--display); letter-spacing: 1.5px; color: var(--dim); }
.card h3 small { font: 600 10px system-ui, sans-serif; letter-spacing: 0; text-transform: lowercase; }
.prompt { font-weight: 700; font-size: 14px; border-left: 5px solid var(--bat); }

#face-legend, #log { list-style: none; margin: 0; padding: 0; }
/* Die-face key: one strip across the top of the board. */
.faces { display: flex; align-items: center; gap: 14px; padding: 6px 12px; }
.faces h3 { margin: 0; white-space: nowrap; }
.faces h3 small { display: block; margin-top: 3px; }
#face-legend { display: flex; flex: 1; justify-content: space-around; gap: 6px; min-width: 0; }
#face-legend li { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 8px; min-width: 0; }
#face-legend li.rolled { background: rgba(255, 255, 255, 0.09); outline: 1px solid rgba(255, 255, 255, 0.25); }
#face-legend .dice { display: flex; gap: 3px; flex: none; }
#face-legend b { display: block; font-size: 12px; letter-spacing: 0.5px; white-space: nowrap; }
#face-legend small { color: var(--dim); font-size: 11px; white-space: nowrap; }
svg.die { width: 22px; height: 22px; display: block; flex: none; }

#log { overflow-y: auto; font-size: 12px; line-height: 1.35; flex: 1; }
#log li { padding: 5px 0 5px 8px; border-left: 3px solid #3a4763; margin-bottom: 4px; color: #cbd5e1; }
#log li.good { border-color: #69db7c; }
#log li.bad { border-color: #ff7b7b; }
#log li.warn { border-color: #ffd43b; }
#log li.info { border-color: #74c0fc; }
#log li:first-child { color: #fff; }

.gutter { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 8px; background: #0b0704; border-radius: 8px; box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.8); }
.gutter svg.die { width: 26px; height: 26px; }
.gutter .slot { width: 26px; height: 26px; border-radius: 6px; border: 1.5px dashed #4a3a2a; }
.gutter small { margin-left: auto; color: var(--dim); font: 700 11px var(--led); }

.btn {
  appearance: none;
  border: 1px solid #3a4763;
  border-radius: 10px;
  background: #1a2437;
  color: var(--ink);
  font: 400 15px/1 var(--display);
  letter-spacing: 1.5px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.2); }
.btn.danger { background: #2b1418; border-color: #8a3038; color: #ffb3b3; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: linear-gradient(#ffd35a, #f0a202); color: #241a00; border-color: #ffe08a; font-size: 18px; padding: 15px 14px; }
.btn.primary:disabled { background: #2a3142; color: #8fa0bd; border-color: #3a4763; }
.btn.primary.pulse { animation: pulse 1.1s ease-in-out infinite; }
.btn.hold { background: #3b2a06; border-color: var(--amber); color: #ffe08a; }
.btn.small { font-size: 12px; padding: 9px 8px; flex: 1; white-space: nowrap; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row.center { justify-content: center; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 197, 61, 0.25); } }

.weather { border-left: 5px solid var(--sky, var(--line)); }
.weather-now b { display: block; font: 400 18px/1.15 var(--display); letter-spacing: 1.5px; color: var(--sky, var(--ink)); }
.weather-now small { color: var(--dim); font-size: 11px; }
.grove { display: flex; align-items: center; gap: 10px; cursor: pointer; background: linear-gradient(rgba(44, 104, 56, 0.45), rgba(20, 58, 32, 0.6)); border-color: #2f7a43; }
.grove-text b { display: block; font: 400 13px/1.2 var(--display); letter-spacing: 1px; }
.grove-text small { color: #cfe8cf; font-size: 11px; }
.skin-list { display: grid; grid-template-columns: 1fr; gap: 5px; }
.skin { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 6px 7px; border-radius: 9px; border: 1px solid #2f3d5c; background: #0f1727; color: #dbe5f7; font: 600 12px system-ui, sans-serif; text-align: left; cursor: pointer; }
.skin:hover { border-color: #4a5f8c; }
.skin.on { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber) inset; color: #fff; }
.skin i { flex: none; width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, 0.35); }
.skin span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch .knob { position: absolute; inset: 0; border-radius: 12px; background: #3a2a1a; border: 1px solid #8a6238; transition: background 0.15s; pointer-events: none; }
.switch .knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #e7d9c6; transition: transform 0.15s; }
.switch input:checked + .knob { background: #f0a202; }
.switch input:checked + .knob::after { transform: translateX(20px); }
.switch input:disabled + .knob { opacity: 0.5; }

/* ---------------------------------------------------------------- modals */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(3, 6, 12, 0.8);
  backdrop-filter: blur(5px);
}
.modal.open { display: flex; }
.sheet {
  width: 100%;
  max-width: 700px;
  max-height: 94vh;
  max-height: 94dvh;
  overflow-y: auto;
  padding: 24px;
  border-radius: 18px;
  border: 1px solid #2f3d5c;
  background: linear-gradient(#18233a, #0e1525);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7);
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}
.sheet h1 { margin: 0; font: 400 46px/1 var(--display); letter-spacing: 3px; color: var(--amber); text-shadow: 0 3px 0 #7a4a00; }
.sheet h1.logo { line-height: 0; text-shadow: none; }
.sheet h1.logo img { width: min(250px, 58vw, 34dvh); height: auto; filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.6)); }
.logo-small { display: block; width: min(120px, 30vw, 18dvh); height: auto; margin: -6px auto 8px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.6)); }
.sheet h2 { margin: 0 0 14px; font: 400 30px/1 var(--display); letter-spacing: 2px; color: var(--amber); }
.tagline { color: #b9c5da; margin: 10px 0 18px; }

/* ---- Home: the clubhouse at night ----
   The outfield wall runs across the top in the field skin's colours, with the logo hung
   where the wall meets the dark. Below it everything is deep navy: slate panels, gold
   for the one thing that matters most, and only a trace of the park behind them (a wash
   of the skin's grass under the wall, the foul lines and home plate in faint chalk at
   the foot). ui.js sets the --hf-* values from the skin. */
:root {
  --hf-grass-a: #459d4a; --hf-grass-b: #358a3b; --hf-infield: #4aa34f;
  --hf-dirt: #b98049; --hf-dirt-dark: #a06a38; --hf-track: #7d4f2c;
  --hf-wall: #0f4a2a; --hf-line: #facc15; --hf-frame: #7b5229; --hf-chalk: #ffffff;
  --gold: #f5c542; --gold-edge: #b08a24; --night: #0b0f1c; --navy: #111a2e; --slot: #263154; --cream: #f5ecd0;
  --ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.ico { flex: none; width: 1.25em; height: 1.25em; margin-right: 0.5em; vertical-align: -0.24em; }
/* Home is a page, not a window: it takes the table's place and the browser scrolls it
   like any other page. (It keeps the .modal class because that is what pauses the game.) */
body.at-home { overflow-x: hidden; overflow-y: auto; }
body.at-home #app { position: fixed; inset: 0; z-index: -1; visibility: hidden; pointer-events: none; }
/* Parts of the scoreboard switch themselves visible (the at-bat arrows); put those away too. */
body.at-home #app * { visibility: hidden !important; }
/* A window opened over Home (how to play, the online lobby) holds the page still behind it. */
body.at-home:has(.modal.open:not(#modal-mode)) { overflow: hidden; }
#modal-mode { position: static; display: none; padding: 0; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
#modal-mode.open { display: block; }
.sheet.home { max-width: none; max-height: none; overflow: visible; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--night); }
.home-inner { position: relative; display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; padding: 0 24px; }
/* The wall runs the width of the page; everything under it keeps to one column. */
.home-col { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 1100px; margin: 0 auto; }
.home-inner > * { position: relative; z-index: 1; }

/* What is left of the park. */
.home-inner > .home-bg { position: absolute; z-index: 0; inset: 0; overflow: hidden; pointer-events: none; }
.home-bg::before {
  content: ''; position: absolute; inset: 0; opacity: 0.3;
  background: radial-gradient(ellipse 70% 360px at 50% 70px, var(--hf-grass-a), transparent 72%);
}
.home-field { position: absolute; left: 50%; bottom: 38px; margin-left: -800px; }
.hf-dirt { fill: var(--hf-dirt); fill-opacity: 0.05; stroke: var(--hf-chalk); stroke-width: 2; stroke-opacity: 0.1; }
.hf-foul { fill: none; stroke: var(--hf-chalk); stroke-width: 3; stroke-opacity: 0.08; }
.hf-box { fill: none; stroke: var(--hf-chalk); stroke-width: 3; stroke-opacity: 0.28; }
.hf-plate { fill: #fbfbf6; fill-opacity: 0.55; }

/* The wall: padding in the skin's colour, the line along its top, the warning track at its foot. */
.home-wall {
  display: flex; align-items: center; justify-content: space-between;
  height: 92px; margin: 0 -24px; padding: 0 clamp(18px, 7%, 70px);
  background: linear-gradient(rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.5)), var(--hf-wall);
  border-top: 5px solid var(--hf-line);
  border-bottom: 10px solid var(--hf-track);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.55);
  color: var(--hf-line); font: 700 14px Arial, sans-serif; letter-spacing: 2px;
}
.home-wall .gap { width: min(170px, 36vw); }
/* The logo straddles the foot of the wall. */
.sheet.home h1.logo { margin-top: -57px; }
.sheet.home h1.logo img { width: min(114px, 24vw, 14dvh); filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.7)) drop-shadow(0 0 26px rgba(0, 0, 0, 0.5)); }
.sheet.home .tagline { margin: 8px 0 0; font-size: 14px; letter-spacing: 0.5px; color: #fff; opacity: 0.7; }

/* The last line on the page, under home plate. */
.home-foot { margin: auto 0 0; padding: 82px 0 16px; font: 800 10px/1.8 var(--ui); letter-spacing: 2.5px; text-transform: uppercase; color: #6f7f9c; }
.home-foot span { white-space: nowrap; }
.home-foot i { margin: 0 6px; font-style: normal; color: var(--gold); opacity: 0.7; }

/* Section names: a gold diamond, the name, and a rule running off to the right. */
.home-label { display: flex; align-items: center; gap: 10px; margin: 32px 0 14px; font: 800 12px/1 var(--ui); letter-spacing: 3px; text-transform: uppercase; color: var(--gold); text-align: left; }
.home-label::before { content: '◆'; letter-spacing: 0; }
.home-label::after { content: ''; flex: 1; height: 1px; margin-left: 8px; background: linear-gradient(90deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0)); }
.home-label:first-of-type { margin-top: 22px; }

/* Panels: slate on navy. */
.sheet.home .mode, .home-setup, .home-account {
  background: linear-gradient(160deg, #1f2847, #171e38);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

/* Home's buttons. Gold is spent once, on the one thing most players came to do. */
.sheet.home .btn { display: inline-flex; align-items: center; justify-content: center; height: 42px; padding: 0 16px; white-space: nowrap; border-radius: 12px; font: 800 12px/1 var(--ui); letter-spacing: 2px; text-transform: uppercase; }
.sheet.home .btn .ico { width: 16px; height: 16px; margin-right: 8px; color: var(--gold); }
.sheet.home .btn.primary { height: 48px; margin-bottom: 4px; border: 0; background: var(--gold); color: var(--night); font-size: 14px; box-shadow: 0 4px 0 var(--gold-edge), 0 12px 22px rgba(245, 197, 66, 0.16); }
.sheet.home .btn.primary:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-edge); }
.sheet.home .btn.primary:disabled { background: var(--slot); color: #8fa0bd; box-shadow: none; }
.sheet.home .btn.solid { background: var(--slot); border: 1px solid rgba(255, 255, 255, 0.1); color: #e7ecf5; }
.sheet.home .btn.outline { background: var(--navy); border: 1px solid rgba(245, 197, 66, 0.6); color: var(--gold); }
.sheet.home .btn.pill { border-radius: 999px; background: #232c4b; border: 1px solid rgba(255, 255, 255, 0.12); color: #dfe6f3; }
.sheet.home .btn.small { flex: none; height: 38px; font-size: 11px; }
.sheet.home .btn[hidden] { display: none; }
.sheet.home .btn.home-resume { display: flex; width: max-content; max-width: 100%; margin: 16px auto 0; border-radius: 999px; background: var(--navy); border: 1px solid var(--gold); color: var(--gold); }
.sheet.home .btn.home-resume[hidden] { display: none; }

/* ONLINE PLAYER: whose jersey this device is wearing. */
.home-account { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 14px 18px; text-align: left; }
.avatar { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: linear-gradient(#3a5fc4, #253f8c); border: 2px solid rgba(255, 255, 255, 0.16); color: #fff; font: 800 17px/1 var(--ui); }
.avatar .ico { width: 22px; height: 22px; margin: 0; }
.avatar b, .signed .avatar .ico { display: none; }
.signed .avatar b { display: block; }
/* A player who has given Clerk a picture wears it instead of their initial. */
.avatar img { grid-area: 1 / 1; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.avatar:has(img:not([hidden])) b { display: none; }
.who { flex: 1 1 260px; display: grid; gap: 5px; min-width: 0; }
#home-who { font-size: 14px; line-height: 1.4; color: #c3cde0; }
.signed #home-who { font-size: 16px; }
#home-who b { color: #fff; }
.who small { display: none; font-size: 12px; color: #7b89a6; overflow-wrap: anywhere; }
.signed .who small { display: block; }
#home-mail:not(:empty)::after { content: ' • '; }
.status { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, 0.1); background: var(--navy); color: #8fa0c4; font: 800 10px/1 var(--ui); letter-spacing: 2px; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #69db7c; box-shadow: 0 0 8px rgba(105, 219, 124, 0.7); }

/* PLAY: three cards of one height, each read from the top left. */
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.mode {
  position: relative;
  overflow: hidden;
  display: grid;
  justify-items: start;
  align-content: start;
  padding: 24px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s, box-shadow 0.14s;
}
/* A floodlight, far off, in the corner of every card. */
.mode::before { content: ''; position: absolute; top: -46px; right: -56px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255, 255, 255, 0.035); pointer-events: none; }
.mode > * { position: relative; }
div.mode { cursor: default; }
.mode:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gold), 0 14px 34px rgba(0, 0, 0, 0.5); }
@media (hover: hover) {
  .sheet.home .mode:hover { box-shadow: 0 0 0 2px var(--gold), 0 14px 34px rgba(0, 0, 0, 0.5); }
  .sheet.home button.mode:hover { transform: translateY(-4px); }
}
/* The game on the table. */
.sheet.home .mode.selected { background: linear-gradient(160deg, #26304f, #1b2340); box-shadow: 0 0 0 2px var(--gold), 0 0 34px rgba(245, 197, 66, 0.22); }
.mode.selected::after { content: 'NOW PLAYING'; position: absolute; top: 24px; right: 22px; padding: 7px 12px; border-radius: 999px; background: var(--gold); color: var(--night); font: 800 10px/1 var(--ui); letter-spacing: 2px; }
.mode-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 13px; background: var(--slot); border: 1px solid rgba(255, 255, 255, 0.1); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07); }
.mode-icon svg { display: block; width: 34px; height: 34px; }
.mode-title { margin-top: 16px; font: 800 23px/1.1 var(--ui); letter-spacing: 1px; color: var(--cream); }
.mode-desc { margin-top: 8px; font-size: 14px; line-height: 1.55; color: #aab4cc; }
/* The foot of a card: who plays whom, or what kind of game it is. */
.mode-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; width: 100%; margin-top: 18px; }
.mode-foot i { font: 700 11px/1 var(--ui); letter-spacing: 1px; color: #6f7f9c; }
.mode-foot em { margin-left: auto; font: 800 10px/1 var(--ui); letter-spacing: 2px; color: #6f7f9c; }
.die-chip { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #fff; }
.die-chip svg { display: block; width: 20px; height: 20px; }
.die-chip.away { background: #3558b8; box-shadow: 0 3px 0 #223a80; }
.die-chip.home { background: #a8322f; box-shadow: 0 3px 0 #6f1f1d; }
.tag { padding: 8px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.05); border: 1px solid rgba(255, 255, 255, 0.12); color: #8fa0c4; font: 800 10px/1 var(--ui); letter-spacing: 1.5px; }
.mode.online .btn.primary { width: 100%; margin-top: 16px; }
/* Playing a friend: open a room, or type the code of theirs. */
.friend { display: grid; gap: 8px; width: 100%; margin-top: 8px; }
.join { display: flex; gap: 8px; min-width: 0; }
.join input { flex: 1; width: 0; min-width: 0; height: 42px; padding: 0 6px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.1); background: var(--navy); color: var(--ink); font: 700 15px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; text-align: center; text-transform: uppercase; }
.join input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.join input::placeholder { color: #5d6b88; font: 800 11px var(--ui); letter-spacing: 2px; }
.join .btn { flex: none; padding: 0 14px; }
.mode.online .form-error { width: 100%; min-height: 0; margin-top: 10px; }
.mode.online .form-error:empty { display: none; }
@media (min-width: 861px) {
  /* Icon, name, then the words take what room is left, so every card's last line sits on one level. */
  .mode { grid-template-rows: auto auto 1fr; }
}

/* GAME SETUP: how the game plays on the first row, how it looks on the second. */
.home-setup { display: grid; gap: 18px; padding: 18px; text-align: left; }
.setup-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; min-width: 0; }
.setup-name { font: 800 11px/1 var(--ui); letter-spacing: 3px; text-transform: uppercase; color: #7b89a6; }
.innings { display: flex; align-items: center; gap: 12px; }
.innings .unit { font-size: 13px; color: #6f7f9c; }
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 999px; background: var(--navy); border: 1px solid rgba(255, 255, 255, 0.08); }
.seg button { width: 46px; height: 34px; padding: 0; border: 0; border-radius: 999px; background: transparent; color: #8fa0c4; font: 800 14px var(--ui); cursor: pointer; transition: background 0.12s, color 0.12s; }
.seg button:hover { color: #fff; }
.seg button.on { background: var(--gold); color: var(--night); box-shadow: 0 2px 10px rgba(245, 197, 66, 0.3); }
.seg button:focus-visible, .sheet.home .skin:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.home-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.home-toggle { display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 6px 0 12px; border-radius: 999px; background: var(--navy); border: 1px solid rgba(255, 255, 255, 0.1); color: #aab4cc; font: 800 11px/1 var(--ui); letter-spacing: 2px; text-transform: uppercase; cursor: pointer; }
.home-toggle .ico { width: 18px; height: 18px; margin: 0; }
.sheet.home .switch .knob { background: var(--slot); border-color: rgba(255, 255, 255, 0.14); }
.sheet.home .switch .knob::after { background: #fff; }
.sheet.home .switch input:checked + .knob { background: var(--gold); border-color: var(--gold); }
.home-skins { display: grid; gap: 12px; min-width: 0; }
.skins-head { display: flex; align-items: center; gap: 12px; }
.skins-head .rule { flex: 1; height: 1px; background: rgba(255, 255, 255, 0.08); }
.skins-head .now { font-size: 12px; color: #6f7f9c; }
.skins-head .now b { color: #e7ecf5; }
.home-skins .skin-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.sheet.home .skin { position: relative; flex-direction: column; align-items: stretch; gap: 0; padding: 0; overflow: hidden; border-radius: 14px; border: 1px solid rgba(255, 255, 255, 0.1); background: #151c33; color: #aab4cc; transition: transform 0.12s, box-shadow 0.12s; }
.sheet.home .skin i { width: auto; height: 44px; border: 0; border-radius: 0; }
.sheet.home .skin svg { display: block; width: 100%; height: 100%; }
.sheet.home .skin span { padding: 12px 14px; font: 700 13px/1 var(--ui); letter-spacing: 0.3px; text-align: left; }
.sheet.home .skin:hover { border-color: rgba(245, 197, 66, 0.55); transform: translateY(-2px); }
.sheet.home .skin.on { border-color: var(--gold); background: #221e16; box-shadow: 0 0 0 1px var(--gold), 0 6px 20px rgba(245, 197, 66, 0.16); color: var(--cream); }
.sheet.home .skin.on span { padding-right: 36px; }
.sheet.home .skin.on::after { content: '✓'; position: absolute; right: 11px; bottom: 9px; width: 19px; height: 19px; border-radius: 50%; background: var(--gold); color: var(--night); font: 800 11px/19px var(--ui); text-align: center; }

/* ---- online lobby ---- */
.sheet.online { max-width: 560px; }
.sheet.online section { margin: 0 0 14px; }
.sheet.online section[hidden] { display: none; }
.tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 14px; }
.tabs button { border: 1px solid #33415e; background: #121b2e; color: var(--ink); border-radius: 999px; padding: 8px 16px; cursor: pointer; font: 400 13px var(--display); letter-spacing: 1px; }
.tabs button.on { background: var(--amber); color: #241a00; border-color: #ffe08a; }
.form { display: grid; gap: 10px; text-align: left; max-width: 380px; margin: 0 auto; }
.form label { display: grid; gap: 4px; font-size: 12px; color: var(--dim); }
.form label[hidden] { display: none; }
.sheet.online input { width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid #33415e; background: #0b1220; color: var(--ink); font: 600 15px system-ui, sans-serif; }
.sheet.online input:focus { outline: 2px solid var(--amber); outline-offset: 1px; }
.form-error { min-height: 18px; margin: 0; color: #ff8787; font-size: 13px; text-align: center; }
.codebox { display: inline-block; margin: 6px 0 10px; padding: 12px 16px; border-radius: 12px; border: 1px dashed var(--amber); background: #0b1220; color: var(--amber); font: 700 19px ui-monospace, Menlo, Consolas, monospace; letter-spacing: 2px; user-select: all; -webkit-user-select: all; word-break: break-all; }
.codebox.big { font-size: 40px; letter-spacing: 8px; padding: 10px 22px; }
.sheet.online .hint { color: #b9c5da; font-size: 13px; max-width: 440px; margin: 10px auto 14px; }
/* Three balls tossed in turn while the lobby looks for an opponent. */
.searching { display: flex; justify-content: center; gap: 14px; height: 54px; align-items: flex-end; margin: 6px 0 12px; }
.searching i { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffffff, #e9e4d4 70%, #b9b2a0); box-shadow: inset -2px 0 0 -1px #c0392b, inset 2px 0 0 -1px #c0392b, 0 2px 4px rgba(0, 0, 0, 0.5); animation: toss 1.05s cubic-bezier(0.3, 0, 0.7, 1) infinite; }
.searching i:nth-child(2) { animation-delay: 0.15s; }
.searching i:nth-child(3) { animation-delay: 0.3s; }
@keyframes toss { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-30px); } }
.sheet.online h3 { font-family: var(--display, inherit); color: var(--amber); letter-spacing: 2px; margin: 0; }
.search-time { color: #b9c5da; font: 700 15px ui-monospace, Menlo, Consolas, monospace; margin: 4px 0 0; }
@media (prefers-reduced-motion: reduce) { .searching i { animation: none; } }
.sheet.online .fine { color: #6f7f9c; font-size: 11px; margin: 10px 0 0; }
.link { border: 0; background: none; padding: 0; color: #8db8ff; font: inherit; text-decoration: underline; cursor: pointer; }
.sheet.online .btn { display: inline-block; }
.sheet.online .btn.primary { width: 100%; }
.sheet.online .btn-row { margin-bottom: 6px; }
.sheet.online .btn-row .btn { flex: none; }

.tutorial { max-width: 860px; text-align: left; }
.tutorial h2 { text-align: center; }
.tut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.tut-grid section { background: rgba(8, 13, 24, 0.6); border: 1px solid #25324b; border-radius: 12px; padding: 12px 14px; }
.tut-grid h4 { margin: 0 0 6px; font: 400 16px/1.1 var(--display); letter-spacing: 1px; color: #fff; }
.tut-grid p { margin: 0 0 6px; font-size: 13px; line-height: 1.45; color: #c7d1e3; }
.tut-grid p.hint { color: var(--amber); font-size: 12px; }
.zones { list-style: none; margin: 0; padding: 0; font-size: 13px; line-height: 1.4; color: #c7d1e3; }
.zones li { margin-bottom: 5px; }
.zones b { margin-right: 4px; }
.zones .sky-rain { color: #74c0fc; }
.zones .sky-heat { color: #ffa94d; }
.zones .sky-snow { color: #d0ebff; }
.tut-grid section.wide { grid-column: 1 / -1; }
.tutorial .btn.primary { display: block; width: 100%; }

.sheet.confirm { max-width: 480px; }
.sheet.confirm p { margin: 0 auto 16px; max-width: 380px; color: #cbd5e1; line-height: 1.45; }
.sheet.confirm .confirm-score { font: 700 15px var(--led); letter-spacing: 1px; color: var(--amber); margin-bottom: 10px; }
.sheet.confirm .btn-row { gap: 10px; }
.sheet.confirm .btn { flex: 1 1 160px; font-size: 16px; padding: 14px 12px; }
.over .over-score { display: flex; gap: 16px; justify-content: center; align-items: center; font: 700 30px var(--led); margin: 14px 0 4px; }
.over .over-score i { color: var(--dim); font-style: normal; }

/* ---------------------------------------------------------------- small screens */

@media (max-width: 860px) {
  #app { padding: 5px; gap: 5px; }
  .jt { grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 8px 6px; }
  .jt-board { grid-column: 1 / -1; grid-row: 1; }
  .jt-atbat { grid-template-columns: auto auto; align-items: center; justify-content: start; gap: 10px; }
  .jt-atbat > .jt-label { display: none; }
  .chip { min-width: 54px; padding: 4px 6px 3px; }
  .chip b { font-size: 14px; }
  .chip .arrow { top: -11px; }
  .half { white-space: normal; font-size: 12px; letter-spacing: 0.5px; text-align: center; }
  .half span { white-space: nowrap; }
  .half small { display: block; margin: 4px 0 0; font-size: 9px; letter-spacing: 1px; }
  #linescore { font-size: 13px; }
  #linescore th, #linescore td { height: 22px; }
  #linescore thead th { height: 26px; }
  #linescore th.team { width: 78px; font-size: 13px; }
  #linescore th.team small { display: none; }
  #linescore thead th.length { font-size: 8px; letter-spacing: 0.5px; padding: 0 2px; }
  #linescore .total { width: 30px; }
  .jt-count { gap: 8px; }
  .count-lights { gap: 5px; }
  .lights .jt-label { width: 50px; font-size: 9px; }
  .light { width: 12px; height: 12px; }
  .mini-diamond { transform: scale(0.8); margin: -6px; }

  #stage { grid-template-columns: 1fr; grid-template-rows: auto auto minmax(0, 1fr); gap: 5px; }
  #center { grid-row: 1; gap: 5px; }
  #lane-wrap { width: 100%; aspect-ratio: 1000 / 960; max-height: 54vh; max-height: 54dvh; }
  .faces { padding: 4px 6px; }
  .faces h3 { display: none; }
  #face-legend { gap: 2px; }
  #face-legend li { flex-direction: column; gap: 2px; padding: 3px 4px; text-align: center; }
  #face-legend b { font-size: 10px; }
  #face-legend small { display: none; }
  #face-legend svg.die { width: 16px; height: 16px; }
  #right { grid-row: 2; display: grid; grid-template-columns: auto 1fr; gap: 5px; align-items: stretch; }
  #left { grid-row: 3; gap: 5px; overflow: hidden; }
  .prompt { grid-column: 1 / -1; padding: 7px 10px; font-size: 13px; }
  .card.grow { padding: 7px 10px; }
  .card.grow h3 { display: none; }
  .gutter-card { padding: 6px 8px; }
  .gutter-card h3 { display: none; }
  .gutter { gap: 5px; padding: 5px 6px; }
  .gutter small { display: none; }
  .gutter svg.die, .gutter .slot { width: 22px; height: 22px; }
  .btn.hold { grid-column: 1 / -1; padding: 10px; }
  .weather { grid-column: 1 / -1; padding: 6px 10px; }
  .weather h3 { display: none; }
  .weather-now { display: flex; align-items: baseline; gap: 8px; }
  .weather-now b { font-size: 14px; }
  .grove { padding: 6px 10px; }
  .skins { grid-column: 1 / -1; padding: 6px 8px; }
  .skins h3 { display: none; }
  .skin-list { grid-template-columns: 1fr 1fr; }
  .skin { padding: 5px; font-size: 11px; }
  .skin i { width: 16px; height: 16px; }
  .btn-row { grid-column: 1 / -1; }
  .btn.small { padding: 7px 4px; font-size: 11px; }

  .sheet { padding: 16px; }
  .sheet h1 { font-size: 34px; }
  .modes, .tut-grid { grid-template-columns: 1fr; }
  .codebox { font-size: 15px; letter-spacing: 1px; }
  .codebox.big { font-size: 32px; }
  /* Home on a phone: the cards stack, each with its icon beside its name. */
  .modes { gap: 10px; }
  .mode { grid-template-columns: auto 1fr; column-gap: 14px; padding: 16px; }
  .mode-icon { width: 44px; height: 44px; }
  .mode-icon svg { width: 30px; height: 30px; }
  .mode-title { margin-top: 0; align-self: center; font-size: 20px; }
  .mode-desc, .mode-foot, .mode.online .btn.primary, .friend, .mode.online .form-error { grid-column: 1 / -1; }
  .mode-desc { margin-top: 10px; font-size: 13px; }
  .mode-foot { margin-top: 12px; }
  .mode.selected::after { top: 16px; right: 14px; }
  .home-inner { padding: 0 12px; }
  /* Two lines on a phone, broken at the middle dot, with home plate lifted clear of them. */
  .home-field { bottom: 58px; }
  .home-foot { letter-spacing: 2px; }
  .home-foot i { margin: 0 4px; }
  .home-foot .brk { display: block; height: 0; overflow: hidden; }
  .home-wall { height: 70px; margin: 0 -12px; padding: 0 16px; font-size: 11px; letter-spacing: 1px; border-top-width: 4px; border-bottom-width: 8px; }
  .home-wall .gap { width: min(120px, 30vw); }
  .sheet.home h1.logo { margin-top: -46px; }
  .sheet.home h1.logo img { width: min(92px, 24vw, 13dvh); }
  .sheet.home .tagline { font-size: 14px; }
  .home-label { margin: 28px 0 12px; }
  .home-label:first-of-type { margin-top: 20px; }
  .home-account { padding: 14px; }
  .who { flex-basis: calc(100% - 60px); }
  .sheet.home .home-account .btn { flex: 1; }
  .home-setup { padding: 14px; }
  .innings, .home-tools { width: 100%; }
  .innings { flex-wrap: wrap; }
  .innings .setup-name { flex-basis: 100%; }
  .seg { flex: 1; }
  .seg button { flex: 1; width: auto; height: 38px; }
  .home-toggle { width: 100%; }
  .home-toggle .switch { margin-left: auto; }
  .sheet.home .home-tools .btn { flex: 1; }
  .home-skins .skin-list { grid-template-columns: 1fr 1fr; gap: 10px; }
}
