:root {
  color-scheme: light;
  --navy: #071328;
  --blue: #0b2f61;
  --red: #e5333d;
  --ink: #111827;
  --muted: #677184;
  --line: #dfe3e9;
  --paper: #fff;
  --background: #f3f5f8;
  --visitor-color: #64748b;
  --home-color: #334155;
}

* { box-sizing: border-box; }

html {
  background: var(--background);
  overscroll-behavior: none;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--background);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", sans-serif;
}

a { color: inherit; }

button, input, select { font: inherit; }

button, select { cursor: pointer; }

.home-shell,
.game-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.site-header,
.game-header {
  display: flex;
  align-items: center;
  min-height: 78px;
}

.game-header { justify-content: space-between; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand img { width: 32px; height: 32px; border-radius: 7px; }

.brand span {
  color: var(--navy);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: .06em;
}

.brand small { color: var(--muted); font-size: .72rem; font-weight: 700; }
.brand-compact { gap: 7px; }
.brand-compact img { width: 26px; height: 26px; border-radius: 6px; }
.brand-compact span { font-size: .95rem; }

.back-link {
  color: var(--blue);
  font-size: .86rem;
  font-weight: 700;
  text-decoration: none;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 8px 0 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: .64rem;
  font-weight: 900;
  letter-spacing: .13em;
}

h1, h2, p { margin-top: 0; }
.section-heading h1 { margin: 0; font-size: 1.35rem; }

.game-count {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 700;
}

.date-nav {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 100px;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.date-nav button {
  min-height: 38px;
  color: var(--blue);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: .74rem;
  font-weight: 800;
}

.date-nav button:disabled { cursor: not-allowed; opacity: .45; }

.date-picker { position: relative; text-align: center; }
.date-picker time { font-size: .88rem; font-weight: 800; }
.date-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.date-picker:focus-within { outline: 2px solid var(--blue); outline-offset: 3px; border-radius: 3px; }
#previous-date { width: 48px; justify-self: start; padding: 0 3px; font-size: .68rem; }

.date-forward {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
}

.date-forward button { min-width: 0; padding: 0 3px; font-size: .68rem; }

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

.empty-message {
  margin: 36px 0;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
  text-align: center;
}

.game-card {
  position: relative;
  min-width: 0;
  min-height: 132px;
  padding: 13px;
  overflow: hidden;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}

.game-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--visitor-color) 0 50%, var(--home-color) 50%);
  content: "";
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 13px;
}

.card-time { color: var(--muted); font-size: .72rem; font-weight: 700; }

.teams { display: grid; gap: 6px; }

.teams strong {
  font-size: .78rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.teams span { margin-right: 5px; color: var(--muted); font-size: .6rem; font-weight: 800; }

.game-card:hover { border-color: #aeb8c7; }
.game-card:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid #7aa7e3;
  outline-offset: 2px;
}

.match-card {
  position: relative;
  padding: 22px 18px 20px;
  overflow: hidden;
  color: white;
  background: linear-gradient(110deg, var(--visitor-color) 0 49%, var(--home-color) 51% 100%);
  border-radius: 8px;
}

.match-card::before {
  position: absolute;
  inset: 0;
  background: rgba(7, 19, 40, .52);
  content: "";
}

.match-card > * { position: relative; }

.matchup { display: grid; gap: 6px; }
.matchup strong { font-size: clamp(1.12rem, 5.5vw, 1.55rem); line-height: 1.3; }
.matchup span { color: #9ba8bb; font-size: .72rem; font-weight: 800; }
.match-time { margin: 16px 0 0; color: #c5ccda; font-size: .78rem; }
.match-umpire { margin: 6px 0 0; color: #d9dee7; font-size: .78rem; }

.visitor-t { --visitor-color: #ffe100; }
.home-t { --home-color: #ffe100; }
.visitor-db { --visitor-color: #005bac; }
.home-db { --home-color: #005bac; }
.visitor-g { --visitor-color: #f47a00; }
.home-g { --home-color: #f47a00; }
.visitor-d { --visitor-color: #003e8d; }
.home-d { --home-color: #003e8d; }
.visitor-c { --visitor-color: #e60012; }
.home-c { --home-color: #e60012; }
.visitor-s { --visitor-color: #00744a; }
.home-s { --home-color: #00744a; }
.visitor-h { --visitor-color: #d9ad00; }
.home-h { --home-color: #d9ad00; }
.visitor-f { --visitor-color: #00a0e9; }
.home-f { --home-color: #00a0e9; }
.visitor-b { --visitor-color: #9b855d; }
.home-b { --home-color: #9b855d; }
.visitor-e { --visitor-color: #870010; }
.home-e { --home-color: #870010; }
.visitor-l { --visitor-color: #173f73; }
.home-l { --home-color: #173f73; }
.visitor-m { --visitor-color: #111827; }
.home-m { --home-color: #111827; }

.surge-notice {
  margin-top: 12px;
  padding: 13px 14px;
  color: #8c1820;
  background: #fff0f1;
  border-left: 4px solid var(--red);
  border-radius: 4px;
}

.surge-notice strong, .surge-notice span { display: block; }
.surge-notice strong { margin-bottom: 3px; font-size: .84rem; }
.surge-notice span { font-size: .72rem; }

.reaction-history {
  margin-top: 12px;
  padding: 16px 18px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.history-heading { display: flex; align-items: center; justify-content: space-between; }
.history-heading h1 { margin: 0; font-size: .92rem; }
.history-heading span { color: var(--muted); font-size: .66rem; font-weight: 700; }
.reaction-history > p { margin: 14px 0 0; color: var(--muted); font-size: .72rem; }

.reaction-history ol {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.reaction-history li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: .72rem;
}

.reaction-history time { color: var(--muted); }
.reaction-history li span { color: #8c1820; font-weight: 800; }

.action-area { padding: 22px 0 0; }
.action-area > p { margin-bottom: 10px; color: var(--muted); font-size: .76rem; text-align: center; }

.abs-button {
  display: grid;
  width: 100%;
  min-height: 112px;
  place-content: center;
  color: white;
  background: var(--blue);
  border: 0;
  border-bottom: 5px solid #061d3b;
  border-radius: 8px;
}

.abs-button:not(:disabled):active { border-bottom-width: 2px; transform: translateY(3px); }
.abs-button:disabled { color: #eef0f3; background: #a3a8b0; border-bottom-color: #858a92; cursor: not-allowed; }
.abs-button strong { font-size: 2.2rem; letter-spacing: .08em; }
.abs-button span { margin-top: 3px; font-size: .77rem; font-weight: 700; }
.abs-availability { margin: 10px 0 0; color: #6b7280; font-size: .76rem; font-weight: 700; text-align: center; }

.game-error { margin-top: 30vh; color: var(--muted); text-align: center; }

.details-dialog {
  width: min(100%, 560px);
  max-height: 88vh;
  margin: auto auto 0;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 12px 12px 0 0;
}

.details-dialog::backdrop { background: rgba(4, 12, 25, .62); }
.details-dialog form { padding: 10px 18px max(24px, env(safe-area-inset-bottom)); }

.sheet-handle { width: 38px; height: 4px; margin: 0 auto 18px; background: #cbd0d8; border-radius: 4px; }
.sheet-heading { display: flex; align-items: start; justify-content: space-between; margin-bottom: 18px; }
.sheet-heading h2 { margin: 0; font-size: 1.25rem; }

.close-button {
  width: 36px;
  height: 36px;
  color: #455064;
  background: #eef0f3;
  border: 0;
  border-radius: 50%;
  font-size: 1.35rem;
}

.details-dialog form > label,
.details-dialog legend { display: block; margin-bottom: 7px; font-size: .78rem; font-weight: 800; }

.details-dialog input[type="text"],
.details-dialog select {
  width: 100%;
  min-height: 44px;
  margin-bottom: 16px;
  padding: 0 11px;
  color: var(--ink);
  background: white;
  border: 1px solid #cdd3dc;
  border-radius: 5px;
}

fieldset { margin: 0 0 16px; padding: 0; border: 0; }
.choice-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice-row label { position: relative; }
.choice-row input { position: absolute; opacity: 0; }
.choice-row span {
  display: grid;
  min-height: 44px;
  padding: 5px;
  place-items: center;
  color: #3e4757;
  background: white;
  border: 1px solid #cdd3dc;
  border-radius: 5px;
  font-size: .72rem;
  font-weight: 700;
  text-align: center;
}

.choice-row input:checked + span { color: var(--blue); background: #eaf0f8; border-color: var(--blue); }
.choice-row input:focus-visible + span { outline: 3px solid #7aa7e3; outline-offset: 2px; }

.submit-button {
  width: 100%;
  min-height: 50px;
  color: white;
  background: var(--blue);
  border: 0;
  border-radius: 5px;
  font-weight: 800;
}

[hidden] { display: none !important; }

@media (min-width: 600px) {
  .home-shell, .game-shell { padding-right: 24px; padding-left: 24px; }
  .game-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .game-card { min-height: 150px; padding: 16px; }
}

@media (max-width: 350px) {
  .home-shell, .game-shell { padding-right: 10px; padding-left: 10px; }
  .game-grid { gap: 7px; }
  .game-card { min-height: 126px; padding: 11px 9px; }
  .teams strong { font-size: .78rem; }
}
