/* =================================================================
   FootyTiers — universal brand
   Dark grey ground · white text · green + yellow accents · Teko + Inter

   Deliberately avoided (the "generated game" look):
   glows/gradients, translucent white borders, rounded boxes-in-boxes,
   pill badges with tracked caps, frosted sticky header, hover lift +
   shadow, rainbow tier fills, centred max-width column.
   Instead: flat ground, opaque hairline rules, square corners, words not
   chips, colour used as thin stripes, left-aligned full-width layout.
   ================================================================= */
:root {
  --bg:        #1b1c1e;
  --bg-2:      #151618;
  --card:      #26282b;
  --rule:      #34373b;
  --rule-2:    #45494e;

  --white:  #ffffff;
  --ink:    #e6e7e9;
  --muted:  #8f949a;
  --on-accent: #141517;

  --green:  #3ecf6e;
  --yellow: #f5c84c;
  --red:    #e5484d;
  --grey:   #6b7178;

  --display: "Teko", "Arial Narrow", sans-serif;
  --body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--body);
  font-size: 14px;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
button, input, select { font-family: var(--body); }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

/* ---------- Masthead ---------- */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 20px 32px 6px;
}
.title { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }

/* Two flat colour blocks — a nod to teletext headers */
.wordmark {
  display: inline-flex;
  align-self: center;
  font-family: var(--display);
  font-weight: 600;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--on-accent);
  text-decoration: none;
}
.wordmark b, .wordmark span { font-weight: 600; padding: 6px 8px 1px; }
.wordmark b { background: var(--green); }
.wordmark span { background: var(--yellow); }

.title h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 40px;
  line-height: 0.8;
  color: var(--white);
}

/* Board controls — pinned bottom-right, on a solid strip so they read over content */
.actions {
  position: fixed;
  right: 24px;
  bottom: 20px;
  z-index: 50;
  display: flex;
  background: var(--bg-2);
  border: 1px solid var(--rule-2);
  padding: 8px 4px 6px;
}
.actions button {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 400;
  line-height: 1;
  background: none;
  color: var(--ink);
  border: none;
  border-left: 1px solid var(--rule-2);
  padding: 4px 14px 0;
  cursor: pointer;
}
.actions button:first-child { border-left: none; }
.actions button:hover { color: var(--green); text-decoration: underline; text-underline-offset: 3px; }
#export-btn { color: var(--yellow); }
#reset-all-btn:hover { color: var(--red); }

/* ---------- Home / club index ---------- */
.home-main { padding: 28px 32px 60px; max-width: 760px; }
.home-heading {
  font-family: var(--display);
  font-weight: 500;
  font-size: 34px;
  line-height: 1;
  margin: 0 0 18px;
  color: var(--white);
}
.club-index { list-style: none; margin: 0; padding: 0; counter-reset: page 100; }
.club-index li { counter-increment: page; display: flex; align-items: baseline; gap: 14px; }
/* page numbers, teletext-index style */
.club-index li::before {
  content: counter(page);
  font-family: var(--display);
  font-size: 22px;
  color: var(--yellow);
  min-width: 36px;
}
.club-index a, .club-index .club-row {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  color: var(--white);
  text-decoration: none;
}
.club-index a:hover .club-name { color: var(--green); }
.club-index .leader { flex: 1; border-bottom: 2px dotted var(--rule-2); transform: translateY(-5px); }
.club-name { font-family: var(--display); font-size: 30px; line-height: 1; }
.club-meta { font-size: 13px; color: var(--muted); }
.club-index li.disabled { opacity: 0.45; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 0 32px;
  padding: 22px 32px 96px; /* room for the pinned controls */
}

/* ---------- Tier rows ---------- */
#tiers { border-top: 1px solid var(--rule); }
.tier {
  display: grid;
  grid-template-columns: 150px 1fr;
  border-bottom: 1px solid var(--rule);
  border-left: 6px solid var(--tier, var(--grey));
  min-height: 84px;
}
.tier-keep { min-height: 112px; }

.tier-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 10px 14px;
  border-right: 1px solid var(--rule);
}
.tier-label .lbl {
  font-family: var(--display);
  font-size: 27px;
  font-weight: 500;
  line-height: 0.9;
  color: var(--white);
}
.tier-label .sub { font-size: 12px; color: var(--yellow); margin-top: 5px; }

.tier-drop {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  align-content: flex-start;
}
.drag-over { background: rgba(62,207,110,0.07) !important; box-shadow: inset 0 0 0 1px var(--green); }

/* Keep — position columns */
.keep-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.keep-col { display: flex; flex-direction: column; border-left: 1px solid var(--rule); }
.keep-col:first-child { border-left: none; }
.keep-col-head {
  font-family: var(--display);
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  padding: 7px 8px 2px;
}
.keep-col-drop {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 4px 6px 8px;
  align-content: flex-start;
  flex: 1;
}

/* ---------- Undecided pool ---------- */
#pool-wrapper { margin-top: 28px; }
.pool-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding-bottom: 8px;
  margin-bottom: 10px;
  border-bottom: 2px solid var(--rule);
}
.pool-header h2, .panel h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 26px;
  line-height: 1;
  color: var(--white);
}
#pool-count { color: var(--muted); font-size: 13px; }
.pool { display: flex; flex-wrap: wrap; gap: 6px; min-height: 110px; }

/* ---------- Player card ---------- */
.player {
  position: relative;
  width: 92px;
  background: var(--card);
  border: 1px solid var(--rule-2);
  border-radius: 2px;
  cursor: grab;
  user-select: none;
  display: flex;
  flex-direction: column;
  padding: 5px 6px 6px;
}
.player:hover { border-color: var(--white); }
.player:active { cursor: grabbing; }
.player.dragging { opacity: 0.35; }

.player .meta {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--muted);
  min-height: 11px;
}
.player .reg { margin-left: auto; }
.player.reg-hg .reg    { color: var(--green); }
.player.reg-u21 .reg   { color: var(--yellow); }
.player.reg-unreg .reg { color: var(--red); }

.player .name {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 500;
  line-height: 0.92;
  color: var(--white);
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: normal;
  overflow-wrap: normal;
}
.player .val {
  font-family: var(--display);
  font-size: 18px;
  line-height: 1;
  color: var(--yellow);
  margin-top: 3px;
}
.player .status { font-size: 9.5px; font-weight: 600; font-style: italic; margin-top: 1px; }

/* Status = a 3px edge in its colour + the word on full cards */
.player.purchase { box-shadow: inset 3px 0 0 var(--green); }
.player.purchase .status { color: var(--green); }
.player.loanee   { box-shadow: inset 3px 0 0 var(--yellow); }
.player.loanee .status { color: var(--yellow); }
.player.eoc      { box-shadow: inset 3px 0 0 var(--ink); }
.player.eoc .status { color: var(--ink); }
/* no strike-through: January end-of-contract players still sell (at a discount) */
.player.eoc .val { color: var(--muted); }
.player.injured  { box-shadow: inset 3px 0 0 var(--red); }
.player.injured .status { color: var(--red); }
.player.locked {
  cursor: default;
  border-style: dashed;
  background: repeating-linear-gradient(135deg, var(--card) 0 6px, #2c2e32 6px 12px);
}
.player.locked:hover { border-color: var(--rule-2); }
.player.locked .status { color: var(--muted); }
/* Out on loan: hatched like a locked card, but movable */
.player.on-loan { background: repeating-linear-gradient(135deg, var(--card) 0 6px, #2c2e32 6px 12px); }
.player.on-loan .status { color: var(--muted); }

/* Compact (inside tiers): name + registration mark only */
.player.compact { width: 78px; padding: 4px 5px 5px; }
.player.compact .meta { position: absolute; top: 3px; right: 4px; min-height: 0; font-size: 8.5px; }
.player.compact .name { font-size: 16px; margin-top: 9px; }


/* ---------- Sidebar: one ruled column, no boxes ---------- */
#sidebar { border-left: 1px solid var(--rule); padding-left: 24px; }
.panel { padding: 14px 0 16px; border-bottom: 1px solid var(--rule); }
.panel:first-child { padding-top: 0; }
.panel h3 { font-size: 23px; margin-bottom: 8px; }

.grand-total {
  font-family: var(--display);
  font-size: 66px;
  font-weight: 500;
  line-height: 0.85;
  color: var(--yellow);
  white-space: nowrap;
  padding-top: 4px;
}

.mult-row, .sub-row, .reg-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
}
.swatch { width: 10px; height: 10px; }
.mult-row input {
  width: 56px;
  background: transparent;
  color: var(--white);
  border: none;
  border-bottom: 1px solid var(--rule-2);
  border-radius: 0;
  padding: 2px 2px;
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.mult-row input:focus { outline: none; border-bottom-color: var(--yellow); }

.sub-row .val, .purchase-row .val {
  font-family: var(--display);
  font-size: 21px;
  line-height: 1;
  color: var(--yellow);
}
.sub-row.negative .val { color: var(--red); }

.reg-row .count { font-weight: 600; font-variant-numeric: tabular-nums; }
.reg-row.breach, .reg-row.breach .count { color: var(--red); }

.injury-warning {
  margin-top: 8px;
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
}

/* Signings form — ledger-style inputs */
#purchase-form {
  display: grid;
  grid-template-columns: 1fr 52px 66px auto;
  gap: 8px;
  margin-bottom: 8px;
  align-items: end;
}
#purchase-form input, #purchase-reg {
  min-width: 0;
  background: transparent;
  color: var(--white);
  border: none;
  border-bottom: 1px solid var(--rule-2);
  border-radius: 0;
  padding: 4px 2px;
  font-size: 13px;
}
#purchase-reg { font-size: 12px; }
#purchase-reg option { background: var(--bg-2); color: var(--white); }
#purchase-form input:focus, #purchase-reg:focus { outline: none; border-bottom-color: var(--yellow); }
#purchase-form button {
  font-family: var(--display);
  font-size: 19px;
  line-height: 1;
  background: var(--green);
  color: var(--on-accent);
  border: none;
  border-radius: 0;
  padding: 5px 10px 1px;
  cursor: pointer;
}
#purchase-form button:hover { background: var(--white); }

.purchase-row {
  display: grid;
  grid-template-columns: 10px 1fr auto 18px;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.purchase-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.purchase-row .del {
  background: none; color: var(--muted); border: none;
  cursor: pointer; font-size: 15px; line-height: 1; padding: 0;
}
.purchase-row .del:hover { color: var(--red); }
.reg-note { font-size: 11px; font-weight: 600; margin-left: 6px; color: var(--muted); }
.reg-note.hg  { color: var(--green); }
.reg-note.u21 { color: var(--yellow); }

/* editable tier labels */
.lbl[contenteditable] { outline: none; }
.lbl[contenteditable]:hover { text-decoration: underline dotted var(--muted); text-underline-offset: 4px; }
.lbl[contenteditable]:focus { text-decoration: underline var(--yellow); cursor: text; }

/* ---------- PNG export sheet ---------- */
.export-sheet { color: var(--ink); font-family: var(--body); }
/* cloned on-screen header: the sheet supplies the outer padding */
.export-sheet .topbar, .export-sheet .tt-header { padding-left: 0; padding-right: 0; }
.export-sheet .topbar { margin-bottom: 18px; }
.export-sheet .pct-static { min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; color: var(--white); }
.export-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 32px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; padding: 16px; }
  #sidebar { border-left: none; padding-left: 0; margin-top: 28px; border-top: 2px solid var(--rule); padding-top: 14px; }
  .topbar { padding: 14px 16px 4px; }
  .actions { right: 12px; bottom: 12px; left: 12px; justify-content: center; }
  .tier { grid-template-columns: 104px 1fr; }
  .tier-label .lbl { font-size: 22px; }
  .keep-grid { overflow-x: auto; grid-template-columns: repeat(6, minmax(86px, 1fr)); }
}
@media (max-width: 480px) {
  .home-main { padding: 22px 16px 48px; }
  .title h1 { font-size: 32px; }
  #purchase-form {
    grid-template-columns: 1fr 50px auto;
    grid-template-areas: "name name name" "val reg btn";
  }
  #purchase-form #purchase-name  { grid-area: name; }
  #purchase-form #purchase-value { grid-area: val; }
  #purchase-form #purchase-reg   { grid-area: reg; width: 100%; }
  #purchase-form button          { grid-area: btn; }
}
