/* Owner Desk · Tier list (2026-11-02)
 *
 * The editor is light, like the desk; the downloadable PNG is dark, rendered
 * on the server. Three columns on a desk: pool, board, tier/image rail. On a
 * phone the board is the surface and the pool and rail are bottom sheets.
 */

.tier-room {
  --tier-ink: #12233b;
  --tier-muted: #64748b;
  --tier-line: #d8e1ec;
  --tier-panel: #ffffff;
  --tier-paper: #f4f7fb;
  --tier-gold: #b8892d;
  display: grid;
  gap: 14px;
  min-width: 0;
  color: var(--tier-ink);
}
.tier-room * { box-sizing: border-box; }
.tier-room-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.tier-room-head h1 {
  margin: 2px 0 4px;
  font: 900 clamp(30px, 3.4vw, 48px)/0.95 var(--font-display, "Barlow Condensed", sans-serif);
  letter-spacing: -0.02em;
}
.tier-room-head p { margin: 0; color: var(--tier-muted); font-size: 13px; max-width: 58ch; }
.tier-room-head .eyebrow { color: var(--tier-gold); font-size: 9px; font-weight: 900; letter-spacing: .18em; text-transform: uppercase; }
.tier-room-boards { display: flex; align-items: center; gap: 8px; }
.tier-room-boards select,
.tier-room-boards button {
  min-height: 40px;
  border: 1px solid var(--tier-line);
  border-radius: 10px;
  background: #fff;
  color: var(--tier-ink);
  font: 800 12px/1 var(--font-body, sans-serif);
  padding: 0 12px;
}
.tier-room-boards select { max-width: 280px; }
.tier-room-boards button { cursor: pointer; }
.tier-room-boards button:disabled { opacity: .45; cursor: not-allowed; }

.tier-room-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--tier-line);
  border-radius: 13px;
  background: #eef3f9;
}
.tier-room-tabs button {
  min-height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--tier-muted);
  font: 900 11px/1 var(--font-body, sans-serif);
  letter-spacing: .04em;
  cursor: pointer;
}
.tier-room-tabs button.is-active { background: #0d213b; color: #fff; }
.tier-room-save {
  margin-left: auto;
  padding-right: 8px;
  color: var(--tier-muted);
  font: 800 10px/1 var(--font-body, sans-serif);
}
.tier-room-save.is-saving { color: var(--tier-gold); }
.tier-room-save.is-error { color: #a12a36; }

.tier-room-body {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr) 292px;
  gap: 12px;
  align-items: start;
  min-width: 0;
}
.tier-panel {
  min-width: 0;
  border: 1px solid var(--tier-line);
  border-radius: 16px;
  background: var(--tier-panel);
  box-shadow: 0 12px 30px rgba(13, 33, 59, .05);
}
.tier-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 14px 8px;
}
.tier-panel-head h2 { margin: 0; font: 900 13px/1.1 var(--font-body, sans-serif); letter-spacing: .04em; text-transform: uppercase; }
.tier-panel-head small { color: var(--tier-muted); font-size: 9px; font-weight: 700; }

.tier-scope {
  display: flex;
  gap: 3px;
  margin: 0 12px;
  padding: 3px;
  border-radius: 10px;
  background: #eef2f7;
}
.tier-scope button {
  flex: 1;
  min-height: 30px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--tier-muted);
  font: 800 10px/1 var(--font-body, sans-serif);
  cursor: pointer;
}
.tier-scope button.is-active { background: #fff; color: var(--tier-ink); box-shadow: 0 2px 8px rgba(13, 33, 59, .1); }
.tier-chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 12px 0; }
.tier-chips button {
  min-width: 32px;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--tier-line);
  border-radius: 7px;
  background: #fff;
  color: var(--tier-muted);
  font: 900 9px/1 var(--font-body, sans-serif);
  cursor: pointer;
}
.tier-chips button.is-active { border-color: #0d213b; background: #0d213b; color: #fff; }
.tier-search { padding: 10px 12px 4px; }
.tier-search input {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--tier-line);
  border-radius: 9px;
  padding: 0 11px;
  color: var(--tier-ink);
  font: 600 12px/1 var(--font-body, sans-serif);
}
.tier-pool-meta { display: flex; justify-content: space-between; gap: 8px; padding: 6px 14px 0; color: var(--tier-muted); font-size: 9px; font-weight: 700; }
.tier-pool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  padding: 8px 12px 10px;
}
.tier-pool-face {
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--tier-muted);
  cursor: grab;
  text-align: center;
}
.tier-pool-face:active { cursor: grabbing; }
.tier-pool-face .tier-face-img { display: block; aspect-ratio: 1; border-radius: 9px; background: #e9eef5; overflow: hidden; position: relative; }
.tier-pool-face img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tier-pool-face b { display: block; margin-top: 3px; overflow: hidden; font: 700 8px/1.15 var(--font-body, sans-serif); text-overflow: ellipsis; white-space: nowrap; }
.tier-pool-face.is-placed { opacity: .38; }
.tier-pool-face.is-selected .tier-face-img { outline: 3px solid var(--tier-gold); outline-offset: 1px; }
.tier-pool-more { margin: 0 12px 12px; width: calc(100% - 24px); min-height: 32px; border: 1px dashed var(--tier-line); border-radius: 8px; background: #fff; color: var(--tier-muted); font: 800 10px/1 var(--font-body, sans-serif); cursor: pointer; }
.tier-coverage { margin: 0; padding: 10px 14px 12px; border-top: 1px solid #edf1f6; color: var(--tier-muted); font-size: 9.5px; line-height: 1.45; }
.tier-coverage strong { color: var(--tier-ink); }

.tier-board-panel { padding: 14px; }
.tier-title-row { display: grid; gap: 5px; margin-bottom: 10px; }
.tier-title-row label { color: var(--tier-muted); font: 900 8px/1 var(--font-body, sans-serif); letter-spacing: .16em; text-transform: uppercase; }
.tier-title-input {
  width: 100%;
  min-height: 52px;
  max-height: 220px;
  resize: vertical;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  background: #f7f9fc;
  color: var(--tier-ink);
  font: 900 clamp(19px, 2.4vw, 30px)/1.02 var(--font-display, "Barlow Condensed", sans-serif);
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.tier-title-input:focus { outline: none; border-color: var(--tier-gold); background: #fff; }
.tier-board-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; color: var(--tier-muted); font-size: 10px; font-weight: 700; }
.tier-board-meta button { min-height: 28px; border: 1px solid var(--tier-line); border-radius: 7px; background: #fff; color: var(--tier-ink); font: 800 9px/1 var(--font-body, sans-serif); cursor: pointer; }
.tier-board-rows { display: grid; gap: 7px; }
.tier-row {
  display: flex;
  align-items: stretch;
  gap: 7px;
  min-height: 82px;
  border: 1px solid #e7edf5;
  border-radius: 11px;
  background: #fbfcfe;
  overflow: hidden;
}
.tier-row.is-target { border-color: var(--tier-gold); box-shadow: 0 0 0 2px rgba(184, 137, 45, .18); }
.tier-block {
  display: flex;
  flex: 0 0 92px;
  align-items: center;
  justify-content: center;
  padding: 7px 6px;
  background: var(--tier-color, #e7e2d7);
  color: #17130c;
  text-align: center;
}
.tier-block-label,
.tier-block-input {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: 900 12px/1.05 var(--font-display, "Barlow Condensed", sans-serif);
  letter-spacing: .01em;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.tier-block-label { cursor: text; }
.tier-block-input { min-height: 42px; outline: 2px solid rgba(18, 35, 59, .5); border-radius: 5px; resize: none; }
.tier-drop {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  align-content: center;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 7px;
}
.tier-drop-hint { color: #9aa8b8; font: 700 9px/1 var(--font-body, sans-serif); padding: 0 4px; }
.tier-face {
  position: relative;
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
  border-radius: 8px;
  background: #e9eef5;
  overflow: hidden;
  cursor: grab;
}
.tier-face img { width: 100%; height: 100%; object-fit: contain; display: block; pointer-events: none; }
.tier-face.is-selected { outline: 3px solid var(--tier-gold); outline-offset: -1px; }
.tier-face-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  background: rgba(7, 6, 4, .72);
  color: #fff;
  font: 900 12px/1 sans-serif;
  opacity: 0;
  cursor: pointer;
}
.tier-face:hover .tier-face-remove,
.tier-face:focus-within .tier-face-remove { opacity: 1; }
.tier-board-hint { margin: 9px 2px 0; color: var(--tier-muted); font-size: 9.5px; line-height: 1.4; }

.tier-rail { padding: 12px; }
.tier-rail h2 { margin: 0 0 3px; font: 900 12px/1 var(--font-body, sans-serif); letter-spacing: .05em; text-transform: uppercase; }
.tier-rail > p { margin: 0 0 8px; color: var(--tier-muted); font-size: 9.5px; line-height: 1.4; }
.tier-label-rows { display: grid; gap: 5px; }
.tier-label-row { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; align-items: center; gap: 6px; }
.tier-label-swatch { width: 10px; height: 26px; border-radius: 4px; background: var(--tier-color, #ddd); }
.tier-label-input {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--tier-line);
  border-radius: 7px;
  padding: 0 8px;
  color: var(--tier-ink);
  font: 700 10px/1 var(--font-body, sans-serif);
}
.tier-label-tools { display: flex; gap: 2px; }
.tier-label-tools button {
  width: 24px;
  height: 26px;
  border: 1px solid var(--tier-line);
  border-radius: 6px;
  background: #fff;
  color: var(--tier-ink);
  font: 800 9px/1 var(--font-body, sans-serif);
  cursor: pointer;
}
.tier-label-tools button:disabled { opacity: .3; cursor: not-allowed; }
.tier-add {
  width: 100%;
  min-height: 32px;
  margin-top: 8px;
  border: 1px dashed var(--tier-line);
  border-radius: 8px;
  background: #fff;
  color: var(--tier-ink);
  font: 800 10px/1 var(--font-body, sans-serif);
  cursor: pointer;
}
.tier-add:disabled { opacity: .4; cursor: not-allowed; }
.tier-rail hr { margin: 12px 0; border: 0; border-top: 1px solid #edf1f6; }
.tier-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 7px 0 3px; font: 700 10px/1.2 var(--font-body, sans-serif); }
.tier-toggle { width: 36px; height: 20px; border: 0; border-radius: 999px; background: #d8e1ec; position: relative; cursor: pointer; }
.tier-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 999px; background: #fff; transition: left .12s ease; }
.tier-toggle.is-on { background: var(--tier-gold); }
.tier-toggle.is-on::after { left: 18px; }
.tier-download {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
  border: 0;
  border-radius: 10px;
  background: var(--tier-gold);
  color: #17130c;
  font: 900 12px/1 var(--font-body, sans-serif);
  letter-spacing: .02em;
  cursor: pointer;
}
.tier-download:disabled { opacity: .55; cursor: wait; }
.tier-rail .tier-no-post { color: var(--tier-ink); font-weight: 800; }
.tier-notice { padding: 10px 12px; border-radius: 10px; border: 1px solid #e2c987; background: #fbf6e8; color: #6d5718; font-size: 10.5px; font-weight: 700; }
.tier-notice.is-error { border-color: #e3a1ad; background: #fff0f2; color: #8f1b31; }
.tier-loading { display: grid; gap: 8px; padding: 18px; }
.tier-loading i { height: 14px; border-radius: 6px; background: #e9eef5; }
.tier-loading i:nth-child(2) { width: 70%; }
.tier-loading i:nth-child(3) { width: 45%; }

.tier-preview-panel { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--tier-line); border-radius: 16px; background: #0b1420; color: #e8edf4; }
.tier-preview-panel[hidden] { display: none; }
.tier-preview-panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tier-preview-panel h2 { margin: 0; font: 900 13px/1 var(--font-body, sans-serif); letter-spacing: .05em; text-transform: uppercase; }
.tier-preview-meta { color: #8fa1b7; font-size: 9.5px; font-weight: 700; }
.tier-preview-image { width: 100%; max-height: 72vh; object-fit: contain; border-radius: 8px; background: #070604; }
.tier-preview-note { margin: 0; color: #aebccd; font-size: 10px; line-height: 1.45; }
.tier-preview-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tier-preview-actions .tier-download { width: auto; min-width: 180px; margin: 0; padding: 0 16px; }

.tier-mobile-bar { display: none; }
.tier-sheet-backdrop { display: none; }

@media (max-width: 1080px) {
  .tier-room-body { grid-template-columns: 230px minmax(0, 1fr); }
  .tier-rail { grid-column: 1 / -1; }
  .tier-label-rows { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .tier-room { gap: 10px; }
  .tier-room-head h1 { font-size: 34px; }
  .tier-room-head p { font-size: 11.5px; }
  .tier-room-boards { width: 100%; }
  .tier-room-boards select { flex: 1; max-width: none; }
  .tier-room-tabs { position: sticky; top: 58px; z-index: 6; }
  .tier-room-body { display: block; }
  .tier-room-body > .tier-panel { display: none; }
  .tier-room[data-mobile-panel="board"] .tier-board-panel { display: block; }
  .tier-room[data-mobile-panel="players"] .tier-pool-panel,
  .tier-room[data-mobile-panel="tiers"] .tier-rail {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 42;
    max-height: 82vh;
    overflow: auto;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    box-shadow: 0 -18px 50px rgba(9, 20, 36, .28);
  }
  .tier-room[data-mobile-panel="players"] .tier-pool-panel { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .tier-room[data-mobile-panel="tiers"] .tier-rail { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .tier-room[data-mobile-panel="players"] .tier-sheet-backdrop,
  .tier-room[data-mobile-panel="tiers"] .tier-sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 41;
    border: 0;
    background: rgba(7, 18, 33, .44);
  }
  .tier-pool-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tier-board-panel { padding: 10px; }
  .tier-title-input { font-size: 26px; }
  .tier-block { flex-basis: 66px; }
  .tier-block-label { font-size: 11px; }
  .tier-face { flex-basis: 50px; width: 50px; height: 50px; }
  .tier-row { min-height: 68px; }
  .tier-face-remove { opacity: 1; }
  .tier-mobile-bar {
    display: flex;
    position: sticky;
    bottom: 0;
    z-index: 9;
    gap: 5px;
    padding: 8px 0 max(8px, env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(244,247,251,0), #f4f7fb 28%);
  }
  .tier-mobile-bar button {
    flex: 1;
    min-height: 40px;
    border: 1px solid var(--tier-line);
    border-radius: 9px;
    background: #fff;
    color: var(--tier-ink);
    font: 800 10px/1 var(--font-body, sans-serif);
  }
  .tier-mobile-bar button.is-active { background: #0d213b; color: #fff; border-color: #0d213b; }
  .tier-mobile-bar .tier-download { flex: 1.3; margin: 0; min-height: 40px; }
  .tier-label-rows { grid-template-columns: 1fr; }
  .tier-preview-image { max-height: 60vh; }
}

/* The Preview tab replaces the editor surface with the exact rendered PNG. */
.tier-room[data-tier-view="preview"] .tier-room-body,
.tier-room[data-tier-view="preview"] .tier-mobile-bar { display: none; }
.tier-room[data-tier-view="preview"] .tier-preview-panel { display: grid; }
.tier-sheet-close { display: none; }
@media (max-width: 760px) {
  .tier-sheet-close {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    margin-left: auto;
    padding: 0 12px;
    border: 1px solid var(--tier-line);
    border-radius: 8px;
    background: #fff;
    color: var(--tier-ink);
    font: 800 10px/1 var(--font-body, sans-serif);
  }
  .tier-panel-head { flex-wrap: wrap; }
}

/* Grid children default to min-width:auto, which lets a long board title or a
 * long <select> option push the 390 px room to 620 px. Every direct child gets
 * a shrinkable minimum, and the mobile bar is pinned above the site tab bar. */
.tier-room > * { min-width: 0; }
.tier-room-head > div:first-child { flex: 1 1 420px; min-width: 0; max-width: 100%; }
.tier-room-head p { max-width: 100%; }
.tier-room-boards { min-width: 0; flex-wrap: wrap; flex: 0 1 auto; }
.tier-room-boards select { min-width: 0; max-width: 280px; }
.tier-room-tabs { min-width: 0; }
.tier-room-save { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tier-room-body, .tier-board-panel, .tier-title-row, .tier-title-input { min-width: 0; }
@media (max-width: 760px) {
  .tier-room { padding-bottom: 88px; }
  .tier-room-head > div:first-child { flex: 1 1 100%; }
  .tier-room-boards { width: 100%; flex-wrap: nowrap; }
  .tier-room-boards select { width: auto; max-width: none; flex: 1 1 auto; }
  .tier-room-boards button { flex: 0 0 auto; }
  .tier-mobile-bar {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: calc(62px + env(safe-area-inset-bottom));
    z-index: 2147481500;
    gap: 4px;
    padding: 6px;
    border: 1px solid var(--tier-line);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(9, 20, 36, .18);
  }
  .tier-mobile-bar button { min-height: 38px; }
  .tier-mobile-bar .tier-download { min-height: 38px; }
}
@media (max-width: 760px) {
  .tier-room[data-mobile-panel="players"] .tier-mobile-bar,
  .tier-room[data-mobile-panel="tiers"] .tier-mobile-bar { display: none; }
}
body.tier-list-mode #league-ticker { display: none !important; }
