:root {
  --paper: #f3efe2;
  --paper-deep: #e3dbc4;
  --ink: #1c1b19;
  --muted: #666157;
  --pitch: #1e7a3d;
  --pitch-dark: #14572b;
  --gold: #d9a521;
  --gold-deep: #8a5a14;
  --line: #11110f;
  --danger: #b42318;
  --focus: #0b5cad;
  --shadow: 6px 6px 0 #11110f;
  color-scheme: light;
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  color: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(90deg, rgba(30, 122, 61, 0.05) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--paper);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
.match-card:focus-visible,
.player-row:focus-visible,
.back-button:focus-visible,
.period-tab:focus-visible,
.shot-dot:focus-visible,
.shot-controls button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.app-shell {
  min-height: 100vh;
  padding-bottom: 86px;
}

.masthead {
  padding: 18px 16px 14px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 10px, transparent 10px 22px),
    var(--pitch);
  border-bottom: 4px solid var(--line);
  color: white;
}

.brand {
  margin: 0;
  color: var(--gold);
  font-family: "Press Start 2P", monospace;
  font-size: clamp(1.3rem, 6.8vw, 3rem);
  line-height: 1.08;
  text-transform: uppercase;
  text-shadow:
    2px 2px 0 var(--gold-deep),
    4px 4px 0 #2a1a09,
    -1px -1px 0 #fff2a8;
}

.masthead-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
}

.user-block {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fffbea;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 700;
  text-transform: uppercase;
}

.logout-button,
.tab-button,
.primary-button,
.seg-button {
  min-height: 42px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: #fffdf5;
  color: var(--ink);
  font-weight: 800;
  box-shadow: 3px 3px 0 var(--line);
}

.logout-button {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 0.78rem;
}

.main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px 12px 24px;
}

.login-wrap {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.login-panel {
  width: min(100%, 430px);
  border: 4px solid var(--line);
  background: #fffaf0;
  box-shadow: var(--shadow);
}

.login-panel .masthead {
  border-bottom-width: 4px;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.field {
  display: grid;
  gap: 6px;
  font-weight: 800;
}

.field span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  text-transform: uppercase;
}

.field input {
  width: 100%;
  min-height: 46px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: white;
  padding: 8px 10px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
}

.primary-button {
  width: 100%;
  background: var(--gold);
  padding: 9px 12px;
}

.error-text {
  min-height: 20px;
  color: var(--danger);
  font-weight: 800;
}

.standings-strip {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 8px;
}

.strip-row,
.table-row,
.team-row {
  display: grid;
  align-items: center;
  gap: 8px;
}

.strip-row {
  grid-template-columns: 32px 1fr 56px;
  min-height: 34px;
  padding: 4px 6px;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 800;
}

.is-you {
  background: #fff0ba;
  box-shadow: inset 0 0 0 2px var(--line);
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-head h2 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.88rem;
  line-height: 1.45;
}

.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

.match-list {
  display: grid;
  gap: 12px;
}

.match-card {
  display: grid;
  gap: 10px;
  border: 3px solid var(--line);
  background: #fffaf0;
  padding: 10px;
  box-shadow: 4px 4px 0 var(--line);
  color: inherit;
  text-decoration: none;
}

.match-topline,
.match-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.versus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.scorebox {
  min-width: 54px;
  border: 3px solid var(--line);
  background: var(--ink);
  color: #fffdf5;
  padding: 6px 4px;
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.1rem;
  font-weight: 800;
}

.team-side {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.team-side.right {
  text-align: right;
}

.country-chip {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  border: 3px solid var(--line);
  border-radius: 0;
  padding: 5px 7px;
  background:
    linear-gradient(135deg, var(--team-primary) 0 50%, var(--team-secondary) 50% 100%);
  color: var(--chip-text);
  font-weight: 900;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.55);
}

.right .country-chip {
  grid-template-columns: minmax(0, 1fr) 30px;
}

.right .country-chip img {
  order: 2;
}

.country-chip img,
.flag-placeholder {
  width: 30px;
  height: 23px;
  border: 2px solid var(--line);
  background: #fffdf5;
  object-fit: cover;
}

.country-chip span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.your-team .country-chip {
  box-shadow: inset 0 0 0 3px var(--gold);
}

.owner-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.right .owner-line {
  justify-content: end;
}

.owner-badge {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--owner-color);
  color: white;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.undrafted {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 800;
}

.tag {
  display: inline-block;
  border: 2px solid var(--line);
  background: #fff0ba;
  color: var(--ink);
  padding: 3px 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.tag.h2h {
  background: #ffdfd8;
}

.empty-state {
  border: 3px dashed var(--line);
  background: #fffdf5;
  padding: 18px;
  font-weight: 700;
}

.leaderboard {
  border: 3px solid var(--line);
  background: #fffdf5;
}

.table-row {
  grid-template-columns: 40px minmax(0, 1fr) 64px 74px 74px;
  min-height: 44px;
  padding: 8px;
  border-bottom: 2px solid var(--line);
}

.table-row:last-child {
  border-bottom: 0;
}

.table-row.header {
  background: var(--pitch);
  color: white;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.table-row.no-proj {
  grid-template-columns: 40px minmax(0, 1fr) 64px 74px;
}

.num {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 900;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.player-row {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  font-weight: 900;
}

.team-detail {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  border: 3px solid var(--line);
  background: #fffaf0;
  padding: 10px;
}

.team-row {
  grid-template-columns: minmax(0, 1fr) 48px 48px;
  min-height: 38px;
  border-bottom: 1px solid rgba(28, 27, 25, 0.18);
}

.team-row.has-expected {
  grid-template-columns: minmax(0, 1fr) 42px 42px 52px;
}

.team-label {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.team-label img,
.team-label .flag-placeholder {
  width: 30px;
  height: 23px;
  border: 2px solid var(--line);
  background: #fffdf5;
  object-fit: cover;
}

.team-label span:last-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.team-row:last-child {
  border-bottom: 0;
}

.segmented {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.seg-button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 5px 9px;
  font-size: 0.82rem;
}

.seg-button.active,
.tab-button.active {
  background: var(--gold);
}

.bottom-tabs {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 4px solid var(--line);
  background: var(--pitch-dark);
}

.tab-button {
  min-height: 48px;
  padding: 6px 4px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.preview-line {
  display: grid;
  gap: 5px;
  border-top: 2px solid rgba(28, 27, 25, 0.18);
  padding-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.back-button,
.period-tab,
.shot-controls button {
  min-height: 36px;
  border: 3px solid var(--line);
  border-radius: 0;
  background: #fffdf5;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 900;
  text-transform: uppercase;
  box-shadow: 3px 3px 0 var(--line);
}

.match-page {
  display: grid;
  gap: 14px;
}

.match-hero,
.detail-panel,
.result-panel,
.stat-group,
.shot-section {
  border: 3px solid var(--line);
  background: #fffaf0;
  padding: 12px;
  box-shadow: 4px 4px 0 var(--line);
}

.hero-versus {
  margin: 12px 0;
}

.hero-score {
  min-width: 70px;
  font-size: 1.4rem;
}

.match-detail-grid,
.stat-groups {
  display: grid;
  gap: 12px;
}

.detail-panel {
  display: grid;
  gap: 10px;
}

.panel-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.detail-panel h3,
.stat-group h3,
.shot-section h3 {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.76rem;
  line-height: 1.5;
}

.metric-list,
.prob-grid,
.h2h-list {
  display: grid;
  gap: 6px;
}

.metric-list > div,
.h2h-list > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 5px 6px;
}

.prob-grid {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  font-family: "IBM Plex Mono", monospace;
}

.info-pop {
  position: relative;
}

.info-pop summary {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

.info-pop summary::-webkit-details-marker {
  display: none;
}

.info-pop p {
  position: absolute;
  top: 34px;
  right: 0;
  z-index: 6;
  width: min(260px, calc(100vw - 36px));
  margin: 0;
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 9px;
  box-shadow: 4px 4px 0 var(--line);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

.expected-goals {
  display: grid;
  gap: 4px;
  border: 3px solid var(--line);
  background: var(--ink);
  color: #fffdf5;
  padding: 8px;
}

.expected-goals span {
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.expected-goals strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  font-weight: 900;
}

.prob-grid strong,
.metric-list strong,
.stat-value,
.shot-card strong,
.shot-card span,
.result-panel span {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.pill-row,
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pill-row span,
.form-badge {
  border: 2px solid var(--line);
  background: #fff0ba;
  padding: 3px 6px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  font-weight: 900;
}

.pele-panel {
  background: var(--pitch-dark);
  color: #fff9d8;
}

.pele-panel h3 {
  color: var(--gold);
}

.pele-head,
.pele-row,
.tilt-grid {
  display: grid;
  gap: 8px;
}

.pele-head {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 900;
  text-transform: uppercase;
}

.pele-head span:last-child {
  text-align: right;
}

.pele-bars {
  display: grid;
  gap: 7px;
}

.pele-row {
  grid-template-columns: minmax(0, 1fr) 76px minmax(0, 1fr);
  align-items: center;
}

.pele-side {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.pele-side.right {
  grid-template-columns: minmax(0, 1fr) 58px;
}

.pele-side > span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.pele-side.right > span {
  text-align: right;
}

.pele-label {
  color: #f2d347;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.seg-bar {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 2px;
  min-width: 0;
  height: 13px;
  border: 2px solid var(--line);
  background: #062b16;
  padding: 2px;
}

.seg-bar i {
  display: block;
  min-width: 0;
  background: transparent;
}

.seg-bar i.on {
  background: #24b55a;
  box-shadow: inset 0 -2px 0 #0f6e35;
}

.tilt-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tilt-card {
  display: grid;
  gap: 5px;
  place-items: center;
  min-width: 0;
  border: 2px solid var(--line);
  background: #fffdf5;
  color: var(--ink);
  padding: 10px 8px;
  text-align: center;
}

.tilt-card strong,
.tilt-card span,
.tilt-card small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tilt-card strong,
.tilt-card span {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 900;
}

.tilt-card strong {
  font-size: 0.95rem;
}

.tilt-card span {
  display: grid;
  gap: 1px;
  line-height: 1.2;
}

.tilt-card small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.form-row {
  border-top: 2px solid rgba(28, 27, 25, 0.18);
  padding-top: 10px;
  font-size: 0.84rem;
  font-weight: 800;
}

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

.result-panel > div,
.scorers {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.period-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 4px 0 7px;
}

.period-tab {
  flex: 0 0 auto;
  padding: 4px 9px;
  font-size: 0.76rem;
}

.period-tab.active {
  background: var(--gold);
}

.stat-group {
  box-shadow: none;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(54px, 0.8fr) minmax(0, 1.2fr) minmax(54px, 0.8fr);
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border-top: 1px solid rgba(28, 27, 25, 0.18);
  padding: 7px 0;
}

.stat-label {
  color: var(--muted);
  text-align: center;
  font-size: 0.86rem;
  font-weight: 800;
}

.stat-value {
  justify-self: start;
  min-width: 48px;
  padding: 3px 6px;
  text-align: center;
  font-weight: 900;
}

.stat-value:last-child {
  justify-self: end;
}

.stat-value.leader {
  border: 2px solid var(--line);
  background: var(--leader-bg);
  color: var(--leader-text);
}

.shot-layout {
  display: grid;
  gap: 12px;
}

.pitch {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border: 3px solid var(--line);
  background:
    linear-gradient(90deg, transparent calc(50% - 1px), rgba(255, 255, 255, 0.8) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    repeating-linear-gradient(90deg, #238a47 0 12%, #1e7a3d 12% 24%);
}

.pitch::before,
.pitch::after {
  position: absolute;
  top: 25%;
  bottom: 25%;
  width: 14%;
  border: 2px solid rgba(255, 255, 255, 0.75);
  content: "";
}

.pitch::before {
  left: 0;
  border-left: 0;
}

.pitch::after {
  right: 0;
  border-right: 0;
}

.shot-dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: var(--gold);
  transform: translate(-50%, -50%);
  box-shadow: 2px 2px 0 var(--line);
}

.shot-dot.away {
  background: #fffdf5;
}

.shot-dot.active {
  width: 24px;
  height: 24px;
  background: var(--danger);
}

.shot-card {
  display: grid;
  gap: 8px;
  border: 3px solid var(--line);
  background: #fffdf5;
  padding: 10px;
}

.shot-controls {
  display: flex;
  gap: 8px;
}

.shot-controls button {
  flex: 1;
  font-size: 0.76rem;
}

@media (min-width: 760px) {
  .main {
    padding: 18px 18px 34px;
  }

  .today-grid {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
  }

  .standings-strip {
    position: sticky;
    top: 16px;
  }

  .match-card {
    padding: 14px;
  }

  .country-chip {
    min-height: 52px;
    font-size: 1.02rem;
  }

  .table-row {
    grid-template-columns: 54px minmax(0, 1fr) 90px 110px 110px;
  }

  .table-row.no-proj {
    grid-template-columns: 54px minmax(0, 1fr) 90px 110px;
  }
}

@media (min-width: 900px) {
  .match-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .leaderboard + .team-detail {
    margin-top: 0;
  }

  .leaderboard,
  .team-detail {
    min-width: 0;
  }

  section:has(> .leaderboard) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
  }

  section:has(> .leaderboard) .section-head,
  section:has(> .leaderboard) .leaderboard {
    grid-column: 1;
  }

  section:has(> .leaderboard) .team-detail {
    grid-column: 2;
    grid-row: 2;
    position: sticky;
    top: 18px;
  }

  .match-detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .shot-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.55fr);
    align-items: stretch;
  }

  .pitch {
    min-height: 360px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .match-card,
  .tab-button,
  .primary-button,
  .logout-button,
  .seg-button,
  .back-button,
  .period-tab,
  .shot-controls button {
    transition: transform 120ms ease, box-shadow 120ms ease;
  }

  .match-card:hover,
  .tab-button:hover,
  .primary-button:hover,
  .logout-button:hover,
  .seg-button:hover,
  .back-button:hover,
  .period-tab:hover,
  .shot-controls button:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 var(--line);
  }
}

@media (max-width: 420px) {
  .brand {
    font-size: 1.2rem;
  }

  .masthead-row {
    align-items: start;
  }

  .user-block {
    flex-direction: column;
    align-items: end;
    gap: 5px;
  }

  .country-chip {
    grid-template-columns: 24px minmax(0, 1fr);
    min-height: 48px;
    gap: 6px;
    padding: 5px;
    font-size: 0.86rem;
  }

  .right .country-chip {
    grid-template-columns: minmax(0, 1fr) 24px;
  }

  .country-chip img,
  .flag-placeholder {
    width: 24px;
    height: 18px;
  }

  .versus {
    gap: 5px;
  }

  .scorebox {
    min-width: 42px;
    font-size: 0.9rem;
  }

  .table-row {
    grid-template-columns: 34px minmax(0, 1fr) 50px 62px 62px;
    gap: 5px;
    font-size: 0.86rem;
  }

  .table-row.no-proj {
    grid-template-columns: 34px minmax(0, 1fr) 50px 62px;
  }

  .team-row {
    grid-template-columns: minmax(0, 1fr) 42px 42px;
  }

  .team-row.has-expected {
    grid-template-columns: minmax(0, 1fr) 36px 36px 44px;
  }

  .team-label {
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 8px;
  }

  .team-label img,
  .team-label .flag-placeholder {
    width: 26px;
    height: 20px;
  }
}
