:root {
  color-scheme: light;
  --ink: #17201c;
  --muted: #68736f;
  --line: #c9d7d0;
  --paper: #f3f6f2;
  --panel: #ffffff;
  --field: #175c45;
  --field-dark: #0d3b2d;
  --clay: #b9522d;
  --gold: #f1c74b;
  --shadow: 0 12px 32px rgba(17, 54, 41, 0.09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--paper); color: var(--ink); font-family: "Segoe UI", system-ui, sans-serif; }
button, input, select { font: inherit; }
button, .file-button { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); padding: 0 14px; font-weight: 700; cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(14, 116, 214, .28); outline-offset: 2px; }
button:disabled { cursor: not-allowed; opacity: .45; }

.lineup-header { min-height: 88px; padding: 14px max(20px, calc((100vw - 1180px) / 2)); background: linear-gradient(120deg, var(--field-dark), var(--field)); color: #fff; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 5px solid var(--gold); }
.lineup-header h1 { margin: 2px 0 0; font-size: clamp(1.55rem, 4vw, 2.25rem); }
.lineup-header .eyebrow { color: #d6ece3; }
.lineup-header img { width: min(190px, 35vw); max-height: 58px; object-fit: contain; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-admin-button { min-height: 36px; border-color: rgba(255,255,255,.6); background: rgba(255,255,255,.12); color: #fff; font-size: .82rem; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .13em; font-size: .73rem; font-weight: 800; }

.lineup-shell { width: min(1180px, calc(100% - 28px)); margin: 22px auto 48px; }
.view-tabs { margin-bottom: 16px; padding: 5px; display: inline-flex; gap: 4px; border: 1px solid var(--line); border-radius: 12px; background: #e7eee9; }
.view-tabs button { border-color: transparent; background: transparent; color: var(--muted); }
.view-tabs button.active { border-color: var(--field); background: var(--field); color: #fff; box-shadow: 0 4px 12px rgba(23, 92, 69, .2); }
.notice { margin-bottom: 16px; border: 1px solid #e4bd52; border-left: 6px solid var(--gold); border-radius: 12px; padding: 14px 16px; background: #fff9df; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.notice.compact { margin: 14px 0; }
.notice p { margin: 3px 0 0; color: var(--muted); }
.file-button { display: inline-flex; align-items: center; white-space: nowrap; }
.file-button input { display: none; }

.step-card, .player-panel, .lineup-panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.step-card { display: flex; align-items: center; gap: 14px; padding: 16px 20px; margin-bottom: 18px; }
.step-number, .step-label span { width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--field); color: #fff; font-weight: 800; }
.step-content { flex: 1; display: grid; grid-template-columns: auto minmax(220px, 420px) 1fr; align-items: center; gap: 12px; }
.step-content.pin-step-content { display: block; }
.pin-unlock-form { width: min(440px, 100%); display: grid; gap: 7px; }
.pin-unlock-form > label, .unlocked-team-panel > label { color: var(--muted); font-size: .82rem; font-weight: 800; }
.pin-entry-row { display: grid; grid-template-columns: minmax(160px, 1fr) auto; gap: 8px; }
.pin-entry-row input { min-height: 50px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; font-size: 1.15rem; letter-spacing: .22em; }
.pin-entry-row button { min-width: 112px; }
.unlocked-team-panel { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.4fr); gap: 8px 16px; align-items: end; }
.unlocked-team-heading { grid-column: 1; grid-row: 1 / span 2; min-height: 86px; padding: 12px 14px; border-radius: 10px; background: #eaf5f0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.unlocked-team-heading span { display: block; color: var(--muted); font-size: .73rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.unlocked-team-heading strong { display: block; margin-top: 3px; color: var(--field-dark); font-size: 1.3rem; }
.unlocked-team-heading button { min-height: 36px; padding: 0 10px; font-size: .78rem; }
.unlocked-team-panel > label { grid-column: 2; }
.unlocked-team-panel > select { grid-column: 2; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.unlocked-team-panel .helper { grid-column: 2; }
.step-content label { font-weight: 800; }
.step-content select, .pitcher-field select, .search-field input { width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; color: var(--ink); }
.helper { margin: 0; color: var(--muted); font-size: .9rem; }
.helper.error-text { color: #9c2d23; font-weight: 700; }

.maker-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, .88fr); gap: 18px; align-items: start; }
.player-panel, .lineup-panel { padding: 20px; }
.section-heading { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 16px; }
.section-heading h2 { margin: 5px 0 0; font-size: 1.35rem; color: var(--field-dark); }
.step-label { margin: 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .82rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.step-label span { width: 25px; height: 25px; flex-basis: 25px; font-size: .8rem; }
.count-pill { padding: 6px 10px; background: #e6f2ed; color: var(--field-dark); border-radius: 999px; font-size: .82rem; font-weight: 800; white-space: nowrap; }
.search-field, .pitcher-field { display: grid; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 800; }
.player-panel h3 { margin: 18px 0 9px; font-size: .95rem; }
.sub-heading { margin-top: 18px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.sub-heading h3 { margin: 0; }
.sub-heading span { color: var(--muted); font-size: .78rem; }
.player-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.player-choice { width: 100%; min-height: 33px; padding: 3px 8px; display: flex; align-items: center; justify-content: flex-start; text-align: left; white-space: normal; line-height: 1.15; }
.player-choice.selected { border-color: var(--field); background: #eaf5f0; color: var(--field-dark); box-shadow: inset 4px 0 var(--field); }
.player-name { flex: 1; }
.sub-tag { color: var(--clay); font-size: .73rem; font-weight: 900; text-transform: uppercase; }
.empty { grid-column: 1 / -1; margin: 0; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }

.order-toolbar { margin-bottom: 7px; padding: 7px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-radius: 9px; background: #eaf5f0; }
.order-toolbar > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--field-dark); font-size: .78rem; font-weight: 800; }
.order-toolbar-actions { display: flex; gap: 5px; flex: 0 0 auto; }
.order-toolbar-actions button { min-height: 32px; padding: 0 9px; font-size: .74rem; }
.batting-order { min-height: 220px; display: grid; gap: 4px; }
.lineup-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 5px; align-items: center; padding: 3px 5px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfb; }
.lineup-row.selected { border-color: var(--field); background: #edf7f2; box-shadow: inset 3px 0 var(--field); }
.order-number { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 7px; background: var(--field-dark); color: #fff; font-size: .78rem; font-weight: 900; }
.lineup-name-button { min-width: 0; min-height: 31px; justify-content: flex-start; overflow: hidden; border: 0; background: transparent; padding: 0 6px; text-align: left; text-overflow: ellipsis; white-space: nowrap; font-size: .84rem; font-weight: 750; }
.lineup-name-button small { margin-left: 5px; color: var(--clay); font-size: .66rem; text-transform: uppercase; }
.row-actions { display: flex; gap: 4px; }
.row-actions button { min-height: 30px; min-width: 30px; padding: 0; }
.lineup-empty { min-height: 220px; border: 2px dashed #d3dfd9; border-radius: 12px; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 22px; }
.pitcher-field { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-message { min-height: 20px; margin: 11px 0; color: #9c2d23; font-size: .87rem; font-weight: 700; }
.submit-button, button.primary { width: 100%; border-color: var(--field); background: var(--field); color: #fff; }
.submit-button { min-height: 54px; font-size: 1.03rem; }
.cancel-button { min-height: 36px; margin: 8px auto 0; display: block; border-color: transparent; background: transparent; color: var(--muted); font-size: .82rem; }
.cancel-button:hover { color: #9c2d23; text-decoration: underline; }
.print-help { margin: 8px 0 0; color: var(--muted); font-size: .84rem; font-weight: 700; }

dialog { width: min(430px, calc(100% - 32px)); border: 0; border-radius: 16px; padding: 26px; text-align: center; box-shadow: 0 24px 70px rgba(8, 35, 25, .28); }
dialog::backdrop { background: rgba(8, 35, 25, .62); }
dialog h2 { margin: 10px 0 8px; color: var(--field-dark); }
dialog p { color: var(--muted); }
.success-mark { width: 56px; height: 56px; margin: auto; border-radius: 50%; display: grid; place-items: center; background: var(--field); color: #fff; font-size: 2rem; font-weight: 900; }
.dialog-actions { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.admin-dialog { text-align: left; }
.admin-dialog > h2, .admin-dialog > p { text-align: center; }
.admin-form { display: grid; gap: 7px; margin-top: 16px; }
.admin-form label { color: var(--muted); font-size: .82rem; font-weight: 800; }
.admin-form input, .admin-form select { width: 100%; min-height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.admin-form button { margin-top: 4px; }
.admin-status { min-height: 22px; margin: 12px 0 0; text-align: center; font-size: .86rem; font-weight: 700; }

.board-view { padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.board-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.board-toolbar h2 { margin: 4px 0; color: var(--field-dark); font-size: clamp(1.45rem, 4vw, 2rem); }
.board-toolbar p { margin: 0; color: var(--muted); }
.board-toolbar label { min-width: 230px; display: grid; gap: 6px; color: var(--muted); font-size: .82rem; font-weight: 800; }
.board-toolbar select { min-height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.board-summary { margin: 18px 0 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.summary-chip { padding: 7px 11px; border-radius: 999px; background: #eef3f0; color: var(--muted); font-size: .82rem; font-weight: 800; }
.summary-chip.complete { background: #e3f3ec; color: var(--field-dark); }
.summary-chip.bye { background: #fff3c4; color: #745913; }
.lineup-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.team-status-card { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfb; overflow: hidden; }
.team-status-head { padding: 14px; display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.team-status-head h3 { margin: 0; color: var(--field-dark); }
.team-status-head p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.status-badge { padding: 5px 8px; border-radius: 999px; white-space: nowrap; font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; background: #f1ece7; color: #82512e; }
.status-badge.submitted { background: #ddf1e7; color: #0d5c3f; }
.team-status-body { padding: 0 14px 14px; }
.team-status-body > p { margin: 0; color: var(--muted); font-size: .88rem; }
.bye-card .team-status-head { padding-bottom: 8px; }
.team-status-body > .bye-message { padding: 8px 0 12px; color: #745913; font-size: 1.15rem; font-weight: 900; letter-spacing: .12em; }
.submitted-details { border-top: 1px solid var(--line); padding-top: 10px; }
.submitted-details summary { color: var(--field); cursor: pointer; font-weight: 800; }
.submitted-details ol { margin: 10px 0 0; padding-left: 28px; }
.submitted-details li { margin: 3px 0; font-size: .86rem; }
.submitted-details .pitcher-line { margin: 10px 0 0; padding: 8px; border-radius: 8px; background: #eaf5f0; color: var(--field-dark); font-size: .82rem; font-weight: 800; }
.board-print-button { width: 100%; min-height: 40px; margin-top: 10px; border-color: var(--field); background: var(--field); color: #fff; }
.board-empty { grid-column: 1 / -1; padding: 28px; border: 2px dashed var(--line); border-radius: 12px; text-align: center; color: var(--muted); }

@media (max-width: 820px) {
  .maker-grid { grid-template-columns: 1fr; }
  .step-content { grid-template-columns: 1fr; gap: 6px; }
  .unlocked-team-panel { grid-template-columns: 1fr; }
  .unlocked-team-heading, .unlocked-team-panel > label, .unlocked-team-panel > select, .unlocked-team-panel .helper { grid-column: 1; grid-row: auto; }
  .helper { margin-top: 2px; }
  .lineup-board { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .lineup-header { min-height: 76px; }
  .lineup-header img { width: 110px; }
  .header-actions { gap: 7px; }
  .header-admin-button { min-height: 34px; padding: 0 9px; }
  .lineup-shell { width: min(100% - 18px, 1180px); margin-top: 12px; }
  .notice { align-items: stretch; flex-direction: column; }
  .file-button { justify-content: center; }
  .step-card, .player-panel, .lineup-panel { border-radius: 12px; padding: 15px; }
  .step-card { align-items: flex-start; }
  .player-list { grid-template-columns: 1fr; }
  .view-tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .view-tabs button { white-space: normal; }
  .board-view { padding: 15px; }
  .board-toolbar { align-items: stretch; flex-direction: column; }
  .board-toolbar label { min-width: 0; }
  .lineup-board { grid-template-columns: 1fr; }
  .section-heading { align-items: center; }
  #loadDefaultBtn { min-height: 38px; padding: 0 9px; font-size: .78rem; }
  .order-toolbar { align-items: stretch; flex-direction: column; }
  .order-toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .pin-entry-row { grid-template-columns: 1fr; }
  .pin-entry-row button { width: 100%; }
}
