:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #f7fbff;
  --muted: #a9b4c1;
  --panel: #101820;
  --panel-2: #17222d;
  --line: rgba(255, 255, 255, 0.14);
  --accent: #19b57a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0a0f14;
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #233242;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

button:hover {
  border-color: rgba(255, 255, 255, 0.32);
  filter: brightness(1.1);
}

input[type="text"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #0f1720;
  color: var(--ink);
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: #0f1720;
  color: var(--ink);
}

textarea {
  resize: vertical;
}

input[type="color"] {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 7px;
  background: transparent;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.controller-page {
  background:
    linear-gradient(135deg, rgba(25, 181, 122, 0.14), transparent 34%),
    linear-gradient(225deg, rgba(227, 59, 73, 0.14), transparent 38%),
    #0a0f14;
}

.controller-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.topbar,
.settings-panel,
.team-editor,
.count-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(16, 24, 32, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.55rem, 3vw, 2.4rem);
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.language-toggle {
  display: grid;
  grid-template-columns: repeat(2, 42px);
  gap: 4px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 3px;
  background: #0f1720;
}

.language-toggle button {
  min-height: 34px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.language-toggle button.active {
  background: var(--accent);
  color: #06110c;
}

.links a,
.ghost-button,
.wide-button {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  color: var(--ink);
  background: #132b3d;
  text-decoration: none;
  font-weight: 900;
}

.links a.overlay-link {
  background: #176b3f;
  border-color: rgba(95, 235, 161, 0.45);
}

.links a.controller-link {
  background: #8c2630;
  border-color: rgba(255, 121, 133, 0.48);
}

.links a.overlay-link:hover,
.links a.controller-link:hover {
  filter: brightness(1.14);
}

.score-control {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 0.9fr) 1fr;
  gap: 16px;
  margin-top: 16px;
}

.team-editor,
.count-panel,
.settings-panel {
  padding: 16px;
}

.team-editor,
.count-panel {
  display: grid;
  gap: 14px;
}

.team-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  border-radius: 7px;
  padding: 0 14px;
  background: #182737;
  font-weight: 900;
  text-transform: uppercase;
}

.team-header > span {
  overflow: hidden;
  max-width: 55%;
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.team-header output {
  font-size: 2rem;
}

.team-text-input input {
  min-height: 58px;
  font-size: 2rem;
  font-weight: 900;
}

.team-totals {
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 10px;
  align-items: center;
}

.team-totals span {
  display: flex;
  align-items: baseline;
  gap: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.team-totals output {
  color: var(--ink);
  font-size: 1.65rem;
}

.score-buttons,
.pitcher-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.score-buttons {
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.score-buttons button {
  min-height: 36px;
  padding: 0 6px;
}

.color-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 10px;
}

.inning-row,
.half-toggle,
.count-grid,
.pitch-buttons,
.mini-controls,
.base-buttons {
  display: grid;
  gap: 8px;
}

.inning-row {
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
}

.inning-row strong {
  display: grid;
  min-height: 52px;
  place-items: center;
  border-radius: 7px;
  background: #0f1720;
  font-size: 1.8rem;
}

.half-toggle,
.pitch-buttons {
  grid-template-columns: repeat(2, 1fr);
}

.half-toggle button.active {
  background: var(--accent);
  color: #06110c;
}

.count-grid {
  grid-template-columns: repeat(3, 1fr);
}

.count-grid div {
  display: grid;
  gap: 2px;
  place-items: center;
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1720;
}

.count-grid span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.count-grid output {
  font-size: 2rem;
  font-weight: 950;
}

.mini-controls {
  grid-template-columns: repeat(3, 1fr);
}

.mini-controls div {
  display: grid;
  gap: 8px;
}

.base-panel {
  display: grid;
  gap: 8px;
}

.base-panel > span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.base-buttons {
  grid-template-columns: repeat(5, 1fr);
}

.base-buttons button.active {
  background: #f4c343;
  color: #141007;
}

.pitcher-chooser {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0f1720;
}

.pitcher-chooser.hidden {
  display: none;
}

.pitcher-list {
  display: grid;
  gap: 8px;
}

.pitcher-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
}

.pitcher-row {
  align-items: center;
}

.pitcher-row output {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 7px;
  background: #0f1720;
  font-size: 1.35rem;
  font-weight: 950;
}

.wide-button {
  width: 100%;
  background: #244333;
}

.settings-panel {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  align-items: end;
  margin-top: 16px;
}

.toggle {
  display: flex;
  align-items: center;
  min-height: 42px;
}

.toggle input {
  width: 18px;
  height: 18px;
}

.overlay-page {
  overflow: hidden;
  background: transparent;
}

.obs-stage {
  width: 100vw;
  height: 100vh;
  position: relative;
}

.scorebug {
  position: absolute;
  left: 34px;
  bottom: 34px;
  width: min(860px, calc(100vw - 68px));
  filter: drop-shadow(0 20px 32px rgba(0, 0, 0, 0.45));
}

.event-strip,
.pitcher-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(90deg, #101820, #1c2935);
  color: #dce8f2;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.event-strip {
  border-radius: 8px 8px 0 0;
}

.score-main {
  display: grid;
  grid-template-columns: 1fr 158px 1fr;
  min-height: 88px;
  background: rgba(8, 12, 16, 0.92);
  border-left: 1px solid rgba(255, 255, 255, 0.16);
  border-right: 1px solid rgba(255, 255, 255, 0.16);
}

.team-card {
  --team-bg: #174b8a;
  --team-text: #ffffff;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background:
    linear-gradient(90deg, var(--team-bg), color-mix(in srgb, var(--team-bg), black 24%));
  color: var(--team-text);
  min-width: 0;
}

.team-card strong {
  display: block;
  overflow: hidden;
  font-size: clamp(1.05rem, 2.2vw, 1.62rem);
  font-weight: 1000;
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.team-card span {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  opacity: 0.78;
  font-size: 0.74rem;
  font-weight: 850;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.team-card output {
  display: grid;
  min-height: 68px;
  place-items: center;
  border-left: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 3.1rem;
  font-weight: 1000;
  line-height: 1;
}

.logo-box {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.16);
}

.logo-box img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.game-state {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  align-items: center;
  justify-items: center;
  padding: 8px;
  background: #071017;
}

.inning-base-row {
  display: grid;
  grid-template-columns: 58px 58px;
  gap: 12px;
  align-items: center;
  justify-content: center;
}

.inning-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 58px;
  height: 42px;
  border-radius: 6px;
  background: #101b26;
  font-weight: 1000;
}

.inning-badge span {
  color: #f4c343;
  font-size: 1rem;
}

.inning-badge strong {
  font-size: 1.8rem;
}

.bases {
  position: relative;
  width: 58px;
  height: 42px;
}

.bases span {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.08);
  transform: rotate(45deg);
}

.bases span.active {
  border-color: #f4c343;
  background: #f4c343;
  box-shadow: 0 0 14px rgba(244, 195, 67, 0.75);
}

.bases span:nth-child(1) {
  right: 5px;
  top: 16px;
}

.bases span:nth-child(2) {
  left: 21px;
  top: 4px;
}

.bases span:nth-child(3) {
  left: 5px;
  top: 16px;
}

.count-line {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%;
  gap: 4px;
}

.count-line span {
  display: flex;
  justify-content: center;
  gap: 4px;
  border-radius: 5px;
  padding: 6px 0;
  background: #172533;
  color: #c3cfda;
  font-size: 0.95rem;
  font-weight: 950;
}

.count-line b {
  color: #ffffff;
}

.pitcher-strip {
  justify-content: flex-start;
  gap: 10px;
  border-radius: 0 0 8px 8px;
  border-top: 0;
}

.pitcher-strip strong {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pitcher-strip strong:first-of-type {
  margin-right: auto;
}

.pitcher-strip.hidden {
  display: none;
}

.line-scorebug {
  position: absolute;
  left: 34px;
  bottom: 34px;
  width: min(1050px, calc(100vw - 68px));
  filter: drop-shadow(0 20px 32px rgba(0, 0, 0, 0.45));
}

.line-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px 8px 0 0;
  background: linear-gradient(90deg, #101820, #1c2935);
  color: #dce8f2;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.line-score-table {
  --inning-count: 9;
  display: grid;
  grid-template-columns: minmax(150px, 1.35fr) repeat(var(--inning-count), minmax(34px, 0.34fr)) repeat(2, minmax(48px, 0.46fr));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  background: rgba(7, 16, 23, 0.94);
}

.line-cell {
  display: grid;
  min-height: 46px;
  place-items: center;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  color: #f7fbff;
  font-weight: 950;
}

.line-heading,
.line-corner {
  min-height: 34px;
  background: #101b26;
  color: #b9c6d2;
  font-size: 0.86rem;
}

.line-total-heading,
.line-total {
  background: #172533;
  color: #ffffff;
}

.line-team {
  --team-bg: #174b8a;
  --team-text: #ffffff;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  justify-content: start;
  padding: 0 10px;
  background: linear-gradient(90deg, var(--team-bg), color-mix(in srgb, var(--team-bg), black 24%));
  color: var(--team-text);
}

.line-team img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.line-team span {
  overflow: hidden;
  justify-self: start;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.line-inning {
  background: rgba(9, 18, 27, 0.92);
  font-size: 1.12rem;
}

.line-total {
  font-size: 1.32rem;
}

.lineup-controller-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.lineup-status-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  background: rgba(16, 24, 32, 0.92);
}

.lineup-status-panel span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lineup-status-panel strong {
  color: var(--accent);
  font-size: 1.2rem;
  text-transform: uppercase;
}

.lineup-editor {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(16, 24, 32, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

.lineup-editor-header {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.lineup-editor-header img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.12);
}

.lineup-editor-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.lineup-editor-header strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  font-size: 1.7rem;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.lineup-save-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.lineup-inputs {
  display: grid;
  gap: 8px;
}

.lineup-input-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.lineup-input-row span {
  display: grid;
  min-height: 42px;
  place-items: center;
  border-radius: 7px;
  background: #172533;
  color: #f4c343;
  font-size: 1.1rem;
  font-weight: 950;
}

.lineup-overlay {
  --team-bg: #174b8a;
  --team-text: #ffffff;
  position: absolute;
  inset: 34px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  color: var(--team-text);
  filter: drop-shadow(0 20px 32px rgba(0, 0, 0, 0.45));
}

.lineup-overlay.hidden {
  display: none;
}

.lineup-overlay-header {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: min(620px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px 16px;
  background: linear-gradient(90deg, var(--team-bg), color-mix(in srgb, var(--team-bg), black 24%));
}

.lineup-overlay-header img {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.lineup-overlay-header span {
  display: block;
  opacity: 0.74;
  font-size: 0.82rem;
  font-weight: 950;
}

.lineup-overlay-header strong {
  display: block;
  overflow: hidden;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.lineup-field {
  position: relative;
  min-height: 640px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.08)),
    url("/assets/lineup-field.png") center / cover no-repeat;
}

.lineup-player-card {
  position: absolute;
  z-index: 1;
  display: grid;
  gap: 4px;
  justify-items: center;
  width: min(250px, 25vw);
  min-height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 7px 10px;
  background: rgba(8, 12, 16, 0.88);
  color: #f7fbff;
  text-align: center;
}

.lineup-player-card span {
  display: grid;
  min-width: 54px;
  min-height: 28px;
  place-items: center;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--team-bg);
  color: var(--team-text);
  font-size: 1rem;
  font-weight: 1000;
}

.lineup-player-card strong {
  width: 100%;
  overflow: hidden;
  font-size: clamp(1rem, 1.7vw, 1.35rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lineup-player-card[data-order="1"] { left: 50%; top: 51%; transform: translateX(-50%); }
.lineup-player-card[data-order="2"] { left: 50%; bottom: 5%; transform: translateX(-50%); }
.lineup-player-card[data-order="3"] { right: 12%; top: 49%; }
.lineup-player-card[data-order="4"] { right: 28%; top: 36%; }
.lineup-player-card[data-order="5"] { left: 15%; top: 49%; }
.lineup-player-card[data-order="6"] { left: 31%; top: 33%; }
.lineup-player-card[data-order="7"] { left: 8%; top: 22%; }
.lineup-player-card[data-order="8"] { left: 50%; top: 7%; transform: translateX(-50%); }
.lineup-player-card[data-order="9"] { right: 8%; top: 22%; }

.lineup-reserves {
  display: grid;
  gap: 8px;
  width: min(980px, 100%);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(8, 12, 16, 0.88);
}

.lineup-reserves > span {
  color: #b9c6d2;
  font-size: 0.78rem;
  font-weight: 950;
}

.lineup-reserves div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lineup-reserves b {
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.92rem;
}

.license-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.license-card {
  display: grid;
  gap: 16px;
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: rgba(16, 24, 32, 0.95);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

.license-copy {
  margin: 0;
  color: var(--muted);
}

.license-message {
  min-height: 24px;
  color: var(--accent);
  font-weight: 900;
}

.license-brand {
  position: fixed;
  right: 10px;
  bottom: 8px;
  z-index: 20;
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(8, 12, 16, 0.68);
  color: rgba(247, 251, 255, 0.78);
  font-size: 0.72rem;
  font-weight: 800;
  pointer-events: none;
}

@media (max-width: 880px) {
  .score-control,
  .settings-panel,
  .base-buttons,
  .lineup-controller-grid,
  .lineup-save-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .links {
    justify-content: flex-start;
  }

  .scorebug {
    left: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .line-scorebug {
    left: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }

  .score-main {
    grid-template-columns: 1fr;
  }

  .game-state {
    grid-row: 2;
  }

  .lineup-overlay {
    inset: 12px;
  }

  .lineup-field {
    min-height: 620px;
  }

  .lineup-player-card {
    width: min(240px, 44vw);
  }
}
