.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--overlay);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 920px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-strong);
}

.modal-scroll {
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: none;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--accent-ink);
  background: var(--accent);
}

.detail {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 36px;
  padding: 32px;
}

.detail-media {
  position: sticky;
  top: 32px;
  align-self: start;
}

.detail-art {
  display: block;
  width: 100%;
}

.detail-header {
  padding-right: 44px;
  margin-bottom: 20px;
}

.detail-kicker {
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.detail-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.detail-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.detail-hp {
  font-size: 1.6rem;
  font-weight: 700;
  white-space: nowrap;
}

.detail-hp span {
  margin-right: 4px;
  color: var(--text-faint);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.energy-row {
  display: inline-flex;
  gap: 3px;
}

.energy {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  font-size: 0.65rem;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.detail-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.stat {
  flex: 1 1 120px;
  padding: 12px 14px;
  background: var(--panel);
}

.stat-label {
  display: block;
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.stat-value {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 18px;
}

.stat-none {
  color: var(--text-faint);
  font-weight: 500;
}

.type-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail-section {
  margin-top: 28px;
}

.section-label {
  color: var(--text-faint);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.move {
  padding: 14px 16px;
  background: var(--bg);
}

.move + .move {
  margin-top: 8px;
}

.move-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.move-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.move-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.move-damage {
  font-weight: 700;
  font-size: 1.05rem;
  white-space: nowrap;
}

.move-text {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 8px;
}

.ability-tag {
  padding: 2px 8px;
  background: #c8352e;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rule {
  padding: 10px 14px;
  color: var(--text-muted);
  font-size: 0.83rem;
  background: var(--bg);
}

.rule + .rule {
  margin-top: 8px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.info-cell {
  padding: 12px 14px;
  background: var(--panel);
  min-width: 0;
}

.info-value {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.set-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
}

.set-link:hover {
  color: var(--accent);
}

.set-symbol {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

.legality {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
}

.legality.legal {
  color: #4caf6a;
}

.legality.banned {
  color: #e05252;
}

.legality.not-legal {
  color: var(--text-faint);
}

.flavor {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
  margin: 28px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.modal .empty {
  border: none;
}

@media (max-width: 760px) {
  .detail {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 24px;
  }

  .detail-media {
    position: static;
    max-width: 260px;
  }
}
