:root {
  color-scheme: dark;
  --ink: #f3efe6;
  --muted: #b3aa9a;
  --paper: #0c0b0a;
  --panel: rgba(18, 17, 16, 0.86);
  --line: rgba(189, 168, 120, 0.35);
  --accent: #d7b36a;
  --accent-2: #8b6a2f;
  --accent-3: #9c2f2f;
  --accent-4: #f0d9a1;
  --shadow: 0 18px 40px rgba(5, 5, 5, 0.5);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(160deg, rgba(20, 18, 16, 0.68) 0%, rgba(26, 22, 18, 0.55) 55%, rgba(18, 16, 14, 0.6) 100%),
    radial-gradient(circle at 30% 20%, rgba(156, 47, 47, 0.18), transparent 45%),
    radial-gradient(circle at 70% 70%, rgba(215, 179, 106, 0.16), transparent 55%),
    url("bg.jpg") center / cover no-repeat fixed;
  background-blend-mode: multiply, normal, normal, normal;
  background-attachment: fixed;
}

.page::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.15;
  z-index: -1;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 14px 24px;
  align-items: start;
}

.hero-text {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--accent);
  margin: 0 0 10px;
}

h1 {
  font-family: "Noto Serif SC", "Songti SC", "STSong", "Source Han Serif SC",
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-size: clamp(26px, 3.2vw, 40px);
  margin: 0 0 10px;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.6);
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.actions {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.actions-right {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.actions-right .mini {
  display: none;
}



.upload {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0f23;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(255, 79, 216, 0.4);
}

.upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.ghost {
  border: 1px solid var(--line);
  background: rgba(18, 17, 16, 0.9);
  color: var(--ink);
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.ghost.mini {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
}



.share {
  background: linear-gradient(135deg, rgba(215, 179, 106, 0.9), rgba(139, 106, 47, 0.85));
  border-color: rgba(215, 179, 106, 0.7);
  color: #1a1206;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.assign-panel {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 40;
}

.assign-panel.is-open {
  display: block;
}

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

.assign-sheet {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  background: rgba(18, 17, 16, 0.95);
  border-radius: 18px;
  padding: 16px;
  box-shadow: 0 24px 60px rgba(5, 5, 5, 0.6);
}

.assign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  margin-bottom: 12px;
}

.assign-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.assign-btn {
  border: 1px solid rgba(189, 168, 120, 0.35);
  background: rgba(20, 18, 16, 0.9);
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink);
}

.assign-btn.tier-top {
  background: linear-gradient(135deg, rgba(215, 179, 106, 0.3), rgba(139, 106, 47, 0.3));
}

.assign-btn.tier-elite {
  background: linear-gradient(135deg, rgba(240, 217, 161, 0.35), rgba(215, 179, 106, 0.3));
}

.assign-btn.tier-god {
  background: linear-gradient(135deg, rgba(183, 150, 92, 0.35), rgba(122, 85, 38, 0.3));
}

.assign-btn.tier-mid {
  background: linear-gradient(135deg, rgba(156, 47, 47, 0.35), rgba(100, 24, 24, 0.35));
}

.assign-btn.tier-bad {
  background: linear-gradient(135deg, rgba(82, 25, 25, 0.4), rgba(48, 12, 12, 0.4));
}

.assign-btn.back {
  grid-column: span 2;
}

.board {
  display: grid;
  gap: 14px;
}

.tier {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: linear-gradient(135deg, rgba(24, 21, 18, 0.95), rgba(12, 10, 8, 0.92));
  min-height: 92px;
  border: 1px solid rgba(189, 168, 120, 0.25);
}

.tier-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  background: linear-gradient(135deg, rgba(215, 179, 106, 0.9), rgba(139, 106, 47, 0.85));
  color: #1a1206;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.08em;
}

.tier-label::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 6px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0));
  opacity: 0.5;
}

.tier[data-tier="tier-elite"] .tier-label {
  background: linear-gradient(135deg, rgba(240, 217, 161, 0.9), rgba(215, 179, 106, 0.85));
}

.tier[data-tier="tier-god"] .tier-label {
  background: linear-gradient(135deg, rgba(140, 180, 185, 0.9), rgba(72, 106, 110, 0.85));
  color: #0f1a1b;
}

.tier[data-tier="tier-mid"] .tier-label {
  background: linear-gradient(135deg, rgba(156, 47, 47, 0.75), rgba(100, 24, 24, 0.85));
  color: #f1e6d2;
}

.tier[data-tier="tier-bad"] .tier-label {
  background: linear-gradient(135deg, rgba(82, 25, 25, 0.9), rgba(48, 12, 12, 0.9));
  color: #f1e6d2;
}

.tier-dropzone {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  min-height: 92px;
  align-items: center;
  background: rgba(14, 13, 12, 0.78);
}

.tier-dropzone.drag-over,
.pool-drop.drag-over {
  outline: 2px dashed rgba(215, 179, 106, 0.8);
  background: rgba(40, 30, 20, 0.6);
  box-shadow: inset 0 0 0 2px rgba(215, 179, 106, 0.25);
}

.pool {
  background: linear-gradient(135deg, rgba(20, 18, 16, 0.92), rgba(12, 10, 8, 0.9));
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  border: 1px solid rgba(189, 168, 120, 0.25);
}

.pool-header {
  display: grid;
  gap: 6px;
}

.pool-sections {
  display: grid;
  gap: 14px;
}

.pool-section {
  border: 1px solid rgba(189, 168, 120, 0.25);
  border-radius: 14px;
  background: rgba(20, 18, 16, 0.65);
  overflow: hidden;
}

.section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border: 0;
  background: rgba(46, 36, 26, 0.65);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.pool-section[data-section="minor"] .section-toggle {
  background: rgba(215, 179, 106, 0.22);
}

.pool-section[data-section="edo"] .section-toggle {
  background: rgba(215, 179, 106, 0.3);
}

.pool-section[data-section="sengoku"] .section-toggle {
  background: rgba(156, 47, 47, 0.35);
}

.pool-section[data-section="heian"] .section-toggle {
  background: rgba(124, 92, 255, 0.25);
}

.pool-section[data-section="ancient"] .section-toggle {
  background: rgba(215, 179, 106, 0.2);
}

.pool-section[data-section="bakumatsu"] .section-toggle {
  background: rgba(156, 47, 47, 0.25);
}

.pool-section[data-section="edo-final"] .section-toggle {
  background: rgba(215, 179, 106, 0.28);
}

.pool-section[data-section="kunimatsu"] .section-toggle {
  background: rgba(110, 90, 60, 0.28);
}

.section-toggle .chevron {
  font-size: 16px;
  color: var(--muted);
}

.pool-header h2 {
  margin: 0;
  font-family: "Noto Serif SC", "Songti SC", "STSong", "Source Han Serif SC",
    "Noto Sans SC", "PingFang SC", "Microsoft YaHei", serif;
  font-weight: 700;
  font-size: 18px;
}

.pool-header p {
  margin: 0;
  color: var(--muted);
}


.pool-drop {
  min-height: 110px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px dashed var(--line);
  background: rgba(18, 17, 16, 0.7);
}

.pool-drop.is-collapsed {
  display: none;
}

.tier-item {
  width: 90px;
  height: 130px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(189, 168, 120, 0.4);
  background: rgba(26, 22, 18, 0.95);
  display: grid;
  place-items: center;
  box-shadow: 0 12px 28px rgba(5, 5, 5, 0.5);
  cursor: grab;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.item-name {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 4px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #f3efe6;
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.04em;
}

.item-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.65);
  color: #f5ead4;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 2;
}

.tier-dropzone .tier-item:hover .item-remove {
  opacity: 1;
  transform: scale(1);
}

.tier-item:active {
  cursor: grabbing;
}

.tier-item:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.6);
}

.tier-item::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.tier-item:hover::after {
  opacity: 0.6;
}

.tier-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(18, 17, 16, 0.8);
}

@media (max-width: 900px) {
  .tier {
    grid-template-columns: 110px 1fr;
  }

  .tier-label {
    font-size: 18px;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 28px 16px 40px;
    gap: 20px;
  }

  .hero {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    align-items: flex-start;
    gap: 10px;
  }

  .actions {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
    width: 100%;
    flex-direction: column;
  }

  .actions .ghost {
    width: 100%;
  }

  .actions-right {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
  }

  .actions {
    display: none;
  }

  .actions-right .mini {
    display: inline-flex;
  }

  .actions-right .ghost {
    padding: 6px 10px;
    font-size: 12px;
    border-radius: 10px;
  }

  .tier {
    grid-template-columns: 1fr;
  }

  .tier-label {
    padding: 12px;
    justify-content: flex-start;
  }

  .tier-dropzone,
  .pool-drop {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 10px 12px 14px;
    gap: 10px;
    scroll-snap-type: x mandatory;
  }

  .tier-item {
    width: 72px;
    height: 104px;
    scroll-snap-align: start;
    flex: 0 0 auto;
  }

  .section-toggle {
    padding: 10px 12px;
    font-size: 14px;
  }
}

@media (max-width: 420px) {
  h1 {
    font-size: 24px;
  }

  .subtitle {
    font-size: 14px;
  }

  .tier-label {
    font-size: 16px;
  }
}

body.force-mobile .page {
  padding: 28px 16px 40px;
  gap: 20px;
}

body.force-mobile .hero {
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  align-items: flex-start;
  gap: 10px;
}

body.force-mobile .actions {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
  width: 100%;
  flex-direction: column;
}

body.force-mobile .actions .ghost {
  width: 100%;
}

body.force-mobile .actions {
  display: none;
}

body.force-mobile .actions-right {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

body.force-mobile .actions-right .ghost {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
}

body.force-mobile .actions-right .mini {
  display: inline-flex;
}


body.force-mobile .tier {
  grid-template-columns: 1fr;
}

body.force-mobile .tier-label {
  padding: 12px;
  justify-content: flex-start;
  font-size: 16px;
}

body.force-mobile .tier-dropzone,
body.force-mobile .pool-drop {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 10px 12px 14px;
  gap: 10px;
  scroll-snap-type: x mandatory;
}

body.force-mobile .tier-item {
  width: 72px;
  height: 104px;
  scroll-snap-align: start;
  flex: 0 0 auto;
}

body.force-mobile .section-toggle {
  padding: 10px 12px;
  font-size: 14px;
}

body.force-mobile h1 {
  font-size: 24px;
}

body.force-mobile .subtitle {
  font-size: 14px;
}
