:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-muted: #eef4ef;
  --ink: #17211d;
  --muted: #66736e;
  --line: #dce5df;
  --accent: #0f766e;
  --accent-strong: #0b5f5a;
  --accent-soft: #d9f0eb;
  --hit: #116149;
  --out: #a33a2f;
  --other: #7a5b11;
  --warning: #b45309;
  --shadow: 0 14px 34px rgba(22, 39, 34, 0.11);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, 0.08), transparent 280px),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 12px;
  background: rgba(247, 248, 245, 0.92);
  border-bottom: 1px solid rgba(220, 229, 223, 0.85);
  backdrop-filter: blur(16px);
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  background: url("assets/icon.svg") center / contain no-repeat;
}

.topbar h1,
.loading-panel h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.15;
}

.topbar p,
.loading-panel p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 10px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  background: rgba(247, 248, 245, 0.9);
  border-bottom: 1px solid rgba(220, 229, 223, 0.75);
  backdrop-filter: blur(14px);
}

.tab {
  min-height: 38px;
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.22);
}

.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px 16px 88px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 84px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 22px rgba(22, 39, 34, 0.06);
}

.metric b {
  display: block;
  font-size: 1.55rem;
  line-height: 1.15;
}

.metric span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel + .panel,
.stack > .panel + .panel {
  margin-top: 14px;
}

.panel-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 1rem;
}

.panel-header > div {
  min-width: 0;
}

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

.panel-body {
  padding: 16px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 14px;
}

.draft-board {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 14px;
  align-items: start;
}

.draft-board.teams-only {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

.draft-column {
  min-height: 260px;
}

.draft-column.drag-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12), var(--shadow);
}

.draft-player {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: grab;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.game-draft-player {
  padding: 8px 10px;
}

.game-draft-player[role="button"] {
  cursor: pointer;
}

.draft-player.drop-before::before,
.draft-player.drop-after::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  z-index: 2;
  height: 3px;
  background: var(--accent);
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.draft-player.drop-before::before {
  top: -7px;
}

.draft-player.drop-after::after {
  bottom: -7px;
}

.draft-column.drop-empty .empty {
  position: relative;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.draft-column.drop-empty .empty::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  height: 3px;
  background: var(--accent);
  border-radius: 999px;
}

.draft-player.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.draft-player.dragging {
  opacity: 0.34;
  cursor: grabbing;
}

.draft-drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.98;
  box-shadow: 0 18px 42px rgba(22, 39, 34, 0.24);
  transform: scale(1.03) rotate(-0.8deg);
  transform-origin: center;
}

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

.draft-card-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.draft-card-main.assigned {
  grid-template-columns: 30px minmax(0, 1fr);
}

.draft-player-copy {
  min-width: 0;
}

.game-draft-player .draft-player-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  align-items: center;
}

.game-draft-player .draft-player-name {
  min-height: 22px;
}

.game-draft-player .result-pills {
  min-height: 18px;
}

.draft-player-name {
  display: inline-flex;
  max-width: 100%;
  min-height: 26px;
  gap: 7px;
  align-items: center;
  padding: 0;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  text-align: left;
}

.draft-player-name span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batting-order {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
}

.draft-role-field {
  display: grid;
  width: 72px;
}

.draft-role-field .select {
  min-height: 38px;
  padding: 6px 8px;
}

.draft-actions {
  flex-wrap: nowrap;
  align-items: end;
  gap: 8px;
}

.draft-player.assigned .draft-actions {
  justify-content: flex-start;
}

.paste-draft-player.assigned .draft-card-main.assigned {
  grid-template-columns: 30px minmax(0, 1fr);
}

.paste-draft-player:not(.assigned) .draft-card-main {
  grid-template-columns: minmax(0, 1fr) auto;
}

.paste-draft-player:not(.assigned) .draft-actions {
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  justify-content: flex-end;
}

.game-draft-player .draft-card-main.assigned {
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: start;
}

.game-board .draft-player.assigned .draft-actions {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
  align-items: center;
  justify-content: flex-end;
  padding-left: 0;
}

.row-actions {
  justify-content: flex-end;
}

.remove-match-button {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  font-size: 0.78rem;
}

.button.mobile-team-switch {
  display: none;
}

.expand-button.expanded {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.draft-stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(74px, 0.75fr) repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.draft-stat-label {
  align-self: center;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.draft-stats span {
  min-width: 0;
  text-align: center;
}

.draft-stats b,
.draft-stats small {
  display: block;
}

.draft-stats b {
  font-size: 0.82rem;
}

.draft-stats small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
}

.result-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.result-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 0.68rem;
  font-weight: 900;
}

.result-pill.hit {
  color: var(--hit);
  background: #e2f3eb;
}

.result-pill.out {
  color: var(--out);
  background: #fae7e2;
}

.result-pill.other {
  color: var(--other);
  background: #f8efcf;
}

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

.match-check {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
}

.compact-textarea {
  min-height: 150px;
}

.three-column {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(280px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.game-split-header {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 220px) auto auto;
  align-items: end;
}

.game-split-header > * {
  min-width: 0;
}

.game-split-header > div:first-child {
  align-self: center;
}

.game-split-header .button {
  white-space: nowrap;
}

.game-date-field {
  min-width: 0;
  max-width: 100%;
}

.game-date-field .input {
  min-width: 0;
  max-width: 100%;
  -webkit-appearance: none;
  appearance: none;
}

.remove-drop-zone {
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  width: 54px;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms ease, background-color 120ms ease;
}

.remove-drop-zone span {
  display: inline-grid;
  min-width: 82px;
  min-height: 36px;
  place-items: center;
  color: #ffffff;
  background: var(--out);
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 900;
  transform: rotate(-90deg);
  box-shadow: 0 10px 24px rgba(163, 58, 47, 0.2);
}

.remove-drop-left {
  left: 0;
}

.remove-drop-right {
  right: 0;
}

body.dragging-draft-player .remove-drop-zone {
  pointer-events: auto;
  opacity: 0.82;
  background: rgba(163, 58, 47, 0.08);
}

body.dragging-draft-player .remove-drop-zone.drag-over {
  opacity: 1;
  background: rgba(163, 58, 47, 0.18);
}

.finish-button {
  color: var(--accent-strong);
  background: #eef8f2;
  border-color: rgba(15, 118, 110, 0.18);
}

.score-drawer {
  box-shadow: 0 10px 24px rgba(22, 39, 34, 0.08);
}

.compact-score-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.team-editor,
.score-entry {
  min-width: 0;
}

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

.roster-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px 112px auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.roster-edit-row.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.roster-player {
  min-width: 0;
  padding: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

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

.roster-player span {
  font-weight: 850;
}

.roster-player small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.mini-field {
  display: grid;
  gap: 4px;
}

.mini-field span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.mini-field .input,
.mini-field .select {
  min-height: 36px;
  padding: 7px 8px;
}

.compact-field {
  min-width: 220px;
}

.stats-controls {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 150px 110px 110px 140px;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.single-column-controls {
  grid-template-columns: minmax(220px, 1fr) 150px 110px 110px 140px;
}

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

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

.stat-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-row-button {
  width: 100%;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.stat-row-button:hover,
.stat-row-button:focus-visible {
  border-color: var(--accent);
  outline: none;
  box-shadow: inset 3px 0 0 var(--accent);
}

.stat-player {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 850;
}

.stat-values {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.stat-values span {
  min-width: 0;
  text-align: right;
}

.stat-values b,
.stat-values small {
  display: block;
}

.stat-values b {
  font-size: 0.88rem;
}

.stat-values small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.stat-values .sub-stat {
  color: var(--accent-strong);
  font-size: 0.62rem;
}

.stat-list.stat-grid {
  min-width: 620px;
  gap: 0;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-list.stat-grid .stat-header,
.stat-list.stat-grid .stat-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.45fr) repeat(5, minmax(76px, 0.72fr));
  gap: 8px;
  align-items: center;
}

.stat-list.stat-grid .stat-header {
  padding: 9px 12px;
  color: var(--muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
}

.stat-list.stat-grid .stat-cell {
  text-align: right;
}

.stat-sort-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.stat-sort-button:not(:first-child) {
  justify-content: flex-end;
  text-align: right;
}

.stat-sort-button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-sort-button.active {
  color: var(--accent-strong);
}

.stat-sort-button.active.desc::after,
.stat-sort-button.active.asc::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 5px;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
}

.stat-sort-button.active.desc::after {
  border-top: 6px solid currentColor;
}

.stat-sort-button.active.asc::after {
  border-bottom: 6px solid currentColor;
}

.stat-list.stat-grid .stat-row {
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.stat-list.stat-grid .stat-row:last-child {
  border-bottom: 0;
}

.stat-cell {
  font-size: 0.88rem;
  font-weight: 800;
}

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

.field label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
}

.textarea {
  min-height: 270px;
  resize: vertical;
  line-height: 1.45;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  color: var(--ink);
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-weight: 800;
  cursor: pointer;
}

.button.primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.button.danger {
  color: var(--out);
  background: #fff2ef;
  border-color: #f0c6be;
}

.button.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.button.small-button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

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

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

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.row.interactive {
  cursor: pointer;
}

.row.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.row-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
  font-weight: 850;
}

.row-title span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-muted);
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.hit {
  color: var(--hit);
  background: #e2f3eb;
}

.badge.out {
  color: var(--out);
  background: #fae7e2;
}

.badge.other {
  color: var(--other);
  background: #f8efcf;
}

.badge.warn {
  color: var(--warning);
  background: #fff3df;
}

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

.score-button {
  min-height: 52px;
  padding: 0 8px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.98rem;
  font-weight: 900;
}

.score-button.hit {
  color: var(--hit);
  background: #eef8f2;
}

.score-button.out {
  color: var(--out);
  background: #fff2ef;
}

.score-button.other {
  color: var(--other);
  background: #fff8df;
}

.history-grid {
  display: grid;
  gap: 12px;
}

.history-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.history-card.collapsed {
  gap: 0;
}

.history-card-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.history-toggle {
  flex: 0 0 auto;
}

.history-toggle.expanded {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.history-card h3,
.history-card h4 {
  margin: 0;
}

.history-card h3 {
  font-size: 0.98rem;
}

.history-card h4 {
  font-size: 0.82rem;
}

.history-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-teams {
  display: flex;
  gap: 8px;
}

.history-teams {
  align-items: flex-start;
}

.history-team {
  flex: 1 1 0;
  min-width: 0;
}

.history-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.history-player {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px;
  background: var(--surface-muted);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 700;
}

.history-player-info {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.history-player-name {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.history-player-name > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-player-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(42px, 1fr));
  gap: 8px;
  min-width: 210px;
  text-align: right;
}

.history-player-stats span {
  min-width: 0;
}

.history-player-stats b,
.history-player-stats small {
  display: block;
}

.history-player-stats b {
  font-size: 0.82rem;
}

.history-player-stats small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 900;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  background: rgba(23, 33, 29, 0.28);
  backdrop-filter: blur(3px);
}

.profile-modal {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 60px rgba(22, 39, 34, 0.26);
}

.profile-modal-header,
.profile-modal-footer {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.profile-modal-header h2 {
  margin: 0;
  font-size: 1rem;
}

.profile-modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.profile-modal-body {
  display: grid;
  gap: 14px;
  padding: 16px;
  overflow-y: auto;
}

.profile-modal-footer {
  align-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.profile-section {
  display: grid;
  gap: 8px;
}

.profile-section-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 900;
}

.muted-head {
  color: var(--muted);
}

.profile-section-head small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

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

.profile-alias-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.roster-add-results {
  display: grid;
  gap: 8px;
}

.roster-add-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px 58px auto;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px 12px;
  color: var(--ink);
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
}

.roster-add-result b,
.roster-add-result small {
  display: block;
}

.roster-add-result small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.roster-add-stat {
  text-align: center;
}

.roster-add-status {
  justify-self: end;
  min-width: 72px;
  padding: 7px 10px;
  color: var(--accent-strong);
  text-align: center;
  background: var(--accent-soft);
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
}

.roster-add-result:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.profile-stats span {
  min-width: 0;
  text-align: center;
}

.profile-stats b,
.profile-stats small {
  display: block;
}

.profile-stats b {
  color: #7a8580;
  font-size: 0.9rem;
}

.profile-stats small {
  margin-top: 2px;
  color: #8a948f;
  font-size: 0.62rem;
  font-weight: 900;
}

.leaderboard {
  width: 100%;
  border-collapse: collapse;
}

.leaderboard th,
.leaderboard td {
  padding: 10px 8px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.leaderboard th:first-child,
.leaderboard td:first-child {
  text-align: left;
}

.stat-table th,
.stat-table td {
  white-space: nowrap;
}

.stat-table {
  table-layout: fixed;
}

.stat-table th:nth-child(1),
.stat-table td:nth-child(1) {
  width: 34%;
}

.stat-table th:nth-child(2),
.stat-table td:nth-child(2),
.stat-table th:nth-child(3),
.stat-table td:nth-child(3) {
  width: 15%;
}

.stat-table th:nth-child(4),
.stat-table td:nth-child(4),
.stat-table th:nth-child(5),
.stat-table td:nth-child(5),
.stat-table th:nth-child(6),
.stat-table td:nth-child(6) {
  width: 12%;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
  background: var(--surface-muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.loading-panel {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  text-align: center;
}

.loading-panel .brand-mark {
  width: 72px;
  height: 72px;
  margin-bottom: 12px;
}

.split-title {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.split-title h3 {
  margin: 0;
  font-size: 0.92rem;
}

.note {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.soft-panel {
  margin-top: 12px;
  box-shadow: none;
}

.spaced-toolbar {
  margin-top: 12px;
}

.code {
  overflow-x: auto;
  padding: 12px;
  background: #10201b;
  border-radius: var(--radius);
  color: #e7f6ef;
  font-size: 0.82rem;
}

@media (max-width: 860px) {
  .dashboard-grid,
  .two-column,
  .three-column,
  .draft-board,
  .draft-board.teams-only {
    grid-template-columns: 1fr;
  }

  .game-layout,
  .stats-controls {
    grid-template-columns: 1fr;
  }

  .game-split-header {
    grid-template-columns: 1fr;
  }

  .compact-score-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

  .history-player-stats {
    min-width: 190px;
  }

}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: auto 1fr;
  }

  .sync-pill {
    grid-column: 1 / -1;
    width: fit-content;
  }

  .main {
    padding-inline: 10px;
  }

  .panel-header,
  .panel-body {
    padding: 12px;
  }

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

  .panel-header .toolbar,
  .panel-header .button,
  .panel-header .field {
    width: 100%;
  }

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

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

  .draft-player {
    grid-template-columns: 1fr;
  }

  .button.mobile-team-switch {
    display: inline-flex;
    width: 44px;
    min-width: 44px;
    min-height: 34px;
    padding: 0;
    color: var(--accent-strong);
    background: var(--accent-soft);
    border-color: rgba(15, 118, 110, 0.2);
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1;
  }

  .draft-card-main.assigned {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .game-draft-player .draft-card-main.assigned {
    grid-template-columns: 30px minmax(0, 1fr) auto;
  }

  .paste-draft-player:not(.assigned) .draft-card-main {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .draft-actions {
    justify-content: flex-start;
  }

  .draft-role-field {
    width: 70px;
  }

  .history-player {
    grid-template-columns: 1fr;
  }

  .history-player-stats {
    width: 100%;
    min-width: 0;
    text-align: left;
  }

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

  .stat-values span {
    text-align: left;
  }

  .roster-edit-row {
    grid-template-columns: 1fr 72px 104px;
  }

  .roster-edit-row .button {
    grid-column: 1 / -1;
  }

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

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

  .modal-layer {
    align-items: end;
    padding: 10px;
  }

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

  .profile-modal-footer .button {
    flex: 1 1 0;
  }

  .roster-add-result {
    grid-template-columns: minmax(0, 1fr) repeat(2, 46px);
  }

  .roster-add-status {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .profile-stats {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
  }

  .compact-field {
    min-width: 100%;
  }

  .stat-table th,
  .stat-table td {
    padding: 8px 3px;
    font-size: 0.72rem;
  }

  .stat-table th:first-child,
  .stat-table td:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
