:root {
  --page: #eee8dc;
  --surface: #fffdf7;
  --surface-strong: #f8f3e9;
  --line: #d7cdbd;
  --ink: #20251f;
  --muted: #6a655e;
  --home-kit: linear-gradient(90deg, #20251f 0 50%, #f5dc75 50%);
  --home-kit-primary: #20251f;
  --away-kit: #d83f4f;
  --away-kit-primary: #d83f4f;
  --away-ink: #211d15;
  --pitch-a: #246e42;
  --pitch-b: #2d8050;
  --pitch-line: rgba(255, 255, 255, 0.78);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  height: 100vh;
  overflow: hidden;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(229, 208, 162, 0.35), rgba(232, 237, 222, 0.18)),
    var(--page);
  user-select: none;
  -webkit-user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  height: 100vh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  background: rgba(255, 253, 247, 0.94);
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 230px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 28%, rgba(255, 255, 255, 0.85) 29% 33%, transparent 34%),
    conic-gradient(from 18deg, #20251f 0 10%, transparent 10% 20%, #20251f 20% 30%, transparent 30% 40%, #20251f 40% 50%, transparent 50% 60%, #20251f 60% 70%, transparent 70% 80%, #20251f 80% 90%, transparent 90% 100%),
    #f4f0e6;
  border: 2px solid #20251f;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.control {
  display: grid;
  gap: 5px;
}

.control > span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

select,
input {
  min-height: 36px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}

select:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgba(216, 63, 79, 0.25);
  outline-offset: 2px;
}

select {
  padding: 0 34px 0 10px;
}

.segmented {
  display: flex;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mode-button {
  flex: 1;
  text-align: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
  border-right: 1px solid var(--line);
  cursor: pointer;
}

.mode-button:last-child {
  border-right: 0;
}

.mode-button[aria-pressed="true"] {
  color: #fffdf7;
  background: #263028;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ghost-button {
  min-height: 36px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.ghost-button.icon-button {
  min-width: 36px;
  width: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.ghost-button.icon-button svg {
  display: block;
}

.welcome-banner {
  text-align: center;
  font-size: clamp(1rem, 1.4vw, 1.25rem);
  font-weight: 600;
  color: var(--ink);
  padding: 6px 12px;
  margin: 4px 0 8px;
  min-height: 1.2em;
}

.welcome-banner:empty {
  display: none;
}

.app-footer {
  text-align: center;
  padding: 12px 16px;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--surface);
  overflow: hidden;
}

.login-overlay::before {
  content: "";
  position: absolute;
  width: min(75vmin, 620px);
  height: min(75vmin, 620px);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background:
    radial-gradient(circle at 50% 50%, transparent 0 28%, rgba(32, 37, 31, 0.9) 29% 33%, transparent 34%),
    conic-gradient(from 18deg, #20251f 0 10%, transparent 10% 20%, #20251f 20% 30%, transparent 30% 40%, #20251f 40% 50%, transparent 50% 60%, #20251f 60% 70%, transparent 70% 80%, #20251f 80% 90%, transparent 90% 100%),
    #f4f0e6;
  border: 6px solid #20251f;
  border-radius: 50%;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.login-title {
  position: absolute;
  top: clamp(24px, 6vh, 56px);
  left: 0;
  right: 0;
  z-index: 2;
  margin: 0;
  padding: 0 16px;
  text-align: center;
  font-size: clamp(1.4rem, 3.5vw, 2.2rem);
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.5px;
}

.login-card {
  position: relative;
  z-index: 2;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(2px);
  padding: 32px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: auto;
}

.screenshot-button {
  color: #fffdf7;
  background: #263028;
  border-color: #263028;
}

.ghost-button:hover,
.mode-button:hover,
.swatch:hover,
.pen-swatch:hover {
  filter: brightness(0.97);
}

.ghost-button[aria-pressed="true"] {
  color: #fffdf7;
  background: #263028;
  border-color: #263028;
}

.pen-control {
  min-width: 178px;
}

.pen-palette {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pen-swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--pen-swatch);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.pen-swatch.is-active {
  box-shadow: 0 0 0 3px rgba(32, 37, 31, 0.18), 0 0 0 1px var(--line);
}

.custom-pen-color {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.custom-pen-color input {
  width: 34px;
  height: 34px;
  min-height: 0;
  padding: 0;
  border: 0;
  cursor: pointer;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.board-panel,
.team-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.82);
}

.board-panel {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  overflow: hidden;
  border-width: 0 0 1px;
  border-radius: 0;
}

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

.legend,
.status-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  display: inline-block;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.home-dot {
  background: var(--home-kit);
}

.away-dot {
  background: var(--away-kit);
}

.legend-line {
  width: 24px;
  height: 2px;
  display: inline-block;
  background: #f6df81;
}

.legend-ball {
  width: 24px;
  height: 2px;
  display: inline-block;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgba(32, 37, 31, 0.24);
}

.status-strip span {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-strong);
}

.pitch-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 8px;
  container-type: size;
}

.pitch {
  position: relative;
  aspect-ratio: 2 / 1;
  width: min(100cqw, 200cqh);
  height: auto;
  max-width: 100%;
  max-height: 100%;
  min-width: 280px;
  overflow: hidden;
  border: 3px solid var(--pitch-line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 50%, transparent 50%) 0 0 / 18.18% 100%,
    linear-gradient(90deg, var(--pitch-a), var(--pitch-b));
  box-shadow: inset 0 0 0 1px rgba(24, 61, 35, 0.45), 0 18px 44px rgba(60, 48, 28, 0.16);
  touch-action: none;
}

.app-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--page);
}

.app-shell:fullscreen .workspace {
  min-height: 0;
}

.app-shell:fullscreen .board-panel {
  min-height: 0;
}

.app-shell:fullscreen .pitch-frame {
  overflow: hidden;
}

.app-shell:fullscreen .pitch {
  width: min(100cqw, 200cqh);
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.app-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--page);
}

.app-shell:-webkit-full-screen .workspace {
  min-height: 0;
}

.app-shell:-webkit-full-screen .board-panel {
  min-height: 0;
}

.app-shell:-webkit-full-screen .pitch-frame {
  overflow: hidden;
}

.app-shell:-webkit-full-screen .pitch {
  width: min(100cqw, 200cqh);
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.pitch::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.08));
  pointer-events: none;
}

.pitch-mark {
  position: absolute;
  border-color: var(--pitch-line);
  pointer-events: none;
}

.halfway {
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--pitch-line);
}

.center-circle {
  left: 50%;
  top: 50%;
  width: 17.5%;
  height: 27%;
  border: 2px solid var(--pitch-line);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.center-spot,
.penalty-spot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pitch-line);
  transform: translate(-50%, -50%);
}

.center-spot {
  left: 50%;
  top: 50%;
}

.penalty-box {
  top: 21%;
  width: 15.7%;
  height: 58%;
  border: 2px solid var(--pitch-line);
}

.penalty-box.left {
  left: -2px;
}

.penalty-box.right {
  right: -2px;
}

.six-yard {
  top: 36%;
  width: 5.3%;
  height: 28%;
  border: 2px solid var(--pitch-line);
}

.six-yard.left {
  left: -2px;
}

.six-yard.right {
  right: -2px;
}

.penalty-spot.left {
  left: 10.5%;
  top: 50%;
}

.penalty-spot.right {
  left: 89.5%;
  top: 50%;
}

.goal {
  top: 43%;
  width: 2.4%;
  height: 14%;
  border: 2px solid var(--pitch-line);
  background: rgba(255, 255, 255, 0.07);
}

.goal.left {
  left: 0;
  border-left: 0;
}

.goal.right {
  right: 0;
  border-right: 0;
}

.counter-layer,
.ball-trail-layer,
.drawing-layer,
.ball-layer,
.player-layer {
  position: absolute;
  inset: 0;
}

.counter-layer {
  z-index: 2;
  overflow: visible;
  display: none;
}

.ball-trail-layer {
  z-index: 3;
  overflow: visible;
  pointer-events: none;
}

.drawing-layer {
  display: block;
  width: 100%;
  height: 100%;
  z-index: 4;
  overflow: visible;
  pointer-events: none;
}

.pitch.is-drawing .drawing-layer {
  z-index: 7;
  cursor: crosshair;
  pointer-events: all;
}

.drawing-stroke {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.counter-line {
  stroke: #f5dc75;
  stroke-width: 0.34;
  stroke-linecap: round;
  stroke-dasharray: 1.2 1.1;
  opacity: 0.76;
}

.pressure-ring {
  fill: rgba(245, 220, 117, 0.16);
  stroke: #f5dc75;
  stroke-width: 0.4;
}

.ball-layer {
  z-index: 6;
  pointer-events: none;
}

.ball {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(22px, 2.4vw, 32px);
  aspect-ratio: 1;
  border: 2px solid rgba(32, 37, 31, 0.86);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #20251f 0 12%, transparent 13%),
    conic-gradient(from 18deg, #20251f 0 10%, transparent 10% 20%, #20251f 20% 30%, transparent 30% 40%, #20251f 40% 50%, transparent 50% 60%, #20251f 60% 70%, transparent 70% 80%, #20251f 80% 90%, transparent 90% 100%),
    #fffdf7;
  box-shadow: 0 8px 18px rgba(13, 38, 21, 0.3);
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  transition: left 700ms cubic-bezier(0.19, 1, 0.22, 1), top 700ms cubic-bezier(0.19, 1, 0.22, 1), box-shadow 160ms ease, transform 160ms ease;
}

.ball.is-selected {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.86), 0 0 0 8px rgba(32, 37, 31, 0.2), 0 10px 22px rgba(13, 38, 21, 0.32);
}

.ball.is-attached {
  border-color: #f5dc75;
}

.ball.is-moving {
  transform: translate(-50%, -50%) scale(1.08);
}

.ball-target {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(18px, 2vw, 26px);
  aspect-ratio: 1;
  border: 2px solid rgba(255, 253, 247, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(32, 37, 31, 0.18);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 140ms ease, transform 140ms ease;
}

.ball-target.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.04);
}

.ball-planned-line {
  stroke: #fffdf7;
  stroke-width: 0.45;
  stroke-linecap: round;
  stroke-dasharray: 1 1;
  opacity: 0.94;
}

.ball-completed-line {
  stroke: #20251f;
  stroke-width: 0.48;
  stroke-linecap: round;
  opacity: 0.82;
}

.player-layer {
  z-index: 5;
}

.player {
  --player-color: #fff;
  position: absolute;
  width: clamp(34px, 4.4vw, 52px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--player-color);
  border: 2px solid rgba(255, 255, 255, 0.94);
  border-radius: 50%;
  box-shadow: 0 8px 18px rgba(13, 38, 21, 0.28);
  transform: translate(-50%, -50%);
  user-select: none;
}

.player.home {
  cursor: grab;
  transition: box-shadow 160ms ease, transform 160ms ease, background-color 160ms ease;
}

.player.away {
  color: var(--away-ink);
  pointer-events: none;
  transition: left 430ms cubic-bezier(0.2, 0.78, 0.22, 1), top 430ms cubic-bezier(0.2, 0.78, 0.22, 1), transform 160ms ease;
}

.player.home.is-dragging {
  cursor: grabbing;
  transition: none;
  transform: translate(-50%, -50%) scale(1.05);
  box-shadow: 0 10px 28px rgba(18, 25, 20, 0.32);
}

.player.is-selected {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 10px 28px rgba(18, 25, 20, 0.3);
}

.player.has-ball {
  box-shadow: 0 0 0 4px rgba(245, 220, 117, 0.9), 0 10px 28px rgba(18, 25, 20, 0.3);
}

.player.is-selected.has-ball {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 0 8px rgba(245, 220, 117, 0.45), 0 10px 28px rgba(18, 25, 20, 0.3);
}

.player-number {
  font-weight: 800;
  font-size: clamp(0.82rem, 1.4vw, 1rem);
  line-height: 1;
}

.player-label {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  max-width: 112px;
  padding: 3px 7px;
  overflow: hidden;
  color: #fffdf7;
  background: rgba(23, 27, 24, 0.74);
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%) translateY(-2px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.player:hover .player-label,
.player.is-selected .player-label {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.team-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.panel-section {
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.section-title {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

#selectedSummary {
  max-width: 160px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.25;
  text-align: right;
}

.kit-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.segmented .side-button {
  flex: 1 1 50%;
  width: 50%;
}

.swatch {
  width: 28px;
  height: 28px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
}

.swatch.is-active {
  box-shadow: 0 0 0 3px rgba(32, 37, 31, 0.18), 0 0 0 1px var(--line);
}

.roster-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0;
}

.roster-heading {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) 92px;
  gap: 8px;
  padding: 10px 14px;
  color: var(--muted);
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.roster-list {
  min-height: 0;
  overflow: auto;
  padding: 8px;
}

.roster-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 88px;
  gap: 8px;
  align-items: center;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}

.roster-row + .roster-row {
  margin-top: 5px;
}

.roster-row:hover {
  background: rgba(248, 243, 233, 0.9);
}

.roster-row.is-selected {
  border-color: rgba(216, 63, 79, 0.36);
  background: #fff6f3;
}

.roster-row input,
.roster-row select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  border-radius: 7px;
}

.roster-row input[type="number"] {
  padding-right: 2px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  background: var(--surface);
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--surface-strong);
}

.metric span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.metric strong {
  font-size: 0.86rem;
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: flex-start;
  }

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

  .team-panel {
    grid-template-rows: auto auto auto;
  }

  .roster-list {
    max-height: 420px;
  }

  .pitch {
    width: min(100cqw, 200cqh);
    max-width: 100%;
  }
}

@media (max-width: 620px) {
  .workspace {
    padding: 10px;
  }

  .board-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .pitch-frame {
    padding: 0;
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .segmented,
  .action-buttons,
  .ghost-button,
  .control select {
    width: 100%;
  }

  .ghost-button.icon-button {
    width: 36px;
  }

  .action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .mode-button {
    flex: 1;
    padding: 0 8px;
  }

  .player {
    width: clamp(28px, 8.7vw, 40px);
  }

  .roster-heading,
  .roster-row {
    grid-template-columns: 48px minmax(0, 1fr) 80px;
  }

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

  .modal-content {
    padding: 18px;
  }
}

/* Settings Modal */
.modal {
  border: none;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  width: min(720px, calc(100vw - 32px));
  height: min(780px, calc(100vh - 40px));
  height: min(780px, calc(100dvh - 40px));
  max-width: 720px;
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow: hidden;
  background: var(--surface);
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  padding: 24px;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

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

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 16px;
}

.modal-content h3 {
  margin-top: 24px;
  margin-bottom: 12px;
  font-size: 1rem;
}

.settings-section {
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.settings-section h3 {
  margin-top: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.settings-group label {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--muted);
}

.side-setting {
  max-width: 260px;
  margin-top: 14px;
}

.settings-metrics {
  background: transparent;
}

.roster-settings {
  flex: 0 0 auto;
  max-height: 34vh;
  max-height: 34dvh;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.settings-player-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.settings-player-row input[type="number"] {
  width: 60px;
}

.settings-player-row input[type="text"] {
  flex: 1;
}

.settings-player-row select {
  width: 100px;
}

.modal-actions {
  position: sticky;
  bottom: -24px;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 2px;
  background: var(--surface);
}

@media (max-width: 620px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    padding: 18px;
  }

  .modal {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  .modal-actions {
    bottom: -18px;
  }
}
