:root {
  color-scheme: dark;
  --board-green: #11180f;
  --board-green-2: #1d2b1a;
  --painted-green: #243521;
  --gold: #e6b54c;
  --gold-bright: #ffd36a;
  --score-red: #f04a45;
  --score-red-dark: #7e201f;
  --trojan-blue: #21388f;
  --cream: #f7efd7;
  --chalk: #d9e3cb;
  --shadow: rgba(0, 0, 0, 0.42);
  --panel-radius: 8px;
  --app-width: 100vw;
  --app-height: 100vh;
  --app-top: 0px;
  --app-left: 0px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(230, 181, 76, 0.13), transparent 28%),
    radial-gradient(circle at 76% 80%, rgba(33, 56, 143, 0.16), transparent 30%),
    linear-gradient(135deg, #080b08, #182317 52%, #090c08);
  color: var(--cream);
  font-family: "Arial Narrow", "Roboto Condensed", Impact, system-ui, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.28;
  background-image:
    linear-gradient(90deg, transparent 0 10px, rgba(255, 255, 255, 0.03) 10px 11px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.025) 0 1px, transparent 1px 7px);
  mix-blend-mode: overlay;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid var(--gold-bright);
  outline-offset: 3px;
}

.scoreboard-shell {
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(280px, 0.95fr) minmax(210px, 1fr);
  gap: clamp(10px, 1.6vw, 20px);
  width: 100vw;
  height: 100svh;
  min-height: 360px;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
}

.team-panel,
.center-panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 4px solid #050705;
  border-radius: var(--panel-radius);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04), transparent 18% 82%, rgba(255, 255, 255, 0.04)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.026) 0 1px, transparent 1px 42px),
    linear-gradient(180deg, var(--painted-green), var(--board-green));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    inset 0 22px 48px rgba(255, 255, 255, 0.04),
    inset 0 -34px 60px rgba(0, 0, 0, 0.35),
    0 18px 45px var(--shadow);
}

.team-panel::after,
.center-panel::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background:
    linear-gradient(rgba(255, 255, 255, 0.08), transparent 18%),
    radial-gradient(circle at center, transparent 45%, rgba(0, 0, 0, 0.26));
}

.team-panel {
  display: grid;
  grid-template-rows: minmax(96px, 1fr) minmax(122px, auto) minmax(52px, 0.46fr);
  gap: clamp(8px, 1.4vh, 14px);
  padding: clamp(12px, 2vw, 20px);
}

.team-readout {
  z-index: 1;
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 0;
  padding: clamp(8px, 1.5vh, 14px);
  border: 2px solid rgba(230, 181, 76, 0.54);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(6, 9, 6, 0.82), rgba(6, 9, 6, 0.44)),
    radial-gradient(circle at center, rgba(240, 74, 69, 0.11), transparent 52%);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, 0.55);
}

.side-label,
.board-label,
.brand-copy p {
  margin: 0;
  color: var(--gold);
  font-size: clamp(0.72rem, 1.3vw, 1rem);
  font-weight: 800;
  letter-spacing: 0.16rem;
  line-height: 1;
  text-transform: uppercase;
}

.team-readout h1 {
  max-width: 100%;
  margin: 0.36rem 0 0.08rem;
  overflow-wrap: anywhere;
  color: var(--chalk);
  font-size: clamp(1.4rem, 4.2vw, 3.9rem);
  font-weight: 900;
  line-height: 0.95;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #050605, 0 0 18px rgba(230, 181, 76, 0.26);
}

.score-digits,
.inning-number {
  color: var(--score-red);
  font-family: Impact, Haettenschweiler, "Arial Black", sans-serif;
  line-height: 0.88;
  text-align: center;
  text-shadow:
    0 0 4px rgba(240, 74, 69, 0.7),
    0 0 18px rgba(240, 74, 69, 0.36),
    4px 5px 0 var(--score-red-dark);
}

.score-digits {
  width: 100%;
  font-size: clamp(5rem, 20vw, 13.5rem);
  font-variant-numeric: tabular-nums;
}

.score-button {
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 28%),
    linear-gradient(180deg, #be2633, #8f1723);
  box-shadow:
    inset 0 -6px 0 rgba(0, 0, 0, 0.25),
    0 10px 22px rgba(0, 0, 0, 0.3);
  transition: transform 120ms ease, filter 120ms ease;
}

.score-button:active {
  transform: translateY(3px) scale(0.99);
  filter: brightness(0.9);
}

.score-button span {
  font-size: clamp(2rem, 7vw, 5.4rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.32);
}

.correction-button {
  align-self: stretch;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 34%),
    linear-gradient(180deg, #30415b, #1b2534);
}

.correction-button span {
  font-size: clamp(1.3rem, 3.4vw, 2.7rem);
}

.center-panel {
  z-index: 2;
  display: grid;
  grid-template-rows: auto minmax(120px, 1fr) auto auto;
  align-items: center;
  gap: clamp(9px, 1.6vh, 16px);
  padding: clamp(12px, 2vw, 20px);
}

.brand-lockup {
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: clamp(8px, 1.3vw, 14px);
}

.scoreboard-logo {
  width: clamp(60px, 11vw, 116px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 242, 135, 0.62);
  border-radius: 50%;
  box-shadow:
    0 8px 14px rgba(0, 0, 0, 0.36),
    0 0 0 4px rgba(230, 181, 76, 0.2);
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.brand-copy strong {
  display: block;
  color: var(--cream);
  font-size: clamp(1.45rem, 4.2vw, 4.1rem);
  font-weight: 900;
  line-height: 0.94;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #050605;
}

.inning-board {
  z-index: 1;
  display: grid;
  justify-items: center;
  align-content: center;
  min-height: 0;
  padding: clamp(12px, 2vh, 20px);
  border-top: 2px solid rgba(230, 181, 76, 0.42);
  border-bottom: 2px solid rgba(230, 181, 76, 0.42);
  background: rgba(0, 0, 0, 0.22);
}

.inning-display {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: clamp(8px, 1.2vw, 14px);
  width: 100%;
}

.half-inning {
  min-width: 3.7ch;
  color: var(--cream);
  font-size: clamp(1.1rem, 2.4vw, 2.4rem);
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 0 2px 0 #000;
}

.inning-number {
  min-width: 1.4ch;
  font-size: clamp(4.6rem, 14vw, 10.5rem);
}

.inning-controls,
.modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
}

.small-control,
.reset-button,
.modal-button {
  z-index: 1;
  min-height: 44px;
  border-radius: 6px;
  font-weight: 900;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.22), 0 7px 14px rgba(0, 0, 0, 0.28);
}

.small-control {
  flex: 1;
  border: 1px solid rgba(230, 181, 76, 0.34);
  background: linear-gradient(180deg, #f1c35d, #bd822d);
  color: #171006;
}

.next-half {
  background: linear-gradient(180deg, #2d53bd, #20358c);
  color: var(--cream);
}

.game-strip {
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2vw, 18px);
  min-width: 0;
}

.softball-diamond {
  position: relative;
  width: clamp(58px, 9vw, 90px);
  aspect-ratio: 1;
  transform: rotate(45deg);
  border: 2px solid rgba(247, 239, 215, 0.62);
  border-radius: 4px;
  background: rgba(6, 9, 6, 0.45);
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.38);
}

.base,
.plate {
  position: absolute;
  width: 16%;
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--cream);
  box-shadow: 0 0 10px rgba(247, 239, 215, 0.42);
}

.base-one {
  right: -8%;
  top: 42%;
}

.base-two {
  left: 42%;
  top: -8%;
}

.base-three {
  left: -8%;
  top: 42%;
}

.plate {
  left: 42%;
  bottom: -8%;
  background: var(--gold-bright);
}

.inning-markers {
  display: grid;
  grid-template-columns: repeat(7, minmax(12px, 1fr));
  gap: 5px;
  min-width: min(46vw, 180px);
}

.inning-markers span {
  height: 10px;
  border-radius: 2px;
  background: rgba(247, 239, 215, 0.24);
  box-shadow: inset 0 0 0 1px rgba(247, 239, 215, 0.12);
}

.inning-markers span.is-active {
  background: var(--gold-bright);
  box-shadow: 0 0 12px rgba(255, 211, 106, 0.58);
}

.reset-button {
  justify-self: center;
  width: min(100%, 220px);
  border: 1px solid rgba(247, 239, 215, 0.2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 36%),
    linear-gradient(180deg, #2a302b, #111511);
  color: var(--cream);
}

.modal-backdrop {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 5, 4, 0.72);
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-card {
  width: min(430px, 92vw);
  border: 3px solid rgba(230, 181, 76, 0.72);
  border-radius: 8px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 26%),
    #141d12;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.56);
}

.modal-card h2 {
  margin: 0 0 8px;
  color: var(--gold-bright);
  font-size: 1.7rem;
  line-height: 1;
  text-transform: uppercase;
}

.modal-card p {
  margin: 0 0 18px;
  color: var(--chalk);
  font: 700 1rem/1.35 system-ui, sans-serif;
}

.modal-button {
  flex: 1;
}

.modal-button.ghost {
  background: #334136;
}

.modal-button.danger {
  background: linear-gradient(180deg, #f05a55, #9d202b);
}

.rotate-notice {
  display: none;
}

@media (max-aspect-ratio: 1/1) {
  body {
    overflow: hidden;
  }

  .scoreboard-shell {
    filter: blur(4px) brightness(0.46);
    pointer-events: none;
  }

  .rotate-notice {
    position: fixed;
    z-index: 12;
    inset: 0;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 18px;
    padding: 24px;
    background: rgba(6, 9, 6, 0.64);
    text-align: center;
  }

  .rotate-notice img {
    width: min(44vw, 160px);
    filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.36));
  }

  .rotate-notice p {
    margin: 0;
    color: var(--gold-bright);
    font-size: clamp(1.8rem, 9vw, 3.8rem);
    font-weight: 900;
    line-height: 0.98;
    text-transform: uppercase;
    text-shadow: 0 3px 0 #050605;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .scoreboard-shell {
    position: fixed;
    top: calc(var(--app-top) + 8px);
    left: var(--app-left);
    right: auto;
    transform: none;
    grid-template-columns: minmax(0, 1.42fr) minmax(158px, 0.5fr) minmax(0, 1.42fr);
    gap: 7px;
    width: var(--app-width);
    height: calc(var(--app-height) - 16px);
    min-height: 0;
    padding: 8px max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left));
  }

  .team-panel {
    grid-template-columns: minmax(82px, 0.42fr) minmax(0, 1fr) minmax(54px, 0.25fr);
    grid-template-rows: 1fr;
    gap: 7px;
    padding: 10px;
  }

  .visitor-panel {
    grid-template-columns: minmax(54px, 0.25fr) minmax(0, 1fr) minmax(82px, 0.42fr);
  }

  .visitor-panel .primary-score-button {
    grid-column: 3;
  }

  .visitor-panel .team-readout {
    grid-column: 2;
    grid-row: 1;
  }

  .visitor-panel .correction-button {
    grid-column: 1;
    grid-row: 1;
  }

  .team-readout {
    grid-template-rows: auto auto minmax(0, 1fr);
    padding: 8px;
  }

  .team-readout h1 {
    margin-top: 0.25rem;
    font-size: clamp(1.05rem, 3vw, 1.95rem);
  }

  .center-panel {
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    gap: 6px;
    padding: 8px;
  }

  .scoreboard-logo {
    width: clamp(42px, 7vw, 68px);
  }

  .brand-copy {
    display: none;
  }

  .brand-copy strong {
    font-size: clamp(1.05rem, 3vw, 1.85rem);
  }

  .inning-board {
    padding: 8px;
  }

  .score-digits {
    font-size: clamp(4.2rem, 22vh, 8rem);
  }

  .score-button span {
    font-size: clamp(1.65rem, 8vh, 3.4rem);
  }

  .correction-button span {
    font-size: clamp(1rem, 5vh, 1.9rem);
  }

  .inning-number {
    font-size: clamp(3.5rem, 18vh, 6.7rem);
  }

  .half-inning {
    font-size: clamp(0.95rem, 4vh, 1.55rem);
  }

  .softball-diamond {
    width: clamp(44px, 8vh, 58px);
  }

  .inning-markers {
    min-width: min(22vw, 112px);
  }

  .small-control,
  .reset-button {
    min-height: 34px;
  }

  .reset-button {
    width: min(100%, 150px);
  }

  .modal-card {
    padding: 16px;
  }
}

@media (max-width: 1000px) and (orientation: landscape) {
  .scoreboard-shell {
    grid-template-columns: minmax(0, 1.42fr) minmax(150px, 0.5fr) minmax(0, 1.42fr);
    gap: 6px;
  }

  .team-readout h1 {
    font-size: clamp(0.95rem, 2.9vw, 1.55rem);
  }

  .brand-copy p {
    display: none;
  }

  .brand-copy strong {
    font-size: clamp(1.1rem, 3.6vw, 2.1rem);
  }

  .score-digits {
    font-size: clamp(3.8rem, 21vh, 7.6rem);
  }

  .side-label,
  .board-label {
    font-size: clamp(0.62rem, 1.7vw, 0.82rem);
    letter-spacing: 0.1rem;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .scoreboard-shell {
    min-height: 0;
    margin: 0 auto;
  }
}
