@font-face {
  font-family: "Press Start 2P";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/press-start-2p-latin.woff2") format("woff2");
}
@font-face {
  font-family: "VT323";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/vt323-latin.woff2") format("woff2");
}

:root {
  --field: #006800;
  --field-dark: #003800;
  --field-line: #e8e8e8;
  --midfield: #f8d800;
  --black: #000;
  --white: #fcfcfc;
  --yellow: #f8d800;
  --red: #f83828;
  --blue: #58d0ff;
  --navy: #2038ec;
  --orange: #f87800;
  --green-lit: #20f020;
  --muted: #d0d0d0;
  --line: #3a3a3a;
  --pixel: "Press Start 2P", system-ui, sans-serif;
  --mono: "VT323", "Courier New", ui-monospace, monospace;
  --g: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
html {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--mono);
  font-size: 22px;
  color: var(--white);
  background-color: var(--field-dark);
  background-image:
    linear-gradient(90deg, transparent calc(50% - 2px), var(--midfield) calc(50% - 2px), var(--midfield) calc(50% + 2px), transparent calc(50% + 2px)),
    repeating-linear-gradient(90deg, transparent 0, transparent 38px, rgba(232, 232, 232, 0.35) 38px, rgba(232, 232, 232, 0.35) 40px),
    repeating-linear-gradient(0deg, var(--field) 0, var(--field) 16px, var(--field-dark) 16px, var(--field-dark) 32px);
  background-attachment: fixed;
}

button, select, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.boot {
  font-family: var(--pixel);
  font-size: 16px;
  text-align: center;
  padding: 40vh 16px 0;
  color: var(--yellow);
}

.app {
  min-height: 100vh;
  padding: 16px 16px 24px;
  max-width: 1120px;
  margin: 0 auto;
}

/* Main Tecmo scoreboard */
.board {
  background: var(--black);
  border: 4px solid var(--yellow);
  box-shadow: 0 0 0 4px #000, 8px 8px 0 #001400;
  padding: 12px;
  margin-bottom: 16px;
}
.board-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.brand {
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--yellow);
  letter-spacing: 2px;
  text-shadow: 4px 4px 0 var(--red);
  margin: 0;
  line-height: 1;
}
.week-chip {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--black);
  background: var(--yellow);
  border: 2px solid var(--white);
  padding: 8px;
  line-height: 1;
}
.scoreboard {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  border: 4px solid var(--white);
  padding: 12px 8px 16px;
  background: #000;
}
.score-side { text-align: center; min-width: 0; }
.score-side.home .score-name { color: var(--red); }
.score-side.away .score-name { color: var(--blue); }
.score-name {
  font-family: var(--pixel);
  font-size: 8px;
  text-transform: uppercase;
  margin-bottom: 8px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.score-num {
  font-family: var(--pixel);
  font-size: 24px;
  color: var(--yellow);
  line-height: 1;
}
.score-mid { text-align: center; }
.clock {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--green-lit);
  margin-bottom: 8px;
  line-height: 1.5;
}
.score-vs {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--white);
}
.board-subline {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--white);
  text-align: center;
  margin: 8px 0 0;
  letter-spacing: 0.5px;
}

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
.btn {
  font-family: var(--pixel);
  font-size: 8px;
  text-transform: uppercase;
  color: var(--black);
  background: var(--yellow);
  border: 2px solid var(--white);
  box-shadow: inset -2px -2px 0 #b89000, 4px 4px 0 #000;
  padding: 12px 12px;
  cursor: pointer;
  line-height: 1.4;
  min-height: 44px;
}
.btn:active { box-shadow: inset 2px 2px 0 #b89000; transform: translate(2px, 2px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-red { background: var(--red); color: var(--white); box-shadow: inset -2px -2px 0 #8c1810, 4px 4px 0 #000; }
.badge {
  font-family: var(--pixel);
  font-size: 8px;
  padding: 10px 8px;
  border: 2px solid var(--white);
  line-height: 1;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.badge.mock { background: var(--orange); color: #000; }
.badge.real { background: var(--green-lit); color: #000; }
.toggle, .select {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--white);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  min-height: 44px;
}
.select {
  background: #000;
  border: 2px solid var(--white);
  padding: 8px;
}
.toggle input { accent-color: var(--yellow); width: 20px; height: 20px; }

/* Matchup picker */
.matchups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 16px;
}
.matchup-tab {
  background: #000;
  border: 2px solid #6a6a6a;
  color: var(--white);
  font-family: var(--mono);
  font-size: 22px;
  text-align: left;
  padding: 10px 12px;
  cursor: pointer;
  line-height: 1.2;
  min-height: 44px;
}
.matchup-tab.selected {
  border-color: var(--yellow);
  box-shadow: 0 0 0 2px #000, 0 0 0 4px var(--yellow);
}
.matchup-tab .arrow {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--yellow);
  display: inline-block;
  width: 16px;
}
.matchup-tab.selected .arrow { animation: blink 0.9s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* One-team toggle (mobile) */
.team-toggle {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 16px;
}
.team-toggle button {
  font-family: var(--pixel);
  font-size: 8px;
  line-height: 1.5;
  min-height: 48px;
  padding: 8px;
  cursor: pointer;
  background: #000;
  color: var(--white);
  border: 2px solid #6a6a6a;
  text-transform: uppercase;
}
.team-toggle button .pts {
  display: block;
  font-size: 16px;
  color: var(--yellow);
  margin-top: 4px;
}
.team-toggle button.on-home { border-color: var(--red); box-shadow: 0 0 0 2px var(--red); }
.team-toggle button.on-away { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue); }

/* Team panels */
.team-panel {
  background: #000;
  border: 4px solid var(--white);
  box-shadow: 8px 8px 0 #001400;
  margin-bottom: 16px;
  overflow: hidden;
}
.team-panel.home { border-color: var(--red); }
.team-panel.away { border-color: var(--blue); }
.team-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: #000;
  border-bottom: 4px solid var(--white);
  font-family: var(--pixel);
  font-size: 8px;
  text-transform: uppercase;
  line-height: 1.5;
}
.team-panel.home .team-head { border-bottom-color: var(--red); }
.team-panel.away .team-head { border-bottom-color: var(--blue); }
.team-head .total { color: var(--yellow); font-size: 16px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.lineup {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 22px;
}
table.lineup th {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--yellow);
  text-align: right;
  padding: 8px;
  border-bottom: 2px solid var(--line);
  text-transform: uppercase;
  line-height: 1.5;
}
table.lineup th:nth-child(1),
table.lineup th:nth-child(2),
table.lineup td:nth-child(1),
table.lineup td:nth-child(2) { text-align: left; }
table.lineup td {
  padding: 8px;
  border-bottom: 2px solid #222;
  vertical-align: middle;
  white-space: nowrap;
}
.slot-id { font-family: var(--pixel); font-size: 8px; color: var(--yellow); width: 52px; line-height: 1.5; }
.player-cell { min-width: 180px; }
.player-name { font-size: 24px; line-height: 1.1; color: var(--white); }
.sub-note { color: var(--blue); font-size: 18px; display: block; line-height: 1.2; }
.qcell { text-align: right; font-variant-numeric: tabular-nums; color: var(--white); }
.qcell .who { display: block; font-size: 16px; color: var(--blue); line-height: 1.1; }
.total-cell {
  text-align: right;
  color: var(--yellow);
  font-family: var(--pixel);
  font-size: 16px;
  line-height: 1.5;
}
.dash { color: #9a9a9a; }

.btn-sub {
  font-family: var(--pixel);
  font-size: 8px;
  background: var(--navy);
  color: #fff;
  border: 2px solid var(--white);
  padding: 10px 8px;
  cursor: pointer;
  min-height: 44px;
  min-width: 56px;
  box-shadow: 2px 2px 0 #000;
  line-height: 1.3;
}
.btn-sub:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sub .sub-short { display: none; }

.bench {
  padding: 12px;
  font-family: var(--mono);
  font-size: 20px;
  color: var(--muted);
  border-top: 2px solid var(--line);
  line-height: 1.3;
}
.bench strong {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--yellow);
  margin-right: 8px;
}

/* Mobile slot cards */
.slot-list { display: none; padding: 8px; }
.slot-card {
  border: 2px solid var(--line);
  padding: 12px;
  margin-bottom: 8px;
  background: #000;
}
.slot-card:last-child { margin-bottom: 0; }
.slot-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.slot-card-top .slot-id { flex: 0 0 auto; }
.slot-card-top .player-block { flex: 1 1 auto; min-width: 0; }
.slot-card-top .slot-total {
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--yellow);
  line-height: 1;
}
.slot-card .player-block { margin: 4px 0 0; }
.slot-card .player-name { font-size: 24px; }
.qchips {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.qchips.ot { grid-template-columns: repeat(5, 1fr); }
.qchip {
  border: 2px solid var(--white);
  padding: 8px 4px;
  text-align: center;
  background: #080808;
  min-height: 64px;
}
.qchip .qlab {
  display: block;
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--yellow);
  margin-bottom: 4px;
  line-height: 1.5;
}
.qchip .qpts {
  display: block;
  font-family: var(--mono);
  font-size: 22px;
  color: var(--white);
  line-height: 1;
}
.qchip .who {
  display: block;
  font-size: 16px;
  color: var(--blue);
  margin-top: 2px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qchip.empty { border-color: #555; }
.qchip.empty .qpts { color: #9a9a9a; }
.qchip.subbed { border-color: var(--blue); }

/* Override log */
.log {
  background: #000;
  border: 2px solid var(--white);
  padding: 12px;
  margin-bottom: 16px;
}
.log h2 {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--yellow);
  margin: 0 0 8px;
  text-transform: uppercase;
  line-height: 1.5;
}
.log p, .log li {
  font-family: var(--mono);
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--white);
  line-height: 1.3;
}
.log ul { margin: 0; padding-left: 20px; }

.credit {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--white);
  text-align: center;
  padding: 8px;
  line-height: 1.3;
  background: #000;
  border: 2px solid #3a3a3a;
}

/* Substitution overlay */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  z-index: 20;
}
.modal {
  background: #000;
  border: 4px solid var(--yellow);
  box-shadow: 0 0 0 4px #000, 8px 8px 0 #001400;
  width: min(480px, 100%);
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 16px;
}
.modal h2 {
  font-family: var(--pixel);
  font-size: 16px;
  color: var(--yellow);
  text-align: center;
  line-height: 1.6;
  margin: 0 0 12px;
  text-transform: uppercase;
}
.modal .meta {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--blue);
  text-align: center;
  margin-bottom: 12px;
  line-height: 1.6;
  text-transform: uppercase;
}
.modal label.choice {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 22px;
  padding: 8px 4px;
  min-height: 44px;
  cursor: pointer;
  color: var(--white);
}
.modal label.choice .sel {
  font-family: var(--pixel);
  font-size: 8px;
  color: var(--yellow);
  width: 16px;
  animation: blink 0.9s steps(1) infinite;
}
.modal label.choice .sel.off { visibility: hidden; animation: none; }
.out-line {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--muted);
  margin: 8px 0 12px;
  line-height: 1.3;
}
.err {
  color: var(--red);
  font-family: var(--mono);
  font-size: 20px;
  margin: 8px 0;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 16px;
}
.hint { font-family: var(--mono); font-size: 18px; color: var(--muted); text-align: center; margin-top: 8px; line-height: 1.3; }

@media (max-width: 800px) {
  .app { padding: 8px 8px 20px; }
  .score-num { font-size: 16px; }
  .matchups { grid-template-columns: 1fr; }
  .team-toggle { display: grid; }
  .table-wrap { display: none; }
  .slot-list { display: block; }
  .team-panel { display: none; }
  .team-panel.on { display: block; }
  .btn-sub .sub-full { display: none; }
  .btn-sub .sub-short { display: inline; }
  .team-head .total { display: none; }
}

@media (min-width: 801px) {
  .team-toggle, .slot-list { display: none; }
}
