@font-face {
  font-family: "Manrope";
  src: url("./assets/fonts/Manrope-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("./assets/fonts/Manrope-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("./assets/fonts/Manrope-Semibold.ttf") format("truetype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Manrope";
  src: url("./assets/fonts/Manrope-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Clash Display";
  src: url("./assets/fonts/ClashDisplay-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Clash Display";
  src: url("./assets/fonts/ClashDisplay-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg: #0b0d0d;
  --surface: #111414;
  --surface-2: #171a1a;
  --glass: rgba(16, 19, 19, 0.82);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --white: #ffffff;
  --muted: #8c9290;
  --muted-2: #666c6a;
  --emerald: #244a3d;
  --accent: #d66a2f;
  --accent-hover: #e47a3d;
  --accent-soft: rgba(214, 106, 47, 0.14);
  --display: "Clash Display", "Nimbus Sans Narrow", Arial, sans-serif;
  --ui: "Manrope", "Nimbus Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--white);
  font-family: var(--ui);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

body { min-height: 100vh; }
button, select, input { font: inherit; }
button, select { cursor: pointer; }

.topbar {
  height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(11, 13, 13, 0.92);
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 10;
}

.brand {
  color: var(--white);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 40px;
  height: 40px;
  display: block;
  flex: 0 0 auto;
  object-fit: cover;
}

.brand-name,
.catalog-count,
.eyebrow,
.roster-heading,
.download-button {
  font-family: var(--ui);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.brand-name {
  font-size: 15px;
  letter-spacing: -0.01em;
}
.catalog-count { color: var(--muted); font-size: 12px; }

.workspace {
  min-height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 376px minmax(0, 1fr);
}

.editor-panel {
  padding: 32px 24px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  overflow-y: auto;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 32px;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  margin: 0 0 8px;
}

h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  line-height: 0.96;
  letter-spacing: -0.025em;
}

.icon-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--white);
}

.icon-button:hover { border-color: var(--line-strong); }
.icon-button svg, .download-button svg, .share-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.editor-instruction {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  color: #d9dddb;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
}

.editor-instruction span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--line);
}

.formation-control { grid-column: 1 / -1; }

label > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

select, .player-row input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-2);
  color: var(--white);
  outline: none;
}

select { padding: 0 40px 0 16px; }
select:focus, .player-row input:focus { border-color: var(--white); }

.roster-heading {
  display: flex;
  justify-content: space-between;
  padding: 24px 0 8px;
  color: var(--muted);
  font-size: 10px;
}

.number-visibility-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.number-visibility-toggle > span {
  display: inline;
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1;
}

.number-visibility-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  display: grid;
  place-items: center;
  appearance: none;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface-2);
}

.number-visibility-toggle input::after {
  content: "";
  width: 7px;
  height: 4px;
  border-left: 2px solid var(--white);
  border-bottom: 2px solid var(--white);
  transform: translateY(-1px) rotate(-45deg) scale(0);
}

.number-visibility-toggle input:checked {
  border-color: var(--accent);
  background: var(--accent);
}

.number-visibility-toggle input:checked::after {
  border-color: #0b0d0d;
  transform: translateY(-1px) rotate(-45deg) scale(1);
}

.number-visibility-toggle input:focus-visible {
  outline: 2px solid var(--white);
  outline-offset: 3px;
}

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

.player-row {
  position: relative;
  display: grid;
  grid-template-columns: 24px 56px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255,255,255,0.025);
}

.player-suggestions {
  position: absolute;
  z-index: 30;
  top: calc(100% - 4px);
  right: 8px;
  left: 96px;
  max-height: 292px;
  overflow-y: auto;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  background: #101313;
  box-shadow: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.26) transparent;
}

.player-suggestions[hidden] { display: none; }

.player-suggestion {
  width: 100%;
  min-height: 56px;
  padding: 9px 12px 9px 13px;
  border: 0;
  border-top: 1px solid rgba(255,255,255,0.075);
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.player-suggestion:hover,
.player-suggestion.active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.player-suggestions-context {
  min-height: 34px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.075em;
  line-height: 1;
  text-transform: uppercase;
}

.player-suggestions-context span:last-child {
  color: #c97749;
  text-align: right;
}

.player-suggestion-identity {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.player-suggestion-identity strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-suggestion-identity small {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-suggestion-details {
  flex: 0 0 auto;
  color: #b9bfbd;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.player-suggestion-custom {
  margin-top: 0;
  border-top-color: rgba(214,106,47,0.32);
  background: rgba(214,106,47,0.055);
}

.player-suggestion-custom .player-suggestion-details { color: #c97749; }

.player-row.selected {
  border-color: rgba(255,255,255,0.48);
  background: rgba(255,255,255,0.055);
}

.player-index {
  color: var(--muted-2);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.player-row input {
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
}

.player-row .number-input { padding: 0; text-align: center; }

.stage-panel {
  min-width: 0;
  padding: 24px 32px 40px;
  background: var(--bg);
}

.stage-toolbar {
  max-width: 696px;
  min-height: 48px;
  margin: 0 auto 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.stage-toolbar p {
  margin: 0;
  color: #d9dddb;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}
.stage-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.download-button,
.share-button {
  height: 48px;
  padding: 0 16px;
  border-radius: 16px;
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 11px;
  white-space: nowrap;
}

.download-button {
  border: 0;
  background: var(--accent);
  color: #0b0d0d;
}

.share-button {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.download-button:hover:not(:disabled) { background: var(--accent-hover); }
.share-button:hover:not(:disabled) { border-color: rgba(255,255,255,0.36); background: #1d2121; }
.download-button:disabled { opacity: 0.4; cursor: wait; }
.share-button:disabled { opacity: 0.55; cursor: wait; }

.status-message:empty { display: none; }
.status-message {
  width: min(100%, 696px);
  margin: 0 auto 16px;
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 12px;
  color: #d9dddb;
  background: #171a1a;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.status-message-error { border-color: rgba(240,76,56,0.42); }

.canvas-shell {
  position: relative;
  width: min(100%, 696px);
  margin: 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 24px;
  overflow: hidden;
  background: var(--emerald);
  line-height: 0;
  box-shadow: 0 24px 72px rgba(0,0,0,0.36);
}

.canvas-field-editor {
  position: absolute;
  z-index: 3;
  width: min(360px, calc(100% - 16px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(255,255,255,0.24);
  border-radius: 10px;
  background: #0d1010;
  line-height: normal;
}

.canvas-field-editor[hidden] { display: none; }

.canvas-player-suggestions {
  grid-column: 1 / -1;
  max-height: 244px;
  overflow-y: auto;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 6px;
  background: #101313;
  box-shadow: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.26) transparent;
}

.canvas-player-suggestions[hidden] { display: none; }

.canvas-field-editor[data-field="number"] {
  width: min(168px, calc(100% - 16px));
  grid-template-columns: 64px auto;
}

.canvas-field-editor input {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  outline: none;
  background: rgba(255,255,255,0.06);
  color: var(--white);
  font-family: var(--ui);
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
}

.canvas-field-editor[data-field="number"] input { text-align: center; }

.canvas-field-editor input:focus {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.canvas-field-editor button {
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #0b0d0d;
  font-family: var(--ui);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 5;
  touch-action: pan-y;
  cursor: grab;
}

canvas.dragging { cursor: grabbing; }

.site-disclaimer {
  padding: 24px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.site-disclaimer p {
  max-width: 960px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  text-align: center;
}

.site-contact {
  display: block;
  width: max-content;
  margin: 8px auto 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.site-contact:hover,
.site-contact:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 920px) {
  .workspace { grid-template-columns: 1fr; }
  .stage-panel { grid-row: 1; padding: 16px 16px 32px; }
  .editor-panel {
    grid-row: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 32px 24px;
  }
  .canvas-shell, .stage-toolbar { max-width: 600px; }
}

@media (max-width: 560px) {
  .topbar { height: 64px; padding: 0 16px; }
  .catalog-count { display: none; }
  .workspace { min-height: calc(100vh - 64px); }
  .stage-panel { padding: 8px 8px 24px; }
  .stage-toolbar {
    padding: 8px;
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .stage-toolbar p { font-size: 14px; }
  .stage-actions { width: 100%; display: grid; grid-template-columns: 1fr; }
  .stage-actions .download-button,
  .stage-actions .share-button { width: 100%; }
  .canvas-shell { border-radius: 16px; }
  .editor-panel { padding: 32px 16px; }
  h1 { font-size: 32px; }
  .control-grid { gap: 16px; }
  .site-disclaimer { padding: 24px 16px; }
}
