* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --ink: #17231d;
  --muted: #66736b;
  --canvas: #f3f5ef;
  --surface: #ffffff;
  --line: #dfe5dc;
  --green-950: #0b2d1e;
  --green-900: #123b2a;
  --green-700: #246247;
  --green-100: #dfece3;
  --lime: #c9e55b;
  --orange: #ef7d32;
  --orange-soft: #fff0e4;
  --red: #c94343;
  --red-soft: #fff0ef;
  --shadow: 0 18px 55px rgba(24, 47, 35, 0.1);
  font-family: Inter, ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

html {
  background: var(--canvas);
  touch-action: manipulation;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -5%, rgba(201, 229, 91, 0.2), transparent 30rem),
    var(--canvas);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

button,
a,
label {
  -webkit-touch-callout: none;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(36, 98, 71, 0.35);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 720px);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: calc(10px + env(safe-area-inset-top)) 18px 10px;
  background: rgba(243, 245, 239, 0.92);
  border-bottom: 1px solid rgba(18, 59, 42, 0.08);
  backdrop-filter: blur(18px);
}

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

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: var(--green-900);
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(18, 59, 42, 0.2);
}

.brand-mark svg {
  width: 28px;
  fill: white;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.02rem;
  letter-spacing: -0.03em;
}

.brand small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  padding: 0;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}

.icon-button svg {
  width: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

main {
  padding: 18px 16px 30px;
}

.page-heading {
  margin: 4px 2px 18px;
}

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

.eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--green-700);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

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

h1,
h2,
h3 {
  letter-spacing: -0.035em;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.75rem, 7vw, 2.35rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 4px;
  font-size: 1rem;
}

.lede,
.helper-text {
  color: var(--muted);
  line-height: 1.5;
}

.lede {
  margin-bottom: 0;
  font-size: 0.95rem;
}

.helper-text {
  margin: 6px 0 0;
  font-size: 0.82rem;
}

.card {
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 8px 30px rgba(24, 47, 35, 0.045);
}

.card + .card,
.card + .section,
.section + .card {
  margin-top: 14px;
}

.hero-card {
  overflow: hidden;
  padding: 26px 22px 22px;
  background:
    linear-gradient(130deg, rgba(201, 229, 91, 0.95), rgba(223, 236, 227, 0.96)),
    var(--green-100);
  border: 0;
  box-shadow: var(--shadow);
}

.hero-ball {
  float: right;
  width: 84px;
  margin: -10px -4px 6px 14px;
  fill: rgba(18, 59, 42, 0.16);
}

.hero-card h1 {
  max-width: 430px;
  margin-bottom: 10px;
}

.hero-card p {
  max-width: 470px;
  margin-bottom: 22px;
  color: rgba(11, 45, 30, 0.72);
  line-height: 1.5;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 17px;
  border: 1px solid transparent;
  border-radius: 15px;
  font-weight: 780;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}

.button:active {
  transform: scale(0.98);
}

.button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.5);
  opacity: 0.45;
}

.button svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.button-primary {
  background: var(--green-900);
  color: white;
  box-shadow: 0 10px 24px rgba(18, 59, 42, 0.19);
}

.button-accent {
  background: var(--orange);
  color: white;
  box-shadow: 0 10px 24px rgba(239, 125, 50, 0.23);
}

.button-secondary {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.button-ghost {
  min-height: 40px;
  padding: 8px 10px;
  background: transparent;
  color: var(--green-700);
}

.button-danger {
  background: var(--red-soft);
  color: var(--red);
}

.button-wide {
  width: 100%;
}

.section {
  margin-top: 24px;
}

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

.section-heading h2 {
  margin: 0;
  font-size: 1.08rem;
}

.section-heading span {
  color: var(--muted);
  font-size: 0.78rem;
}

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

.mini-stat {
  padding: 14px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(18, 59, 42, 0.09);
  border-radius: 16px;
}

.mini-stat strong,
.mini-stat span {
  display: block;
}

.mini-stat strong {
  font-size: 1.3rem;
}

.mini-stat span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 650;
}

.empty-card {
  padding: 34px 22px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  place-items: center;
  background: var(--green-100);
  border-radius: 20px;
  color: var(--green-900);
  font-size: 1.75rem;
}

.empty-card p {
  margin: 0 auto 18px;
  max-width: 360px;
  color: var(--muted);
  line-height: 1.5;
}

.player-list,
.selection-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.player-row,
.selection-row {
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.player-row.dragging {
  position: relative;
  z-index: 5;
  border-color: var(--green-700);
  box-shadow: var(--shadow);
  cursor: grabbing;
  opacity: 0.96;
  transform: scale(1.02);
}

.player-list.reordering .player-row:not(.dragging) {
  border-style: dashed;
}

body.is-reordering {
  user-select: none;
  -webkit-user-select: none;
}

.drag-handle {
  display: grid;
  width: 34px;
  height: 42px;
  flex: 0 0 34px;
  padding: 0;
  place-items: center;
  background: transparent;
  border: 0;
  color: #93a098;
  cursor: grab;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle svg {
  width: 18px;
  fill: currentColor;
}

.reorder-buttons {
  display: grid;
  flex: 0 0 27px;
  gap: 2px;
}

.reorder-button {
  display: grid;
  width: 27px;
  height: 24px;
  padding: 0;
  place-items: center;
  background: #f4f7f3;
  border: 0;
  border-radius: 8px;
  color: var(--green-700);
  cursor: pointer;
}

.reorder-button:disabled {
  color: #c8d0ca;
  cursor: default;
}

.reorder-button svg {
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.shirt-number,
.player-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  background: var(--green-100);
  border-radius: 13px;
  color: var(--green-900);
  font-weight: 850;
}

.player-copy {
  min-width: 0;
  flex: 1;
}

.player-copy strong,
.player-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-copy strong {
  font-size: 0.96rem;
}

.player-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.row-action {
  display: grid;
  width: 38px;
  height: 38px;
  padding: 0;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
}

.row-action svg {
  width: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.row-action.danger {
  color: var(--red);
}

.count-badge {
  display: inline-grid;
  min-width: 36px;
  height: 30px;
  padding: 0 8px;
  place-items: center;
  background: var(--orange-soft);
  border: 1px solid rgba(239, 125, 50, 0.25);
  border-radius: 999px;
  color: #a94c15;
  font-size: 0.78rem;
  font-weight: 850;
}

.stepper {
  display: flex;
  gap: 7px;
  margin-bottom: 18px;
}

.stepper span {
  height: 5px;
  flex: 1;
  background: var(--line);
  border-radius: 999px;
}

.stepper span.active,
.stepper span.done {
  background: var(--green-700);
}

.selection-row {
  position: relative;
  cursor: pointer;
}

.selection-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.selection-row.selected {
  background: #f2f8f3;
  border-color: rgba(36, 98, 71, 0.45);
  box-shadow: inset 0 0 0 1px rgba(36, 98, 71, 0.12);
}

.selection-row.is-bench.selected {
  background: var(--orange-soft);
  border-color: rgba(239, 125, 50, 0.5);
}

.check-mark {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  background: white;
  border: 2px solid #b8c3bb;
  border-radius: 9px;
  color: transparent;
  font-size: 0.8rem;
  font-weight: 900;
}

.selection-row.selected .check-mark {
  background: var(--green-700);
  border-color: var(--green-700);
  color: white;
}

.selection-row.is-bench.selected .check-mark {
  background: var(--orange);
  border-color: var(--orange);
}

.setup-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
  margin-top: 18px;
}

.setup-actions.single {
  grid-template-columns: 1fr;
}

.choice-group + .choice-group {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.choice-group-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.choice-group-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.selection-count {
  flex: 0 0 auto;
  padding: 5px 9px;
  background: var(--green-100);
  border-radius: 999px;
  color: var(--green-900);
  font-size: 0.72rem;
  font-weight: 800;
}

.selection-count.invalid {
  background: var(--red-soft);
  color: var(--red);
}

.match-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 10px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--green-700);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.live-pill::before {
  width: 8px;
  height: 8px;
  background: var(--lime);
  border: 3px solid rgba(36, 98, 71, 0.15);
  border-radius: 50%;
  content: "";
}

.live-pill.paused::before {
  background: #f3b13c;
}

.live-pill.expired::before {
  background: var(--orange);
}

.timer-card {
  position: relative;
  display: flex;
  min-height: 112px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
  padding: 18px 20px;
  background: var(--green-950);
  border: 0;
  color: white;
  text-align: left;
  box-shadow: 0 22px 60px rgba(11, 45, 30, 0.22);
}

.timer-card.expired {
  background: #8d3b14;
  animation: alert-pulse 1.7s ease-in-out infinite;
}

@keyframes alert-pulse {
  50% { box-shadow: 0 22px 70px rgba(239, 125, 50, 0.38); }
}

.timer-label {
  margin-bottom: 5px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.timer-value {
  display: inline-block;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.35rem, 11vw, 3.2rem);
  font-weight: 850;
  letter-spacing: -0.055em;
  line-height: 1;
}

.timer-state {
  display: block;
  margin-top: 5px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.73rem;
  font-weight: 650;
}

.timer-controls {
  flex: 0 0 auto;
}

.timer-controls .timer-control-button {
  min-width: 104px;
  min-height: 50px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: white;
  box-shadow: none;
}

@media (max-width: 370px) {
  .timer-card {
    gap: 10px;
    padding-right: 15px;
    padding-left: 15px;
  }

  .timer-controls .timer-control-button {
    min-width: 94px;
    padding-right: 10px;
    padding-left: 10px;
  }
}

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

.bench-player,
.field-player {
  position: relative;
  min-width: 0;
  padding: 15px;
  border-radius: 18px;
}

.bench-player {
  background: var(--orange-soft);
  border: 1px solid rgba(239, 125, 50, 0.3);
}

.field-player {
  background: var(--surface);
  border: 1px solid var(--line);
}

.field-player.next-out {
  background: #f2f8f3;
  border-color: rgba(36, 98, 71, 0.35);
}

.bench-player strong,
.field-player strong,
.bench-player small,
.field-player small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bench-player strong,
.field-player strong {
  padding-right: 38px;
  font-size: 0.96rem;
}

.bench-player small,
.field-player small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.bench-player .count-badge,
.field-player .count-badge {
  position: absolute;
  top: 11px;
  right: 10px;
}

.keeper-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  background: #f5f1ff;
  border: 1px solid #ded2f4;
  border-radius: 18px;
}

.keeper-icon {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  background: #e7dcfb;
  border-radius: 13px;
  font-size: 1.2rem;
}

.keeper-card strong,
.keeper-card small {
  display: block;
}

.keeper-card small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.swap-panel {
  position: sticky;
  z-index: 10;
  bottom: calc(76px + env(safe-area-inset-bottom));
  margin-top: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow: 0 15px 45px rgba(24, 47, 35, 0.16);
  backdrop-filter: blur(16px);
}

.swap-panel .button-accent {
  min-height: 58px;
  font-size: 1rem;
}

.swap-secondary {
  display: flex;
  justify-content: center;
  margin-top: 4px;
}

.manual-panel {
  margin-top: 18px;
  padding: 18px;
  background: var(--surface);
  border: 2px solid rgba(239, 125, 50, 0.32);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.manual-panel .selection-list {
  margin-top: 13px;
}

.undo-bar {
  position: fixed;
  z-index: 50;
  right: 16px;
  bottom: calc(91px + env(safe-area-inset-bottom));
  left: 16px;
  display: flex;
  max-width: 688px;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: auto;
  padding: 9px 10px 9px 17px;
  background: var(--green-950);
  border-radius: 18px;
  color: white;
  box-shadow: 0 16px 50px rgba(11, 45, 30, 0.35);
}

.undo-bar span {
  font-size: 0.86rem;
  font-weight: 700;
}

.undo-bar button {
  min-height: 40px;
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.15);
  color: white;
}

.no-subs-card {
  padding: 30px 22px;
  background: var(--green-100);
  border: 0;
  text-align: center;
}

.no-subs-card .empty-icon {
  background: white;
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(100%, 720px);
  min-height: calc(70px + env(safe-area-inset-bottom));
  margin: auto;
  padding: 7px 18px calc(7px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 15px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-decoration: none;
}

.bottom-nav a.active {
  background: var(--green-100);
  color: var(--green-900);
}

.bottom-nav svg {
  width: 21px;
  fill: currentColor;
}

.toast {
  position: fixed;
  z-index: 100;
  top: calc(82px + env(safe-area-inset-top));
  left: 50%;
  max-width: calc(100vw - 32px);
  padding: 10px 15px;
  background: var(--green-950);
  border-radius: 999px;
  color: white;
  font-size: 0.82rem;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.dialog {
  width: min(calc(100% - 28px), 500px);
  padding: 0;
  background: var(--surface);
  border: 0;
  border-radius: 24px;
  box-shadow: 0 30px 100px rgba(11, 45, 30, 0.3);
}

.dialog::backdrop {
  background: rgba(11, 30, 21, 0.55);
  backdrop-filter: blur(3px);
}

.dialog form {
  padding: 20px;
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.dialog-heading h2 {
  margin: 0;
}

.field-label {
  display: block;
  margin: 14px 2px 7px;
  font-size: 0.82rem;
  font-weight: 800;
}

.field-label span {
  color: var(--muted);
  font-weight: 500;
}

.text-input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  background: #fbfcfa;
  border: 1px solid #cdd6cf;
  border-radius: 14px;
  color: var(--ink);
  font-size: 1rem;
}

select.text-input {
  appearance: auto;
}

.settings-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.settings-copy {
  min-width: 0;
}

.settings-copy strong,
.settings-copy small {
  display: block;
}

.settings-copy strong {
  font-size: 0.88rem;
}

.settings-copy small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.settings-action {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 8px 12px;
  font-size: 0.78rem;
}

.notification-prompt form {
  text-align: center;
}

.notification-prompt h2 {
  margin: 7px 0 9px;
}

.notification-prompt p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.prompt-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 14px;
  place-items: center;
  background: var(--green-100);
  border-radius: 19px;
  color: var(--green-900);
}

.prompt-icon svg {
  width: 27px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

@media (max-width: 390px) {
  .settings-section {
    align-items: flex-start;
    flex-direction: column;
  }
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.muted-note {
  padding: 13px 14px;
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

@media (min-width: 600px) {
  main {
    padding-right: 24px;
    padding-left: 24px;
  }

  .app-header {
    padding-right: 26px;
    padding-left: 26px;
  }

  .player-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .bench-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 370px) {
  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand small {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
