:root {
  color-scheme: light;
  --ink: #20242c;
  --muted: #69707d;
  --line: #d7dce3;
  --surface: #ffffff;
  --page: #f5f2ed;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --warm: #b45309;
  --danger: #b42318;
  --shadow: 0 16px 40px rgba(32, 36, 44, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 18px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.ghost {
  background: #eef4ff;
  color: var(--accent-strong);
  border: 1px solid #c7d7fe;
}

button.ghost:hover {
  background: #dbe8ff;
}

a {
  color: var(--accent-strong);
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr minmax(320px, 520px);
  gap: 28px;
  align-items: end;
  padding: 28px 0 22px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--warm);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 2.9rem, 3.4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.lookup-form label,
#player-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-top: 7px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 430px) 1fr;
  gap: 18px;
}

.lookup-results:empty {
  display: none;
}

.lookup-panel {
  margin-bottom: 18px;
  padding: 18px;
}

.lookup-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

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

.match-row {
  display: flex;
  min-height: 0;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 12px 14px;
  text-align: left;
}

.match-row:hover {
  border-color: #a8c3ff;
  background: #f2f6ff;
  color: var(--ink);
}

.match-row strong,
.match-row small {
  display: block;
}

.match-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.match-action {
  flex: 0 0 auto;
  color: var(--accent-strong);
  font-size: 0.84rem;
  font-weight: 800;
}

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

.editor-panel,
.list-panel {
  padding: 18px;
}

.form-head,
.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.full-field {
  margin-bottom: 14px;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.list-head input {
  max-width: 260px;
}

.archive-filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(150px, 190px) minmax(130px, 170px);
  gap: 10px;
  width: min(100%, 650px);
}

.archive-filters input,
.archive-filters select {
  max-width: none;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  outline: none;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.player-list {
  display: grid;
  gap: 14px;
}

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

.page-count {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.page-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.page-button {
  min-width: 38px;
  min-height: 36px;
  padding: 0 11px;
  font-size: 0.84rem;
  font-weight: 800;
}

.page-button.active {
  background: var(--accent);
  color: #fff;
}

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

.page-ellipsis {
  display: inline-grid;
  min-width: 24px;
  place-items: center;
  color: var(--muted);
  font-weight: 800;
}

.player-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: stretch;
  border: 1px solid #dbe5f4;
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.09), rgba(180, 83, 9, 0.04)),
    #ffffff;
  box-shadow: 0 10px 24px rgba(32, 36, 44, 0.07);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.player-card:hover {
  transform: translateY(-1px);
  border-color: #a8c3ff;
  box-shadow: 0 16px 34px rgba(32, 36, 44, 0.1);
}

.player-main {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 16px;
  min-width: 0;
}

.player-avatar {
  display: grid;
  width: 70px;
  height: 86px;
  place-items: center;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(135deg, #1d4ed8, #60a5fa);
  color: #ffffff;
  font-weight: 900;
  letter-spacing: 0;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #eef4ff;
}

.player-content {
  min-width: 0;
}

.player-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.player-card h3 {
  margin: 0;
  font-size: 1.12rem;
  line-height: 1.15;
}

.player-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.87rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
}

.pill {
  border: 1px solid #dce2e8;
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff;
}

.market-value {
  flex: 0 0 auto;
  border: 1px solid #bfd2ff;
  border-radius: 999px;
  background: #eef4ff;
  color: var(--accent-strong);
  padding: 6px 10px;
  font-size: 0.86rem;
  line-height: 1.1;
  text-align: right;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.detail-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid #e2e7ec;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  padding: 8px 9px;
}

.detail-item small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.detail-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 0.86rem;
  line-height: 1.2;
}

.reference-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--accent-strong);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

.reference-link:hover {
  text-decoration: underline;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

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

.card-actions .ghost {
  width: auto;
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 800;
}

.delete {
  width: 42px;
  background: #fff2f0;
  color: var(--danger);
  border: 1px solid #ffd0c9;
}

.delete:hover {
  background: #ffe3de;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100% - 40px));
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  border-radius: 8px;
  background: #20242c;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

@media (max-width: 860px) {
  .toolbar,
  .workspace {
    grid-template-columns: 1fr;
  }

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

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

  .list-head {
    align-items: stretch;
    flex-direction: column;
  }

  .archive-filters {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .page-controls {
    justify-content: flex-start;
  }

  .player-title-row {
    display: grid;
  }

  .market-value {
    justify-self: start;
    text-align: left;
  }
}
