* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #0b3d2e;
  --green-light: #14523e;
  --cream: #faf7f0;
  --ink: #1c1c1c;
  --muted: #6b6b62;
  --accent: #b8442c;
  --line: #ddd8cc;
  --row-alt: #f3efe4;
}

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.45;
}

header {
  background: var(--green);
  color: #f5f1e6;
  padding: 1.2rem 1.5rem 0;
}
header h1 { font-size: 1.6rem; letter-spacing: .02em; }
header .sub { color: #c9d6c5; font-size: .85rem; margin-top: .15rem; }

nav#tabs { margin-top: .9rem; display: flex; gap: .25rem; flex-wrap: wrap; }
nav#tabs a {
  color: #e8e4d5;
  text-decoration: none;
  padding: .45rem .95rem;
  border-radius: 6px 6px 0 0;
  font-size: .95rem;
}
nav#tabs a.active { background: var(--cream); color: var(--green); font-weight: bold; }
nav#tabs a:not(.active):hover { background: var(--green-light); }

main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }

.tab { display: none; }
.tab.active { display: block; }

.controls {
  display: flex; gap: .9rem; align-items: end; flex-wrap: wrap;
  margin-bottom: 1rem;
}
.controls label { font-size: .8rem; color: var(--muted); display: flex; flex-direction: column; gap: .2rem; }
input[type="search"], select, button {
  font-family: inherit; font-size: 1rem;
  padding: .45rem .6rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}
input[type="search"] { width: min(420px, 90vw); }
button {
  background: var(--green); color: #fff; border: none; cursor: pointer;
  padding: .5rem 1.2rem;
}
button:hover { background: var(--green-light); }

h2 { font-size: 1.35rem; margin: 1.1rem 0 .4rem; color: var(--green); }
h3 { font-size: 1.05rem; margin: 1rem 0 .35rem; color: var(--green); }
.note { color: var(--muted); font-size: .82rem; margin: .3rem 0 .6rem; }
.warn { color: var(--accent); font-weight: bold; font-size: .95rem; }

details.more-awards { margin-bottom: 1rem; }
details.more-awards summary {
  cursor: pointer; color: var(--muted); font-size: .85rem;
  padding: .35rem 0; user-select: none;
}
details.more-awards summary:hover { color: var(--green); }
details.more-awards[open] summary { margin-bottom: .35rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 1rem; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: .35rem .55rem; text-align: right; white-space: nowrap; }
th:first-child, td:first-child,
th.txt, td.txt { text-align: left; }
thead th {
  background: var(--green); color: #f0ecdf;
  font-family: Verdana, sans-serif; font-size: .7rem; text-transform: uppercase;
  letter-spacing: .04em; position: sticky; top: 0;
}
tbody tr:nth-child(even) { background: var(--row-alt); }
tbody tr:hover { background: #e9f0e4; }
tr.totals td { border-top: 2px solid var(--green); font-weight: bold; background: #eef2e6; }

/* Division/league heading rows inside a single standings table, so every
   division shares one set of column widths. */
tr.section td {
  background: var(--green-light);
  color: #f0ecdf;
  font-family: Verdana, sans-serif;
  font-size: .72rem;
  font-weight: bold;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .4rem .55rem;
}
tbody tr.section:hover td { background: var(--green-light); }
table.standings td:first-child { min-width: 11rem; }

a.player-link, a.team-link { color: var(--accent); text-decoration: none; font-weight: bold; }
a.player-link:hover, a.team-link:hover { text-decoration: underline; }

.bio-card {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.bio-card h2 { margin-top: 0; }
.bio-line { color: var(--muted); font-size: .9rem; }
.badges { margin-top: .45rem; display: flex; gap: .4rem; flex-wrap: wrap; }
.badge {
  font-family: Verdana, sans-serif; font-size: .68rem; font-weight: bold;
  padding: .18rem .55rem; border-radius: 99px;
  background: var(--green); color: #fff;
}
.badge.hof { background: #8a6d1a; }
.badge.ws { background: var(--accent); }
.badge.active {
  background: #e4efe2; color: #1d6b3f; border: 1px solid #a9cbb2;
  font-size: .62rem; padding: .1rem .4rem; vertical-align: .06rem;
}

.result-list { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.result-item {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: .45rem .8rem; cursor: pointer; display: flex; justify-content: space-between;
}
.result-item:hover { background: var(--row-alt); }
.result-item .meta { color: var(--muted); font-size: .82rem; }

.rank-num { color: var(--muted); }

/* season dashboard: each league's Triple Crown leaders above the standings */
.dashboard-lg { margin-bottom: 1rem; }
.dashboard-lg h3 { margin-bottom: .45rem; }
.dashboard-lg h3 .note { font-weight: normal; margin-left: .4rem; }
.tile-grid {
  display: grid; gap: .5rem;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
}
.tile {
  background: #fff; border: 1px solid var(--line); border-radius: 6px;
  padding: .5rem .7rem;
}
.tile-stat {
  display: block; color: var(--muted); text-decoration: none;
  font-size: .68rem; letter-spacing: .05em; text-transform: uppercase;
}
.tile-stat:hover { color: var(--accent); text-decoration: underline; }
.tile-value { font-size: 1.35rem; font-weight: bold; line-height: 1.15; }
.tile-who { font-size: .8rem; }
.tile-team { color: var(--muted); font-size: .72rem; margin-left: .35rem; }
.tile-none, .tile-tied { color: var(--muted); font-style: italic; }

/* the cities a franchise left behind, under its current name */
.former {
  display: block; color: var(--muted); font-size: .74rem;
  font-weight: normal; margin-top: .1rem;
}

footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; border-top: 1px solid var(--line); }
footer a { color: var(--muted); }

.loading { color: var(--muted); font-style: italic; padding: 1rem 0; }

/* ------------------------------------------------ iPad / tablet (≤1024px) */
@media (max-width: 1024px) {
  main { padding: 1rem 1.1rem 2.5rem; }
  table { font-size: .84rem; }
  th, td { padding: .32rem .45rem; }
}

/* ------------------------------------------------ iPhone / phone (≤640px) */
@media (max-width: 640px) {
  header { padding: .9rem 1rem 0; }
  header h1 { font-size: 1.25rem; }
  header .sub { font-size: .75rem; }

  /* horizontally scrollable tab bar */
  nav#tabs {
    margin-top: .7rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav#tabs::-webkit-scrollbar { display: none; }
  nav#tabs a { flex: 0 0 auto; font-size: .88rem; padding: .55rem .8rem; }

  main { padding: .9rem .75rem 2rem; }

  .controls { gap: .55rem; }
  .controls label { flex: 1 1 40%; }
  .controls select { width: 100%; }
  input[type="search"] { width: 100%; }
  /* the Go button only — a direct child. The era buttons are nested inside
     the segmented control and must stay side by side, not stack. */
  .controls > button { flex: 1 1 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1 1 0; padding: .38rem .3rem; text-align: center; }

  table { font-size: .78rem; }
  th, td { padding: .3rem .4rem; }

  .result-item { flex-direction: column; gap: .1rem; }
  .bio-card { padding: .8rem .9rem; }
  .bio-card h2 { font-size: 1.2rem; }
  .bio-line { font-size: .82rem; }
  h2 { font-size: 1.15rem; }
}

/* iOS: comfortable touch targets on any coarse-pointer device */
@media (pointer: coarse) {
  input[type="search"], select, button { min-height: 44px; font-size: 16px; }
  nav#tabs a { min-height: 40px; display: flex; align-items: center; }
  .result-item { padding: .65rem .8rem; }
}

/* iPhone notch / home-indicator safe areas */
@supports (padding: env(safe-area-inset-left)) {
  header { padding-left: max(1.5rem, env(safe-area-inset-left)); padding-right: max(1.5rem, env(safe-area-inset-right)); padding-top: max(1.2rem, env(safe-area-inset-top)); }
  main { padding-left: max(.75rem, env(safe-area-inset-left)); padding-right: max(.75rem, env(safe-area-inset-right)); }
  footer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
}

/* about page — attribution and acknowledgements */
#tab-about { max-width: 46rem; }
#tab-about h3 { margin-top: 1.4rem; }
#tab-about p { line-height: 1.55; margin: .5rem 0; }
#tab-about blockquote, #tab-about em { color: var(--muted); }
.about-lead { font-size: 1.02rem; }
footer p { line-height: 1.6; }

/* position arc: which position a player held, and when */
.pos-arc { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .35rem; }
.pos-run { white-space: nowrap; font-size: .88rem; color: var(--muted); }
.pos-run b { color: inherit; font-family: Verdana, sans-serif; font-size: .8rem;
  background: var(--green); color: #fff; border-radius: 4px; padding: .1rem .35rem;
  margin-right: .2rem; }
.pos-sep { color: var(--muted); font-size: .8rem; padding: 0 .1rem; }

/* Whatever narrows the span — a year, an era, a year pair — shares one row
   beneath the drop-downs. Keeping them together matters: the era buttons are
   a different height from a select, so they leave the baseline ragged inline,
   and picking Custom must reveal From/To next to the button that revealed
   them rather than back up among the other controls. */
#lead-span-detail {
  order: 1; flex: 0 0 100%;
  display: flex; gap: .9rem; align-items: end; flex-wrap: wrap;
}
#lead-era-wrap { display: flex; flex-direction: column; gap: .2rem; }
.seg-label { font-size: .8rem; color: var(--muted); }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.segmented button {
  font: inherit; font-size: .82rem; border: 0; background: #fff;
  color: var(--muted); padding: .32rem .6rem; cursor: pointer;
  border-right: 1px solid var(--line); white-space: nowrap;
}
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--row-alt); }
.segmented button.on { background: var(--green); color: #fff; }

/* franchise season list: manager column */
.mgr-p { color: var(--accent); font-weight: bold; }
.mgr-more { color: var(--muted); font-size: .8em; }
/* reached the postseason but did not win it */
.badge.post { background: #e8e3d6; color: var(--muted); border: 1px solid var(--line); }
/* a ballpark's other names — Parks records them without dates */
.park-alias { display: block; color: var(--muted); font-size: .74rem; }
/* a name the building carried for a stretch, indented under the building */
.park-era { display: inline-block; padding-left: 1.1rem; color: var(--muted); }
