:root {
  --navy: #132257;
  --navy-2: #0d1840;
  --navy-3: #1c2e6e;
  --lightblue: #74AABB;
  --green: #5C8968;
  --spurple: #A072CB;
  --gold: #989756;
  --red: #d43a2c;
  --white: #FFFFFF;
  --ink: #e9edf7;
  --muted: #9aa6c2;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  background: radial-gradient(1200px 800px at 20% -10%, #1c2e6e 0%, var(--navy) 45%, var(--navy-2) 100%);
  color: var(--ink);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(13, 24, 64, 0.65);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.title { display: flex; align-items: baseline; gap: 14px; }
.crest {
  color: var(--gold);
  font-size: 26px;
  transform: translateY(2px);
}
.title h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--white);
}
.subtitle {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.actions button {
  background: var(--navy-3);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.15);
  padding: 9px 14px;
  margin-left: 8px;
  border-radius: 6px;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
}
.actions button:hover { background: var(--lightblue); color: var(--navy); }
.actions button:active { transform: translateY(1px); }
#export-btn { background: var(--gold); color: var(--navy); }
#export-btn:hover { background: #c2c178; }
#reset-all-btn { background: var(--red); color: var(--white); }
#reset-all-btn:hover { background: #ef5246; color: var(--white); }

.logo-wrap {
  margin-top: 4px;
  padding: 12px 10px 4px;
  display: flex;
  justify-content: center;
}
.logo-wrap img {
  max-width: 100%;
  height: auto;
  opacity: 0.95;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 22px;
  padding: 22px 28px 40px;
  max-width: 1700px;
  margin: 0 auto;
}

/* ---------- Tier rows ---------- */
#tiers { display: flex; flex-direction: column; gap: 10px; }

.tier {
  display: grid;
  grid-template-columns: 170px 1fr;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  overflow: hidden;
  min-height: 88px;
}

.tier-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  color: var(--navy);
  text-shadow: 0 1px 0 rgba(255,255,255,0.15);
}
.tier-label .lbl { font-size: 16px; line-height: 1.15; }
.tier-label .sub { font-size: 11px; opacity: 0.85; margin-top: 6px; letter-spacing: 0.14em; }

.tier-drop {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  padding: 4px 12px;
  align-content: flex-start;
  transition: background 0.15s;
}
.tier-drop.drag-over { background: rgba(116, 170, 187, 0.12); }

/* Keep tier — 6 position sub-columns */
.keep-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}
.keep-col {
  display: flex;
  flex-direction: column;
  border-left: 1px dashed rgba(255,255,255,0.10);
  padding: 0;
  min-height: 100%;
}
.keep-col:first-child { border-left: none; }
.keep-col-head {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: center;
  color: var(--lightblue);
  padding: 6px 4px 4px;
  border-bottom: 1px dashed rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.025);
}
.keep-col-drop {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 4px 6px;
  align-content: flex-start;
  justify-content: center;
  flex: 1;
  transition: background 0.15s;
}
.keep-col-drop.drag-over { background: rgba(116, 170, 187, 0.12); }
.tier-keep { min-height: 110px; }

/* ---------- Pool ---------- */
#pool-wrapper {
  margin-top: 18px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 10px 14px 14px;
}
.pool-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 2px 10px;
  border-bottom: 1px dashed rgba(255,255,255,0.1);
  margin-bottom: 10px;
}
.pool-header h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lightblue);
}
#pool-count { color: var(--muted); font-size: 12px; }
.pool {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 110px;
  transition: background 0.15s;
}
.pool.drag-over { background: rgba(116, 170, 187, 0.12); }

/* ---------- Player card ---------- */
.player {
  width: 86px;
  background: rgba(13, 24, 64, 0.6);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  display: flex;
  flex-direction: column;
  transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}
.player:hover {
  transform: translateY(-2px);
  border-color: var(--lightblue);
  box-shadow: 0 6px 14px rgba(0,0,0,0.35);
}
.player:active { cursor: grabbing; }
.player.dragging { opacity: 0.4; }
.player img {
  width: 100%;
  height: 90px;
  object-fit: contain;
  object-position: center;
  display: block;
  background: #1a2658;
  pointer-events: none;
}

/* Compact card — used inside tier rows to save vertical space */
.player.compact { width: 58px; }
.player.compact img { height: 58px; }
.player.compact .name { font-size: 10px; padding: 1px 2px; line-height: 1.1; }

/* editable bits */
.lbl[contenteditable], .val-num[contenteditable] {
  outline: none;
  border-radius: 3px;
  padding: 0 2px;
  transition: background 0.1s;
}
.lbl[contenteditable]:hover, .val-num[contenteditable]:hover {
  background: rgba(255,255,255,0.10);
}
.lbl[contenteditable]:focus, .val-num[contenteditable]:focus {
  background: rgba(255,255,255,0.18);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.35);
  cursor: text;
}
.val { cursor: default; }
.val-num { cursor: text; }
.player .name {
  font-size: 11px;
  text-align: center;
  padding: 4px 2px 2px;
  color: var(--white);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player .val {
  font-size: 10px;
  text-align: center;
  padding: 0 2px 4px;
  color: var(--gold);
  font-weight: 700;
}

/* ---------- Sidebar ---------- */
#sidebar { display: flex; flex-direction: column; gap: 14px; }
.panel {
  background: rgba(13, 24, 64, 0.55);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 14px 16px;
}
.panel h3 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lightblue);
}
.grand-total {
  font-size: clamp(20px, 4vw, 32px);
  font-weight: 800;
  color: var(--gold);
  letter-spacing: 0.01em;
  text-align: center;
  padding: 6px 0 2px;
  white-space: nowrap;
}

.mult-row, .sub-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}
.swatch {
  width: 12px; height: 12px; border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.2);
}
.mult-row input {
  width: 64px;
  background: rgba(255,255,255,0.06);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 4px 6px;
  text-align: right;
  font-size: 12px;
}
.mult-row input:focus { outline: 1px solid var(--lightblue); }
.sub-row .val { color: var(--gold); font-weight: 700; }
.sub-row.negative .val { color: var(--spurple); }

/* Incoming transfers form */
#purchase-form {
  display: grid;
  grid-template-columns: 1fr 70px 32px;
  gap: 6px;
  margin-bottom: 8px;
}
#purchase-form input {
  background: rgba(255,255,255,0.06);
  color: var(--white);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  padding: 5px 7px;
  font-size: 12px;
}
#purchase-form input:focus { outline: 1px solid var(--spurple); }
#purchase-form button {
  background: var(--spurple);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
}
#purchase-form button:hover { background: #b58cd9; }

.purchase-row {
  display: grid;
  grid-template-columns: 14px 1fr auto 20px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.purchase-row:first-child { border-top: none; }
.purchase-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purchase-row .val { color: var(--spurple); font-weight: 700; }
.purchase-row .del {
  background: transparent;
  color: var(--muted);
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.purchase-row .del:hover { color: var(--red); }

/* purchase card visual treatment */
.player.purchase {
  border-color: var(--spurple);
  box-shadow: 0 0 0 1px rgba(160, 114, 203, 0.35) inset;
  background: linear-gradient(180deg, rgba(160,114,203,0.18) 0%, rgba(13,24,64,0.6) 60%);
  position: relative;
}
.player.purchase::after {
  content: "IN";
  position: absolute;
  top: 3px;
  right: 3px;
  background: var(--spurple);
  color: var(--white);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 1px 4px;
  border-radius: 3px;
}
.player.purchase img {
  background: rgba(160,114,203,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Loanee card — gold outline + LOAN badge */
.player.loanee {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(152, 151, 86, 0.45) inset;
  position: relative;
}
.player.loanee::after {
  content: "LOAN";
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--gold);
  color: var(--navy);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 1px 4px;
  border-radius: 3px;
}
.player.loanee .val { color: var(--gold); }

/* End-of-contract card — light-blue outline + EOC badge */
.player.eoc {
  border-color: var(--lightblue);
  box-shadow: 0 0 0 1px rgba(116, 170, 187, 0.45) inset;
  position: relative;
}
.player.eoc::after {
  content: "EOC";
  position: absolute;
  top: 3px;
  left: 3px;
  background: var(--lightblue);
  color: var(--navy);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 1px 4px;
  border-radius: 3px;
}
.player.eoc .val { color: var(--lightblue); }

/* tier label colours via inline bg, but ensure contrast for red & spurple */
.tier-label[data-id="relsea"], .tier-label[data-id="buyer"] { color: var(--white); }
.tier-label[data-id="loan"] { color: var(--navy); }
