:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #657382;
  --line: #d9e2ea;
  --paper: #ffffff;
  --wash: #f5f7f8;
  --team-wash: #18593c;
  --green: #24714f;
  --green-dark: #18593c;
  --blue: #06498f;
  --blue-dark: #003f7f;
  --blue-soft: #e8f1f8;
  --hero-overlay: rgba(0, 47, 96, 0.86);
  --amber: #b56f14;
  --red: #b64242;
  --shadow: 0 14px 34px rgba(24, 38, 52, 0.11);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--wash);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.4;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c8d4df;
  border-radius: 7px;
  color: var(--ink);
  background: #ffffff;
  padding: 7px 9px;
}

select {
  min-width: 126px;
}

label {
  display: grid;
  gap: 5px;
  color: #34495c;
  font-size: 0.9rem;
  font-weight: 800;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  color: #34495c;
  font-size: 0.9rem;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(245px, 1fr) auto;
  align-items: end;
  gap: 18px;
  padding: 14px clamp(14px, 3vw, 34px);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 5px 18px rgba(20, 32, 43, 0.06);
}

.brand {
  display: inline-flex;
  align-items: flex-end;
  justify-self: start;
  gap: 12px;
  min-height: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 108px;
  height: 108px;
  place-items: center;
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
}

.brand-mark img {
  width: 108px;
  height: 108px;
  display: block;
  object-fit: contain;
}

.brand-tagline {
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
  line-height: 34px;
  white-space: nowrap;
}

.main-nav,
.hero-actions,
.panel-heading,
.section-heading,
.command-bar,
.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.main-nav {
  justify-content: flex-end;
  justify-self: end;
  flex-wrap: wrap;
}

.main-nav button {
  min-height: 34px;
  color: #415365;
  background: transparent;
  padding: 0 11px;
}

.main-nav button.active {
  color: #ffffff;
  background: var(--green-dark);
}

.primary-button {
  color: #ffffff;
  background: var(--green);
  padding: 0 15px;
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  color: #15354f;
  background: var(--blue-soft);
  padding: 0 13px;
}

.text-button {
  min-height: 34px;
  color: var(--blue);
  background: transparent;
  padding: 0 4px;
}

.large-button {
  min-height: 48px;
  padding: 0 20px;
}

.full-width {
  width: 100%;
}

.view {
  padding: 22px clamp(14px, 3vw, 34px) 36px;
}

.home-view {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  align-items: center;
  gap: clamp(18px, 4vw, 54px);
  min-height: calc(100vh - 68px);
  color: #ffffff;
  background:
    linear-gradient(var(--hero-overlay), var(--hero-overlay)),
    url("https://images.unsplash.com/photo-1508344928928-7165b67de128?auto=format&fit=crop&w=1600&q=80");
  background-position: center;
  background-size: cover;
}

.hero-copy {
  max-width: 680px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--blue-dark);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-view .eyebrow,
.home-view .hero-text {
  color: #ffffff;
}

.primary-button,
.primary-button:hover,
.demo-button.primary,
.howto-card > span,
.step-heading span,
.stepper button,
.player-number,
.status-pill,
.inning-card h3 {
  color: #ffffff !important;
}

.hero-copy h1 {
  margin-bottom: 12px;
  font-size: clamp(2.7rem, 7vw, 5.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.hero-text {
  max-width: 570px;
  font-size: 1.18rem;
}

.preview-panel,
.setup-panel,
.command-bar,
.summary-strip,
.lineup-section,
.stats-section,
.inning-card,
.price-card,
.team-card {
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-panel {
  color: var(--ink);
  padding: clamp(16px, 3vw, 24px);
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.preview-header span,
.muted,
.payment-note {
  color: var(--muted);
}

.preview-header strong {
  color: var(--green);
}

.mini-scoreboard,
.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.mini-scoreboard div,
.summary-strip div {
  padding: 12px;
  background: #f1f5f7;
  border-radius: 8px;
}

.mini-scoreboard strong,
.mini-scoreboard span,
.summary-strip strong,
.summary-strip span {
  display: block;
}

.mini-scoreboard strong,
.summary-strip strong {
  color: var(--blue-dark);
  font-size: 1.35rem;
}

.mini-scoreboard span,
.summary-strip span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.preview-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.preview-list div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.page-view {
  max-width: 1120px;
  margin: 0 auto;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

.page-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.9rem, 4vw, 3.3rem);
  letter-spacing: 0;
}

.centered-heading {
  display: block;
  max-width: 720px;
  margin-right: auto;
  margin-left: auto;
  text-align: center;
}

.team-grid,
.pricing-grid,
.howto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
}

.team-card,
.price-card,
.howto-card {
  padding: 18px;
}

.team-card h3,
.price-card h3,
.howto-card h3 {
  margin-bottom: 8px;
}

.empty-team-card {
  max-width: 520px;
}

.howto-card {
  display: grid;
  align-content: start;
  gap: 8px;
}

.howto-card > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #ffffff;
  background: var(--blue);
  border-radius: 50%;
  font-size: 0.82rem;
  font-weight: 900;
}

.howto-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.howto-demo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.demo-input,
.demo-select,
.demo-button,
.demo-status,
.demo-stepper,
.demo-check,
.demo-jersey,
.demo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  border-radius: 7px;
  padding: 0 10px;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.demo-input,
.demo-select {
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #cbd6df;
}

.demo-select::after {
  content: "▾";
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.7rem;
}

.demo-input.wide,
.demo-select.wide {
  min-width: 112px;
}

.demo-select.sit {
  color: var(--red);
  background: #fff3f3;
  border-color: #e3c2c5;
}

.demo-button.primary {
  color: #ffffff;
  background: var(--blue);
}

.demo-button.secondary {
  color: var(--green-dark);
  background: #eef6f0;
  border: 1px solid #cfe1d5;
}

.demo-status.playing {
  color: var(--green-dark);
  background: #eef8f0;
  border: 1px solid #b8d8c0;
}

.demo-status.out {
  color: var(--red);
  background: #fff0f0;
  border: 1px solid #efc4c4;
}

.demo-stepper,
.demo-check {
  color: #34495c;
  background: #eef3f6;
}

.demo-stepper strong {
  margin: 0 9px;
  color: var(--ink);
}

.demo-jersey {
  width: 38px;
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #cbd6df;
}

.demo-icon {
  width: 32px;
  padding: 0;
  color: var(--blue);
  background: #edf3f7;
  border: 1px solid #cdd9e3;
}

.demo-icon.danger {
  color: var(--red);
  background: #fff0f0;
  border-color: #f0caca;
  font-size: 1rem;
}

.team-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.team-meta span,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.82rem;
  font-weight: 900;
}

.team-meta span {
  color: #34495c;
  background: #eef3f6;
}

.price {
  margin-bottom: 6px;
  color: var(--blue-dark);
  font-size: 2.5rem;
  font-weight: 900;
}

.price span {
  color: var(--muted);
  font-size: 1rem;
}

.featured-card {
  border-color: #9cc3a8;
}

.payment-note {
  margin: 14px 0 0;
  text-align: center;
}

.builder-view {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  gap: 12px;
  background: var(--team-wash);
}

.setup-panel {
  position: sticky;
  top: 142px;
  display: grid;
  align-self: start;
  gap: 14px;
  max-height: calc(100vh - 160px);
  padding: 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel-heading,
.section-heading {
  justify-content: space-between;
}

.panel-heading h2,
.panel-heading h3,
.section-heading h2 {
  margin: 0;
}

.compact-heading {
  margin: 0;
}

.setup-step {
  display: grid;
  gap: 12px;
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.roster-step {
  min-height: 300px;
}

.step-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.step-heading span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  color: #ffffff;
  background: var(--blue);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 900;
}

.step-heading h3 {
  margin: 0;
  font-size: 0.95rem;
}

.roster-frame {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 190px;
  overflow: hidden;
  padding: 12px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.theme-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 10px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 7px;
  white-space: nowrap;
}

.toggle-row input {
  width: 34px;
  min-height: 20px;
  accent-color: var(--blue);
}

.logo-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 38px;
  border-radius: 7px;
  cursor: pointer;
}

.logo-control button {
  min-height: 38px;
}

.stepper-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stepper {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #f1f5f7;
  border-radius: 8px;
}

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

.stepper div {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 6px;
}

.stepper button {
  min-height: 34px;
  color: #ffffff;
  background: var(--blue);
}

.stepper strong {
  text-align: center;
}

.rules-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--blue);
}

.player-list {
  display: grid;
  align-content: start;
  gap: 6px;
  min-height: 0;
  margin-top: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 2px;
}

.player-list::-webkit-scrollbar {
  width: 8px;
}

.player-list::-webkit-scrollbar-thumb {
  background: #b8c5d0;
  border-radius: 999px;
}

.player-row {
  display: grid;
  grid-template-columns: 22px 42px 58px minmax(0, 1fr) 28px 28px 28px;
  align-items: center;
  gap: 5px;
}

.jersey-input {
  min-width: 0;
  padding-right: 6px;
  padding-left: 6px;
  text-align: center;
  font-weight: 900;
}

.player-row input[data-player-input] {
  min-width: 0;
}

.player-number {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #ffffff;
  background: var(--blue);
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 900;
}

.availability-button {
  min-height: 34px;
  padding: 0 6px;
  color: var(--green-dark);
  background: #eef8f0;
  border: 1px solid #b8d8c0;
  border-radius: 7px;
  font-size: 0.68rem;
  font-weight: 900;
}

.availability-button.is-out {
  color: var(--red);
  background: #fff0f0;
  border-color: #efc4c4;
}

.player-icon-button {
  display: grid;
  width: 100%;
  min-height: 34px;
  place-items: center;
  padding: 0;
  color: var(--blue);
  background: #edf3f7;
  border: 1px solid #cdd9e3;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1;
  font-weight: 900;
}

.player-icon-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.remove-player {
  color: var(--red);
  background: #fff0f0;
  border-color: #f0caca;
  font-size: 1.05rem;
}

.panel-actions {
  display: grid;
}

.workspace {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.command-bar {
  flex-wrap: wrap;
  padding: 14px;
}

.summary-strip {
  padding: 12px;
}

.pdf-header {
  display: none;
}

.lineup-section,
.stats-section {
  padding: 14px;
}

.status-pill {
  color: #ffffff;
  background: var(--green);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 9px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #31465a;
  background: #edf3f7;
  font-size: 0.82rem;
}

tr:last-child td {
  border-bottom: 0;
}

.player-name-cell {
  min-width: 128px;
  font-weight: 900;
}

.empty-lineup-cell {
  color: var(--muted);
  background: #f8fafb;
  font-weight: 900;
}

.sit-cell select {
  color: var(--red);
  border-color: #e5b8b8;
  background: #fff6f6;
}

.inning-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 12px;
}

.inning-card {
  overflow: hidden;
}

.inning-card h3 {
  margin: 0;
  padding: 10px 12px;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.98rem;
}

.position-list {
  display: grid;
  margin: 0;
  padding: 10px 12px 12px;
  gap: 7px;
}

.position-list div {
  display: grid;
  grid-template-columns: 98px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.position-list dt {
  color: var(--muted);
  font-weight: 900;
}

.position-list dd {
  margin: 0;
  font-weight: 800;
}

.position-player-select {
  min-width: 0;
  min-height: 34px;
  padding: 5px 8px;
  font-weight: 800;
}

.x-value,
.sit-count {
  color: var(--red);
  font-weight: 900;
}

.balanced {
  color: var(--green);
  font-weight: 900;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .main-nav {
    justify-content: flex-start;
    overflow-x: auto;
  }

  .home-view,
  .builder-view {
    grid-template-columns: 1fr;
  }

  .setup-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .inning-grid,
  .team-grid,
  .howto-grid,
  .pricing-grid {
    grid-template-columns: repeat(2, minmax(210px, 1fr));
  }
}

@media (max-width: 640px) {
  .view {
    padding-right: 12px;
    padding-left: 12px;
  }

  .topbar {
    position: static;
    gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .brand {
    gap: 10px;
  }

  .brand-mark,
  .brand-mark img {
    width: 76px;
    height: 76px;
  }

  .brand-tagline {
    font-size: 0.84rem;
    line-height: 30px;
  }

  .home-view {
    min-height: auto;
    padding-top: 32px;
  }

  .hero-actions,
  .command-bar,
  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-actions button,
  .command-bar button {
    width: 100%;
  }

  .mini-scoreboard,
  .summary-strip,
  .stepper-grid,
  .inning-grid,
  .team-grid,
  .howto-grid,
  .pricing-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: landscape;
    margin: 0.45in;
  }

  html,
  body {
    background: #ffffff;
    height: auto !important;
    overflow: visible !important;
  }

  body,
  main,
  .view {
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
  }

  main {
    display: block !important;
  }

  #homeView,
  #teamsView,
  #pricingView,
  .view[hidden]:not(#builderView) {
    display: none !important;
    height: 0 !important;
    max-height: 0 !important;
    overflow: hidden !important;
    break-after: avoid !important;
    page-break-after: avoid !important;
  }

  .topbar,
  .setup-panel,
  .command-bar,
  .summary-strip,
  .home-view,
  .page-view {
    display: none !important;
  }

  .builder-view {
    display: block !important;
    position: static !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    break-before: avoid !important;
    page-break-before: avoid !important;
  }

  .workspace {
    display: block !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    break-before: avoid !important;
    page-break-before: avoid !important;
  }

  .table-wrap {
    overflow: visible;
  }

  table {
    width: 100%;
    min-width: 0;
    font-size: 0.78rem;
  }

  th,
  td {
    padding: 5px;
    white-space: normal;
  }

  .player-name-cell {
    min-width: 82px;
  }

  .pdf-header {
    display: block;
    break-before: avoid !important;
    page-break-before: avoid !important;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid #17202a;
  }

  .pdf-header p,
  .pdf-header h2 {
    margin: 0;
  }

  .pdf-header p {
    color: #657382;
    font-size: 0.82rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  .pdf-header h2 {
    margin-top: 3px;
    font-size: 1.8rem;
  }

  .pdf-header span {
    color: #657382;
    font-weight: 800;
  }

  .lineup-section,
  .stats-section,
  .inning-card {
    break-inside: avoid;
    box-shadow: none;
    border-color: #9aa6b2;
    margin-bottom: 14px;
  }

  .lineup-section {
    break-before: avoid !important;
    page-break-before: avoid !important;
  }

  select {
    border: 0;
    appearance: none;
    padding: 0;
  }
}
