:root {
  --draft-blue: #4d8fc8;
  --draft-blue-soft: #dcebf7;
  --draft-red: #c85d56;
  --draft-red-soft: #f6dfdc;
  --draft-gold: #a56d16;
}

@media (prefers-color-scheme: dark) {
  :root {
    --draft-blue-soft: #253c4f;
    --draft-red-soft: #4c2c2a;
    --draft-gold: #e8b65d;
  }
}

button,
input {
  font: inherit;
}

.itemdraft-layout {
  padding-block: clamp(2.5rem, 6vw, 5rem) 3rem;
}

.itemdraft-intro,
.champion-setup,
.draft-topbar,
.shared-champion,
.shop-toolbar,
.itemdraft-actions,
.setup-actions {
  display: flex;
  align-items: center;
}

.itemdraft-intro {
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2rem;
}

.itemdraft-intro h1 {
  margin: 0;
  font-size: clamp(2.8rem, 8vw, 5.5rem);
  letter-spacing: -0.065em;
  line-height: 0.95;
}

.itemdraft-intro p:last-child {
  max-width: 42rem;
  margin: 1rem 0 0;
  color: var(--muted);
}

.itemdraft-actions,
.setup-actions {
  flex-wrap: wrap;
  gap: 0.6rem;
}

.itemdraft-page button,
.itemdraft-page input {
  min-height: 2.75rem;
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  background: var(--surface);
  color: var(--text);
}

.itemdraft-page button {
  padding-inline: 0.85rem;
  cursor: pointer;
  font-weight: 750;
}

.itemdraft-page button:hover:not(:disabled) {
  border-color: var(--text);
}

.itemdraft-page button:focus-visible,
.itemdraft-page input:focus-visible {
  outline: 0.2rem solid var(--focus);
  outline-offset: 0.14rem;
}

.itemdraft-page button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.itemdraft-page .primary-action {
  border-color: var(--text);
  background: var(--text);
  color: var(--background);
}

.champion-setup {
  justify-content: space-between;
  gap: 2rem;
  padding: clamp(1.4rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 1.2rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.champion-setup h2,
.shop-toolbar h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

.champion-setup p:last-child {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.draft-workspace {
  display: grid;
  grid-template-columns: minmax(11rem, 0.72fr) minmax(24rem, 2.1fr) minmax(11rem, 0.72fr);
  gap: 1rem;
  align-items: start;
}

.draft-workspace[hidden] {
  display: none;
}

.draft-topbar {
  grid-column: 1 / -1;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
}

.shared-champion {
  gap: 0.75rem;
}

.shared-champion img,
.item-card img,
.slot-item img,
.champion-option img,
.item-detail img {
  object-fit: cover;
  border-radius: 0.45rem;
}

.shared-champion strong {
  display: block;
  line-height: 1.2;
}

.shared-champion button {
  margin-left: 0.4rem;
}

.draft-status {
  margin: 0;
  font-weight: 800;
}

.draft-status[data-side="blue"] { color: var(--draft-blue); }
.draft-status[data-side="red"] { color: var(--draft-red); }

.team-panel,
.item-shop,
.item-detail {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
}

.team-panel {
  overflow: hidden;
}

.team-panel > h2 {
  margin: 0;
  padding: 0.85rem 1rem;
  color: #fff;
  font-size: 1rem;
}

.team-panel--blue > h2 { background: var(--draft-blue); }
.team-panel--red > h2 { background: var(--draft-red); }

.team-panel section {
  padding: 0.9rem;
}

.team-panel section + section {
  border-top: 1px solid var(--line);
}

.team-panel h3,
.draft-history h2 {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.draft-slots,
#draft-log {
  margin: 0;
  padding: 0;
  list-style: none;
}

.draft-slots {
  display: grid;
  gap: 0.45rem;
}

.slot-item {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.slot-item img {
  width: 2rem;
  height: 2rem;
}

.slot-empty {
  height: 2.1rem;
  border: 1px dashed var(--line);
  border-radius: 0.45rem;
}

.item-shop {
  min-width: 0;
  padding: 1rem;
}

.shop-toolbar {
  justify-content: space-between;
  gap: 1rem;
}

.item-search-label {
  flex: 1;
  max-width: 19rem;
}

#item-search,
#champion-search {
  width: 100%;
  padding-inline: 0.75rem;
}

.tag-filters {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.85rem;
  padding-bottom: 2rem;
  overflow-x: auto;
}

.tag-filters button {
  position: relative;
  width: 2.75rem;
  min-width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  padding: 0;
  border-color: #5b6470;
  background: #18242d;
}

.tag-filter-icon {
  width: 1.35rem;
  height: 1.35rem;
  object-fit: contain;
  image-rendering: auto;
}

.tag-filter-tooltip {
  position: fixed;
  z-index: 20;
  padding: 0.2rem 0.35rem;
  border: 1px solid #5b6470;
  border-radius: 0.2rem;
  background: #101920;
  color: #f2e6c8;
  font-size: 0.67rem;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
}

.tag-filter-tooltip[hidden] {
  display: none;
}

.tag-filters button[aria-pressed="true"] {
  border-color: #c8aa6e;
  background: #263744;
  box-shadow: inset 0 0 0 1px #c8aa6e;
}

.result-count {
  margin: 0.6rem 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.item-grid {
  display: grid;
  max-height: 32rem;
  grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
  gap: 0.45rem;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.item-card {
  position: relative;
  display: grid;
  min-width: 0;
  height: 6.5rem;
  grid-template-rows: 3rem 1.6rem;
  justify-items: center;
  align-content: center;
  gap: 0.35rem;
  padding: 0.4rem;
  background: var(--background) !important;
  font-size: 0.68rem;
  line-height: 1.15;
  text-align: center;
}

.item-card-name {
  display: -webkit-box;
  width: 100%;
  height: 1.6rem;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.item-card img {
  width: 3rem;
  height: 3rem;
}

.item-card[aria-pressed="true"] {
  outline: 0.18rem solid var(--focus);
  outline-offset: -0.18rem;
}

.item-card:disabled img {
  filter: grayscale(1);
}

.draft-history {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

#draft-log {
  display: grid;
  max-height: 8rem;
  gap: 0.3rem;
  overflow-y: auto;
  font-size: 0.8rem;
}

.log-blue { color: var(--draft-blue); }
.log-red { color: var(--draft-red); }
.empty-log { color: var(--muted); }

.item-detail {
  position: fixed;
  z-index: 8;
  right: max(1rem, calc((100vw - var(--shell)) / 2));
  bottom: 1rem;
  width: min(25rem, calc(100% - 2rem));
  max-height: min(38rem, calc(100vh - 2rem));
  padding: 1.2rem;
  overflow-y: auto;
  box-shadow: 0 1.5rem 4rem rgb(0 0 0 / 24%);
  transform: translateY(calc(100% + 2rem));
  visibility: hidden;
  transition: transform 180ms ease, visibility 180ms;
}

.item-detail[data-open="true"] {
  transform: translateY(0);
  visibility: visible;
}

.detail-close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  width: 2.75rem;
  padding: 0 !important;
  font-size: 1.5rem;
}

#detail-content {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
}

#detail-content[hidden] { display: none; }

.detail-price {
  margin: 0;
  color: var(--draft-gold);
  font-weight: 800;
}

.item-detail h2 {
  margin: 0.15rem 2rem 0 0;
  line-height: 1.15;
}

.detail-tags,
.detail-description,
#confirm-item {
  grid-column: 1 / -1;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.detail-tags span {
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 99rem;
  font-size: 0.7rem;
}

.detail-description {
  margin: 0;
  white-space: pre-line;
}

.detail-placeholder {
  padding: 3rem 1rem;
  color: var(--muted);
  text-align: center;
}

.riot-notice {
  max-width: 60rem;
  margin: 2rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.champion-dialog {
  width: min(46rem, calc(100% - 2rem));
  max-height: min(44rem, calc(100% - 2rem));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  color: var(--text);
}

.champion-dialog::backdrop {
  background: rgb(20 20 18 / 64%);
  backdrop-filter: blur(0.2rem);
}

.dialog-panel {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dialog-panel h2 { margin: 0; }

.dialog-header button {
  width: 2.75rem;
  padding: 0;
  font-size: 1.5rem;
}

.champion-grid {
  display: grid;
  max-height: 28rem;
  grid-template-columns: repeat(auto-fill, minmax(6.2rem, 1fr));
  gap: 0.5rem;
  overflow-y: auto;
}

.champion-option {
  display: grid;
  min-height: 7rem;
  justify-items: center;
  align-content: center;
  gap: 0.35rem;
  padding: 0.4rem !important;
  font-size: 0.75rem;
  line-height: 1.15;
}

.champion-option img {
  width: 4rem;
  height: 4rem;
}

@media (max-width: 62rem) {
  .draft-workspace {
    grid-template-columns: minmax(10rem, 0.7fr) minmax(22rem, 2fr);
  }

  .team-panel--red {
    grid-column: 1;
  }

  .item-shop {
    grid-column: 2;
    grid-row: 2 / span 2;
  }
}

@media (max-width: 44rem) {
  .itemdraft-intro,
  .champion-setup,
  .draft-topbar,
  .shop-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .itemdraft-actions {
    align-self: flex-start;
  }

  .draft-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .draft-topbar,
  .team-panel,
  .item-shop,
  .team-panel--red {
    grid-column: 1;
    grid-row: auto;
  }

  .team-panel--blue { order: 1; }
  .item-shop { order: 2; }
  .team-panel--red { order: 3; }

  .draft-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-search-label {
    max-width: none;
  }

  .item-grid {
    max-height: 28rem;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .item-detail {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 78vh;
    border-radius: 1rem 1rem 0 0;
  }
}

@media (max-width: 24rem) {
  .item-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
