:root {
  --ink: #040b13;
  --ink-2: #071522;
  --surface: #0b1b29;
  --surface-2: #102536;
  --line: rgba(126, 178, 209, 0.22);
  --line-strong: rgba(77, 203, 244, 0.52);
  --text: #f3efe5;
  --muted: #8ca3b2;
  --cyan: #4cd7f5;
  --tier-800: #54d8ff;
  --tier-1600: #ff7065;
  --tier-3200: #f29be5;
  --tier-6400: #f1ead6;
  --type-weapon: #e6ad2e;
  --type-vitality: #78c858;
  --type-spirit: #a875e8;
  --danger: #ff6f61;
  --font-sans: Arial, Helvetica, sans-serif;
  --font-mono: Consolas, "Courier New", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--ink);
}

body {
  color: var(--text);
  font-family: var(--font-sans);
}

button,
input,
select {
  font: inherit;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
.item-card:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

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

.counterbuy-app {
  min-height: 100vh;
  display: grid;
  grid-template-rows: 72px auto auto minmax(360px, 1fr) 28px;
  background:
    linear-gradient(90deg, transparent 31px, rgba(76, 215, 245, 0.025) 32px, transparent 33px) 0 0 / 64px 64px,
    linear-gradient(0deg, transparent 31px, rgba(76, 215, 245, 0.018) 32px, transparent 33px) 0 0 / 64px 64px,
    radial-gradient(circle at 22% 3%, rgba(32, 98, 141, 0.19), transparent 32%),
    var(--ink);
}

.counterbuy-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(190px, 1fr) auto minmax(190px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(5, 14, 23, 0.96);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(14px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  justify-self: start;
  color: #9db7d9;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-decoration: none;
}

.back-link span:first-child {
  color: var(--text);
  font-size: 28px;
  font-weight: 400;
  line-height: 1;
}

.back-link:hover {
  color: var(--cyan);
}

.counterbuy-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
}

.counterbuy-brand h1,
.video-credit,
.section-heading h2,
.section-heading p {
  margin: 0;
}

.counterbuy-brand h1 {
  color: #faf6ec;
  font-size: clamp(24px, 2.2vw, 38px);
  line-height: 1;
  letter-spacing: 0.045em;
}

.video-credit {
  color: #76a9ec;
  font-size: clamp(8px, 0.72vw, 11px);
  font-weight: 850;
  line-height: 1.15;
  letter-spacing: 0.09em;
  text-decoration: none;
  white-space: nowrap;
}

.video-credit:hover,
.video-credit:focus-visible {
  color: var(--cyan);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 12px;
}

.lineup-count {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.header-actions button,
.sort-control select {
  min-height: 34px;
  padding: 0 12px;
  color: var(--text);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.header-actions button:hover,
.sort-control select:hover {
  border-color: var(--cyan);
}

.lineup-section,
.overlap-section,
.matrix-section {
  min-width: 0;
  padding-inline: 20px;
}

.lineup-section {
  padding-top: 15px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(126, 178, 209, 0.14);
}

.section-heading {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading p,
.picker-heading p {
  margin: 0 0 3px;
  color: var(--cyan);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.section-heading h2,
.picker-heading h2 {
  margin: 0;
  font-size: 17px;
  line-height: 1;
  letter-spacing: 0.08em;
}

.section-heading > span,
.compact-heading > span {
  color: #617987;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.lineup-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
}

.hero-slot {
  position: relative;
  min-width: 0;
  height: 92px;
  overflow: hidden;
  color: var(--text);
  border: 1px solid rgba(126, 178, 209, 0.32);
  background:
    linear-gradient(90deg, rgba(18, 41, 57, 0.88), rgba(7, 20, 31, 0.96)),
    var(--surface);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.hero-slot-main {
  position: absolute;
  inset: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  align-items: end;
  padding: 0 34px 12px 8px;
  color: inherit;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.hero-slot::after {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--hero-color, var(--cyan));
  content: "";
  opacity: 0.82;
}

.hero-slot:hover {
  border-color: var(--hero-color, var(--cyan));
  background: linear-gradient(90deg, rgba(23, 53, 73, 0.96), rgba(9, 26, 39, 0.98));
}

.hero-slot-image {
  width: 70px;
  height: 86px;
  align-self: end;
  object-fit: contain;
  object-position: center bottom;
  filter: saturate(0.8) contrast(1.08);
}

.hero-slot-copy {
  position: relative;
  z-index: 2;
  min-width: 0;
  padding-bottom: 1px;
}

.hero-slot-copy small,
.hero-slot-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-slot-copy small {
  margin-bottom: 3px;
  color: var(--hero-color, var(--cyan));
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.hero-slot-copy strong {
  font-size: clamp(12px, 1vw, 16px);
  letter-spacing: 0.05em;
}

.remove-hero {
  position: absolute;
  z-index: 3;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #8194a2;
  border: 0;
  background: rgba(4, 11, 19, 0.54);
  font-size: 17px;
  cursor: pointer;
}

.remove-hero:hover {
  color: var(--danger);
}

.add-slot {
  height: 92px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 5px;
  color: #7598c7;
  border: 1px dashed rgba(76, 151, 215, 0.5);
  background: rgba(6, 20, 33, 0.56);
  cursor: pointer;
}

.add-slot span {
  font-size: 31px;
  font-weight: 300;
  line-height: 0.9;
}

.add-slot strong {
  font-size: 9px;
  letter-spacing: 0.14em;
}

.add-slot:hover {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(11, 38, 57, 0.74);
}

.overlap-section {
  padding-top: 8px;
  padding-bottom: 13px;
  border-bottom: 1px solid rgba(126, 178, 209, 0.14);
  background: rgba(5, 14, 23, 0.44);
}

.overlap-heading {
  min-height: 43px;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #6e8695;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.13em;
}

.sort-control select {
  min-height: 30px;
  color: #8fbdf4;
}

.overlap-list {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 380px;
  gap: 8px;
  overflow-x: auto;
  padding: 1px 1px 4px;
  scrollbar-color: rgba(76, 215, 245, 0.3) transparent;
}

.overlap-card {
  --tier-color: var(--tier-3200);
  --type-color: var(--type-spirit);
  position: relative;
  min-height: 82px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 11px;
  overflow: hidden;
  border: 1px solid rgba(126, 178, 209, 0.28);
  background: linear-gradient(135deg, color-mix(in srgb, var(--type-color) 13%, #0f2434), rgba(7, 20, 31, 0.98));
}

.overlap-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--tier-color);
  content: "";
}

.overlap-card.is-shared {
  border-color: color-mix(in srgb, var(--type-color) 78%, white);
  box-shadow: inset 3px 0 0 var(--cyan), 0 0 20px color-mix(in srgb, var(--type-color) 13%, transparent);
}

.overlap-rank {
  position: absolute;
  top: 5px;
  right: 7px;
  color: rgba(224, 234, 241, 0.54);
  font-family: var(--font-mono);
  font-size: 10px;
}

.item-icon-shell {
  --type-color: var(--type-spirit);
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 6px;
  border: 1px solid var(--type-color);
  background: color-mix(in srgb, var(--type-color) 17%, #08131e);
  box-shadow: inset 0 0 16px rgba(0, 0, 0, 0.24);
}

.item-icon-shell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.overlap-copy {
  min-width: 0;
}

.overlap-copy strong {
  display: block;
  padding-right: 18px;
  overflow: hidden;
  font-size: 13px;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overlap-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
}

.impact-badge,
.type-badge,
.price-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border: 1px solid rgba(126, 178, 209, 0.28);
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.impact-badge {
  color: var(--cyan);
}

.price-badge {
  color: var(--tier-color);
  border-color: color-mix(in srgb, var(--tier-color) 50%, transparent);
  background: color-mix(in srgb, var(--tier-color) 8%, transparent);
}

.type-badge {
  color: var(--type-color);
  border-color: color-mix(in srgb, var(--type-color) 48%, transparent);
  background: color-mix(in srgb, var(--type-color) 8%, transparent);
}

.overlap-heroes {
  display: flex;
  margin-left: auto;
}

.overlap-heroes img {
  width: 25px;
  height: 25px;
  margin-left: -5px;
  object-fit: cover;
  border: 1px solid var(--hero-color, var(--cyan));
  border-radius: 50%;
  background: #0d1c28;
}

.matrix-section {
  min-height: 0;
  padding-top: 7px;
  padding-bottom: 12px;
}

.matrix-heading {
  min-height: 48px;
}

.matrix-scroll {
  max-width: 100%;
  overflow: auto;
  border: 1px solid rgba(126, 178, 209, 0.25);
  background: rgba(5, 17, 27, 0.68);
  scrollbar-color: rgba(76, 215, 245, 0.36) transparent;
}

.recommendation-matrix {
  --hero-count: 2;
  min-width: calc(104px + var(--hero-count) * 230px);
  display: grid;
  grid-template-columns: 104px repeat(var(--hero-count), minmax(230px, 1fr));
}

.matrix-corner,
.matrix-hero,
.tier-label,
.recommendation-cell {
  border-right: 1px solid rgba(126, 178, 209, 0.2);
  border-bottom: 1px solid rgba(126, 178, 209, 0.2);
}

.matrix-corner {
  min-height: 48px;
  display: grid;
  place-items: center;
  color: #597180;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.15em;
}

.matrix-hero {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  background: rgba(12, 30, 44, 0.58);
}

.matrix-hero img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.matrix-hero strong {
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tier-label {
  --tier-color: var(--tier-3200);
  min-height: 86px;
  display: grid;
  align-content: start;
  gap: 5px;
  padding: 17px 12px;
  color: var(--tier-color);
  background: color-mix(in srgb, var(--tier-color) 5%, #06121c);
}

.tier-label strong {
  font-family: var(--font-mono);
  font-size: 21px;
  letter-spacing: -0.05em;
}

.tier-label small {
  color: #617685;
  font-size: 8px;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.recommendation-cell {
  min-height: 86px;
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 8px;
  background: rgba(7, 21, 32, 0.42);
}

.recommendation-cell.is-empty {
  place-items: center;
  color: rgba(98, 124, 139, 0.34);
  font-family: var(--font-mono);
  font-size: 16px;
}

.item-card {
  --tier-color: var(--tier-3200);
  --type-color: var(--type-spirit);
  position: relative;
  min-width: 0;
  min-height: 86px;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  padding: 7px 8px;
  color: var(--text);
  border: 1px solid rgba(126, 178, 209, 0.22);
  overflow: hidden;
  background: linear-gradient(90deg, color-mix(in srgb, var(--type-color) 14%, #0c1b28), #081722);
  text-align: left;
}

.item-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: var(--tier-color);
  content: "";
}

.item-card:hover,
.item-card:focus-visible {
  border-color: var(--type-color);
  background: linear-gradient(90deg, color-mix(in srgb, var(--type-color) 20%, #0c1b28), #0a1b28);
}

.item-card .item-icon-shell {
  width: 43px;
  height: 43px;
}

.item-copy {
  min-width: 0;
  align-self: center;
}

.item-copy strong,
.item-target,
.item-reason {
  display: block;
}

.item-copy strong {
  margin-bottom: 3px;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.05;
  letter-spacing: 0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-card-meta {
  display: flex;
  gap: 4px;
  margin-bottom: 5px;
}

.item-card-meta .type-badge,
.item-card-meta .price-badge {
  min-height: 16px;
  padding: 0 4px;
  font-size: 7px;
}

.item-target {
  color: var(--type-color);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.085em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: normal;
}

.item-reason {
  margin-top: 3px;
  color: #7f96a4;
  font-size: 9px;
  line-height: 1.25;
}

.empty-lineup {
  grid-column: 1 / -1;
  min-height: 250px;
  display: grid;
  place-items: center;
  padding: 40px;
  color: #77909f;
  text-align: center;
}

.empty-lineup strong {
  display: block;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 16px;
  letter-spacing: 0.08em;
}

.empty-lineup span {
  font-size: 11px;
}

footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 14px;
  color: #526b79;
  border-top: 1px solid rgba(126, 178, 209, 0.14);
  background: #050c13;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

footer a {
  color: #718c9b;
  text-decoration: none;
}

footer a:hover {
  color: var(--cyan);
}

.hero-picker {
  width: min(930px, calc(100vw - 36px));
  max-height: min(760px, calc(100vh - 36px));
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line-strong);
  background: #07131e;
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.72);
}

.hero-picker::backdrop {
  background: rgba(2, 7, 12, 0.8);
  backdrop-filter: blur(5px);
}

.picker-shell {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-height: inherit;
}

.picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 13px;
  border-bottom: 1px solid var(--line);
}

.picker-heading h2 {
  font-size: 21px;
}

.picker-close {
  width: 38px;
  height: 38px;
  padding: 0;
  color: #8195a2;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 25px;
  cursor: pointer;
}

.picker-close:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.picker-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
}

.hero-search {
  display: block;
  min-width: 0;
}

.hero-search input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--line);
  background: #0c1c29;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.hero-search input::placeholder {
  color: #617988;
}

.auto-add-control {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #8ca3b2;
  cursor: pointer;
  user-select: none;
}

.auto-add-control input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--cyan);
  cursor: pointer;
}

.auto-add-control span,
.auto-add-control strong,
.auto-add-control small {
  display: block;
}

.auto-add-control strong {
  color: var(--text);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.auto-add-control small {
  margin-top: 2px;
  color: #6f8998;
  font-size: 8px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.hero-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 8px;
  overflow-y: auto;
  padding: 0 20px 20px;
}

.hero-choice {
  position: relative;
  min-height: 128px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  padding: 5px 7px 10px;
  color: var(--text);
  border: 1px solid rgba(126, 178, 209, 0.24);
  background: linear-gradient(180deg, #102537, #091722);
  cursor: pointer;
}

.hero-choice img {
  width: 100%;
  height: 96px;
  object-fit: contain;
  object-position: center bottom;
  transition: transform 150ms ease;
}

.hero-choice span {
  overflow: hidden;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hero-choice:hover {
  border-color: var(--cyan);
}

.hero-choice.is-enter-target {
  border-color: color-mix(in srgb, var(--cyan) 62%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan) 16%, transparent);
}

.hero-choice:hover img {
  transform: scale(1.04);
}

.hero-choice:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

@media (max-width: 1180px) {
  .counterbuy-header {
    grid-template-columns: auto 1fr auto;
  }

  .counterbuy-brand {
    justify-content: center;
  }

  .lineup-count {
    display: none;
  }

  .lineup-slots {
    grid-template-columns: repeat(6, minmax(118px, 1fr));
  }

  .hero-slot-main {
    grid-template-columns: 55px minmax(0, 1fr);
    padding-left: 4px;
  }

  .hero-slot-image {
    width: 56px;
  }

  .overlap-list {
    grid-auto-columns: 360px;
  }
}

@media (max-width: 820px) {
  .counterbuy-app {
    grid-template-rows: 62px auto auto minmax(320px, 1fr) auto;
  }

  .counterbuy-header {
    gap: 10px;
    padding-inline: 12px;
  }

  .back-link span:last-child {
    display: none;
  }

  .counterbuy-brand h1 {
    font-size: 24px;
  }

  .lineup-section,
  .overlap-section,
  .matrix-section {
    padding-inline: 12px;
  }

  .lineup-slots {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .section-heading > span {
    display: none;
  }

  .overlap-list {
    grid-auto-columns: min(340px, calc(100vw - 40px));
  }

  .hero-grid {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }

  footer {
    min-height: 38px;
    flex-wrap: wrap;
    justify-content: center;
    padding-block: 7px;
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
