html,
body {
  height: 100%;
}

:root {
  --bg: #06162c;
  --card: #0d2444;
  --card-2: #12315b;
  --text: #eef5ff;
  --muted: #afc5e3;
  --line: #244a7c;
  --win: #168b44;
  --loss: #bb2131;
  --primary: #24c2ff;
  --accent: #ffc20e;
  --grid-columns: minmax(230px, 1.2fr) minmax(240px, 1.05fr) minmax(210px, 0.95fr);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at 85% -10%, #1b4f8f 0%, transparent 45%),
    radial-gradient(circle at -15% 120%, #0e2c52 0%, transparent 45%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
}

.page {
  max-width: 860px;
  margin: 0 auto;
  padding: 14px 12px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  background: linear-gradient(160deg, #0d2b52 0%, #0a2241 100%);
  border: 1px solid #1a4477;
  border-radius: 14px;
  padding: 14px 12px 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

.header-top {
  display: block;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.15rem, 5.6vw, 1.7rem);
  letter-spacing: 0.2px;
}

.header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.team-picker {
  position: relative;
  margin-top: 14px;
}

.team-picker-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #24558e;
  background: #0f294c;
  color: var(--text);
  border-radius: 14px;
  padding: 11px 12px;
  min-height: 54px;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.team-picker-trigger:hover {
  border-color: #4a8bd2;
}

.team-picker-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.team-picker-current {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.team-picker-current img,
.team-option img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  flex: 0 0 auto;
}

.team-picker-current span {
  display: block;
  font-weight: 700;
}

.team-picker-chevron {
  color: var(--muted);
  font-size: 1rem;
}

.team-picker-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid #24558e;
  border-radius: 14px;
  background: rgba(9, 30, 56, 0.98);
  backdrop-filter: blur(12px);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.34);
  max-height: 340px;
  overflow: auto;
  z-index: 3;
}

.team-picker-menu.is-open {
  display: grid;
}

.team-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid #21436e;
  border-radius: 12px;
  background: #112e54;
  color: var(--text);
  padding: 10px;
  min-height: 52px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  text-align: left;
}

.team-option:hover {
  border-color: #4a8bd2;
  background: #15355f;
}

.team-option.is-selected {
  border-color: #ffc20e;
  background: #173864;
}

.team-option span {
  line-height: 1.2;
}

.summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-weight: 700;
  font-size: 0.96rem;
}

.summary span {
  background: #07213f;
  border: 1px solid #24558e;
  padding: 6px 10px;
  border-radius: 999px;
}

.share-btn,
.reset-btn {
  border: 1px solid #3976b8;
  background: #12315b;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 42px;
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.share-btn {
  margin-left: auto;
}

.reset-btn {
  margin-left: 0;
}

.share-btn:hover,
.reset-btn:hover {
  border-color: #57a6ff;
  background: #153865;
}

.share-btn:focus-visible,
.reset-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.share-status {
  min-height: 1.1rem;
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.grid-wrapper {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
  background: linear-gradient(180deg, var(--card) 0%, #0b1f3b 100%);
  flex: 1;
  min-height: 0;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.row {
  display: grid;
  grid-template-columns: var(--grid-columns);
  align-items: stretch;
}

.grid-head {
  background: #173864;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.07em;
}

.grid-head > div,
.game-row > div {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
}

.grid-head > div {
  display: flex;
  align-items: center;
}

.game-row {
  align-items: stretch;
}

.game-row > div {
  min-height: 72px;
}

.game-row--bye {
  background: rgba(9, 25, 47, 0.42);
}

.grid-head > div:nth-child(3) {
  justify-content: flex-start;
  text-align: left;
}

.date-cell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-content: center;
  align-items: center;
  column-gap: 10px;
}

.date-main {
  min-width: 0;
  font-weight: 600;
}

.date-main span {
  display: block;
  white-space: nowrap;
}

.date-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
}

.primetime-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1;
}

.primetime-badge--tnf {
  background: #113d75;
  border-color: #2e76c8;
  color: #d9ecff;
}

.primetime-badge--snf {
  background: #5a4708;
  border-color: #d1a520;
  color: #ffeeb5;
}

.primetime-badge--mnf {
  background: #64161d;
  border-color: #c7414e;
  color: #ffd7db;
}

.game-row:last-child > div {
  border-bottom: 0;
}

.opponent-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 100%;
}

.opponent-cell img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.16));
}

.opponent-cell span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bye-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid #365f8e;
  background: #102948;
  color: #d8e9ff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.result-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 100%;
}

.bye-result {
  color: var(--muted);
  font-weight: 700;
}

.result-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-start;
}

.result-btn {
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 42px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.94rem;
}

.result-btn:hover {
  border-color: #4f8acc;
}

.result-btn.active.win {
  background: #113d26;
  border-color: #3ab569;
  color: #a9f2c2;
}

.result-btn.active.loss {
  background: #4c1a20;
  border-color: #df6773;
  color: #ffc3ca;
}

.result-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

@media (max-width: 760px) {
  .team-picker-menu {
    grid-template-columns: 1fr;
    max-height: 300px;
  }

  .share-btn,
  .reset-btn {
    margin-left: 0;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .grid-head {
    display: none;
  }

  .game-row {
    border-bottom: 1px solid var(--line);
    padding: 6px 0 2px;
  }

  .game-row > div {
    border-bottom: 0;
    padding: 6px 12px;
  }

  .date-cell,
  .opponent-cell,
  .result-cell {
  }

  .date-cell {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .date-main {
    padding-right: 8px;
  }

  .date-meta {
    align-self: start;
  }

  .primetime-badge {
    min-width: 46px;
    padding: 4px 8px;
    font-size: 0.68rem;
  }

  .result-buttons {
    width: 100%;
    gap: 10px;
    justify-content: stretch;
  }

  .result-btn {
    flex: 1;
  }
}

@media (min-width: 761px) {
  .page {
    max-width: 1080px;
    padding: 20px 20px;
  }

  .header {
    padding: 16px;
  }

  .team-picker-trigger {
    max-width: 440px;
  }

  .grid-head > div,
  .game-row > div {
    padding: 14px 16px;
  }

  .game-row > div {
    min-height: 76px;
  }
}
