:root {
  --bg-top: #121212;
  --bg-bottom: #050505;
  --paper: rgba(22, 22, 22, 0.92);
  --paper-strong: #111111;
  --ink: #f3efe8;
  --muted: #b9aea1;
  --line: #38322d;
  --accent: #e3b341;
  --accent-dark: #c7931f;
  --danger: #dc2626;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

::-webkit-scrollbar {
  display: none;
}
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at top left, rgba(227, 179, 65, 0.16), transparent 24%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

button,
input,
summary {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  background: #26211d;
  color: var(--ink);
}

.secondary-button:hover {
  background: #332c26;
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #991b1b;
}

.page {
  width: min(1320px, calc(100% - 28px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.auth-shell {
  min-height: calc(100vh - 76px);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(480px, 100%);
  margin: 0 auto;
}

.auth-form {
  margin-top: 20px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.82rem;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 4.8vw, 4.8rem);
  line-height: 0.95;
  max-width: 840px;
}

.intro {
  max-width: 660px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.08rem;
}

.hero-actions {
  display: flex;
  justify-content: flex-end;
}

.tierlists-menu {
  position: relative;
}

.tierlists-menu summary {
  list-style: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--accent);
  color: #fff;
}

.tierlists-menu summary::-webkit-details-marker {
  display: none;
}

.tierlists-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(420px, 85vw);
  background: var(--paper-strong);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 16px;
  z-index: 5;
}

.menu-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panel {
  background: var(--paper);
  border: 1px solid rgba(56, 50, 45, 0.92);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(12px);
  margin-bottom: 20px;
}

.workspace-board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.unranked-panel {
  position: sticky;
  top: 20px;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading p,
.label,
.status,
.tierlist-meta,
.inline-note {
  color: var(--muted);
}

.controls {
  display: grid;
  gap: 16px;
}

.stack-form {
  display: grid;
  gap: 8px;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

#item-link {
  min-width: 260px;
}

.upload-picker {
  position: relative;
  display: grid;
  gap: 8px;
  min-width: 240px;
}

.upload-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 6;
  display: grid;
  gap: 8px;
  min-width: 180px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #101010;
  box-shadow: var(--shadow);
}

.upload-selection {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.2;
}

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

input[type="text"],
input[type="password"],
input[type="file"] {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #0e0e0e;
  color: var(--ink);
}

input[type="text"],
input[type="password"] {
  width: 100%;
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.status {
  min-height: 1.4em;
  margin: 0;
}

.tierlists-list {
  display: grid;
  gap: 10px;
}

.tierlist-card {
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  gap: 8px;
}

.tierlist-open-button {
  width: 100%;
  border-radius: 18px;
  background: #121212;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 14px;
  text-align: left;
  display: grid;
  gap: 6px;
}

.tierlist-open-button:hover,
.tierlist-open-button.is-active {
  background: #1b1b1b;
}

.tierlist-name {
  font-weight: 700;
}

.tierlist-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tierlist-card-actions button {
  flex: 1;
  min-width: 88px;
  padding: 8px 10px;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

.item-pool,
.tier-dropzone {
  min-height: 100px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  align-content: flex-start;
  border: 2px dashed transparent;
  border-radius: 20px;
  padding: 12px;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.dropzone.is-active {
  border-color: var(--accent);
  background: rgba(15, 118, 110, 0.09);
}

.empty-state {
  color: var(--muted);
}

.tiers {
  display: grid;
  gap: 16px;
}

.tier-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 12px;
  align-items: stretch;
  position: relative;
  padding: 12px;
  border-radius: 26px;
  background: linear-gradient(180deg, rgba(31, 31, 31, 0.98), rgba(17, 17, 17, 0.98));
  border: 1px solid rgba(74, 65, 58, 0.95);
  box-shadow: var(--shadow);
}

.tier-row.is-tier-drop-before::before,
.tier-row.is-tier-drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.tier-row.is-tier-drop-before::before {
  top: -8px;
}

.tier-row.is-tier-drop-after::after {
  bottom: -8px;
}

.tier-label-panel {
  border-radius: 20px;
  padding: 14px;
  display: grid;
  gap: 10px;
  color: #fff;
  box-shadow: var(--shadow);
}

.tier-panel-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.tier-handle {
  justify-self: start;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.tier-handle:hover {
  background: rgba(255, 255, 255, 0.34);
}

.tier-delete-button {
  padding: 8px 12px;
  font-size: 0.85rem;
}

.tier-delete-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tier-delete-button:disabled:hover {
  background: var(--danger);
}

.tier-name-display,
.tier-name-input {
  min-height: 48px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: clamp(1rem, 1.1vw + 0.85rem, 1.85rem);
  font-weight: 700;
  line-height: 1.05;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.tier-name-display {
  cursor: text;
}

.tier-name-input {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
}

.tier-dropzone {
  background: rgba(10, 10, 10, 0.8);
  border: 2px solid rgba(74, 65, 58, 0.95);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.item {
  display: inline-grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #181818;
  border: 1px solid var(--line);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  cursor: grab;
  min-height: 64px;
  min-width: 96px;
  max-width: 220px;
}

.item.has-link {
  border-color: rgba(227, 179, 65, 0.45);
}

.item.is-dragging {
  opacity: 0.4;
}

.item.item-placeholder {
  min-width: 140px;
  border: 2px dashed var(--accent);
  background: rgba(15, 118, 110, 0.08);
  box-shadow: none;
}

.item.is-delete-armed {
  border-color: rgba(220, 38, 38, 0.9);
  background: rgba(80, 14, 14, 0.9);
}

.item.item-placeholder .item-label,
.item.item-placeholder .item-media {
  display: none;
}

.item-label,
.item-label-input {
  font-weight: 700;
  min-width: 0;
}

.item-label:empty {
  display: none;
}

.item-label-input {
  width: 100%;
  padding: 8px 10px;
}

.item.has-image:not(.has-text) {
  grid-template-columns: 1fr;
  max-width: 92px;
  padding: 8px;
}

.item.has-image:not(.has-text) .item-media {
  width: 72px;
  height: 72px;
}

.item.has-image:not(.has-text) .item-label,
.item.has-image:not(.has-text) .item-label-input {
  display: none !important;
}

.item-media {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 12px;
  overflow: hidden;
  background: #222;
  border: 1px solid var(--line);
}

.item-delete-hint {
  grid-column: 1 / -1;
  color: #ffd4d4;
  font-size: 0.8rem;
  font-weight: 700;
}

.item-link-badge {
  grid-column: 1 / -1;
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(227, 179, 65, 0.18);
  color: #f3d38b;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.item-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(6px);
}

.preview-panel {
  position: relative;
  width: min(980px, 100%);
  max-height: min(88vh, 920px);
  display: grid;
  gap: 14px;
  padding: 22px;
  border-radius: 26px;
  background: #090909;
  border: 1px solid rgba(74, 65, 58, 0.95);
  box-shadow: var(--shadow);
}

.preview-close {
  justify-self: end;
}

.preview-head h2,
.preview-head p {
  margin: 0;
}

.preview-meta {
  color: var(--muted);
  word-break: break-word;
}

.preview-body {
  min-height: 0;
  overflow: auto;
}

.preview-image,
.preview-frame {
  width: 100%;
  display: block;
  border: 0;
  border-radius: 18px;
  background: #000;
}

.preview-image {
  max-height: 70vh;
  object-fit: contain;
}

.preview-frame {
  aspect-ratio: 16 / 9;
  min-height: 320px;
}

.preview-link-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 18px;
  background: #111;
  border: 1px solid var(--line);
}

.preview-link-card p,
.preview-link-card a {
  margin: 0;
  color: var(--ink);
  word-break: break-word;
}

.preview-link-card a {
  color: var(--accent);
}

@media (max-width: 820px) {
  .page {
    width: min(100% - 20px, 100%);
    padding-top: 20px;
  }

  .hero,
  .form-row,
  .toolbar,
  .tier-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .workspace-board {
    grid-template-columns: 1fr;
  }

  .tierlists-menu-panel {
    right: auto;
    left: 0;
    width: min(92vw, 420px);
  }

  .item {
    width: 100%;
    max-width: none;
  }
}
