:root {
  color-scheme: light;
  --page-gap: 8px;
  --page-pad: 8px;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --surface-2: #eef2f5;
  --ink: #17212b;
  --muted: #627080;
  --line: #d8e0e7;
  --green: #28784f;
  --green-dark: #1c5e3d;
  --blue: #2f68d6;
  --red: #cf493f;
  --amber: #d99a21;
  --pos-gk: #5c50c8;
  --pos-d: #3e9eb0;
  --pos-m: #b77900;
  --pos-f: #c83d34;
  --pos-be: #64748b;
  --pos-in: #8a94a6;
  --field: #34865a;
  --field-dark: #2b704c;
  --field-line: rgba(255, 255, 255, 0.58);
  --field-stripe: rgba(255, 255, 255, 0.035);
  --shadow: 0 10px 30px rgba(23, 33, 43, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: start;
  width: min(1580px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: var(--page-pad);
  gap: var(--page-gap);
}

.app-header {
  --header-control-height: 44px;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--page-gap);
}

.brand-mark {
  width: var(--header-control-height);
  height: var(--header-control-height);
  flex: 0 0 auto;
  border-radius: 8px;
  display: block;
  object-fit: contain;
}

.view-tabs {
  display: flex;
  flex: 1 1 auto;
  height: var(--header-control-height);
  min-width: 0;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tab-button {
  flex: 1 1 0;
  min-width: 104px;
  min-height: 0;
  padding: 0 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

.tab-button.active {
  background: var(--ink);
  color: #fff;
}

.clock-readout {
  display: grid;
  min-width: 112px;
  min-height: 40px;
  padding: 2px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  place-items: center;
  text-align: center;
}

.clock-readout strong {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 1.55rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.clock-icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.clock-icon-button[hidden] {
  display: none;
}

.clock-icon-button:hover {
  filter: brightness(0.96);
}

.clock-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.clock-icon-button:disabled:hover {
  filter: none;
}

.clock-icon-button.play {
  border-color: transparent;
  background: var(--green);
  color: #fff;
}

.clock-icon-button.pause {
  border-color: transparent;
  background: var(--red);
  color: #fff;
}

.icon {
  width: 22px;
  height: 22px;
  display: block;
}

.mono-time,
.time-code,
.period-code,
.position-code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.time-code {
  display: inline-block;
  min-width: 6ch;
  text-align: right;
}

.period-code {
  color: var(--muted);
  font-weight: 800;
}

.position-code {
  --pos-color: var(--muted);
  display: inline-flex;
  min-width: 2.6ch;
  align-items: center;
  justify-content: center;
  color: var(--pos-color);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
}

.pos-gk {
  --pos-color: var(--pos-gk);
  --slot-color: var(--pos-gk);
}

.pos-d {
  --pos-color: var(--pos-d);
  --slot-color: var(--pos-d);
}

.pos-m {
  --pos-color: var(--pos-m);
  --slot-color: var(--amber);
}

.pos-f {
  --pos-color: var(--pos-f);
  --slot-color: var(--pos-f);
}

.pos-be {
  --pos-color: var(--pos-be);
  --slot-color: var(--pos-be);
}

.pos-in {
  --pos-color: var(--pos-in);
  --slot-color: var(--pos-in);
}

.content {
  min-width: 0;
  touch-action: pan-y;
}

.content.view-transition {
  --view-enter-x: 0;
  animation: view-swipe-enter 190ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
  will-change: transform, opacity;
}

.content.view-swipe-left {
  --view-enter-x: 24px;
}

.content.view-swipe-right {
  --view-enter-x: -24px;
}

@keyframes view-swipe-enter {
  from {
    opacity: 0.45;
    transform: translateX(var(--view-enter-x));
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .content.view-transition {
    animation: none;
  }
}

.app-footer {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 14px clamp(14px, 3vw, 32px) 24px;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.footer-sales {
  display: flex;
  flex-wrap: wrap;
  max-width: 760px;
  align-items: center;
  justify-content: center;
  gap: 8px 12px;
}

.footer-sales p {
  margin: 0;
}

.footer-credit {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
}

.app-footer a {
  color: var(--blue);
  font-weight: 800;
  text-decoration-color: rgba(47, 104, 214, 0.35);
  text-underline-offset: 3px;
}

.app-footer a:hover {
  color: var(--green-dark);
}

.footer-cta {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #fff !important;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.footer-cta:hover {
  color: #fff !important;
  filter: brightness(0.96);
}

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover,
.tab-button:hover {
  filter: brightness(0.96);
}

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

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

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

.button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}

.button.small {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.82rem;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.formation-screen {
  display: grid;
  gap: 10px;
}

.formation-editor,
.roster-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.formation-editor {
  margin-top: 8px;
  padding: 10px;
}

.formation-form {
  display: grid;
  grid-template-columns: max-content minmax(160px, 280px) auto;
  align-items: end;
  gap: 10px;
}

.player-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 128px) auto;
  align-items: end;
  gap: 10px;
  width: 100%;
}

.formation-form {
  width: auto;
}

.formation-rows {
  min-width: 0;
}

.formation-apply .icon {
  display: none;
}

.field-group {
  display: grid;
  min-width: 112px;
  gap: 5px;
}

.formation-form .field-group {
  min-width: 0;
}

.goalie-field {
  justify-items: center;
}

.goalie-field .switch {
  align-self: center;
  margin: 5px 0;
}

.field-group.grow {
  min-width: min(300px, 100%);
  flex: 1 1 260px;
}

label,
.input-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 104, 214, 0.24);
  outline-offset: 2px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.formation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 12px;
  align-items: start;
}

.field-zone,
.lineup-panel,
.roster-table-wrap,
.subs-panel,
.bench-strip,
.event-log {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.field-zone {
  padding: clamp(6px, 1vw, 12px);
}

.pitch {
  position: relative;
  isolation: isolate;
  width: min(560px, 38vw, 100%);
  margin: 0 auto;
  overflow: hidden;
  aspect-ratio: 19 / 20;
  border: 3px solid var(--field-line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, var(--field-stripe) 50%, transparent 50%) 0 0 / 80px 100%,
    linear-gradient(180deg, var(--field), var(--field-dark));
}

.field-clock {
  --field-clock-height: 40px;
  position: absolute;
  top: 12px;
  right: 12px;
  left: 12px;
  z-index: 8;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.field-clock-group {
  display: inline-flex;
  align-items: stretch;
  gap: 5px;
  pointer-events: auto;
}

.field-clock-readout,
.field-clock-period,
.field-clock .clock-icon-button {
  border-color: rgba(255, 255, 255, 0.95);
  background: rgba(255, 255, 255, 0.9);
  box-shadow:
    0 0 0 2px rgba(23, 33, 43, 0.58),
    0 2px 10px rgba(23, 33, 43, 0.2);
}

.field-clock-readout {
  min-height: var(--field-clock-height);
  border-width: 2px;
}

.field-clock-readout.paused {
  border-color: var(--red);
}

.field-clock-readout.running {
  border-color: var(--green);
}

.field-clock-period {
  display: grid;
  min-width: 52px;
  height: var(--field-clock-height);
  padding: 4px 8px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  color: var(--ink);
  line-height: 1;
  text-align: center;
}

.field-clock-period span {
  color: var(--muted);
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field-clock-period strong {
  font-size: 1.08rem;
  line-height: 1;
}

.field-clock .clock-icon-button {
  width: var(--field-clock-height);
  height: var(--field-clock-height);
}

.field-clock .clock-icon-button.play {
  color: var(--green-dark);
}

.field-clock .clock-icon-button.pause {
  color: var(--red);
}

.pitch::after {
  position: absolute;
  z-index: 0;
  inset: 10px;
  border: 2px solid var(--field-line);
  content: "";
  pointer-events: none;
}

.pitch-line {
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

.pitch-line.half {
  top: 50%;
  left: 10px;
  right: 10px;
  border-top: 2px solid var(--field-line);
}

.pitch-line.center-circle {
  top: 50%;
  left: 50%;
  width: 25%;
  aspect-ratio: 1;
  border: 2px solid var(--field-line);
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.pitch-line.center-dot {
  top: 50%;
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--field-line);
  transform: translate(-50%, -50%);
}

.pitch-line.penalty {
  left: 24%;
  width: 52%;
  height: 13%;
  border: 2px solid var(--field-line);
}

.pitch-line.penalty.top {
  top: 10px;
  border-top: 0;
}

.pitch-line.penalty.bottom {
  bottom: 10px;
  border-bottom: 0;
}

.pitch-line.goal {
  left: 37%;
  width: 26%;
  height: 6%;
  border: 2px solid var(--field-line);
}

.pitch-line.goal.top {
  top: 10px;
  border-top: 0;
}

.pitch-line.goal.bottom {
  bottom: 10px;
  border-bottom: 0;
}

.pitch-arrows {
  position: absolute;
  z-index: 5;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.pitch-arrow-head-blue {
  fill: var(--blue);
}

.pitch-arrow-head-red {
  fill: var(--red);
}

.pitch-arrow {
  fill: none;
  stroke: var(--blue);
  stroke-linecap: round;
  stroke-width: 2.6;
  vector-effect: non-scaling-stroke;
}

.pitch-arrow.bench-exit {
  stroke: var(--red);
}

.field-slot-shell {
  --slot-box-width: clamp(56px, 10vw, 82px);
  --slot-box-height: 70px;
  --slot-y-bias: -16px;
  position: absolute;
  display: grid;
  width: var(--slot-box-width);
  height: var(--slot-box-height);
  margin-top: calc((var(--slot-box-height) / -2) + var(--slot-y-bias));
  margin-left: calc(var(--slot-box-width) / -2);
  overflow: visible;
  place-items: center;
  user-select: none;
}

.field-slot {
  position: relative;
  z-index: 2;
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 0;
  place-items: center;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
  touch-action: none;
}

.field-slot:hover,
.field-slot-shell.drag-over .field-slot {
  background: rgba(255, 255, 255, 0.28);
}

.field-slot.changed {
  border-color: #f2c14e;
  box-shadow: 0 0 0 3px rgba(242, 193, 78, 0.24);
}

.position-label {
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0;
}

.position-label .position-code,
.position-code.position-tag {
  min-width: 3ch;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 2px rgba(23, 33, 43, 0.18);
  text-shadow: none;
}

.position-label .position-code {
  padding: 3px 3px 2px;
  font-size: 0.76rem;
  line-height: 1;
}

.position-code.position-tag {
  min-width: 3ch;
  min-height: 26px;
  padding: 4px 1px 2px;
  font-size: 1rem;
  line-height: 1;
}

.slot-name {
  position: absolute;
  z-index: 2;
  top: calc(100% + 2px);
  left: 50%;
  width: max-content;
  max-width: none;
  overflow: visible;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.34);
  transform: translateX(-50%);
  white-space: nowrap;
  pointer-events: none;
}

.player-bubble,
.mini-bubble {
  display: grid;
  place-items: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--slot-color, var(--ink));
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
}

.player-bubble {
  width: 38px;
  height: 38px;
  font-size: 1rem;
}

.player-bubble.empty {
  border-style: dashed;
  background: var(--slot-color, rgba(23, 33, 43, 0.32));
  background: color-mix(in srgb, var(--slot-color, var(--ink)) 58%, var(--ink));
  font-size: 1rem;
}

.slot-incoming-bubble {
  position: absolute;
  z-index: 6;
  top: 50%;
  left: calc(50% + 40px);
  display: grid;
  place-items: center;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.player-bubble.next {
  background: var(--slot-color, var(--blue));
}

.slot-incoming-bubble .player-bubble.incoming {
  background: var(--blue);
  border-color: var(--blue);
}

.field-slot.changed .player-bubble.outgoing {
  border-color: var(--red);
  box-shadow: 0 0 0 2px var(--red);
}

.bench-strip {
  margin-top: 8px;
  padding: 10px;
}

.lineup-start-message {
  display: grid;
  gap: 4px;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(217, 154, 33, 0.58);
  border-radius: 8px;
  background: #fff9ec;
  color: var(--ink);
}

.lineup-start-message strong {
  font-size: 0.9rem;
}

.lineup-start-message span {
  color: var(--muted);
  font-size: 0.82rem;
}

.bench-strip.drag-over {
  border-color: rgba(40, 120, 79, 0.72);
  box-shadow:
    var(--shadow),
    0 0 0 3px rgba(40, 120, 79, 0.14);
}

.subs-panel {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 10px;
}

.bench-head,
.subs-head,
.panel-head,
.event-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.subs-head {
  margin-bottom: 0;
}

.bench-actions,
.event-actions {
  display: inline-flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.bench-action,
.event-action {
  min-height: 38px;
  padding-inline: 10px;
}

.bench-action .icon,
.event-action .icon {
  width: 19px;
  height: 19px;
}

.bench-head h2,
.subs-head h2,
.panel-head h2,
.event-head h2 {
  margin: 0;
  font-size: 0.95rem;
}

.subs-list {
  display: grid;
  gap: 8px;
}

.sub-row {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-around;
  padding: 10px;
  border: 1px solid rgba(217, 154, 33, 0.58);
  border-radius: 8px;
  background: #fff9ec;
}

.sub-flow {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.sub-flow.out {
  justify-content: flex-end;
}

.sub-name {
  overflow: hidden;
  min-width: 0;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sub-name.empty {
  color: var(--muted);
  font-weight: 800;
}

.sub-flow .position-tag {
  flex: 0 0 auto;
}

.sub-arrow {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

.sub-cancel {
  flex: 0 0 auto;
  display: grid;
  width: 34px;
  height: 34px;
  margin: 0 4px;
  padding: 6px;
  place-items: center;
  border: 1px solid rgba(217, 154, 33, 0.72);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.sub-cancel:hover,
.sub-cancel:focus-visible {
  border-color: rgba(190, 83, 52, 0.76);
  color: #be5334;
}

.sub-cancel .icon {
  width: 17px;
  height: 17px;
}

.selected-pill {
  max-width: 260px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-chip {
  display: inline-flex;
  max-width: 190px;
  min-height: 36px;
  align-items: center;
  gap: 8px;
  padding: 5px 9px 5px 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.player-chip:active {
  cursor: grabbing;
}

.player-chip.dragging {
  opacity: 0.45;
}

.drag-ghost {
  position: fixed;
  z-index: 120;
  pointer-events: none;
  opacity: 0.92;
  box-shadow: 0 12px 28px rgba(23, 33, 43, 0.22);
  transform-origin: top left;
}

.player-chip.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47, 104, 214, 0.16);
}

.player-chip.inactive {
  cursor: default;
  opacity: 0.6;
}

.mini-bubble {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-width: 1px;
  font-size: 0.64rem;
}

.chip-text {
  min-width: 0;
}

.chip-text strong,
.chip-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-text strong {
  font-size: 0.82rem;
}

.chip-text span {
  color: var(--muted);
  font-size: 0.68rem;
}

.lineup-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.slot-list {
  display: grid;
  gap: 8px;
}

.slot-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.slot-row.changed {
  border-color: rgba(217, 154, 33, 0.58);
  background: #fff9ec;
}

.slot-meta strong,
.slot-state strong {
  display: block;
}

.slot-meta span,
.slot-state span,
.empty-state,
.form-error {
  color: var(--muted);
  font-size: 0.8rem;
}

.form-error {
  width: 100%;
  color: var(--red);
  font-weight: 800;
}

.slot-state {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.slot-current-next {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.slot-current-next div {
  min-width: 0;
  padding: 7px;
  border-radius: 6px;
  background: var(--surface-2);
}

.slot-current-next strong,
.slot-current-next span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot-current-next strong {
  font-size: 0.82rem;
}

.slot-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
}

.roster-screen {
  display: grid;
  gap: 16px;
}

.roster-table-wrap {
  overflow-x: auto;
}

.roster-settings {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 4px;
}

.setting-title {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.chip-mode-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chip-mode-choice {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.chip-mode-choice.active {
  color: var(--ink);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.sort-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(95, 111, 130, 0.36);
  text-underline-offset: 3px;
}

.sort-header:hover,
.sort-header:focus-visible {
  color: var(--blue);
  text-decoration-color: rgba(47, 104, 214, 0.54);
}

.sort-header.active {
  color: inherit;
}

.sort-indicator {
  display: inline-block;
  min-width: 1ch;
  font-size: 0.8rem;
  line-height: 1;
}

td {
  font-size: 0.92rem;
}

.playtime-cell .time-code {
  min-width: 7ch;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 800;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.playtime-cell.increasing .time-code {
  border-color: rgba(40, 120, 79, 0.34);
  background: #e7f5ee;
  color: var(--green-dark);
}

.playtime-cell.idle .time-code {
  border-color: rgba(100, 116, 139, 0.18);
  background: #f4f6f8;
  color: var(--muted);
}

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

.player-name-cell {
  display: flex;
  min-width: 180px;
  align-items: center;
  gap: 10px;
}

.player-name-link {
  display: block;
}

.roster-badge {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  font-size: 0.76rem;
  line-height: 1;
  text-align: center;
}

.player-name-link {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.45;
  text-decoration-color: rgba(47, 104, 214, 0.45);
  text-underline-offset: 3px;
}

.player-name-link:hover {
  color: var(--blue);
}

.player-name-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 48px;
  height: 28px;
  align-items: center;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #b7c1cb;
  cursor: pointer;
  transition: background 0.16s ease;
}

.switch span::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  content: "";
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--green);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.usage-list {
  display: grid;
  max-width: 220px;
  gap: 3px;
}

.usage-row {
  display: grid;
  grid-template-columns: auto 6ch;
  gap: 8px;
  align-items: center;
  width: max-content;
}

.usage-row .position-code {
  justify-content: center;
}

.usage-row .time-code {
  color: var(--ink);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.event-log {
  padding: 12px;
}

.inactive-strip {
  margin-top: 10px;
}

.empty-padded {
  padding: 18px;
}

.event-list {
  display: grid;
  max-height: 270px;
  overflow: auto;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.event-item {
  display: grid;
  gap: 3px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.event-item strong {
  font-size: 0.86rem;
}

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

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(23, 33, 43, 0.42);
}

.player-modal {
  width: min(420px, 100%);
  max-height: min(720px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(23, 33, 43, 0.28);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.player-modal-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.player-modal-title h2 {
  margin: 0;
  overflow: hidden;
  font-size: 1.08rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-close {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--ink);
}

.modal-close .icon {
  width: 18px;
  height: 18px;
}

.player-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.modal-stat {
  min-width: 0;
  padding: 14px;
  background: var(--surface);
}

.modal-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
  text-transform: uppercase;
}

.modal-stat strong {
  display: block;
  margin-top: 5px;
}

.modal-stat .time-code {
  font-size: 1.25rem;
}

.modal-stat .position-code {
  justify-content: flex-start;
  font-size: 1.1rem;
}

.modal-section {
  display: grid;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.modal-section h3 {
  margin: 0;
  font-size: 0.9rem;
}

.modal-usage {
  max-width: none;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
}

.modal-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (max-width: 1120px) {
  .view-tabs {
    flex: 1 1 auto;
  }

  .formation-grid {
    grid-template-columns: 1fr;
  }

  .lineup-panel {
    grid-template-columns: minmax(0, 1fr);
  }

  .pitch {
    width: min(560px, 100%);
  }
}

@media (max-width: 720px) {
  .formation-editor,
  .roster-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .tab-button {
    min-width: 0;
  }

  .field-clock {
    top: 8px;
    right: 8px;
    left: 8px;
  }

  .field-clock {
    --field-clock-height: 38px;
  }

  .field-clock-readout {
    min-width: 96px;
  }

  .toolbar-actions,
  .player-form {
    display: grid;
    width: 100%;
  }

  .player-form {
    grid-template-columns: minmax(0, 1fr) minmax(82px, 112px);
    gap: 8px;
  }

  .player-form .field-group {
    min-width: 0;
  }

  .player-form .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .formation-form {
    grid-template-columns: 48px minmax(0, 1fr) 44px;
    gap: 8px;
    width: 100%;
  }

  .formation-form .field-group {
    min-width: 0;
  }

  .formation-apply {
    width: 44px;
    min-height: 38px;
    padding: 0;
  }

  .formation-apply .icon {
    display: block;
    width: 20px;
    height: 20px;
  }

  .formation-apply span {
    display: none;
  }

  .formation-form .form-error {
    grid-column: 1 / -1;
  }

  .bench-head {
    align-items: flex-start;
    flex-direction: row;
  }

  .bench-actions,
  .event-actions {
    display: inline-flex;
    width: auto;
  }

  .bench-action,
  .event-action {
    width: auto;
    min-height: 44px;
    padding: 0 12px;
  }

  .bench-action .icon,
  .event-action .icon {
    width: 21px;
    height: 21px;
  }

  .bench-action span,
  .event-action span {
    display: inline;
  }

  .slot-row {
    grid-template-columns: 1fr;
  }

  .slot-controls {
    grid-template-columns: 1fr;
  }

  .slot-current-next {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px;
  }

  .roster-table-wrap {
    overflow-x: visible;
  }

  .roster-table-wrap th:nth-child(2),
  .roster-table-wrap td:nth-child(2),
  .roster-table-wrap th:nth-child(4),
  .roster-table-wrap td:nth-child(4),
  .roster-table-wrap th:nth-child(5),
  .roster-table-wrap td:nth-child(5) {
    display: none;
  }

  .player-name-cell {
    min-width: 0;
  }

  .pitch {
    width: 100%;
  }

  .field-slot-shell {
    --slot-box-height: 58px;
  }

  .slot-name {
    display: none;
  }
}
