﻿@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600;700&display=swap");
@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Condensed:wght@400;500;600&display=swap");
:root {
  --black: #000000ff;
  --prussian-blue: #414a45;
  --orange: #fca311ff;
  --alabaster-grey: #e5e5e5ff;
  --white: #ffffffff;

  --pine-teal: #3b4540;
  --vanilla-cream: var(--alabaster-grey);
  --tiger-flame: var(--orange);
  --carbon-black: #0c100e;

  --tier-row-bg: #151a17;
  --page-bg: #1c201e;

  --bg: var(--black);
  --bg-soft: var(--black);
  --panel: rgba(16, 20, 18, 0.97);
  --panel-2: #131815;
  --surface: #1c221f;
  --surface-raised: #282f2b;
  --surface-hover: #323a35;
  --control-bg: #2b322e;
  --ui-border: #424d47;
  --line: rgba(210, 220, 212, 0.12);
  --text: var(--alabaster-grey);
  --muted: rgba(229, 229, 229, 0.72);
  --accent: rgba(212, 141, 28, 0.9);
  --accent-2: rgba(198, 130, 24, 0.82);
  --danger: var(--orange);
  --ui-yellow: #cf861d;
  --menu-accent: #cf861d;
  --menu-accent-hover: #d48e2b;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.29);
  --tier-cell-size: clamp(70px, 5.5vw, 110px);
  --tier-gap: 0px;
  --tier-item-width: var(--tier-cell-size);
  --tier-item-border: 0px;
  --tier-label-width: clamp(70px, 5.5vw, 110px);
  --tier-cols: 7;
  --layout-left-pad: 8px;
  --layout-right-pad: 14px;
  --layout-col-gap: 14px;
  --layout-left-col-width: clamp(300px, 27vw, 420px);
  --tier-third-end-offset: calc(
    var(--tier-label-width) +
    (var(--tier-item-width) + var(--tier-gap)) * 3 -
    var(--tier-gap)
  );
  --cabinet-panel-bg: var(--surface);
  --cabinet-tab-bg: var(--surface-raised);
  --cabinet-tab-bg-hover: var(--surface-hover);
  --tier-current-width: calc(
    var(--tier-label-width) +
    (var(--tier-item-width) + var(--tier-gap)) * var(--tier-cols) -
    var(--tier-gap) +
    6px
  );
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

*,
*::before,
*::after {
  border-radius: 0 !important;
}

body {
  min-height: 100vh;
  background: var(--page-bg);
  color: var(--text);
  font-family: "Nunito", sans-serif;
  line-height: 1.35;
  padding: 58px 0 24px;
}

.hidden {
  display: none !important;
}

.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  min-height: 48px;
  display: grid;
  grid-template-columns: var(--layout-left-col-width) minmax(0, 1fr);
  align-items: center;
  gap: var(--layout-col-gap);
  padding: 4px var(--layout-right-pad) 4px var(--layout-left-pad);
  margin-bottom: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  overflow: visible;
}

.nav-tools {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: visible;
}

.brand-logo {
  height: 34px;
  width: auto;
  display: block;
  flex: 0 0 auto;
  transform: scaleX(0.9);
  transform-origin: center;
}

.main {
  width: 100%;
  min-width: max-content;
  margin: 0;
  padding: 0 var(--layout-right-pad) 0 var(--layout-left-pad);
  display: grid;
  grid-template-columns: var(--layout-left-col-width) minmax(max-content, 1fr);
  align-items: start;
  gap: var(--layout-col-gap);
  overflow: visible;
}

.site-version {
  justify-self: end;
  align-self: start;
  padding-top: 2px;
  color: rgba(229, 229, 229, 0.38);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.68rem;
  line-height: 1;
  user-select: none;
}

.left-cabinet {
  position: sticky;
  top: 58px;
  left: var(--layout-left-pad);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 6px;
  margin-left: 10px;
  margin-top: -6px;
  background: transparent;
  border: none;
  box-shadow: none;
  min-height: 0;
  min-width: 0;
  width: calc(100% - 10px);
  container-type: inline-size;
}

.cabinet-switch {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  width: 100%;
}

.cabinet-tab {
  min-width: 0;
  border: none;
  background: var(--cabinet-tab-bg);
  color: rgba(229, 229, 229, 0.68);
  font-weight: 400;
  font-size: clamp(0.68rem, 4cqw, 0.88rem);
  padding: 8px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  transition: background 120ms ease, color 120ms ease;
}

.cabinet-tab.active {
  background: var(--cabinet-panel-bg);
  color: var(--text);
}

.cabinet-tab:hover:not(.active) {
  background: var(--cabinet-tab-bg-hover);
  color: rgba(229, 229, 229, 0.88);
}

.cabinet-tab.active:hover {
  background: var(--cabinet-panel-bg);
  color: var(--text);
}

.cabinet-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 0;
  padding: 0;
  background: var(--cabinet-panel-bg);
  border: none;
}

.tools-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: transparent;
  border: none;
}

.tools-section + .tools-section {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.data-section-label {
  font-size: 0.68rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(229, 229, 229, 0.4);
  padding: 10px 14px 4px;
}

.data-btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.data-btn-grid > .data-action-btn {
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

.data-btn-grid > .data-action-btn:nth-child(2n) {
  border-right: none;
}

/* If odd number of items, last one spans full width */
.data-btn-grid > .data-action-btn:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  border-right: none;
}

.data-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  font-size: 0.78rem;
  background: transparent;
  text-align: left;
  color: var(--text);
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  width: 100%;
}

.data-action-btn svg {
  flex-shrink: 0;
  opacity: 0.55;
}

.data-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.data-action-btn:hover svg {
  opacity: 0.8;
}

.data-action-btn:disabled {
  color: rgba(229, 229, 229, 0.3);
  cursor: not-allowed;
}

.data-action-btn:disabled:hover {
  background: transparent;
}

.search-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px 36px;
  gap: 6px;
  background: transparent;
  border: none;
  padding: 0;
}

#searchInput {
  width: 100%;
  min-width: 0;
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--ui-border);
}

#searchInput::placeholder {
  color: rgba(229, 229, 229, 0.35);
}

#searchCabinet {
  padding: 8px;
}

#optionsCabinet,
#dataCabinet {
  padding: 0;
}

.options-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: transparent;
  border: none;
}

/* Option rows share one compact rhythm regardless of control type. */
.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  min-height: 42px;
  padding: 5px 10px;
}

/* Tournament */
body.tournament-active {
  overflow-x: hidden;
}

body.tournament-active .left-cabinet,
body.tournament-active .navbar,
body.tournament-active .recently-removed {
  pointer-events: none;
  filter: grayscale(1);
  opacity: 0.42;
}

.tournament-setup {
  padding: 18px 15px;
}

.tournament-intro {
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.92rem;
  font-weight: 400;
}

.tournament-setup-status {
  color: var(--muted);
  font-size: 0.86rem;
}

.tournament-safety {
  margin: 2px 0 20px;
  color: rgba(229, 229, 229, 0.5);
  font-size: 0.72rem;
}

.tournament-start {
  width: 100%;
  margin-top: 12px;
  border: 1px solid #e6a13b;
  background: var(--menu-accent);
  color: #080a0c;
  cursor: pointer;
  font: 400 0.86rem "Nunito", sans-serif;
  padding: 10px;
}

.tournament-start:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.45;
}

.tournament-overlay {
  position: fixed;
  inset: 48px 0 0 var(--layout-left-col-width);
  z-index: 35;
  display: grid;
  place-items: center;
  width: auto;
  min-height: 0;
  padding: 34px 24px;
  background: #111318;
}

.tournament-overlay.hidden {
  display: none;
}

.tournament-stage {
  width: min(950px, 100%);
  position: relative;
  text-align: center;
}

.tierlist-editor {
  transform-origin: center center;
}

.tierlist-editor.tournament-squish {
  animation: tournament-squish 170ms cubic-bezier(0.55, 0, 0.9, 0.45) forwards;
  pointer-events: none;
}

.tierlist-editor.tournament-restore {
  animation: tournament-restore 190ms cubic-bezier(0.15, 0.75, 0.25, 1) both;
}

.tournament-overlay.tournament-reveal {
  animation: tournament-reveal 140ms ease-out both;
}

@keyframes tournament-squish {
  to { transform: scale(0.02, 1); opacity: 0; }
}

@keyframes tournament-restore {
  from { transform: scale(0.02, 1); opacity: 0; }
  to { transform: scale(1, 1); opacity: 1; }
}

@keyframes tournament-reveal {
  from { opacity: 0; transform: scaleX(0.94); }
  to { opacity: 1; transform: scaleX(1); }
}

.tournament-exit {
  position: absolute;
  right: 0;
  top: -4px;
  border: 1px solid rgba(229, 229, 229, 0.25);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 7px 12px;
}

.tournament-stage h2 {
  font-size: clamp(1.45rem, 3.2vw, 2.2rem);
  font-weight: 400;
}

.tournament-progress {
  width: min(560px, 74%);
  height: 5px;
  margin: 18px auto 0;
  overflow: hidden;
  background: rgba(229, 229, 229, 0.13);
}

.tournament-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--menu-accent);
  transition: width 180ms ease-out;
}

.tournament-prompt-best {
  color: #72d58a;
}

.tournament-prompt-worst {
  color: #e55b68;
}

.tournament-cards {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: clamp(12px, 3vw, 34px);
  margin-top: 28px;
}

.tournament-card {
  width: min(27vw, 280px);
  border: 2px solid rgba(229, 229, 229, 0.18);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 7px 7px 13px;
  font: 400 clamp(0.74rem, 1.4vw, 0.9rem) "Nunito", sans-serif;
}

.tournament-card:hover,
.tournament-card:focus-visible {
  border-color: var(--menu-accent);
  transform: translateY(-4px);
  outline: none;
}

.tournament-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  margin-bottom: 0;
  background: #0b0d11;
}

@media (max-width: 650px) {
  .tournament-overlay { left: 0; padding: 16px 8px; }
  .tournament-cards { gap: 7px; }
  .tournament-card { width: 31vw; padding: 4px 4px 9px; }
}

.options-group {
  container-type: inline-size;
}

.options-group + .options-group {
  margin-top: 3px;
}

.tier-specific-row,
.items-dropdown .option-row {
  padding-left: 10px;
  padding-right: 10px;
}

.tier-specific-row .option-label,
.items-dropdown .option-label {
  font-size: 0.92rem;
  line-height: 1.35;
}

.tier-control-wrap {
  --tier-control-cell: clamp(24px, calc((100cqw - 72px) / 5), 32px);
  --tier-edge-size: clamp(22px, calc(var(--tier-control-cell) * 0.75), 26px);
  position: relative;
  width: max-content;
  margin: 7px auto 5px;
}

.tier-control-grid {
  display: grid;
  grid-template-columns: repeat(5, var(--tier-control-cell));
  grid-auto-rows: var(--tier-control-cell);
  width: max-content;
  border: 3px solid rgba(82, 86, 98, 0.95);
  background: var(--carbon-black);
}

.tier-control-card,
.tier-background-card {
  min-width: 0;
  height: var(--tier-control-cell);
  border: 1px solid rgba(8, 10, 12, 0.9);
  border-radius: 0;
  color: #080a0c;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  overflow: visible;
  padding: 0 4px;
}

.tier-control-card {
  width: var(--tier-control-cell);
  position: relative;
  flex: none;
}

.tier-control-card.selected {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.tier-control-card.dragging { opacity: 0.45; }
.tier-control-card.drop-target {
  outline: 3px dashed #fff;
  outline-offset: -4px;
}

.tier-control-label {
  position: relative;
  z-index: 1;
  display: block;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  pointer-events: none;
}

.tier-background-card {
  grid-column: span var(--background-span, 1);
  width: auto;
  color: var(--text);
  font-size: 0.75rem;
}

.background-short { display: none; }
.tier-background-card[data-span="1"] .background-full { display: none; }
.tier-background-card[data-span="1"] .background-short { display: inline; }

.tier-edge-btn {
  position: absolute;
  width: var(--tier-edge-size);
  height: var(--tier-edge-size);
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  background: var(--carbon-black);
  color: var(--text);
  font-size: 0;
  line-height: 1;
  cursor: pointer;
}

.tier-edge-btn::before {
  content: "×";
  display: inline-block;
  transform: rotate(12deg) scaleY(1.08);
  font-family: "Arial Rounded MT Bold", "Nunito", sans-serif;
  font-size: clamp(0.95rem, calc(var(--tier-control-cell) * 0.55), 1.15rem);
  font-weight: 900;
  line-height: 1;
  text-shadow:
    -0.5px -0.5px 0 rgba(255, 255, 255, 0.18),
    1px 1px 1px rgba(0, 0, 0, 0.3);
  transition: transform 110ms ease, filter 110ms ease;
}

.tier-edge-btn:not(:disabled):hover::before {
  transform: rotate(12deg) scale(1.07, 1.14);
  filter: saturate(1.12) brightness(1.08);
}

.tier-edge-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.tier-add-btn {
  right: calc(100% + 7px);
  top: 10px;
  color: #55d98b;
}
.tier-remove-btn {
  left: calc(100% + 7px);
  bottom: 10px;
  color: #ff6172;
}

.tier-specific-row .option-label {
  max-width: none;
}

.tier-color-popover {
  position: fixed;
  z-index: 100;
  display: grid;
  gap: 10px;
  width: 290px;
  padding: 8px;
  border: 2px solid #fff;
  background: #f4f4f4;
  color: #111;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.tier-popover-name {
  width: 100%;
  min-width: 0;
  height: 30px;
  padding: 3px 7px;
  border: 1px solid #9a9a9a;
  background: #fff;
  color: #111;
  font: inherit;
}

.tier-color-field {
  --picker-hue: #f00;
  position: relative;
  height: 172px;
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, var(--picker-hue));
}

.tier-color-field-cursor {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #111;
  clip-path: circle(50%);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.tier-color-tools {
  display: grid;
  grid-template-columns: auto 1fr 34px;
  align-items: center;
  gap: 12px;
}

.tier-color-swatches { display: flex; gap: 4px; }

.tier-color-swatch {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #888;
}

.tier-color-swatch.active {
  border-color: #111;
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #555;
}

.tier-color-swatch.hidden { display: none; }

.tier-eyedropper {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #888;
  background: #fff;
  color: #111;
  font-size: 1.15rem;
}

.tier-eyedropper svg { width: 19px; height: 19px; fill: currentColor; }

.tier-hue-slider {
  width: 100%;
  height: 18px;
  margin: 0;
  appearance: none;
  background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  cursor: pointer;
}

.tier-hue-slider::-webkit-slider-thumb {
  width: 18px;
  height: 24px;
  appearance: none;
  border: 3px solid #fff;
  background: transparent;
  box-shadow: 0 0 0 2px #777;
  clip-path: circle(50%);
}

.tier-hue-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 3px solid #fff;
  background: transparent;
  box-shadow: 0 0 0 2px #777;
}

.tier-rgb-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tier-rgb-inputs label {
  display: grid;
  gap: 4px;
  text-align: center;
}

.tier-rgb-inputs input {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 4px;
  border: 1px solid #bbb;
  background: #fff;
  color: #111;
  font: inherit;
  text-align: center;
}

.tier-color-actions {
  display: flex;
  justify-content: space-between;
}

.tier-color-action {
  padding: 6px 14px;
  border: 1px solid #888;
  background: #fff;
  color: #111;
  font: inherit;
  cursor: pointer;
}

.tier-image-actions {
  display: flex;
  gap: 8px;
}

.tier-image-actions .tier-color-action {
  flex: 1 1 50%;
  padding-inline: 8px;
}

.size-stepper {
  display: flex;
  align-items: center;
  gap: 0;
}

.size-step-btn {
  width: 32px;
  height: 32px;
  background: var(--carbon-black);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease;
  padding: 0;
}

.size-step-btn:hover {
  background: rgba(255,255,255,0.08);
}

.size-step-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.size-step-value {
  min-width: 46px;
  text-align: center;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--carbon-black);
  border-top: 1px solid rgba(255,255,255,0.1);
  border-bottom: 1px solid rgba(255,255,255,0.1);
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Segmented control */
.seg-control {
  display: flex;
}

.two-choice-control { width: 160px; }
.two-choice-control .seg-btn { flex: 1 1 50%; min-width: 0; }
.numbering-icon { font-family: "IBM Plex Mono", monospace; letter-spacing: -0.08em; }

.seg-btn {
  padding: 5px 11px;
  background: var(--carbon-black);
  color: rgba(229,229,229,0.55);
  border: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.seg-btn:not(:first-child) {
  border-left: none;
}

.seg-btn.active {
  background: rgba(255,255,255,0.13);
  color: var(--text);
}

.seg-btn:hover:not(.active) {
  background: rgba(255,255,255,0.06);
  color: rgba(229,229,229,0.85);
}

.seg-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.option-label {
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--text);
  white-space: nowrap;
}

.left-cabinet input {
  font-size: 0.92rem;
  padding: 7px 9px;
}

.left-cabinet .search-section button {
  font-size: 0.9rem;
  padding: 7px 9px;
}

#tierlistName {
  width: 58%;
  min-width: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem !important;
  padding: 7px 8px !important;
  background: var(--control-bg);
  color: var(--text);
  border: 1px solid var(--ui-border);
}

#tierlistName.default-tierlist-name {
  color: rgba(112, 122, 115, 0.95);
}

#tierlistName::placeholder {
  color: rgba(112, 122, 115, 0.95);
}

.lists-dropdown {
  position: relative;
  margin: 0;
  width: clamp(200px, 22vw, 300px);
  min-width: 200px;
}

.icon-only-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-only-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.results {
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(20, 20, 24, 0.6);
  padding: 8px;
}

.results:not(:empty) {
  min-height: 250px;
  max-height: 560px;
  overflow-y: auto;
}

.results:empty {
  min-height: 0;
  max-height: 0;
  padding: 0;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  overflow: hidden;
}

#searchCabinet .results:empty {
  display: none;
}

#searchCabinet .results:not(:empty) {
  margin-top: 8px;
}

.tierlist {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--carbon-black);
  border: 1px solid var(--carbon-black);
  padding: 1px;
  box-shadow: none;
  width: var(--tier-list-width, var(--tier-current-width));
  max-width: none;
  justify-self: center;
  align-self: start;
  margin-inline: auto;
}

.tier-items {
  cursor: col-resize;
}

input,
button {
  font-family: "Nunito", sans-serif;
}

input {
  font-size: 0.95rem;
}

input {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--carbon-black);
  background: var(--vanilla-cream);
}

input::placeholder {
  color: rgba(64, 68, 76, 0.72);
}

button {
  font-size: 0.82rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--pine-teal);
  color: var(--text);
  padding: 7px 10px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.navbar .lists-toggle {
  font-size: 1rem;
  padding: 6px 12px;
}
/* Title header above the tierlist */
.tierlist-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  background: var(--cabinet-panel-bg);
  border: 1px solid rgba(0,0,0,0.45);
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 400;
  font-family: "IBM Plex Mono", monospace;
  width: var(--tier-current-width);
  max-width: none;
  margin-inline: auto;
  box-shadow: var(--shadow);
  text-align: center;
  flex-shrink: 0;
}

.tierlist-header.hidden { display: none !important; }

.tierlist-column {
  display: flex;
  flex-direction: column;
  justify-self: center;
  align-items: center;
  gap: 0;
  min-width: max-content;
  overflow: visible;
}

button {
  font-size: 0.95rem;
  padding: 8px 10px;
}


.navbar #newListBtn {
  width: 32px;
  height: 32px;
}

.navbar #newListBtn svg {
  width: 18px;
  height: 18px;
}

button:hover {
  background: rgba(229, 229, 229, 0.2);
}

button:active {
  transform: translateY(1px);
}

#searchBtn {
  padding: 8px;
  background: var(--accent);
  color: var(--vanilla-cream);
  font-weight: 400;
}

#searchBtn:hover {
  background: var(--ui-yellow);
}

.search-icon-btn svg {
  display: block;
  width: 20px;
  height: 20px;
  margin: auto;
  fill: currentColor;
}

.custom-item-btn {
  padding: 6px;
  background: var(--surface-raised);
  color: rgba(255, 255, 255, 0.72);
  font-size: 1.35rem;
  line-height: 1;
}

.custom-item-btn:hover { background: var(--surface-hover); }

.custom-item-dialog {
  width: min(390px, calc(100vw - 24px));
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--panel-2);
  color: var(--text);
  box-shadow: var(--shadow);
}

.custom-item-dialog::backdrop { background: rgba(0, 0, 0, 0.62); }
.custom-item-dialog form { display: grid; gap: 9px; }
.custom-item-dialog h2 { margin: 0 0 5px; font-size: 0.98rem; font-weight: 400; }
.custom-item-dialog label { font-size: 0.82rem; color: rgba(255, 255, 255, 0.82); }
.custom-item-dialog input {
  width: 100%;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: var(--carbon-black);
  color: var(--text);
}
.custom-item-limits { margin: 0; font-size: 0.7rem; color: rgba(255, 255, 255, 0.58); }
.custom-item-actions { display: flex; justify-content: flex-end; gap: 7px; margin-top: 5px; }
.custom-item-actions button { padding: 7px 11px; }
.custom-item-add { background: var(--menu-accent); color: #fff; }

#listsToggle {
  background: var(--menu-accent);
  color: #000;
  font-weight: 400;
}

#listsToggle:hover {
  background: var(--menu-accent-hover);
}

#newListBtn {
  line-height: 1;
  background: #2f6e4a;
  border-color: #24553a;
}

#newListBtn:hover {
  background: #3a8159;
  border-color: #2e6948;
}

#exportBtn {
  background: var(--pine-teal);
}

#exportBtn:hover {
  background: rgba(229, 229, 229, 0.2);
}

#importBtn {
  background: var(--pine-teal);
}

#importBtn:hover {
  background: rgba(229, 229, 229, 0.2);
}

/* Mini tier-list toggles: cleaned two-tier visual with vertical sliding knob */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 56px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

/* Track: vertical two-tier split top = S (red), bottom = D (blue) */
.toggle-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid rgba(8, 10, 9, 0.72);
  background: linear-gradient(to bottom, #f56d77 0 50%, #62b4d8 50% 100%);
  box-shadow: inset 0 -6px 14px rgba(0,0,0,0.45);
  transition: filter 140ms ease, box-shadow 160ms ease, background 160ms ease;
}

/* subtle horizontal divider to indicate the two tiers */
.toggle-track::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 1px;
  background: rgba(255,255,255,0.04);
  transform: translateY(-50%);
  pointer-events: none;
}

/* The "game box" knob lives INSIDE the track and slides vertically:
   up to S (red) when ON, down to D (blue) when OFF. */
.toggle-track::after {
  content: "";
  position: absolute;
  z-index: 2;
  left: 50%;
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(8, 10, 9, 0.6);
  background: #cfcfcf; /* darker/greyer when OFF */
  box-shadow: 0 2px 4px rgba(0,0,0,0.45);
  top: 8px; /* centered: 8px padding top and bottom (56 - 14 - 26 travel) */
  transform: translate(-50%, 26px); /* OFF -> bottom (D tier) */
  transition: transform 180ms cubic-bezier(0.2, 0.75, 0.25, 1), background 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

/* When checked -> indicate top (S) tier: brighten track and move knob to top */
.toggle-switch input:checked + .toggle-track {
  filter: saturate(1.06) brightness(1.02);
  box-shadow: inset 0 -6px 16px rgba(0,0,0,0.36), 0 6px 20px rgba(0,0,0,0.28);
  background: linear-gradient(to bottom, #f56d77 0 48%, rgba(255,255,255,0.08) 48% 100%);
}

.toggle-switch input:checked + .toggle-track::after {
  transform: translate(-50%, 0); /* ON -> top (S tier) */
  background: #ffffff; /* bright when ON */
  box-shadow: 0 8px 22px rgba(255,255,255,0.06), 0 3px 8px rgba(0,0,0,0.45);
}

/* Focus-visible for keyboard users */
.toggle-switch input:focus-visible + .toggle-track {
  outline: 3px solid rgba(84, 96, 104, 0.14);
  outline-offset: 4px;
}

.lists-toggle {
  width: 100%;
  border: none;
  text-align: left;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.lists-toggle::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transform-origin: center;
  transition: transform 160ms ease;
}

.lists-toggle[aria-expanded="true"]::before {
  transform: rotate(45deg);
}

.lists-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  min-width: 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(210, 220, 212, 0.05);
  background: var(--panel-2);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  z-index: 60;
}

.lists-header {
  font-size: 0.86rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 8px 10px 4px;
}

.lists-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border-radius: 7px;
  font-size: 0.92rem;
  cursor: pointer;
}

.lists-item:hover {
  background: rgba(229, 229, 229, 0.16);
}

.lists-item-name {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: anywhere;
}

.lists-del-btn {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: var(--danger);
  font-size: 1.15rem;
  padding: 0 6px;
}

.lists-del-btn:hover {
  color: var(--tiger-flame);
}

#results {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0;
}

.game-result {
  border-radius: 8px;
  padding: 6px;
  text-align: center;
  background: rgba(229, 229, 229, 0.12);
  border: 1px solid rgba(229, 229, 229, 0.12);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease;
}

.game-result:hover {
  transform: translateY(-2px);
  border-color: rgba(252, 163, 17, 0.62);
}

.game-result img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: var(--carbon-black);
  margin-bottom: 6px;
}

.game-result span {
  display: block;
  font-size: 0.82rem;
  line-height: 1.25;
  color: rgba(229, 229, 229, 0.86);
}

.tier {
  display: flex;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--carbon-black);
  background: var(--tier-row-bg);
}

.search-result-no-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  margin-bottom: 6px;
  overflow: hidden;
  background: var(--carbon-black);
  color: rgba(229, 229, 229, 0.62);
  font-size: 0.72rem;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.size-drag-value {
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.size-drag-value.dragging {
  color: var(--tiger-flame);
  cursor: col-resize;
}

.tier-label {
  width: var(--tier-label-width);
  flex: 0 0 auto;
  min-width: 30px;
  max-width: 320px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--carbon-black);
  line-height: 1.05;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-all;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
}

.tier-label.resizing { cursor: col-resize; }

.tier[data-tier="S"] .tier-label { background: #f56d77; color: var(--black); }
.tier[data-tier="A"] .tier-label { background: #f4b56f; color: var(--black); }
.tier[data-tier="B"] .tier-label { background: #e9ee63; color: var(--black); }
.tier[data-tier="C"] .tier-label { background: #6dea68; color: var(--black); }
.tier[data-tier="D"] .tier-label { background: #62dde9; color: var(--black); }

/* Wrapper that holds the optional name column + the tierlist side-by-side */
.tierlist-area {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-width: max-content;
  max-width: none;
}

/* The names column lives outside the tierlist, in the empty space to its left */
.tier-names-column {
  display: flex;
  flex-direction: column;
  width: 170px;
  flex-shrink: 0;
  /* match tierlist's gap + border so each name box lines up with its tier row */
  gap: 1px;
  padding: 1px 0;
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
  margin-right: 2px;
}

.tier-names-column.hidden {
  display: none;
}

body.titles-right .tierlist-area { flex-direction: row-reverse; }
body.titles-right .tier-names-column {
  margin-right: 0;
  margin-left: 2px;
}

.tier-names {
  overflow-x: hidden;
  overflow-y: auto;
  font-family: "IBM Plex Sans Condensed", sans-serif;
  font-size: 0.78rem;
  line-height: 1.25;
  color: #d0d0d0;
  background: rgba(10, 10, 14, 0.75);
  padding: 3px 6px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  border: 1px solid rgba(255,255,255,0.08);
  box-sizing: border-box;
}

.tier-names span {
  white-space: normal;
  word-break: break-word;
  padding: 1px 0;
}

.tier-items {
  flex: 1;
  min-height: var(--tier-cell-size);
  display: flex;
  gap: var(--tier-gap);
  padding: 0;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: flex-start;
  justify-content: flex-start;
  overflow: hidden;
}

.tier-game {
  width: var(--tier-item-width);
  height: var(--tier-cell-size);
  flex: 0 0 var(--tier-item-width);
  min-width: 0;
  overflow: hidden;
  cursor: grab;
  position: relative;
  border: var(--tier-item-border) solid var(--tier-background-color, transparent);
  background-clip: padding-box;
  box-shadow: none;
  background: var(--carbon-black);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  contain: layout paint style;
}

.tier-game,
.tier-game * {
  -webkit-user-drag: none;
}

/* Pointer reordering keeps the source in-flow so the grid never collapses. */
.tier-game.tier-pointer-source {
  visibility: hidden;
  pointer-events: none;
}

.tier-pointer-ghost {
  position: fixed !important;
  z-index: 120;
  margin: 0;
  pointer-events: none;
  cursor: grabbing;
  will-change: left, top, transform;
  background: transparent;
}

.tier-game.tier-game-drag-pressure {
  z-index: 1;
  will-change: transform, opacity;
}

.recently-removed {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 80;
  max-width: calc(100vw - 16px);
}

.recently-removed-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.1;
}

.recently-removed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 1px 3px;
}

.recently-removed-label > span {
  display: inline-block;
  transform: rotate(-12deg);
  transform-origin: center;
}

.recently-removed-dismiss {
  flex: 0 0 auto;
  margin: 0 1px 0 0;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1;
  transform: rotate(-12deg);
}

.recently-removed-dismiss:hover {
  background: transparent;
  color: rgba(255, 255, 255, 0.95);
}

.recently-removed-items {
  display: flex;
  align-items: flex-start;
  width: max-content;
  max-width: none;
  overflow: hidden;
  padding: 2px;
  background: rgba(8, 10, 12, 0.72);
}

.recently-removed-items .tier-game {
  flex: 0 0 var(--tier-item-width);
}

.data-attribution {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 100%;
  max-width: 100%;
  padding: 10px 8px 9px;
  color: rgba(229, 229, 229, 0.42);
  line-height: 1;
  text-align: center;
}

.igdb-attribution {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  font-size: 0.78rem;
  text-decoration: none;
}

.igdb-attribution:hover {
  color: rgba(229, 229, 229, 0.72);
}

.igdb-attribution img {
  width: 42px;
  height: auto;
  color: currentColor;
  opacity: 0.8;
}

.creator-attribution {
  color: rgba(229, 229, 229, 0.32);
  font-size: 0.58rem;
}

.tier-game img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Image fit modes (applied via body class) */
body.item-fit-crop    .tier-game img,
body.item-fit-crop    .tier-drop-preview .preview-img { object-fit: cover; }
body.item-fit-stretch .tier-game img,
body.item-fit-stretch .tier-drop-preview .preview-img { object-fit: fill; }
/* Portrait shape always covers — overrides any fit mode */
body.item-shape-portrait .tier-game img,
body.item-shape-portrait .tier-drop-preview .preview-img { object-fit: cover; }

.tier-game.tier-game-source-hidden {
  opacity: 0;
  pointer-events: none;
}

.tier-game.tier-game-source-collapsed {
  position: absolute;
}

.tier-wrap-viewport {
  position: fixed;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.tier-wrap-clone {
  position: absolute;
  margin: 0;
  overflow: hidden;
  pointer-events: none;
  will-change: transform, opacity;
}

.tier-wrap-clone img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

body.item-fit-crop .tier-wrap-clone img { object-fit: cover; }
body.item-fit-stretch .tier-wrap-clone img { object-fit: fill; }
body.item-shape-portrait .tier-wrap-clone img { object-fit: cover; }

.tier-drop-preview {
  position: relative;
  z-index: 2;
  width: var(--tier-item-width);
  height: var(--tier-cell-size);
  flex: 0 0 var(--tier-item-width);
  border: none;
  background: transparent;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.tier-drop-preview .preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.tier-drop-preview.no-image {
  background: rgba(252, 163, 17, 0.28);
}

.no-image {
  display: flex;
  width: var(--tier-cell-size);
  height: var(--tier-cell-size);
  padding: 4px;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.67rem;
  background: rgba(229, 229, 229, 0.35);
  color: var(--muted);
}

@media (max-width: 1080px) {
  .nav-tools {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    min-width: 0;
    justify-self: center;
  }

  .main {
    grid-template-columns: var(--layout-left-col-width) minmax(max-content, 1fr);
    gap: 10px;
  }

  .left-cabinet {
    margin-left: 0;
    margin-top: 0;
    min-height: 0;
  }

  .results:not(:empty) {
    max-height: 320px;
  }
}



@media (max-width: 640px) {
  .navbar {
    gap: 6px;
    padding: 4px 8px;
  }

  .nav-tools {
    gap: 6px;
  }

  .lists-dropdown {
    min-width: 130px;
  }

  .main {
    width: 100%;
    min-width: max-content;
    gap: 10px;
    grid-template-columns: var(--layout-left-col-width) minmax(max-content, 1fr);
    padding: 0 10px 0 6px;
  }

  .left-cabinet {
    padding: 8px;
    margin-left: 0;
    margin-top: 0;
    gap: 0;
  }

  .search-section { grid-template-columns: minmax(0, 1fr) 40px 40px; }
}

/* ===== LOADING SPINNERS ===== */

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 0;
  color: #999;
  font-size: 0.9rem;
}

.loading-spinner::before {
  content: "";
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(255,255,255,0.15);
  border-top-color: #aaa;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

/* Tierlist overlay spinner */
.tierlist-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 32, 38, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  border-radius: 4px;
  gap: 10px;
  color: #bbb;
  font-size: 0.95rem;
}

.tierlist-loading-overlay::before {
  content: "";
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255,255,255,0.12);
  border-top-color: #ccc;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.tierlist-column {
  position: relative;
}


